Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: hide menu resize when collapsed (#5076)
Mathias Mogensen72049d28d5f2
diff --git a/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart b/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dartindex 8fd945aa58..04da5665a8 100644--- a/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/home/home_service.dart@@ -6,9 +6,10 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';import 'package:appflowy_result/appflowy_result.dart';class HomeService {- Future<FlowyResult<ViewPB, FlowyError>> readApp({required String appId}) {+ static Future<FlowyResult<ViewPB, FlowyError>> readApp({+ required String appId,+ }) {final payload = ViewIdPB.create()..value = appId;-return FolderEventGetView(payload).send();}}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/desktop_home_screen.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/desktop_home_screen.dartindex 5172ba004d..b9017e04e6 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/desktop_home_screen.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/desktop_home_screen.dart@@ -76,13 +76,11 @@ class DesktopHomeScreen extends StatelessWidget {HomeBloc(workspaceSetting)..add(const HomeEvent.initial()),),BlocProvider<HomeSettingBloc>(- create: (_) {- return HomeSettingBloc(- workspaceSetting,- context.read<AppearanceSettingsCubit>(),- context.widthPx,- )..add(const HomeSettingEvent.initial());- },+ create: (_) => HomeSettingBloc(+ workspaceSetting,+ context.read<AppearanceSettingsCubit>(),+ context.widthPx,+ )..add(const HomeSettingEvent.initial()),),BlocProvider<FavoriteBloc>(create: (context) =>@@ -91,44 +89,38 @@ class DesktopHomeScreen extends StatelessWidget {],child: HomeHotKeys(child: Scaffold(- body: MultiBlocListener(- listeners: [- BlocListener<HomeBloc, HomeState>(- listenWhen: (p, c) => p.latestView != c.latestView,- listener: (context, state) {- final view = state.latestView;- if (view != null) {- // Only open the last opened view if the [TabsState.currentPageManager] current opened plugin is blank and the last opened view is not null.- // All opened widgets that display on the home screen are in the form of plugins. There is a list of built-in plugins defined in the [PluginType] enum, including board, grid and trash.- final currentPageManager =- context.read<TabsBloc>().state.currentPageManager;+ floatingActionButton: enableMemoryLeakDetect+ ? const FloatingActionButton(+ onPressed: dumpMemoryLeak,+ child: Icon(Icons.memory),+ )+ : null,+ body: BlocListener<HomeBloc, HomeState>(+ listenWhen: (p, c) => p.latestView != c.latestView,+ listener: (context, state) {+ final view = state.latestView;+ if (view != null) {+ // Only open the last opened view if the [TabsState.currentPageManager] current opened plugin is blank and the last opened view is not null.+ // All opened widgets that display on the home screen are in the form of plugins. There is a list of built-in plugins defined in the [PluginType] enum, including board, grid and trash.+ final currentPageManager =+ context.read<TabsBloc>().state.currentPageManager;- if (currentPageManager.plugin.pluginType ==- PluginType.blank) {- getIt<TabsBloc>().add(- TabsEvent.openPlugin(plugin: view.plugin()),- );- }- }- },- ),- ],+ if (currentPageManager.plugin.pluginType ==+ PluginType.blank) {+ getIt<TabsBloc>().add(+ TabsEvent.openPlugin(plugin: view.plugin()),+ );+ }+ }+ },child: BlocBuilder<HomeSettingBloc, HomeSettingState>(buildWhen: (previous, current) => previous != current,- builder: (context, state) {- return FlowyContainer(- Theme.of(context).colorScheme.surface,- child: _buildBody(context, userProfile, workspaceSetting),- );- },+ builder: (context, state) => FlowyContainer(+ Theme.of(context).colorScheme.surface,+ child: _buildBody(context, userProfile, workspaceSetting),+ ),),),- floatingActionButton: enableMemoryLeakDetect- ? FloatingActionButton(- onPressed: () async => dumpMemoryLeak(),- child: const Icon(Icons.memory),- )- : null,),),);@@ -147,35 +139,30 @@ class DesktopHomeScreen extends StatelessWidget {final layout = HomeLayout(context);final homeStack = HomeStack(layout: layout,- delegate: DesktopHomeScreenStackAdaptor(- buildContext: context,- ),+ delegate: DesktopHomeScreenStackAdaptor(context),);final menu = _buildHomeSidebar(+ context,layout: layout,- context: context,userProfile: userProfile,workspaceSetting: workspaceSetting,);- final homeMenuResizer = _buildHomeMenuResizer(context: context);- final editPanel = _buildEditPanel(- layout: layout,- context: context,- );- const bubble = QuestionBubble();+ final homeMenuResizer = _buildHomeMenuResizer(context, layout: layout);+ final editPanel = _buildEditPanel(context, layout: layout);+return _layoutWidgets(layout: layout,homeStack: homeStack,homeMenu: menu,editPanel: editPanel,- bubble: bubble,+ bubble: const QuestionBubble(),homeMenuResizer: homeMenuResizer,);}- Widget _buildHomeSidebar({+ Widget _buildHomeSidebar(+ BuildContext context, {required HomeLayout layout,- required BuildContext context,required UserProfilePB userProfile,required WorkspaceSettingPB workspaceSetting,}) {@@ -186,8 +173,8 @@ class DesktopHomeScreen extends StatelessWidget {return FocusTraversalGroup(child: RepaintBoundary(child: homeMenu));}- Widget _buildEditPanel({- required BuildContext context,+ Widget _buildEditPanel(+ BuildContext context, {required HomeLayout layout,}) {final homeBloc = context.read<HomeSettingBloc>();@@ -199,12 +186,14 @@ class DesktopHomeScreen extends StatelessWidget {if (panelContext == null) {return const SizedBox.shrink();}+return FocusTraversalGroup(child: RepaintBoundary(child: EditPanel(panelContext: panelContext,- onEndEdit: () =>- homeBloc.add(const HomeSettingEvent.dismissEditPanel()),+ onEndEdit: () => homeBloc.add(+ const HomeSettingEvent.dismissEditPanel(),+ ),),),);@@ -212,9 +201,14 @@ class DesktopHomeScreen extends StatelessWidget {);}- Widget _buildHomeMenuResizer({- required BuildContext context,+ Widget _buildHomeMenuResizer(+ BuildContext context, {+ required HomeLayout layout,}) {+ if (!layout.showMenu) {+ return const SizedBox.shrink();+ }+return MouseRegion(cursor: SystemMouseCursors.resizeLeftRight,child: GestureDetector(@@ -261,11 +255,7 @@ class DesktopHomeScreen extends StatelessWidget {).animate(layout.animDuration, Curves.easeOutQuad),bubble- .positioned(- right: 20,- bottom: 16,- animate: true,- )+ .positioned(right: 20, bottom: 16, animate: true).animate(layout.animDuration, Curves.easeOut),editPanel.animatedPanelX(@@ -275,8 +265,8 @@ class DesktopHomeScreen extends StatelessWidget {curve: Curves.easeOutQuad,).positioned(- right: 0,top: 0,+ right: 0,bottom: 0,width: layout.editPanelWidth,),@@ -287,12 +277,7 @@ class DesktopHomeScreen extends StatelessWidget {curve: Curves.easeOutQuad,duration: layout.animDuration.inMilliseconds * 0.001,)- .positioned(- left: 0,- top: 0,- width: layout.menuWidth,- bottom: 0,- ),+ .positioned(left: 0, top: 0, width: layout.menuWidth, bottom: 0),homeMenuResizer.positioned(left: layout.menuWidth - 5).animate(layout.animDuration, Curves.easeOutQuad),@@ -302,14 +287,13 @@ class DesktopHomeScreen extends StatelessWidget {}class DesktopHomeScreenStackAdaptor extends HomeStackDelegate {- DesktopHomeScreenStackAdaptor({required this.buildContext});+ DesktopHomeScreenStackAdaptor(this.buildContext);final BuildContext buildContext;@overridevoid didDeleteStackWidget(ViewPB view, int? index) {- final homeService = HomeService();- homeService.readApp(appId: view.parentViewId).then((result) {+ HomeService.readApp(appId: view.parentViewId).then((result) {result.fold((parentView) {final List<ViewPB> views = parentView.childViews;@@ -319,16 +303,12 @@ class DesktopHomeScreenStackAdaptor extends HomeStackDelegate {lastView = views[index - 1];}- getIt<TabsBloc>().add(- TabsEvent.openPlugin(plugin: lastView.plugin()),- );- } else {- getIt<TabsBloc>().add(- TabsEvent.openPlugin(- plugin: BlankPagePlugin(),- ),- );+ return getIt<TabsBloc>()+ .add(TabsEvent.openPlugin(plugin: lastView.plugin()));}++ getIt<TabsBloc>()+ .add(TabsEvent.openPlugin(plugin: BlankPagePlugin()));},(err) => Log.error(err),);diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dartindex 8d5a0259ee..dddc78e87a 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/navigation.dart@@ -1,5 +1,7 @@import 'dart:io';+import 'package:flutter/material.dart';+import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/workspace/application/home/home_setting_bloc.dart';@@ -9,7 +11,6 @@ import 'package:flowy_infra/size.dart';import 'package:flowy_infra_ui/style_widget/icon_button.dart';import 'package:flowy_infra_ui/style_widget/text.dart';import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';-import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:provider/provider.dart';import 'package:styled_widget/styled_widget.dart';@@ -75,11 +76,9 @@ class FlowyNavigation extends StatelessWidget {child: FlowyIconButton(width: 24,hoverColor: Colors.transparent,- onPressed: () {- context- .read<HomeSettingBloc>()- .add(const HomeSettingEvent.collapseMenu());- },+ onPressed: () => context+ .read<HomeSettingBloc>()+ .add(const HomeSettingEvent.collapseMenu()),iconPadding: const EdgeInsets.fromLTRB(2, 2, 2, 2),icon: FlowySvg(FlowySvgs.hide_menu_m,@@ -88,9 +87,9 @@ class FlowyNavigation extends StatelessWidget {),),);- } else {- return const SizedBox.shrink();}++ return const SizedBox.shrink();},);}