#178 pick mode: allow nav from filter pages

This commit is contained in:
Thibault Deckers 2022-02-08 12:06:26 +09:00
parent b9ef030001
commit 6c145d5bb5
7 changed files with 16 additions and 14 deletions

View file

@ -1,11 +1,11 @@
enum AppMode { main, pickExternal, pickInternal, view }
enum AppMode { main, pickMediaExternal, pickMediaInternal, pickFilterInternal, view }
extension ExtraAppMode on AppMode {
bool get canSearch => this == AppMode.main || this == AppMode.pickExternal;
bool get canSearch => this == AppMode.main || this == AppMode.pickMediaExternal;
bool get canSelect => this == AppMode.main;
bool get hasDrawer => this == AppMode.main || this == AppMode.pickExternal;
bool get hasDrawer => this == AppMode.main || this == AppMode.pickMediaExternal;
bool get isPicking => this == AppMode.pickExternal || this == AppMode.pickInternal;
bool get isPickingMedia => this == AppMode.pickMediaExternal || this == AppMode.pickMediaInternal;
}

View file

@ -110,7 +110,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
return AnimatedBuilder(
animation: collection.filterChangeNotifier,
builder: (context, child) {
final removableFilters = appMode != AppMode.pickInternal;
final removableFilters = appMode != AppMode.pickMediaInternal;
return Selector<Query, bool>(
selector: (context, query) => query.enabled,
builder: (context, queryEnabled, child) {
@ -185,7 +185,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
);
} else {
final appMode = context.watch<ValueNotifier<AppMode>>().value;
Widget title = Text(appMode.isPicking ? l10n.collectionPickPageTitle : l10n.collectionPageTitle);
Widget title = Text(appMode.isPickingMedia ? l10n.collectionPickPageTitle : l10n.collectionPageTitle);
if (appMode == AppMode.main) {
title = SourceStateAwareAppBarTitle(
title: title,

View file

@ -43,12 +43,13 @@ class InteractiveTile extends StatelessWidget {
_goToViewer(context);
}
break;
case AppMode.pickExternal:
case AppMode.pickMediaExternal:
ViewerService.pick(entry.uri);
break;
case AppMode.pickInternal:
case AppMode.pickMediaInternal:
Navigator.pop(context, entry);
break;
case AppMode.pickFilterInternal:
case AppMode.view:
break;
}

View file

@ -39,7 +39,7 @@ class _ItemPickDialogState extends State<ItemPickDialog> {
Widget build(BuildContext context) {
final liveFilter = collection.filters.firstWhereOrNull((v) => v is QueryFilter && v.live) as QueryFilter?;
return ListenableProvider<ValueNotifier<AppMode>>.value(
value: ValueNotifier(AppMode.pickInternal),
value: ValueNotifier(AppMode.pickMediaInternal),
child: MediaQueryDataProvider(
child: Scaffold(
body: SelectionProvider<AvesEntry>(

View file

@ -65,7 +65,7 @@ class _AlbumPickPageState extends State<_AlbumPickPage> {
@override
Widget build(BuildContext context) {
return ListenableProvider<ValueNotifier<AppMode>>.value(
value: ValueNotifier(AppMode.pickInternal),
value: ValueNotifier(AppMode.pickFilterInternal),
child: Selector<Settings, Tuple2<AlbumChipGroupFactor, ChipSortFactor>>(
selector: (context, s) => Tuple2(s.albumGroupFactor, s.albumSortFactor),
builder: (context, s, child) {

View file

@ -51,6 +51,7 @@ class _InteractiveFilterTileState<T extends CollectionFilter> extends State<Inte
final appMode = context.read<ValueNotifier<AppMode>>().value;
switch (appMode) {
case AppMode.main:
case AppMode.pickMediaExternal:
final selection = context.read<Selection<FilterGridItem<T>>>();
if (selection.isSelecting) {
selection.toggleSelection(gridItem);
@ -58,10 +59,10 @@ class _InteractiveFilterTileState<T extends CollectionFilter> extends State<Inte
_goToCollection(context, filter);
}
break;
case AppMode.pickInternal:
case AppMode.pickFilterInternal:
Navigator.pop<T>(context, filter);
break;
case AppMode.pickExternal:
case AppMode.pickMediaInternal:
case AppMode.view:
break;
}

View file

@ -94,7 +94,7 @@ class _HomePageState extends State<HomePage> {
}
break;
case 'pick':
appMode = AppMode.pickExternal;
appMode = AppMode.pickMediaExternal;
// TODO TLAD apply pick mimetype(s)
// some apps define multiple types, separated by a space (maybe other signs too, like `,` `;`?)
String? pickMimeTypes = intentData['mimeType'];
@ -199,7 +199,7 @@ class _HomePageState extends State<HomePage> {
String routeName;
Set<CollectionFilter?>? filters;
if (appMode == AppMode.pickExternal) {
if (appMode == AppMode.pickMediaExternal) {
routeName = CollectionPage.routeName;
} else {
routeName = _shortcutRouteName ?? settings.homePage.routeName;