From 83e8ea1dcbe5c0ed0b14e9604a6936ddb62cbbe2 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 17 Aug 2024 11:31:52 +0800 Subject: [PATCH] fix: disable more button in row page --- .../lib/mobile/application/mobile_router.dart | 9 +++++++- .../presentation/base/mobile_view_page.dart | 22 +++++++++++++------ .../card_detail/widgets/row_page_button.dart | 1 + .../editor/mobile_editor_screen.dart | 4 ++++ .../lib/startup/tasks/generate_router.dart | 10 ++++++++- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/frontend/appflowy_flutter/lib/mobile/application/mobile_router.dart b/frontend/appflowy_flutter/lib/mobile/application/mobile_router.dart index 7fc1f0824b..da1d9de7ca 100644 --- a/frontend/appflowy_flutter/lib/mobile/application/mobile_router.dart +++ b/frontend/appflowy_flutter/lib/mobile/application/mobile_router.dart @@ -18,14 +18,21 @@ extension MobileRouter on BuildContext { ViewPB view, { Map? arguments, bool addInRecent = true, + bool showMoreButton = true, }) async { // set the current view before pushing the new view getIt().latestOpenView = view; unawaited(getIt().updateRecentViews([view.id], true)); + final queryParameters = view.queryParameters(arguments); + + if (view.layout == ViewLayoutPB.Document) { + queryParameters[MobileDocumentScreen.viewShowMoreButton] = + showMoreButton.toString(); + } final uri = Uri( path: view.routeName, - queryParameters: view.queryParameters(arguments), + queryParameters: queryParameters, ).toString(); await push(uri); } diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart index 55d67ad6af..4b242bdbe1 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/base/mobile_view_page.dart @@ -26,6 +26,7 @@ class MobileViewPage extends StatefulWidget { required this.viewLayout, this.title, this.arguments, + this.showMoreButton = true, }); /// view id @@ -33,6 +34,7 @@ class MobileViewPage extends StatefulWidget { final ViewLayoutPB viewLayout; final String? title; final Map? arguments; + final bool showMoreButton; @override State createState() => _MobileViewPageState(); @@ -215,13 +217,19 @@ class _MobileViewPageState extends State { ]); } - actions.addAll([ - MobileViewPageMoreButton( - view: view, - isImmersiveMode: isImmersiveMode, - appBarOpacity: _appBarOpacity, - ), - ]); + if (widget.showMoreButton) { + actions.addAll([ + MobileViewPageMoreButton( + view: view, + isImmersiveMode: isImmersiveMode, + appBarOpacity: _appBarOpacity, + ), + ]); + } else { + actions.addAll([ + const HSpace(18.0), + ]); + } return actions; } diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/row_page_button.dart b/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/row_page_button.dart index 5db3de5c7d..bced3bd396 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/row_page_button.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/row_page_button.dart @@ -89,6 +89,7 @@ class _OpenRowPageButtonState extends State { await context.pushView( view!, addInRecent: false, + showMoreButton: false, ); } } diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/editor/mobile_editor_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/editor/mobile_editor_screen.dart index 14c4e022ae..b70c06b8bf 100644 --- a/frontend/appflowy_flutter/lib/mobile/presentation/editor/mobile_editor_screen.dart +++ b/frontend/appflowy_flutter/lib/mobile/presentation/editor/mobile_editor_screen.dart @@ -7,15 +7,18 @@ class MobileDocumentScreen extends StatelessWidget { super.key, required this.id, this.title, + this.showMoreButton = true, }); /// view id final String id; final String? title; + final bool showMoreButton; static const routeName = '/docs'; static const viewId = 'id'; static const viewTitle = 'title'; + static const viewShowMoreButton = 'show_more_button'; @override Widget build(BuildContext context) { @@ -23,6 +26,7 @@ class MobileDocumentScreen extends StatelessWidget { id: id, title: title, viewLayout: ViewLayoutPB.Document, + showMoreButton: showMoreButton, ); } } diff --git a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart index 765081be21..2159abfd1d 100644 --- a/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart +++ b/frontend/appflowy_flutter/lib/startup/tasks/generate_router.dart @@ -493,9 +493,17 @@ GoRoute _mobileEditorScreenRoute() { pageBuilder: (context, state) { final id = state.uri.queryParameters[MobileDocumentScreen.viewId]!; final title = state.uri.queryParameters[MobileDocumentScreen.viewTitle]; + final showMoreButton = bool.tryParse( + state.uri.queryParameters[MobileDocumentScreen.viewShowMoreButton] ?? + 'true', + ); return MaterialExtendedPage( - child: MobileDocumentScreen(id: id, title: title), + child: MobileDocumentScreen( + id: id, + title: title, + showMoreButton: showMoreButton ?? true, + ), ); }, );