Move map browser entrance from tab to collections page

This commit is contained in:
Ming Ming 2024-10-27 03:31:01 +08:00
parent cecd0691fe
commit c81c80a272
9 changed files with 101 additions and 48 deletions

View file

@ -583,6 +583,10 @@ const _viewerBottomAppBarButtonsDefault = [
ViewerAppBarButtonType.delete,
];
const _homeCollectionsNavBarButtonsDefault = [
PrefHomeCollectionsNavButton(
type: HomeCollectionsNavBarButtonType.map,
isMinimized: false,
),
PrefHomeCollectionsNavButton(
type: HomeCollectionsNavBarButtonType.sharing,
isMinimized: false,

View file

@ -22,7 +22,6 @@ 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';
@ -121,11 +120,6 @@ 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,
@ -137,7 +131,7 @@ class _HomeState extends State<Home> with TickerProviderStateMixin {
return PageView.builder(
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
itemCount: 4,
itemCount: 3,
itemBuilder: (context, index) => SlideTransition(
position: Tween(
begin: const Offset(0, .05),
@ -164,9 +158,6 @@ 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

@ -37,6 +37,7 @@ import 'package:nc_photos/widget/enhanced_photo_browser.dart';
import 'package:nc_photos/widget/fade_out_list.dart';
import 'package:nc_photos/widget/handler/double_tap_exit_handler.dart';
import 'package:nc_photos/widget/home_app_bar.dart';
import 'package:nc_photos/widget/map_browser.dart';
import 'package:nc_photos/widget/navigation_bar_blur_filter.dart';
import 'package:nc_photos/widget/new_collection_dialog.dart';
import 'package:nc_photos/widget/page_visibility_mixin.dart';

View file

@ -242,3 +242,23 @@ class _NavBarTrashButton extends StatelessWidget {
final bool isMinimized;
}
class _NavBarMapButton extends StatelessWidget {
const _NavBarMapButton({
required this.isMinimized,
});
@override
Widget build(BuildContext context) {
return _NavBarButton(
icon: const Icon(Icons.map_outlined),
label: L10n.global().homeTabMapBrowser,
isMinimized: isMinimized,
onPressed: () {
Navigator.of(context).pushNamed(MapBrowser.routeName);
},
);
}
final bool isMinimized;
}

View file

@ -6,6 +6,7 @@ enum HomeCollectionsNavBarButtonType {
edited,
archive,
trash,
map,
;
static HomeCollectionsNavBarButtonType fromValue(int value) =>
@ -76,6 +77,8 @@ class _NavigationBarState extends State<_NavigationBar> {
return _NavBarArchiveButton(isMinimized: btn.isMinimized);
case HomeCollectionsNavBarButtonType.trash:
return _NavBarTrashButton(isMinimized: btn.isMinimized);
case HomeCollectionsNavBarButtonType.map:
return _NavBarMapButton(isMinimized: btn.isMinimized);
}
}

View file

@ -27,10 +27,8 @@ import 'package:nc_photos/np_api_util.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/stream_extension.dart';
import 'package:nc_photos/stream_util.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:nc_photos/widget/network_thumbnail.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_common/object_util.dart';
@ -46,6 +44,12 @@ 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
@ -77,47 +81,43 @@ class _WrappedMapBrowser extends StatelessWidget {
},
),
],
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(),
child: Scaffold(
body: Stack(
children: [
const _MapView(),
Positioned.directional(
textDirection: Directionality.of(context),
top: MediaQuery.of(context).padding.top + 8,
end: 8,
child: const _DateRangeToggle(),
),
),
Positioned(
left: 8,
right: 8,
top: MediaQuery.of(context).padding.top + 8,
child: _BlocSelector<bool>(
_BlocSelector<bool>(
selector: (state) => state.isShowDataRangeControlPanel,
builder: (context, isShowDataRangeControlPanel) =>
_PanelContainer(
isShow: isShowDataRangeControlPanel,
child: const _DateRangeControlPanel(),
builder: (context, isShowAnyPanel) => Positioned.fill(
child: isShowAnyPanel
? GestureDetector(
onTap: () {
context.addEvent(const _CloseControlPanel());
},
)
: const SizedBox.shrink(),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: NavigationBarBlurFilter(
height: AppDimension.of(context).homeBottomAppBarHeight,
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(),
),
),
),
),
],
],
),
),
);
}

View file

@ -36,6 +36,7 @@ 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';
@ -215,6 +216,7 @@ 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) {

View file

@ -123,3 +123,26 @@ class _TrashButton extends StatelessWidget {
final bool isMinimized;
final VoidCallback? onPressed;
}
class _MapButton extends StatelessWidget {
const _MapButton({
required this.isMinimized,
this.onPressed,
});
@override
Widget build(BuildContext context) {
return HomeCollectionsNavBarButton(
icon: const Icon(Icons.map_outlined),
label: L10n.global().homeTabMapBrowser,
isMinimized: isMinimized,
isUseTooltipWhenMinimized: false,
onPressed: () {
onPressed?.call();
},
);
}
final bool isMinimized;
final VoidCallback? onPressed;
}

View file

@ -137,6 +137,13 @@ class _DemoButtonDelegate extends StatelessWidget {
context.addEvent(_ToggleMinimized(type));
},
);
case HomeCollectionsNavBarButtonType.map:
return _MapButton(
isMinimized: isMinimized,
onPressed: () {
context.addEvent(_ToggleMinimized(type));
},
);
}
}
@ -209,6 +216,8 @@ class _CandidateButtonDelegate extends StatelessWidget {
return const _ArchiveButton(isMinimized: false);
case HomeCollectionsNavBarButtonType.trash:
return const _TrashButton(isMinimized: false);
case HomeCollectionsNavBarButtonType.map:
return const _MapButton(isMinimized: false);
}
}