albums: allow sorting when selecting album
This commit is contained in:
parent
fa738b6a55
commit
2236be7d60
1 changed files with 43 additions and 28 deletions
|
@ -1,8 +1,10 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:aves/model/filters/album.dart';
|
import 'package:aves/model/filters/album.dart';
|
||||||
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/model/source/collection_lens.dart';
|
import 'package:aves/model/source/collection_lens.dart';
|
||||||
import 'package:aves/model/source/collection_source.dart';
|
import 'package:aves/model/source/collection_source.dart';
|
||||||
|
import 'package:aves/model/source/enums.dart';
|
||||||
import 'package:aves/services/android_app_service.dart';
|
import 'package:aves/services/android_app_service.dart';
|
||||||
import 'package:aves/services/image_file_service.dart';
|
import 'package:aves/services/image_file_service.dart';
|
||||||
import 'package:aves/widgets/collection/collection_actions.dart';
|
import 'package:aves/widgets/collection/collection_actions.dart';
|
||||||
|
@ -14,11 +16,14 @@ import 'package:aves/widgets/common/aves_dialog.dart';
|
||||||
import 'package:aves/widgets/common/entry_actions.dart';
|
import 'package:aves/widgets/common/entry_actions.dart';
|
||||||
import 'package:aves/widgets/common/icons.dart';
|
import 'package:aves/widgets/common/icons.dart';
|
||||||
import 'package:aves/widgets/filter_grids/albums_page.dart';
|
import 'package:aves/widgets/filter_grids/albums_page.dart';
|
||||||
|
import 'package:aves/widgets/filter_grids/common/chip_actions.dart';
|
||||||
|
import 'package:aves/widgets/filter_grids/common/chip_set_action_delegate.dart';
|
||||||
import 'package:aves/widgets/filter_grids/common/filter_grid_page.dart';
|
import 'package:aves/widgets/filter_grids/common/filter_grid_page.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
|
class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
|
||||||
final CollectionLens collection;
|
final CollectionLens collection;
|
||||||
|
@ -58,39 +63,49 @@ class SelectionActionDelegate with FeedbackMixin, PermissionAwareMixin {
|
||||||
|
|
||||||
Future<void> _moveSelection(BuildContext context, {@required bool copy}) async {
|
Future<void> _moveSelection(BuildContext context, {@required bool copy}) async {
|
||||||
final source = collection.source;
|
final source = collection.source;
|
||||||
|
final chipSetActionDelegate = AlbumChipSetActionDelegate(source: source);
|
||||||
final destinationAlbum = await Navigator.push(
|
final destinationAlbum = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute<String>(
|
MaterialPageRoute<String>(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return FilterGridPage(
|
return Selector<Settings, ChipSortFactor>(
|
||||||
source: source,
|
selector: (context, s) => s.albumSortFactor,
|
||||||
appBar: SliverAppBar(
|
builder: (context, sortFactor, child) {
|
||||||
leading: BackButton(),
|
return FilterGridPage(
|
||||||
title: Text(copy ? 'Copy to Album' : 'Move to Album'),
|
source: source,
|
||||||
actions: [
|
appBar: SliverAppBar(
|
||||||
IconButton(
|
leading: BackButton(),
|
||||||
icon: Icon(AIcons.createAlbum),
|
title: Text(copy ? 'Copy to Album' : 'Move to Album'),
|
||||||
onPressed: () async {
|
actions: [
|
||||||
final newAlbum = await showDialog<String>(
|
IconButton(
|
||||||
context: context,
|
icon: Icon(AIcons.createAlbum),
|
||||||
builder: (context) => CreateAlbumDialog(),
|
onPressed: () async {
|
||||||
);
|
final newAlbum = await showDialog<String>(
|
||||||
if (newAlbum != null && newAlbum.isNotEmpty) {
|
context: context,
|
||||||
Navigator.pop<String>(context, newAlbum);
|
builder: (context) => CreateAlbumDialog(),
|
||||||
}
|
);
|
||||||
},
|
if (newAlbum != null && newAlbum.isNotEmpty) {
|
||||||
tooltip: 'Create album',
|
Navigator.pop<String>(context, newAlbum);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: 'Create album',
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(AIcons.sort),
|
||||||
|
onPressed: () => chipSetActionDelegate.onActionSelected(context, ChipSetAction.sort),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
floating: true,
|
||||||
),
|
),
|
||||||
],
|
filterEntries: AlbumListPage.getAlbumEntries(source),
|
||||||
floating: true,
|
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
||||||
),
|
emptyBuilder: () => EmptyContent(
|
||||||
filterEntries: AlbumListPage.getAlbumEntries(source),
|
icon: AIcons.album,
|
||||||
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
text: 'No albums',
|
||||||
emptyBuilder: () => EmptyContent(
|
),
|
||||||
icon: AIcons.album,
|
onTap: (filter) => Navigator.pop<String>(context, (filter as AlbumFilter)?.album),
|
||||||
text: 'No albums',
|
);
|
||||||
),
|
},
|
||||||
onTap: (filter) => Navigator.pop<String>(context, (filter as AlbumFilter)?.album),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue