From 9a1f17d41c7626d0bbca5228e1e80acc624df4d4 Mon Sep 17 00:00:00 2001 From: appflowy Date: Mon, 26 Jul 2021 11:51:39 +0800 Subject: [PATCH] config menu user bloc --- .../lib/user/infrastructure/i_auth_impl.dart | 1 - .../lib/welcome/application/welcome_bloc.dart | 2 +- app_flowy/lib/welcome/domain/i_welcome.dart | 2 +- .../infrastructure/i_welcome_impl.dart | 2 +- .../application/menu/menu_user_bloc.dart | 1 + app_flowy/lib/workspace/domain/i_user.dart | 14 ++ .../infrastructure/deps_resolver.dart | 22 ++- .../workspace/infrastructure/i_user_impl.dart | 30 ++++ .../infrastructure/repos/user_repo.dart | 16 ++ .../infrastructure/repos/workspace_repo.dart | 15 +- .../presentation/app/app_widget.dart | 9 +- .../presentation/home/home_screen.dart | 6 +- .../presentation/widgets/menu/menu.dart | 148 +++++------------- .../widgets/menu/menu_new_app.dart | 50 ++++++ .../presentation/widgets/menu/menu_size.dart | 4 - .../widgets/menu/menu_top_bar.dart | 37 +++++ .../{user_profile.dart => menu_user.dart} | 10 +- .../presentation/widgets/menu/prelude.dart | 1 - 18 files changed, 229 insertions(+), 141 deletions(-) create mode 100644 app_flowy/lib/workspace/application/menu/menu_user_bloc.dart create mode 100644 app_flowy/lib/workspace/domain/i_user.dart create mode 100644 app_flowy/lib/workspace/infrastructure/i_user_impl.dart create mode 100644 app_flowy/lib/workspace/infrastructure/repos/user_repo.dart create mode 100644 app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart delete mode 100644 app_flowy/lib/workspace/presentation/widgets/menu/menu_size.dart create mode 100644 app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart rename app_flowy/lib/workspace/presentation/widgets/menu/{user_profile.dart => menu_user.dart} (67%) diff --git a/app_flowy/lib/user/infrastructure/i_auth_impl.dart b/app_flowy/lib/user/infrastructure/i_auth_impl.dart index dc113799b9..5f660e01e2 100644 --- a/app_flowy/lib/user/infrastructure/i_auth_impl.dart +++ b/app_flowy/lib/user/infrastructure/i_auth_impl.dart @@ -1,6 +1,5 @@ import 'package:app_flowy/workspace/presentation/home/home_screen.dart'; import 'package:dartz/dartz.dart'; -import 'package:flowy_infra/time/duration.dart'; import 'package:flowy_infra_ui/widget/route/animation.dart'; import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart'; import 'package:app_flowy/user/domain/i_auth.dart'; diff --git a/app_flowy/lib/welcome/application/welcome_bloc.dart b/app_flowy/lib/welcome/application/welcome_bloc.dart index 6595029a4a..bb157d9078 100644 --- a/app_flowy/lib/welcome/application/welcome_bloc.dart +++ b/app_flowy/lib/welcome/application/welcome_bloc.dart @@ -13,7 +13,7 @@ class WelcomeBloc extends Bloc { Stream mapEventToState(WelcomeEvent event) async* { yield* event.map( getUser: (val) async* { - final authState = await authImpl.currentUserState(); + final authState = await authImpl.currentUserDetail(); yield state.copyWith(auth: authState); }, ); diff --git a/app_flowy/lib/welcome/domain/i_welcome.dart b/app_flowy/lib/welcome/domain/i_welcome.dart index 7ef7b5959c..fb2c645770 100644 --- a/app_flowy/lib/welcome/domain/i_welcome.dart +++ b/app_flowy/lib/welcome/domain/i_welcome.dart @@ -4,7 +4,7 @@ import 'package:flutter/widgets.dart'; import 'auth_state.dart'; abstract class IWelcomeAuth { - Future currentUserState(); + Future currentUserDetail(); } abstract class IWelcomeRoute { diff --git a/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart b/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart index 63fab6c446..e6b8e60f3c 100644 --- a/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart +++ b/app_flowy/lib/welcome/infrastructure/i_welcome_impl.dart @@ -13,7 +13,7 @@ export 'package:app_flowy/welcome/domain/i_welcome.dart'; class WelcomeAuthImpl implements IWelcomeAuth { @override - Future currentUserState() { + Future currentUserDetail() { final result = UserEventGetStatus().send(); return result.then((result) { return result.fold( diff --git a/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart b/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart @@ -0,0 +1 @@ + diff --git a/app_flowy/lib/workspace/domain/i_user.dart b/app_flowy/lib/workspace/domain/i_user.dart new file mode 100644 index 0000000000..947df99c8c --- /dev/null +++ b/app_flowy/lib/workspace/domain/i_user.dart @@ -0,0 +1,14 @@ +import 'package:dartz/dartz.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart'; + +export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart'; +export 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; +export 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart'; + +abstract class IUser { + Future> deleteWorkspace(String workspaceId); + Future> fetchUserDetail(String userId); + Future> signOut(); +} diff --git a/app_flowy/lib/workspace/infrastructure/deps_resolver.dart b/app_flowy/lib/workspace/infrastructure/deps_resolver.dart index a193abe94d..aaf134c01f 100644 --- a/app_flowy/lib/workspace/infrastructure/deps_resolver.dart +++ b/app_flowy/lib/workspace/infrastructure/deps_resolver.dart @@ -16,8 +16,10 @@ import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart'; import 'package:flowy_editor/flowy_editor.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; import 'package:get_it/get_it.dart'; +import 'i_user_impl.dart'; import 'i_view_impl.dart'; class HomeDepsResolver { @@ -32,10 +34,10 @@ class HomeDepsResolver { (appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId))); //workspace - getIt.registerFactoryParam((workspaceId, _) => - IWorkspaceImpl(repo: WorkspaceRepo(workspaceId: workspaceId))); - getIt.registerFactoryParam((workspacId, _) => - IWorkspaceWatchImpl(repo: WorkspaceWatchRepo(workspaceId: workspacId))); + getIt.registerFactoryParam( + (user, _) => IWorkspaceImpl(repo: WorkspaceRepo(user: user))); + getIt.registerFactoryParam( + (user, _) => IWorkspaceWatchImpl(repo: WorkspaceWatchRepo(user: user))); // View getIt.registerFactoryParam( @@ -47,11 +49,15 @@ class HomeDepsResolver { getIt.registerFactoryParam( (docId, _) => IDocImpl(repo: DocRepository(docId: docId))); + // User + getIt.registerFactoryParam( + (user, _) => IUserImpl(repo: UserRepo(user: user))); + //Bloc - getIt.registerFactoryParam( - (workspaceId, _) => MenuBloc(getIt(param1: workspaceId))); - getIt.registerFactoryParam((workspaceId, _) => - MenuWatchBloc(getIt(param1: workspaceId))); + getIt.registerFactoryParam( + (user, _) => MenuBloc(getIt(param1: user))); + getIt.registerFactoryParam( + (user, _) => MenuWatchBloc(getIt(param1: user))); getIt.registerFactoryParam( (appId, _) => AppBloc(getIt(param1: appId))); diff --git a/app_flowy/lib/workspace/infrastructure/i_user_impl.dart b/app_flowy/lib/workspace/infrastructure/i_user_impl.dart new file mode 100644 index 0000000000..9d8fe3ce02 --- /dev/null +++ b/app_flowy/lib/workspace/infrastructure/i_user_impl.dart @@ -0,0 +1,30 @@ +import 'package:dartz/dartz.dart'; + +import 'package:app_flowy/workspace/domain/i_user.dart'; +import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; +export 'package:app_flowy/workspace/domain/i_user.dart'; +export 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; + +class IUserImpl extends IUser { + UserRepo repo; + IUserImpl({ + required this.repo, + }); + + @override + Future> deleteWorkspace(String workspaceId) { + // TODO: implement deleteWorkspace + throw UnimplementedError(); + } + + @override + Future> fetchUserDetail(String userId) { + return repo.fetchUserDetail(userId: userId); + } + + @override + Future> signOut() { + // TODO: implement signOut + throw UnimplementedError(); + } +} diff --git a/app_flowy/lib/workspace/infrastructure/repos/user_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/user_repo.dart new file mode 100644 index 0000000000..5b6f131193 --- /dev/null +++ b/app_flowy/lib/workspace/infrastructure/repos/user_repo.dart @@ -0,0 +1,16 @@ +import 'package:dartz/dartz.dart'; +import 'package:flowy_sdk/dispatch/dispatch.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; + +class UserRepo { + final UserDetail user; + UserRepo({ + required this.user, + }); + + Future> fetchUserDetail( + {required String userId}) { + return UserEventGetStatus().send(); + } +} diff --git a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart index 6484108870..774ed698bc 100644 --- a/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart +++ b/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart @@ -5,6 +5,7 @@ import 'package:dartz/dartz.dart'; import 'package:flowy_infra/flowy_logger.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-observable/subject.pb.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/observable.pb.dart'; @@ -13,9 +14,9 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/workspace_query.pb.dart'; import 'package:flowy_sdk/rust_stream.dart'; class WorkspaceRepo { - String workspaceId; + UserDetail user; WorkspaceRepo({ - required this.workspaceId, + required this.user, }); Future> createApp(String appName, String desc) { @@ -38,7 +39,7 @@ class WorkspaceRepo { Future> getWorkspace( {bool readApps = false}) { final request = QueryWorkspaceRequest.create() - ..workspaceId = workspaceId + ..workspaceId = user.workspace ..readApps = readApps; return WorkspaceEventGetWorkspace(request).send().then((result) { @@ -54,13 +55,13 @@ class WorkspaceWatchRepo { StreamSubscription? _subscription; WorkspaceAddAppCallback? _addAppCallback; WorkspaceUpdatedCallback? _updatedCallback; - final String workspaceId; + final UserDetail user; late WorkspaceRepo _repo; WorkspaceWatchRepo({ - required this.workspaceId, + required this.user, }) { - _repo = WorkspaceRepo(workspaceId: workspaceId); + _repo = WorkspaceRepo(user: user); } void startWatching( @@ -70,7 +71,7 @@ class WorkspaceWatchRepo { _updatedCallback = updatedCallback; _subscription = RustStreamReceiver.listen((observable) { - if (observable.subjectId != workspaceId) { + if (observable.subjectId != user.workspace) { return; } diff --git a/app_flowy/lib/workspace/presentation/app/app_widget.dart b/app_flowy/lib/workspace/presentation/app/app_widget.dart index e793ae5d51..35c243ca31 100644 --- a/app_flowy/lib/workspace/presentation/app/app_widget.dart +++ b/app_flowy/lib/workspace/presentation/app/app_widget.dart @@ -2,7 +2,6 @@ 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_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'; @@ -15,7 +14,7 @@ import 'package:dartz/dartz.dart'; class AppWidget extends MenuItem { final App app; - const AppWidget(this.app, {Key? key}) : super(key: key); + AppWidget(this.app, {Key? key}) : super(key: ValueKey(app.id)); @override Widget build(BuildContext context) { @@ -103,11 +102,11 @@ class AppHeader extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ ExpandableIcon( - theme: ExpandableThemeData( + theme: const ExpandableThemeData( expandIcon: Icons.arrow_right, collapseIcon: Icons.arrow_drop_down, iconColor: Colors.black, - iconSize: HomeMenuSize.collapseIconSize, + iconSize: 24, iconPadding: EdgeInsets.zero, hasIcon: false, ), @@ -116,7 +115,7 @@ class AppHeader extends StatelessWidget { child: Text(app.name), ), SizedBox( - height: HomeMenuSize.createViewButtonSize, + height: 30, child: createViewPopupMenu(context), ), ], diff --git a/app_flowy/lib/workspace/presentation/home/home_screen.dart b/app_flowy/lib/workspace/presentation/home/home_screen.dart index 39dfc4e90a..1e1c65b17c 100644 --- a/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -14,8 +14,8 @@ import 'home_layout.dart'; class HomeScreen extends StatelessWidget { static GlobalKey scaffoldKey = GlobalKey(); - final UserDetail userDetail; - const HomeScreen(this.userDetail, {Key? key}) : super(key: key); + final UserDetail user; + const HomeScreen(this.user, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -74,7 +74,7 @@ class HomeScreen extends StatelessWidget { isCollapseChanged: (isCollapse) { homeBloc.add(HomeEvent.forceCollapse(isCollapse)); }, - workspaceId: userDetail.workspace, + user: user, ); homeMenu = RepaintBoundary(child: homeMenu); homeMenu = FocusTraversalGroup(child: homeMenu); diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu.dart index 2796c7bf90..2a251bb4cc 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu.dart @@ -1,32 +1,34 @@ -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/workspace/presentation/app/app_widget.dart'; -import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; -import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart'; -import 'package:app_flowy/workspace/presentation/widgets/menu/user_profile.dart'; +import 'package:app_flowy/workspace/presentation/widgets/menu/menu_new_app.dart'; +import 'package:app_flowy/workspace/presentation/widgets/menu/menu_top_bar.dart'; import 'package:dartz/dartz.dart'; import 'package:flowy_infra/size.dart'; -import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart'; import 'package:flowy_infra_ui/widget/error_page.dart'; -import 'package:flowy_infra_ui/widget/spacing.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:styled_widget/styled_widget.dart'; + +import 'package:app_flowy/startup/startup.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/presentation/app/app_widget.dart'; +import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; +import 'package:app_flowy/workspace/presentation/widgets/menu/menu_user.dart'; + import 'menu_list.dart'; class HomeMenu extends StatelessWidget { final Function(HomeStackView?) pageContextChanged; final Function(bool) isCollapseChanged; - final String workspaceId; + final UserDetail user; const HomeMenu( {Key? key, required this.pageContextChanged, required this.isCollapseChanged, - required this.workspaceId}) + required this.user}) : super(key: key); @override @@ -34,10 +36,10 @@ class HomeMenu extends StatelessWidget { return MultiBlocProvider( providers: [ BlocProvider( - create: (context) => getIt(param1: workspaceId) - ..add(const MenuEvent.initial())), + create: (context) => + getIt(param1: user)..add(const MenuEvent.initial())), BlocProvider( - create: (context) => getIt(param1: workspaceId) + create: (context) => getIt(param1: user) ..add(const MenuWatchEvent.started())), ], child: MultiBlocListener( @@ -84,12 +86,12 @@ class HomeMenu extends StatelessWidget { return BlocBuilder( builder: (context, state) { return state.map( - initial: (_) => BlocBuilder( - builder: (context, s) => MenuList( - menuItems: menuItemsWithApps(s.apps), - ), + initial: (_) => MenuList( + menuItems: menuItemsWithApps(context.read().state.apps), + ), + loadApps: (s) => MenuList( + menuItems: menuItemsWithApps(some(s.apps)), ), - loadApps: (s) => MenuList(menuItems: menuItemsWithApps(some(s.apps))), loadFail: (s) => FlowyErrorPage(s.error.toString()), ); }, @@ -111,94 +113,30 @@ class HomeMenu extends StatelessWidget { } List menuItemsWithApps(Option> someApps) { - List menuItems = [ - const UserProfile(), - ]; - - // apps - List appWidgets = someApps.fold( - () => [], - (apps) => apps.map((app) => AppWidget(app)).toList(), - ); - - menuItems.addAll(appWidgets); - return menuItems; + return MenuItemBuilder().withUser(user).withApps(someApps).build(); } } -class MenuTopBar extends StatelessWidget { - const MenuTopBar({Key? key}) : super(key: key); - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (context, state) { - return Row( - children: [ - const Image( - fit: BoxFit.cover, - width: 25, - height: 25, - image: AssetImage('assets/images/app_flowy_logo.jpg')), - const HSpace(8), - const Text( - 'AppFlowy', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), - ), - const Spacer(), - IconButton( - icon: const Icon(Icons.arrow_left), - alignment: Alignment.centerRight, - padding: EdgeInsets.zero, - onPressed: () => - context.read().add(const MenuEvent.collapse()), - ), - ], - ); - }, +class MenuItemBuilder { + List items = []; + + MenuItemBuilder(); + + MenuItemBuilder withUser(UserDetail user) { + items.add(MenuUser(user)); + return this; + } + + MenuItemBuilder withApps(Option> someApps) { + List appWidgets = someApps.foldRight( + [], + (apps, _) => apps.map((app) => AppWidget(app)).toList(), ); - } -} - -class NewAppButton extends StatelessWidget { - final Function(String)? press; - - const NewAppButton({this.press, Key? key}) : super(key: key); - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - border: Border( - top: BorderSide(width: 1, color: Colors.grey.shade300), - ), - ), - height: HomeSizes.menuAddButtonHeight, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const Icon(Icons.add_circle_rounded, size: 30), - TextButton( - onPressed: () async => await _showCreateAppDialog(context), - child: const Text( - 'New App', - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 20, - ), - ), - ) - ], - ).padding(horizontal: Insets.l), - ); - } - - Future _showCreateAppDialog(BuildContext context) async { - await Dialogs.showWithContext(CreateAppDialogContext( - confirm: (appName) { - if (appName.isNotEmpty && press != null) { - press!(appName); - } - }, - ), context); + items.addAll(appWidgets); + return this; + } + + List build() { + return items; } } diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart new file mode 100644 index 0000000000..94430c86c1 --- /dev/null +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_new_app.dart @@ -0,0 +1,50 @@ +import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; +import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart'; +import 'package:flowy_infra/size.dart'; +import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart'; +import 'package:flutter/material.dart'; +import 'package:styled_widget/styled_widget.dart'; + +class NewAppButton extends StatelessWidget { + final Function(String)? press; + + const NewAppButton({this.press, Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border( + top: BorderSide(width: 1, color: Colors.grey.shade300), + ), + ), + height: HomeSizes.menuAddButtonHeight, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const Icon(Icons.add_circle_rounded, size: 30), + TextButton( + onPressed: () async => await _showCreateAppDialog(context), + child: const Text( + 'New App', + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), + ) + ], + ).padding(horizontal: Insets.l), + ); + } + + Future _showCreateAppDialog(BuildContext context) async { + await Dialogs.showWithContext(CreateAppDialogContext( + confirm: (appName) { + if (appName.isNotEmpty && press != null) { + press!(appName); + } + }, + ), context); + } +} diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_size.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_size.dart deleted file mode 100644 index 6d5e56a67b..0000000000 --- a/app_flowy/lib/workspace/presentation/widgets/menu/menu_size.dart +++ /dev/null @@ -1,4 +0,0 @@ -class HomeMenuSize { - static double get createViewButtonSize => 30; - static double get collapseIconSize => 24; -} diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart new file mode 100644 index 0000000000..0db99423a4 --- /dev/null +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_top_bar.dart @@ -0,0 +1,37 @@ +import 'package:app_flowy/workspace/application/menu/menu_bloc.dart'; +import 'package:flowy_infra_ui/widget/spacing.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class MenuTopBar extends StatelessWidget { + const MenuTopBar({Key? key}) : super(key: key); + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return Row( + children: [ + const Image( + fit: BoxFit.cover, + width: 25, + height: 25, + image: AssetImage('assets/images/app_flowy_logo.jpg')), + const HSpace(8), + const Text( + 'AppFlowy', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + const Spacer(), + IconButton( + icon: const Icon(Icons.arrow_left), + alignment: Alignment.centerRight, + padding: EdgeInsets.zero, + onPressed: () => + context.read().add(const MenuEvent.collapse()), + ), + ], + ); + }, + ); + } +} diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/user_profile.dart b/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart similarity index 67% rename from app_flowy/lib/workspace/presentation/widgets/menu/user_profile.dart rename to app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart index d05d53fc73..888ff3c0d2 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/user_profile.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/menu_user.dart @@ -1,9 +1,11 @@ import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; +import 'package:flowy_sdk/protobuf/flowy-user/user_detail.pb.dart'; import 'package:flutter/material.dart'; -class UserProfile extends MenuItem { - const UserProfile({Key? key}) : super(key: key); +class MenuUser extends MenuItem { + final UserDetail user; + MenuUser(this.user, {Key? key}) : super(key: ValueKey(user.id)); @override Widget build(BuildContext context) { @@ -12,11 +14,11 @@ class UserProfile extends MenuItem { width: 30, height: 30, child: ClipRRect( - borderRadius: BorderRadius.circular(8), + borderRadius: BorderRadius.circular(10), child: const Image(image: AssetImage('assets/images/avatar.jpg')), ), ), - const HSpace(6), + const HSpace(10), const Text("nathan", style: TextStyle(fontSize: 18)), ]); } diff --git a/app_flowy/lib/workspace/presentation/widgets/menu/prelude.dart b/app_flowy/lib/workspace/presentation/widgets/menu/prelude.dart index c541cb3e36..c08dc66133 100644 --- a/app_flowy/lib/workspace/presentation/widgets/menu/prelude.dart +++ b/app_flowy/lib/workspace/presentation/widgets/menu/prelude.dart @@ -1,2 +1 @@ export 'menu.dart'; -export 'menu_size.dart';