Move map browser to tab instead of being a standalone page

This commit is contained in:
Ming Ming 2024-07-20 16:17:09 +08:00
parent 8c8dcb3e8e
commit 942d36d4a6
5 changed files with 93 additions and 73 deletions

View file

@ -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": {

View file

@ -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"
]
}

View file

@ -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<Home> 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<Home> 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<Home> 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<Home> with TickerProviderStateMixin {
case 2:
return const HomeCollections();
case 3:
return const MapBrowser();
default:
throw ArgumentError("Invalid page index: $index");
}

View file

@ -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<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.dark,
child: Scaffold(
body: MultiBlocListener(
listeners: [
_BlocListenerT<ExceptionEvent?>(
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<bool>(
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<bool>(
selector: (state) => state.isShowDataRangeControlPanel,
builder: (context, isShowDataRangeControlPanel) =>
_PanelContainer(
isShow: isShowDataRangeControlPanel,
child: const _DateRangeControlPanel(),
),
),
),
],
),
return MultiBlocListener(
listeners: [
_BlocListenerT<ExceptionEvent?>(
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<bool>(
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<bool>(
selector: (state) => state.isShowDataRangeControlPanel,
builder: (context, isShowDataRangeControlPanel) =>
_PanelContainer(
isShow: isShowDataRangeControlPanel,
child: const _DateRangeControlPanel(),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: NavigationBarBlurFilter(
height: AppDimension.of(context).homeBottomAppBarHeight,
),
),
],
),
);
}

View file

@ -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<dynamic>? _onGenerateRoute(RouteSettings settings) {