albums/countries/tags: added refresh, stats actions
This commit is contained in:
parent
557a65dbdd
commit
bdd18d9e71
6 changed files with 69 additions and 3 deletions
|
@ -36,7 +36,7 @@ class AlbumListPage extends StatelessWidget {
|
||||||
builder: (context, snapshot) => FilterNavigationPage(
|
builder: (context, snapshot) => FilterNavigationPage(
|
||||||
source: source,
|
source: source,
|
||||||
title: 'Albums',
|
title: 'Albums',
|
||||||
chipSetActionDelegate: AlbumChipSetActionDelegate(),
|
chipSetActionDelegate: AlbumChipSetActionDelegate(source: source),
|
||||||
chipActionDelegate: AlbumChipActionDelegate(source: source),
|
chipActionDelegate: AlbumChipActionDelegate(source: source),
|
||||||
chipActionsBuilder: (filter) => [
|
chipActionsBuilder: (filter) => [
|
||||||
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||||
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
enum ChipSetAction {
|
enum ChipSetAction {
|
||||||
sort,
|
sort,
|
||||||
|
refresh,
|
||||||
|
stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ChipAction {
|
enum ChipAction {
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
|
import 'package:aves/model/source/collection_lens.dart';
|
||||||
|
import 'package:aves/model/source/collection_source.dart';
|
||||||
import 'package:aves/model/source/enums.dart';
|
import 'package:aves/model/source/enums.dart';
|
||||||
import 'package:aves/utils/durations.dart';
|
import 'package:aves/utils/durations.dart';
|
||||||
import 'package:aves/widgets/common/aves_selection_dialog.dart';
|
import 'package:aves/widgets/common/aves_selection_dialog.dart';
|
||||||
|
import 'package:aves/widgets/common/data_providers/media_store_collection_provider.dart';
|
||||||
import 'package:aves/widgets/filter_grids/common/chip_actions.dart';
|
import 'package:aves/widgets/filter_grids/common/chip_actions.dart';
|
||||||
|
import 'package:aves/widgets/stats/stats.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
|
||||||
abstract class ChipSetActionDelegate {
|
abstract class ChipSetActionDelegate {
|
||||||
|
CollectionSource get source;
|
||||||
|
|
||||||
ChipSortFactor get sortFactor;
|
ChipSortFactor get sortFactor;
|
||||||
|
|
||||||
set sortFactor(ChipSortFactor factor);
|
set sortFactor(ChipSortFactor factor);
|
||||||
|
@ -19,6 +26,15 @@ abstract class ChipSetActionDelegate {
|
||||||
case ChipSetAction.sort:
|
case ChipSetAction.sort:
|
||||||
await _showSortDialog(context);
|
await _showSortDialog(context);
|
||||||
break;
|
break;
|
||||||
|
case ChipSetAction.refresh:
|
||||||
|
if (source is MediaStoreSource) {
|
||||||
|
source.clearEntries();
|
||||||
|
unawaited((source as MediaStoreSource).refresh());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ChipSetAction.stats:
|
||||||
|
_goToStats(context);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +54,32 @@ abstract class ChipSetActionDelegate {
|
||||||
sortFactor = factor;
|
sortFactor = factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _goToStats(BuildContext context) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
settings: RouteSettings(name: StatsPage.routeName),
|
||||||
|
builder: (context) => StatsPage(
|
||||||
|
collection: CollectionLens(
|
||||||
|
source: source,
|
||||||
|
groupFactor: settings.collectionGroupFactor,
|
||||||
|
sortFactor: settings.collectionSortFactor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AlbumChipSetActionDelegate extends ChipSetActionDelegate {
|
class AlbumChipSetActionDelegate extends ChipSetActionDelegate {
|
||||||
|
@override
|
||||||
|
final CollectionSource source;
|
||||||
|
|
||||||
|
AlbumChipSetActionDelegate({
|
||||||
|
@required this.source,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ChipSortFactor get sortFactor => settings.albumSortFactor;
|
ChipSortFactor get sortFactor => settings.albumSortFactor;
|
||||||
|
|
||||||
|
@ -49,6 +88,13 @@ class AlbumChipSetActionDelegate extends ChipSetActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
class CountryChipSetActionDelegate extends ChipSetActionDelegate {
|
class CountryChipSetActionDelegate extends ChipSetActionDelegate {
|
||||||
|
@override
|
||||||
|
final CollectionSource source;
|
||||||
|
|
||||||
|
CountryChipSetActionDelegate({
|
||||||
|
@required this.source,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ChipSortFactor get sortFactor => settings.countrySortFactor;
|
ChipSortFactor get sortFactor => settings.countrySortFactor;
|
||||||
|
|
||||||
|
@ -57,6 +103,13 @@ class CountryChipSetActionDelegate extends ChipSetActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TagChipSetActionDelegate extends ChipSetActionDelegate {
|
class TagChipSetActionDelegate extends ChipSetActionDelegate {
|
||||||
|
@override
|
||||||
|
final CollectionSource source;
|
||||||
|
|
||||||
|
TagChipSetActionDelegate({
|
||||||
|
@required this.source,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ChipSortFactor get sortFactor => settings.tagSortFactor;
|
ChipSortFactor get sortFactor => settings.tagSortFactor;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:aves/main.dart';
|
||||||
import 'package:aves/model/filters/filters.dart';
|
import 'package:aves/model/filters/filters.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
|
@ -24,6 +25,7 @@ import 'package:aves/widgets/filter_grids/common/chip_set_action_delegate.dart';
|
||||||
import 'package:aves/widgets/filter_grids/common/decorated_filter_chip.dart';
|
import 'package:aves/widgets/filter_grids/common/decorated_filter_chip.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:draggable_scrollbar/draggable_scrollbar.dart';
|
import 'package:draggable_scrollbar/draggable_scrollbar.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
|
||||||
import 'package:pedantic/pedantic.dart';
|
import 'package:pedantic/pedantic.dart';
|
||||||
|
@ -121,6 +123,15 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
value: ChipSetAction.sort,
|
value: ChipSetAction.sort,
|
||||||
child: MenuRow(text: 'Sort…', icon: AIcons.sort),
|
child: MenuRow(text: 'Sort…', icon: AIcons.sort),
|
||||||
),
|
),
|
||||||
|
if (kDebugMode)
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChipSetAction.refresh,
|
||||||
|
child: MenuRow(text: 'Refresh', icon: AIcons.refresh),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChipSetAction.stats,
|
||||||
|
child: MenuRow(text: 'Stats', icon: AIcons.stats),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onSelected: (action) => chipSetActionDelegate.onActionSelected(context, action),
|
onSelected: (action) => chipSetActionDelegate.onActionSelected(context, action),
|
||||||
|
|
|
@ -33,7 +33,7 @@ class CountryListPage extends StatelessWidget {
|
||||||
builder: (context, snapshot) => FilterNavigationPage(
|
builder: (context, snapshot) => FilterNavigationPage(
|
||||||
source: source,
|
source: source,
|
||||||
title: 'Countries',
|
title: 'Countries',
|
||||||
chipSetActionDelegate: CountryChipSetActionDelegate(),
|
chipSetActionDelegate: CountryChipSetActionDelegate(source: source),
|
||||||
chipActionDelegate: ChipActionDelegate(),
|
chipActionDelegate: ChipActionDelegate(),
|
||||||
chipActionsBuilder: (filter) => [
|
chipActionsBuilder: (filter) => [
|
||||||
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TagListPage extends StatelessWidget {
|
||||||
builder: (context, snapshot) => FilterNavigationPage(
|
builder: (context, snapshot) => FilterNavigationPage(
|
||||||
source: source,
|
source: source,
|
||||||
title: 'Tags',
|
title: 'Tags',
|
||||||
chipSetActionDelegate: TagChipSetActionDelegate(),
|
chipSetActionDelegate: TagChipSetActionDelegate(source: source),
|
||||||
chipActionDelegate: ChipActionDelegate(),
|
chipActionDelegate: ChipActionDelegate(),
|
||||||
chipActionsBuilder: (filter) => [
|
chipActionsBuilder: (filter) => [
|
||||||
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
settings.pinnedFilters.contains(filter) ? ChipAction.unpin : ChipAction.pin,
|
||||||
|
|
Loading…
Reference in a new issue