#967 pick collection with removable contextual filters to edit date/location
This commit is contained in:
parent
e9b86f9d77
commit
71e9e07668
13 changed files with 48 additions and 54 deletions
|
@ -3,7 +3,8 @@ enum AppMode {
|
|||
pickCollectionFiltersExternal,
|
||||
pickSingleMediaExternal,
|
||||
pickMultipleMediaExternal,
|
||||
pickMediaInternal,
|
||||
pickFilteredMediaInternal,
|
||||
pickUnfilteredMediaInternal,
|
||||
pickFilterInternal,
|
||||
screenSaver,
|
||||
setWallpaper,
|
||||
|
@ -40,6 +41,7 @@ extension ExtraAppMode on AppMode {
|
|||
bool get isPickingMedia => {
|
||||
AppMode.pickSingleMediaExternal,
|
||||
AppMode.pickMultipleMediaExternal,
|
||||
AppMode.pickMediaInternal,
|
||||
AppMode.pickFilteredMediaInternal,
|
||||
AppMode.pickUnfilteredMediaInternal,
|
||||
}.contains(this);
|
||||
}
|
||||
|
|
|
@ -385,14 +385,7 @@ class _AvesAppState extends State<AvesApp> with WidgetsBindingObserver {
|
|||
case AppMode.pickMultipleMediaExternal:
|
||||
_saveTopEntries();
|
||||
break;
|
||||
case AppMode.pickCollectionFiltersExternal:
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.pickFilterInternal:
|
||||
case AppMode.screenSaver:
|
||||
case AppMode.setWallpaper:
|
||||
case AppMode.slideshow:
|
||||
case AppMode.view:
|
||||
case AppMode.edit:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case AppLifecycleState.resumed:
|
||||
|
|
|
@ -163,7 +163,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
|||
child: AnimatedBuilder(
|
||||
animation: collection.filterChangeNotifier,
|
||||
builder: (context, child) {
|
||||
final removableFilters = appMode != AppMode.pickMediaInternal;
|
||||
final canRemoveFilters = appMode != AppMode.pickFilteredMediaInternal;
|
||||
return Selector<Query, bool>(
|
||||
selector: (context, query) => query.enabled,
|
||||
builder: (context, queryEnabled, child) {
|
||||
|
@ -172,7 +172,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
|||
builder: (context, _, child) {
|
||||
final useTvLayout = settings.useTvLayout;
|
||||
final actions = _buildActions(context, selection);
|
||||
final onFilterTap = removableFilters ? collection.removeFilter : null;
|
||||
final onFilterTap = canRemoveFilters ? collection.removeFilter : null;
|
||||
return AvesAppBar(
|
||||
contentHeight: appBarContentHeight,
|
||||
pinned: context.select<Selection<AvesEntry>, bool>((selection) => selection.isSelecting),
|
||||
|
|
|
@ -251,7 +251,7 @@ class _CollectionGridContentState extends State<_CollectionGridContent> {
|
|||
if (selection.isSelecting) {
|
||||
child = MultiProvider(
|
||||
providers: [
|
||||
ListenableProvider<ValueNotifier<AppMode>>.value(value: ValueNotifier(AppMode.pickMediaInternal)),
|
||||
ListenableProvider<ValueNotifier<AppMode>>.value(value: ValueNotifier(AppMode.pickFilteredMediaInternal)),
|
||||
ChangeNotifierProvider<Selection<AvesEntry>>.value(value: selection),
|
||||
],
|
||||
child: child,
|
||||
|
|
|
@ -201,15 +201,7 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||
IntentService.submitPickedCollectionFilters(filters);
|
||||
},
|
||||
);
|
||||
case AppMode.main:
|
||||
case AppMode.pickSingleMediaExternal:
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.pickFilterInternal:
|
||||
case AppMode.screenSaver:
|
||||
case AppMode.setWallpaper:
|
||||
case AppMode.slideshow:
|
||||
case AppMode.view:
|
||||
case AppMode.edit:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ class InteractiveTile extends StatelessWidget {
|
|||
case AppMode.pickMultipleMediaExternal:
|
||||
final selection = context.read<Selection<AvesEntry>>();
|
||||
selection.toggleSelection(entry);
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.pickFilteredMediaInternal:
|
||||
case AppMode.pickUnfilteredMediaInternal:
|
||||
Navigator.maybeOf(context)?.pop(entry);
|
||||
case AppMode.pickCollectionFiltersExternal:
|
||||
case AppMode.pickFilterInternal:
|
||||
|
|
|
@ -124,6 +124,7 @@ class _AddShortcutDialogState extends State<AddShortcutDialog> {
|
|||
source: _collection.source,
|
||||
filters: pickFilters,
|
||||
),
|
||||
canRemoveFilters: false,
|
||||
);
|
||||
},
|
||||
fullscreenDialog: true,
|
||||
|
|
|
@ -322,21 +322,31 @@ class _EditEntryDateDialogState extends State<EditEntryDateDialog> {
|
|||
));
|
||||
}
|
||||
|
||||
CollectionLens? _createPickCollection() {
|
||||
final baseCollection = widget.collection;
|
||||
return baseCollection != null
|
||||
? CollectionLens(
|
||||
source: baseCollection.source,
|
||||
filters: baseCollection.filters,
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
Future<void> _pickCopyItemSource() async {
|
||||
final _collection = widget.collection;
|
||||
if (_collection == null) return;
|
||||
final pickCollection = _createPickCollection();
|
||||
if (pickCollection == null) return;
|
||||
|
||||
final entry = await Navigator.maybeOf(context)?.push<AvesEntry>(
|
||||
MaterialPageRoute(
|
||||
settings: const RouteSettings(name: ItemPickPage.routeName),
|
||||
builder: (context) => ItemPickPage(
|
||||
collection: CollectionLens(
|
||||
source: _collection.source,
|
||||
),
|
||||
collection: pickCollection,
|
||||
canRemoveFilters: true,
|
||||
),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
);
|
||||
pickCollection.dispose();
|
||||
if (entry != null) {
|
||||
setState(() => _copyItemSource = entry);
|
||||
}
|
||||
|
|
|
@ -169,9 +169,9 @@ class _EditEntryLocationDialogState extends State<EditEntryLocationDialog> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> _pickLocation() async {
|
||||
CollectionLens? _createPickCollection() {
|
||||
final baseCollection = widget.collection;
|
||||
final mapCollection = baseCollection != null
|
||||
return baseCollection != null
|
||||
? CollectionLens(
|
||||
source: baseCollection.source,
|
||||
filters: {
|
||||
|
@ -180,17 +180,21 @@ class _EditEntryLocationDialogState extends State<EditEntryLocationDialog> {
|
|||
},
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
Future<void> _pickLocation() async {
|
||||
final pickCollection = _createPickCollection();
|
||||
final latLng = await Navigator.maybeOf(context)?.push(
|
||||
MaterialPageRoute(
|
||||
settings: const RouteSettings(name: LocationPickPage.routeName),
|
||||
builder: (context) => LocationPickPage(
|
||||
collection: mapCollection,
|
||||
collection: pickCollection,
|
||||
initialLocation: _mapCoordinates,
|
||||
),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
);
|
||||
mapCollection?.dispose();
|
||||
pickCollection?.dispose();
|
||||
if (latLng != null) {
|
||||
settings.mapDefaultCenter = latLng;
|
||||
setState(() {
|
||||
|
@ -218,20 +222,20 @@ class _EditEntryLocationDialogState extends State<EditEntryLocationDialog> {
|
|||
}
|
||||
|
||||
Future<void> _pickCopyItemSource() async {
|
||||
final _collection = widget.collection;
|
||||
if (_collection == null) return;
|
||||
final pickCollection = _createPickCollection();
|
||||
if (pickCollection == null) return;
|
||||
|
||||
final entry = await Navigator.maybeOf(context)?.push<AvesEntry>(
|
||||
MaterialPageRoute(
|
||||
settings: const RouteSettings(name: ItemPickPage.routeName),
|
||||
builder: (context) => ItemPickPage(
|
||||
collection: CollectionLens(
|
||||
source: _collection.source,
|
||||
),
|
||||
collection: pickCollection,
|
||||
canRemoveFilters: true,
|
||||
),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
);
|
||||
pickCollection.dispose();
|
||||
if (entry != null) {
|
||||
setState(() {
|
||||
_copyItemSource = entry;
|
||||
|
|
|
@ -344,6 +344,7 @@ class _CoverSelectionDialogState extends State<CoverSelectionDialog> {
|
|||
source: context.read<CollectionSource>(),
|
||||
filters: {filter},
|
||||
),
|
||||
canRemoveFilters: false,
|
||||
),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
|
|
|
@ -16,10 +16,12 @@ class ItemPickPage extends StatefulWidget {
|
|||
static const routeName = '/item_pick';
|
||||
|
||||
final CollectionLens collection;
|
||||
final bool canRemoveFilters;
|
||||
|
||||
const ItemPickPage({
|
||||
super.key,
|
||||
required this.collection,
|
||||
required this.canRemoveFilters,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -38,8 +40,9 @@ class _ItemPickPageState extends State<ItemPickPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final liveFilter = collection.filters.firstWhereOrNull((v) => v is QueryFilter && v.live) as QueryFilter?;
|
||||
final mode = widget.canRemoveFilters ? AppMode.pickUnfilteredMediaInternal : AppMode.pickFilteredMediaInternal;
|
||||
return ListenableProvider<ValueNotifier<AppMode>>.value(
|
||||
value: ValueNotifier(AppMode.pickMediaInternal),
|
||||
value: ValueNotifier(mode),
|
||||
child: AvesScaffold(
|
||||
body: SelectionProvider<AvesEntry>(
|
||||
child: QueryProvider(
|
||||
|
|
|
@ -67,13 +67,7 @@ class _InteractiveFilterTileState<T extends CollectionFilter> extends State<Inte
|
|||
}
|
||||
case AppMode.pickFilterInternal:
|
||||
Navigator.maybeOf(context)?.pop<T>(filter);
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.screenSaver:
|
||||
case AppMode.setWallpaper:
|
||||
case AppMode.slideshow:
|
||||
case AppMode.view:
|
||||
case AppMode.edit:
|
||||
case null:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,9 +221,7 @@ class _HomePageState extends State<HomePage> {
|
|||
case AppMode.edit:
|
||||
case AppMode.setWallpaper:
|
||||
await _initViewerEssentials();
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.pickFilterInternal:
|
||||
case AppMode.slideshow:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -331,12 +329,7 @@ class _HomePageState extends State<HomePage> {
|
|||
);
|
||||
},
|
||||
);
|
||||
case AppMode.main:
|
||||
case AppMode.pickCollectionFiltersExternal:
|
||||
case AppMode.pickMediaInternal:
|
||||
case AppMode.pickFilterInternal:
|
||||
case AppMode.screenSaver:
|
||||
case AppMode.slideshow:
|
||||
default:
|
||||
routeName = _initialRouteName ?? settings.homePage.routeName;
|
||||
filters = _initialFilters ?? (settings.homePage == HomePageSetting.collection ? settings.homeCustomCollection : {});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue