mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
rename folder
This commit is contained in:
parent
0bd768415e
commit
78af679626
@ -1,110 +0,0 @@
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class ViewList extends StatelessWidget {
|
||||
final List<View> views;
|
||||
const ViewList(this.views, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Log.info('ViewList build');
|
||||
if (views.isEmpty) {
|
||||
return const SizedBox(
|
||||
height: 30,
|
||||
);
|
||||
} else {
|
||||
return Column(
|
||||
children: buildViewWidgets(),
|
||||
).padding(vertical: Insets.sm);
|
||||
}
|
||||
}
|
||||
|
||||
List<ViewWidget> buildViewWidgets() {
|
||||
var targetViews = views.map((view) {
|
||||
return ViewWidget(
|
||||
icon: const Icon(Icons.file_copy),
|
||||
view: view,
|
||||
);
|
||||
}).toList(growable: true);
|
||||
targetViews.addAll(_mockViewWidgets());
|
||||
return targetViews;
|
||||
}
|
||||
|
||||
// TODO: junlin - remove view mocker after integrate docs storage to db
|
||||
List<ViewWidget> _mockViewWidgets() {
|
||||
// Stub doc views
|
||||
final docViews = _mockDocsViews();
|
||||
return docViews.map((view) {
|
||||
return ViewWidget(
|
||||
icon: Icon(Icons.edit_sharp),
|
||||
view: view,
|
||||
);
|
||||
}).toList(growable: false);
|
||||
}
|
||||
|
||||
// TODO: junlin - remove view mocker after integrate docs storage to db
|
||||
List<View> _mockDocsViews() {
|
||||
// plain text doc
|
||||
var plainTextView = View();
|
||||
plainTextView.id = 'doc_plain_text_document';
|
||||
plainTextView.name = 'Plain Text Doc';
|
||||
// code blocks doc
|
||||
|
||||
return [plainTextView];
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(IterableProperty<View>('views', views));
|
||||
}
|
||||
}
|
||||
|
||||
class ViewWidget extends StatelessWidget {
|
||||
final View view;
|
||||
final Widget icon;
|
||||
const ViewWidget({Key? key, required this.view, required this.icon})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: _handleTapOnView(context),
|
||||
child: Container(
|
||||
height: 30,
|
||||
child: buildContent(),
|
||||
));
|
||||
}
|
||||
|
||||
Row buildContent() {
|
||||
return Row(
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
view.name,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(fontSize: 15),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Function() _handleTapOnView(BuildContext context) {
|
||||
return () {
|
||||
// if (view.id.startsWith('doc')) {
|
||||
// context.read<MenuBloc>().add(MenuEvent.openPage(DocPageContext(view)));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// context.read<MenuBloc>().add(MenuEvent.openPage(GridPageContext(view)));
|
||||
};
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/infrastructure/deps_resolver.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/deps_resolver.dart';
|
||||
import 'package:app_flowy/startup/launch.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/user/infrastructure/deps_resolver.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/home/presentation/home_screen.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/user/application/sign_in/sign_in_bloc.dart';
|
||||
import 'package:app_flowy/user/presentation/sign_in/widgets/background.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra_ui/widget/rounded_button.dart';
|
||||
import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/home/application/edit_pannel/edit_pannel_bloc.dart';
|
||||
import 'package:app_flowy/home/application/home_bloc.dart';
|
||||
import 'package:app_flowy/home/application/watcher/home_watcher_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/home_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/watcher/home_watcher_bloc.dart';
|
||||
import 'package:app_flowy/welcome/application/welcome_bloc.dart';
|
||||
import 'package:app_flowy/welcome/infrastructure/i_welcome_impl.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/home/presentation/home_screen.dart';
|
||||
import 'package:app_flowy/user/presentation/sign_in/sign_in_screen.dart';
|
||||
import 'package:app_flowy/welcome/domain/auth_state.dart';
|
||||
import 'package:app_flowy/welcome/domain/i_welcome.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/i_app.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_app.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
@ -16,19 +16,30 @@ class AppBloc extends Bloc<AppEvent, AppState> {
|
||||
AppEvent event,
|
||||
) async* {
|
||||
yield* event.map(
|
||||
initial: (e) async* {},
|
||||
viewsReceived: (e) async* {
|
||||
yield state;
|
||||
initial: (e) async* {
|
||||
yield* _fetchViews();
|
||||
},
|
||||
createView: (CreateView value) async* {
|
||||
iAppImpl.createView(
|
||||
name: value.name, desc: value.desc, viewType: value.viewType);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Stream<AppState> _fetchViews() async* {
|
||||
final viewsOrFailed = await iAppImpl.getViews();
|
||||
yield viewsOrFailed.fold(
|
||||
(apps) => state.copyWith(views: some(apps)),
|
||||
(error) => state.copyWith(successOrFailure: right(error)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class AppEvent with _$AppEvent {
|
||||
const factory AppEvent.initial() = _Initial;
|
||||
const factory AppEvent.viewsReceived(
|
||||
Either<List<View>, WorkspaceError> appsOrFail) = ViewsReceived;
|
||||
const factory AppEvent.initial() = Initial;
|
||||
const factory AppEvent.createView(
|
||||
String name, String desc, ViewType viewType) = CreateView;
|
||||
}
|
||||
|
||||
@freezed
|
@ -16,13 +16,15 @@ final _privateConstructorUsedError = UnsupportedError(
|
||||
class _$AppEventTearOff {
|
||||
const _$AppEventTearOff();
|
||||
|
||||
_Initial initial() {
|
||||
return const _Initial();
|
||||
Initial initial() {
|
||||
return const Initial();
|
||||
}
|
||||
|
||||
ViewsReceived viewsReceived(Either<List<View>, WorkspaceError> appsOrFail) {
|
||||
return ViewsReceived(
|
||||
appsOrFail,
|
||||
CreateView createView(String name, String desc, ViewType viewType) {
|
||||
return CreateView(
|
||||
name,
|
||||
desc,
|
||||
viewType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -35,28 +37,27 @@ mixin _$AppEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function(Either<List<View>, WorkspaceError> appsOrFail)
|
||||
viewsReceived,
|
||||
required TResult Function(String name, String desc, ViewType viewType)
|
||||
createView,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function(Either<List<View>, WorkspaceError> appsOrFail)?
|
||||
viewsReceived,
|
||||
TResult Function(String name, String desc, ViewType viewType)? createView,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(ViewsReceived value) viewsReceived,
|
||||
required TResult Function(Initial value) initial,
|
||||
required TResult Function(CreateView value) createView,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(ViewsReceived value)? viewsReceived,
|
||||
TResult Function(Initial value)? initial,
|
||||
TResult Function(CreateView value)? createView,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@ -78,25 +79,25 @@ class _$AppEventCopyWithImpl<$Res> implements $AppEventCopyWith<$Res> {
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$InitialCopyWith<$Res> {
|
||||
factory _$InitialCopyWith(_Initial value, $Res Function(_Initial) then) =
|
||||
__$InitialCopyWithImpl<$Res>;
|
||||
abstract class $InitialCopyWith<$Res> {
|
||||
factory $InitialCopyWith(Initial value, $Res Function(Initial) then) =
|
||||
_$InitialCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$InitialCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
|
||||
implements _$InitialCopyWith<$Res> {
|
||||
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
|
||||
: super(_value, (v) => _then(v as _Initial));
|
||||
class _$InitialCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
|
||||
implements $InitialCopyWith<$Res> {
|
||||
_$InitialCopyWithImpl(Initial _value, $Res Function(Initial) _then)
|
||||
: super(_value, (v) => _then(v as Initial));
|
||||
|
||||
@override
|
||||
_Initial get _value => super._value as _Initial;
|
||||
Initial get _value => super._value as Initial;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$_Initial implements _Initial {
|
||||
const _$_Initial();
|
||||
class _$Initial implements Initial {
|
||||
const _$Initial();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -105,7 +106,7 @@ class _$_Initial implements _Initial {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
return identical(this, other) || (other is _Initial);
|
||||
return identical(this, other) || (other is Initial);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -115,8 +116,8 @@ class _$_Initial implements _Initial {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function(Either<List<View>, WorkspaceError> appsOrFail)
|
||||
viewsReceived,
|
||||
required TResult Function(String name, String desc, ViewType viewType)
|
||||
createView,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
@ -125,8 +126,7 @@ class _$_Initial implements _Initial {
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function(Either<List<View>, WorkspaceError> appsOrFail)?
|
||||
viewsReceived,
|
||||
TResult Function(String name, String desc, ViewType viewType)? createView,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
@ -138,8 +138,8 @@ class _$_Initial implements _Initial {
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(ViewsReceived value) viewsReceived,
|
||||
required TResult Function(Initial value) initial,
|
||||
required TResult Function(CreateView value) createView,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
@ -147,8 +147,8 @@ class _$_Initial implements _Initial {
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(ViewsReceived value)? viewsReceived,
|
||||
TResult Function(Initial value)? initial,
|
||||
TResult Function(CreateView value)? createView,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
@ -158,92 +158,111 @@ class _$_Initial implements _Initial {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Initial implements AppEvent {
|
||||
const factory _Initial() = _$_Initial;
|
||||
abstract class Initial implements AppEvent {
|
||||
const factory Initial() = _$Initial;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ViewsReceivedCopyWith<$Res> {
|
||||
factory $ViewsReceivedCopyWith(
|
||||
ViewsReceived value, $Res Function(ViewsReceived) then) =
|
||||
_$ViewsReceivedCopyWithImpl<$Res>;
|
||||
$Res call({Either<List<View>, WorkspaceError> appsOrFail});
|
||||
abstract class $CreateViewCopyWith<$Res> {
|
||||
factory $CreateViewCopyWith(
|
||||
CreateView value, $Res Function(CreateView) then) =
|
||||
_$CreateViewCopyWithImpl<$Res>;
|
||||
$Res call({String name, String desc, ViewType viewType});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ViewsReceivedCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
|
||||
implements $ViewsReceivedCopyWith<$Res> {
|
||||
_$ViewsReceivedCopyWithImpl(
|
||||
ViewsReceived _value, $Res Function(ViewsReceived) _then)
|
||||
: super(_value, (v) => _then(v as ViewsReceived));
|
||||
class _$CreateViewCopyWithImpl<$Res> extends _$AppEventCopyWithImpl<$Res>
|
||||
implements $CreateViewCopyWith<$Res> {
|
||||
_$CreateViewCopyWithImpl(CreateView _value, $Res Function(CreateView) _then)
|
||||
: super(_value, (v) => _then(v as CreateView));
|
||||
|
||||
@override
|
||||
ViewsReceived get _value => super._value as ViewsReceived;
|
||||
CreateView get _value => super._value as CreateView;
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? appsOrFail = freezed,
|
||||
Object? name = freezed,
|
||||
Object? desc = freezed,
|
||||
Object? viewType = freezed,
|
||||
}) {
|
||||
return _then(ViewsReceived(
|
||||
appsOrFail == freezed
|
||||
? _value.appsOrFail
|
||||
: appsOrFail // ignore: cast_nullable_to_non_nullable
|
||||
as Either<List<View>, WorkspaceError>,
|
||||
return _then(CreateView(
|
||||
name == freezed
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
desc == freezed
|
||||
? _value.desc
|
||||
: desc // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
viewType == freezed
|
||||
? _value.viewType
|
||||
: viewType // ignore: cast_nullable_to_non_nullable
|
||||
as ViewType,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ViewsReceived implements ViewsReceived {
|
||||
const _$ViewsReceived(this.appsOrFail);
|
||||
class _$CreateView implements CreateView {
|
||||
const _$CreateView(this.name, this.desc, this.viewType);
|
||||
|
||||
@override
|
||||
final Either<List<View>, WorkspaceError> appsOrFail;
|
||||
final String name;
|
||||
@override
|
||||
final String desc;
|
||||
@override
|
||||
final ViewType viewType;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppEvent.viewsReceived(appsOrFail: $appsOrFail)';
|
||||
return 'AppEvent.createView(name: $name, desc: $desc, viewType: $viewType)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
return identical(this, other) ||
|
||||
(other is ViewsReceived &&
|
||||
(identical(other.appsOrFail, appsOrFail) ||
|
||||
(other is CreateView &&
|
||||
(identical(other.name, name) ||
|
||||
const DeepCollectionEquality().equals(other.name, name)) &&
|
||||
(identical(other.desc, desc) ||
|
||||
const DeepCollectionEquality().equals(other.desc, desc)) &&
|
||||
(identical(other.viewType, viewType) ||
|
||||
const DeepCollectionEquality()
|
||||
.equals(other.appsOrFail, appsOrFail)));
|
||||
.equals(other.viewType, viewType)));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
runtimeType.hashCode ^ const DeepCollectionEquality().hash(appsOrFail);
|
||||
runtimeType.hashCode ^
|
||||
const DeepCollectionEquality().hash(name) ^
|
||||
const DeepCollectionEquality().hash(desc) ^
|
||||
const DeepCollectionEquality().hash(viewType);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
$ViewsReceivedCopyWith<ViewsReceived> get copyWith =>
|
||||
_$ViewsReceivedCopyWithImpl<ViewsReceived>(this, _$identity);
|
||||
$CreateViewCopyWith<CreateView> get copyWith =>
|
||||
_$CreateViewCopyWithImpl<CreateView>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function(Either<List<View>, WorkspaceError> appsOrFail)
|
||||
viewsReceived,
|
||||
required TResult Function(String name, String desc, ViewType viewType)
|
||||
createView,
|
||||
}) {
|
||||
return viewsReceived(appsOrFail);
|
||||
return createView(name, desc, viewType);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function(Either<List<View>, WorkspaceError> appsOrFail)?
|
||||
viewsReceived,
|
||||
TResult Function(String name, String desc, ViewType viewType)? createView,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (viewsReceived != null) {
|
||||
return viewsReceived(appsOrFail);
|
||||
if (createView != null) {
|
||||
return createView(name, desc, viewType);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@ -251,34 +270,35 @@ class _$ViewsReceived implements ViewsReceived {
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(ViewsReceived value) viewsReceived,
|
||||
required TResult Function(Initial value) initial,
|
||||
required TResult Function(CreateView value) createView,
|
||||
}) {
|
||||
return viewsReceived(this);
|
||||
return createView(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(ViewsReceived value)? viewsReceived,
|
||||
TResult Function(Initial value)? initial,
|
||||
TResult Function(CreateView value)? createView,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (viewsReceived != null) {
|
||||
return viewsReceived(this);
|
||||
if (createView != null) {
|
||||
return createView(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ViewsReceived implements AppEvent {
|
||||
const factory ViewsReceived(Either<List<View>, WorkspaceError> appsOrFail) =
|
||||
_$ViewsReceived;
|
||||
abstract class CreateView implements AppEvent {
|
||||
const factory CreateView(String name, String desc, ViewType viewType) =
|
||||
_$CreateView;
|
||||
|
||||
Either<List<View>, WorkspaceError> get appsOrFail =>
|
||||
throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
String get desc => throw _privateConstructorUsedError;
|
||||
ViewType get viewType => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$ViewsReceivedCopyWith<ViewsReceived> get copyWith =>
|
||||
$CreateViewCopyWith<CreateView> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/i_app.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_app.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/edit_context.dart';
|
||||
import 'package:app_flowy/workspace/domain/edit_context.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/edit_context.dart';
|
||||
import 'package:app_flowy/workspace/domain/edit_context.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:dartz/dartz.dart';
|
@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:app_flowy/home/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
@ -6,13 +6,10 @@ typedef AppAddViewCallback = void Function(
|
||||
Either<List<View>, WorkspaceError> viewsOrFailed);
|
||||
|
||||
abstract class IApp {
|
||||
Future<Either<List<View>, WorkspaceError>> getViews({required String appId});
|
||||
Future<Either<List<View>, WorkspaceError>> getViews();
|
||||
|
||||
Future<Either<View, WorkspaceError>> createView(
|
||||
{required String appId,
|
||||
required String name,
|
||||
String? desc,
|
||||
required ViewType viewType});
|
||||
{required String name, String? desc, required ViewType viewType});
|
||||
}
|
||||
|
||||
abstract class IAppWatch {
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
|
||||
abstract class IPageStack {
|
||||
void setPageContext(PageContext context);
|
@ -1,9 +1,9 @@
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack_bloc.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/blank_page.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/fading_index_stack.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/prelude.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/blank_page.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/fading_index_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
List<PageType> pages = PageType.values.toList();
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/blank_page.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/blank_page.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
part 'page_stack_bloc.freezed.dart';
|
@ -1,12 +1,12 @@
|
||||
import 'package:app_flowy/home/application/app/app_bloc.dart';
|
||||
import 'package:app_flowy/home/application/app/app_watch_bloc.dart';
|
||||
import 'package:app_flowy/home/application/menu/menu_bloc.dart';
|
||||
import 'package:app_flowy/home/application/menu/menu_watch.dart';
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/home/infrastructure/i_app_impl.dart';
|
||||
import 'package:app_flowy/home/infrastructure/i_workspace_impl.dart';
|
||||
import 'package:app_flowy/home/infrastructure/repos/app_repo.dart';
|
||||
import 'package:app_flowy/home/infrastructure/repos/workspace_repo.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/i_app_impl.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/i_workspace_impl.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
class HomeDepsResolver {
|
@ -1,10 +1,10 @@
|
||||
import 'package:app_flowy/home/infrastructure/repos/app_repo.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||
import 'package:app_flowy/home/domain/i_app.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_app.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
|
||||
export 'package:app_flowy/home/domain/i_app.dart';
|
||||
export 'package:app_flowy/workspace/domain/i_app.dart';
|
||||
|
||||
class IAppImpl extends IApp {
|
||||
AppRepository repo;
|
||||
@ -13,17 +13,14 @@ class IAppImpl extends IApp {
|
||||
});
|
||||
|
||||
@override
|
||||
Future<Either<List<View>, WorkspaceError>> getViews({required String appId}) {
|
||||
return repo.getViews(appId: appId);
|
||||
Future<Either<List<View>, WorkspaceError>> getViews() {
|
||||
return repo.getViews();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<View, WorkspaceError>> createView(
|
||||
{required String appId,
|
||||
required String name,
|
||||
String? desc,
|
||||
required ViewType viewType}) {
|
||||
return repo.createView(appId, name, desc ?? "", viewType);
|
||||
{required String name, String? desc, required ViewType viewType}) {
|
||||
return repo.createView(name, desc ?? "", viewType);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:app_flowy/home/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/home/infrastructure/repos/workspace_repo.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||
|
||||
export 'package:app_flowy/home/domain/i_workspace.dart';
|
||||
export 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||
|
||||
class IWorkspaceImpl extends IWorkspace {
|
||||
WorkspaceRepo repo;
|
@ -1,5 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:app_flowy/home/domain/i_app.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_app.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
||||
@ -27,7 +27,7 @@ class AppRepository {
|
||||
}
|
||||
|
||||
Future<Either<View, WorkspaceError>> createView(
|
||||
String appId, String name, String desc, ViewType viewType) {
|
||||
String name, String desc, ViewType viewType) {
|
||||
final request = CreateViewRequest.create()
|
||||
..appId = appId
|
||||
..name = name
|
||||
@ -37,7 +37,7 @@ class AppRepository {
|
||||
return WorkspaceEventCreateView(request).send();
|
||||
}
|
||||
|
||||
Future<Either<List<View>, WorkspaceError>> getViews({required String appId}) {
|
||||
Future<Either<List<View>, WorkspaceError>> getViews() {
|
||||
final request = QueryAppRequest.create()
|
||||
..appId = appId
|
||||
..readViews = true;
|
||||
@ -86,7 +86,7 @@ class AppWatchRepository {
|
||||
if (_addViewCallback == null) {
|
||||
return;
|
||||
}
|
||||
_repo.getViews(appId: appId).then((result) {
|
||||
_repo.getViews().then((result) {
|
||||
result.fold(
|
||||
(views) => _addViewCallback!(left(views)),
|
||||
(error) => _addViewCallback!(right(error)),
|
@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:app_flowy/home/domain/i_workspace.dart';
|
||||
import 'package:app_flowy/workspace/domain/i_workspace.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
@ -1,6 +1,7 @@
|
||||
import 'package:app_flowy/home/application/app/app_bloc.dart';
|
||||
import 'package:app_flowy/home/application/app/app_watch_bloc.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/menu/menu_size.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
||||
import 'package:app_flowy/workspace/presentation/app/view_list.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_size.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
@ -9,6 +10,7 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
||||
class AppWidget extends StatelessWidget {
|
||||
final App app;
|
||||
@ -18,32 +20,27 @@ class AppWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AppBloc>(
|
||||
create: (context) => getIt<AppBloc>(param1: app.id)),
|
||||
BlocProvider<AppWatchBloc>(
|
||||
create: (context) => getIt<AppWatchBloc>(param1: app.id)),
|
||||
BlocProvider<AppBloc>(create: (context) {
|
||||
final appBloc = getIt<AppBloc>(param1: app.id);
|
||||
appBloc.add(const AppEvent.initial());
|
||||
return appBloc;
|
||||
}),
|
||||
BlocProvider<AppWatchBloc>(create: (context) {
|
||||
final watchBloc = getIt<AppWatchBloc>(param1: app.id);
|
||||
watchBloc.add(const AppWatchEvent.started());
|
||||
return watchBloc;
|
||||
}),
|
||||
],
|
||||
child: BlocBuilder<AppWatchBloc, AppWatchState>(
|
||||
builder: (context, state) {
|
||||
final child = state.map(
|
||||
initial: (_) => BlocBuilder<AppBloc, AppState>(
|
||||
builder: (context, state) {
|
||||
return Container();
|
||||
return ViewList(state.views);
|
||||
},
|
||||
),
|
||||
loadViews: (s) {
|
||||
return Container();
|
||||
// final child = state.map(
|
||||
// initial: (_) => const CircularProgressIndicator.adaptive(),
|
||||
// loadViews: (s) => ViewList(s.views),
|
||||
// successOrFailure: (s) => FlowyErrorPage(s.error),
|
||||
// );
|
||||
|
||||
// return expandableWrapper(context, Container());
|
||||
},
|
||||
loadFail: (s) {
|
||||
return FlowyErrorPage(s.error.toString());
|
||||
},
|
||||
loadViews: (s) => ViewList(some(s.views)),
|
||||
loadFail: (s) => FlowyErrorPage(s.error.toString()),
|
||||
);
|
||||
|
||||
return expandableWrapper(context, child);
|
||||
@ -74,7 +71,7 @@ class AppWidget extends StatelessWidget {
|
||||
padding: EdgeInsets.only(left: Sizes.iconMed),
|
||||
child: child,
|
||||
),
|
||||
collapsed: const Text("close"),
|
||||
collapsed: const SizedBox(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -130,8 +127,7 @@ class AppHeader extends StatelessWidget {
|
||||
tooltip: 'create new view',
|
||||
icon: const Icon(Icons.add),
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: (viewType) =>
|
||||
handleCreateView(viewType as ViewType, context),
|
||||
onSelected: (viewType) => _createView(viewType as ViewType, context),
|
||||
itemBuilder: (context) => menuItemBuilder());
|
||||
}
|
||||
|
||||
@ -147,13 +143,7 @@ class AppHeader extends StatelessWidget {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
void handleCreateView(ViewType viewType, BuildContext context) {
|
||||
switch (viewType) {
|
||||
case ViewType.Docs:
|
||||
// context
|
||||
// .read<AppEditBloc>()
|
||||
// .add(AppEditEvent.createView(app.id, 'Grid View'));
|
||||
break;
|
||||
}
|
||||
void _createView(ViewType viewType, BuildContext context) {
|
||||
context.read<AppBloc>().add(AppEvent.createView("New view", "", viewType));
|
||||
}
|
||||
}
|
45
app_flowy/lib/workspace/presentation/app/view_list.dart
Normal file
45
app_flowy/lib/workspace/presentation/app/view_list.dart
Normal file
@ -0,0 +1,45 @@
|
||||
import 'package:app_flowy/workspace/presentation/view/view_widget.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
|
||||
class ViewList extends StatelessWidget {
|
||||
final Option<List<View>> views;
|
||||
const ViewList(this.views, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Log.info('ViewList build');
|
||||
return views.fold(
|
||||
() => const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
(views) {
|
||||
return Column(
|
||||
children: buildViewWidgets(views),
|
||||
).padding(vertical: Insets.sm);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<ViewWidget> buildViewWidgets(List<View> views) {
|
||||
var targetViews = views.map((view) {
|
||||
return ViewWidget(
|
||||
icon: const Icon(Icons.file_copy),
|
||||
view: view,
|
||||
);
|
||||
}).toList(growable: true);
|
||||
return targetViews;
|
||||
}
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
views.fold(() => {},
|
||||
(views) => properties.add(IterableProperty<View>('views', views)));
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/application/home_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/home_bloc.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_infra/time/duration.dart';
|
||||
import 'package:flutter/material.dart';
|
@ -1,7 +1,7 @@
|
||||
import 'package:app_flowy/home/application/home_bloc.dart';
|
||||
import 'package:app_flowy/home/application/watcher/home_watcher_bloc.dart';
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/prelude.dart';
|
||||
import 'package:app_flowy/workspace/application/home_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/watcher/home_watcher_bloc.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:flowy_infra/flowy_logger.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/styled_container.dart';
|
46
app_flowy/lib/workspace/presentation/view/view_widget.dart
Normal file
46
app_flowy/lib/workspace/presentation/view/view_widget.dart
Normal file
@ -0,0 +1,46 @@
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ViewWidget extends StatelessWidget {
|
||||
final View view;
|
||||
final Widget icon;
|
||||
const ViewWidget({Key? key, required this.view, required this.icon})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: _handleTapOnView(context),
|
||||
child: Container(
|
||||
height: 30,
|
||||
child: buildContent(),
|
||||
));
|
||||
}
|
||||
|
||||
Row buildContent() {
|
||||
return Row(
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(
|
||||
view.name,
|
||||
textAlign: TextAlign.start,
|
||||
style: const TextStyle(fontSize: 15),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Function() _handleTapOnView(BuildContext context) {
|
||||
return () {
|
||||
// if (view.id.startsWith('doc')) {
|
||||
// context.read<MenuBloc>().add(MenuEvent.openPage(DocPageContext(view)));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// context.read<MenuBloc>().add(MenuEvent.openPage(GridPageContext(view)));
|
||||
};
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BlankPageContext extends PageContext {
|
@ -1,12 +1,12 @@
|
||||
import 'package:app_flowy/home/application/edit_pannel/edit_pannel_bloc.dart';
|
||||
import 'package:app_flowy/home/domain/edit_context.dart';
|
||||
import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
|
||||
import 'package:app_flowy/workspace/domain/edit_context.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/styled_bar_title.dart';
|
||||
import 'package:flowy_infra_ui/style_widget/styled_close_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../home_sizes.dart';
|
||||
|
||||
class EditPannel extends StatelessWidget {
|
||||
late final EditPannelContext editContext;
|
@ -1,4 +1,4 @@
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract class HomeStackPage extends StatefulWidget {
|
@ -1,5 +1,5 @@
|
||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../home_sizes.dart';
|
||||
|
||||
class HomeTopBar extends StatelessWidget {
|
||||
final String title;
|
@ -1,6 +1,6 @@
|
||||
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||
import 'package:app_flowy/home/presentation/widgets/app/app_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'package:app_flowy/home/application/menu/menu_bloc.dart';
|
||||
import 'package:app_flowy/home/application/menu/menu_watch.dart';
|
||||
import 'package:app_flowy/home/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/home/presentation/home_sizes.dart';
|
||||
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
||||
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||
import 'package:app_flowy/startup/startup.dart';
|
||||
import 'package:app_flowy/startup/tasks/application_task.dart';
|
||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_infra/size.dart';
|
||||
import 'package:flowy_infra/text_style.dart';
|
Loading…
Reference in New Issue
Block a user