From 942d36d4a6cdc10f055dd607e06d8ab421c6eca6 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 20 Jul 2024 16:17:09 +0800 Subject: [PATCH] Move map browser to tab instead of being a standalone page --- app/lib/l10n/app_en.arb | 1 + app/lib/l10n/untranslated-messages.txt | 41 +++++++--- app/lib/widget/home.dart | 13 ++- app/lib/widget/map_browser.dart | 109 ++++++++++++------------- app/lib/widget/my_app.dart | 2 - 5 files changed, 93 insertions(+), 73 deletions(-) diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 0675149b..a7162afa 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -1495,6 +1495,7 @@ "mapBrowserDateRangePrevMonth": "Previous month", "mapBrowserDateRangeThisYear": "This year", "mapBrowserDateRangeCustom": "Custom", + "homeTabMapBrowser": "Map", "errorUnauthenticated": "Unauthenticated access. Please sign-in again if the problem continues", "@errorUnauthenticated": { diff --git a/app/lib/l10n/untranslated-messages.txt b/app/lib/l10n/untranslated-messages.txt index e5b40963..bab42341 100644 --- a/app/lib/l10n/untranslated-messages.txt +++ b/app/lib/l10n/untranslated-messages.txt @@ -254,6 +254,7 @@ "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", "mapBrowserDateRangeCustom", + "homeTabMapBrowser", "errorUnauthenticated", "errorDisconnected", "errorLocked", @@ -294,7 +295,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "de": [ @@ -333,7 +335,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "el": [ @@ -475,7 +478,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "es": [ @@ -508,7 +512,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "fi": [ @@ -541,7 +546,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "fr": [ @@ -574,7 +580,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "it": [ @@ -612,7 +619,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "nl": [ @@ -987,6 +995,7 @@ "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", "mapBrowserDateRangeCustom", + "homeTabMapBrowser", "errorUnauthenticated", "errorDisconnected", "errorLocked", @@ -1031,7 +1040,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "pt": [ @@ -1084,7 +1094,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "ru": [ @@ -1117,7 +1128,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "tr": [ @@ -1125,7 +1137,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "zh": [ @@ -1189,7 +1202,8 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ], "zh_Hant": [ @@ -1347,6 +1361,7 @@ "mapBrowserDateRangeThisMonth", "mapBrowserDateRangePrevMonth", "mapBrowserDateRangeThisYear", - "mapBrowserDateRangeCustom" + "mapBrowserDateRangeCustom", + "homeTabMapBrowser" ] } diff --git a/app/lib/widget/home.dart b/app/lib/widget/home.dart index 360293a8..98dafc7d 100644 --- a/app/lib/widget/home.dart +++ b/app/lib/widget/home.dart @@ -22,6 +22,7 @@ import 'package:nc_photos/use_case/import_potential_shared_album.dart'; import 'package:nc_photos/widget/home_collections.dart'; import 'package:nc_photos/widget/home_photos2.dart'; import 'package:nc_photos/widget/home_search.dart'; +import 'package:nc_photos/widget/map_browser.dart'; import 'package:np_codegen/np_codegen.dart'; import 'package:np_common/or_null.dart'; @@ -87,7 +88,7 @@ class _HomeState extends State with TickerProviderStateMixin { } @override - build(BuildContext context) { + Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: _buildBottomNavigationBar(context), body: Builder(builder: (context) => _buildContent(context)), @@ -114,6 +115,11 @@ class _HomeState extends State with TickerProviderStateMixin { selectedIcon: const Icon(Icons.grid_view_sharp), label: L10n.global().collectionsTooltip, ), + NavigationDestination( + icon: const Icon(Icons.map_outlined), + selectedIcon: const Icon(Icons.map), + label: L10n.global().homeTabMapBrowser, + ), ], selectedIndex: _nextPage, onDestinationSelected: _onTapNavItem, @@ -125,7 +131,7 @@ class _HomeState extends State with TickerProviderStateMixin { return PageView.builder( controller: _pageController, physics: const NeverScrollableScrollPhysics(), - itemCount: 3, + itemCount: 4, itemBuilder: (context, index) => SlideTransition( position: Tween( begin: const Offset(0, .05), @@ -152,6 +158,9 @@ class _HomeState extends State with TickerProviderStateMixin { case 2: return const HomeCollections(); + case 3: + return const MapBrowser(); + default: throw ArgumentError("Invalid page index: $index"); } diff --git a/app/lib/widget/map_browser.dart b/app/lib/widget/map_browser.dart index df736452..423f11d0 100644 --- a/app/lib/widget/map_browser.dart +++ b/app/lib/widget/map_browser.dart @@ -25,8 +25,10 @@ import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/stream_extension.dart'; import 'package:nc_photos/theme.dart'; +import 'package:nc_photos/theme/dimension.dart'; import 'package:nc_photos/widget/collection_browser.dart'; import 'package:nc_photos/widget/measure.dart'; +import 'package:nc_photos/widget/navigation_bar_blur_filter.dart'; import 'package:np_codegen/np_codegen.dart'; import 'package:np_common/object_util.dart'; import 'package:np_datetime/np_datetime.dart'; @@ -40,12 +42,6 @@ part 'map_browser/type.dart'; part 'map_browser/view.dart'; class MapBrowser extends StatelessWidget { - static const routeName = "/map-browser"; - - static Route buildRoute() => MaterialPageRoute( - builder: (_) => const MapBrowser(), - ); - const MapBrowser({super.key}); @override @@ -66,57 +62,58 @@ class _WrappedMapBrowser extends StatelessWidget { @override Widget build(BuildContext context) { - return AnnotatedRegion( - value: SystemUiOverlayStyle.dark, - child: Scaffold( - body: MultiBlocListener( - listeners: [ - _BlocListenerT( - selector: (state) => state.error, - listener: (context, error) { - if (error != null) { - SnackBarManager().showSnackBarForException(error.error); - } - }, - ), - ], - child: Stack( - children: [ - const _MapView(), - Positioned.directional( - textDirection: Directionality.of(context), - top: MediaQuery.of(context).padding.top + 8, - end: 8, - child: const _DateRangeToggle(), - ), - _BlocSelector( - selector: (state) => state.isShowDataRangeControlPanel, - builder: (context, isShowAnyPanel) => Positioned.fill( - child: isShowAnyPanel - ? GestureDetector( - onTap: () { - context.addEvent(const _CloseControlPanel()); - }, - ) - : const SizedBox.shrink(), - ), - ), - Positioned( - left: 8, - right: 8, - top: MediaQuery.of(context).padding.top + 8, - child: _BlocSelector( - selector: (state) => state.isShowDataRangeControlPanel, - builder: (context, isShowDataRangeControlPanel) => - _PanelContainer( - isShow: isShowDataRangeControlPanel, - child: const _DateRangeControlPanel(), - ), - ), - ), - ], - ), + return MultiBlocListener( + listeners: [ + _BlocListenerT( + selector: (state) => state.error, + listener: (context, error) { + if (error != null) { + SnackBarManager().showSnackBarForException(error.error); + } + }, ), + ], + child: Stack( + children: [ + const _MapView(), + Positioned.directional( + textDirection: Directionality.of(context), + top: MediaQuery.of(context).padding.top + 8, + end: 8, + child: const _DateRangeToggle(), + ), + _BlocSelector( + selector: (state) => state.isShowDataRangeControlPanel, + builder: (context, isShowAnyPanel) => Positioned.fill( + child: isShowAnyPanel + ? GestureDetector( + onTap: () { + context.addEvent(const _CloseControlPanel()); + }, + ) + : const SizedBox.shrink(), + ), + ), + Positioned( + left: 8, + right: 8, + top: MediaQuery.of(context).padding.top + 8, + child: _BlocSelector( + selector: (state) => state.isShowDataRangeControlPanel, + builder: (context, isShowDataRangeControlPanel) => + _PanelContainer( + isShow: isShowDataRangeControlPanel, + child: const _DateRangeControlPanel(), + ), + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: NavigationBarBlurFilter( + height: AppDimension.of(context).homeBottomAppBarHeight, + ), + ), + ], ), ); } diff --git a/app/lib/widget/my_app.dart b/app/lib/widget/my_app.dart index 3dbab0e7..9055fb33 100644 --- a/app/lib/widget/my_app.dart +++ b/app/lib/widget/my_app.dart @@ -37,7 +37,6 @@ import 'package:nc_photos/widget/home.dart'; import 'package:nc_photos/widget/image_editor.dart'; import 'package:nc_photos/widget/image_enhancer.dart'; import 'package:nc_photos/widget/local_file_viewer.dart'; -import 'package:nc_photos/widget/map_browser.dart'; import 'package:nc_photos/widget/people_browser.dart'; import 'package:nc_photos/widget/places_browser.dart'; import 'package:nc_photos/widget/result_viewer.dart'; @@ -220,7 +219,6 @@ class _WrappedAppState extends State<_WrappedApp> PlacesBrowser.routeName: PlacesBrowser.buildRoute, ArchiveBrowser.routeName: ArchiveBrowser.buildRoute, TrustedCertManager.routeName: TrustedCertManager.buildRoute, - MapBrowser.routeName: MapBrowser.buildRoute, }; Route? _onGenerateRoute(RouteSettings settings) {