fixed delay for actions triggered by popup menu
This commit is contained in:
parent
ed249f7793
commit
0916ed1f6b
6 changed files with 39 additions and 46 deletions
|
@ -258,7 +258,10 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onSelected: _onCollectionActionSelected,
|
onSelected: (action) {
|
||||||
|
// wait for the popup menu to hide before proceeding with the action
|
||||||
|
Future.delayed(Durations.popupMenuAnimation * timeDilation, () => _onCollectionActionSelected(action));
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -278,10 +281,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
widget.appBarHeightNotifier.value = kToolbarHeight + (hasFilters ? FilterBar.preferredHeight : 0);
|
widget.appBarHeightNotifier.value = kToolbarHeight + (hasFilters ? FilterBar.preferredHeight : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onCollectionActionSelected(CollectionAction action) async {
|
Future<void> _onCollectionActionSelected(CollectionAction action) async {
|
||||||
// wait for the popup menu to hide before proceeding with the action
|
|
||||||
await Future.delayed(Durations.popupMenuAnimation * timeDilation);
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case CollectionAction.copy:
|
case CollectionAction.copy:
|
||||||
case CollectionAction.move:
|
case CollectionAction.move:
|
||||||
|
|
|
@ -2,7 +2,6 @@ import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/source/collection_lens.dart';
|
import 'package:aves/model/source/collection_lens.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/utils/durations.dart';
|
|
||||||
import 'package:aves/widgets/common/action_delegates/feedback.dart';
|
import 'package:aves/widgets/common/action_delegates/feedback.dart';
|
||||||
import 'package:aves/widgets/common/action_delegates/permission_aware.dart';
|
import 'package:aves/widgets/common/action_delegates/permission_aware.dart';
|
||||||
import 'package:aves/widgets/common/action_delegates/rename_entry_dialog.dart';
|
import 'package:aves/widgets/common/action_delegates/rename_entry_dialog.dart';
|
||||||
|
@ -31,49 +30,46 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin {
|
||||||
|
|
||||||
bool get hasCollection => collection != null;
|
bool get hasCollection => collection != null;
|
||||||
|
|
||||||
void onActionSelected(BuildContext context, ImageEntry entry, EntryAction action) async {
|
void onActionSelected(BuildContext context, ImageEntry entry, EntryAction action) {
|
||||||
// wait for the popup menu to hide before proceeding with the action
|
|
||||||
await Future.delayed(Durations.popupMenuAnimation * timeDilation);
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case EntryAction.toggleFavourite:
|
case EntryAction.toggleFavourite:
|
||||||
entry.toggleFavourite();
|
entry.toggleFavourite();
|
||||||
break;
|
break;
|
||||||
case EntryAction.delete:
|
case EntryAction.delete:
|
||||||
unawaited(_showDeleteDialog(context, entry));
|
_showDeleteDialog(context, entry);
|
||||||
break;
|
break;
|
||||||
case EntryAction.edit:
|
case EntryAction.edit:
|
||||||
unawaited(AndroidAppService.edit(entry.uri, entry.mimeType));
|
AndroidAppService.edit(entry.uri, entry.mimeType);
|
||||||
break;
|
break;
|
||||||
case EntryAction.info:
|
case EntryAction.info:
|
||||||
showInfo();
|
showInfo();
|
||||||
break;
|
break;
|
||||||
case EntryAction.rename:
|
case EntryAction.rename:
|
||||||
unawaited(_showRenameDialog(context, entry));
|
_showRenameDialog(context, entry);
|
||||||
break;
|
break;
|
||||||
case EntryAction.open:
|
case EntryAction.open:
|
||||||
unawaited(AndroidAppService.open(entry.uri, entry.mimeTypeAnySubtype));
|
AndroidAppService.open(entry.uri, entry.mimeTypeAnySubtype);
|
||||||
break;
|
break;
|
||||||
case EntryAction.openMap:
|
case EntryAction.openMap:
|
||||||
unawaited(AndroidAppService.openMap(entry.geoUri));
|
AndroidAppService.openMap(entry.geoUri);
|
||||||
break;
|
break;
|
||||||
case EntryAction.print:
|
case EntryAction.print:
|
||||||
unawaited(_print(entry));
|
_print(entry);
|
||||||
break;
|
break;
|
||||||
case EntryAction.rotateCCW:
|
case EntryAction.rotateCCW:
|
||||||
unawaited(_rotate(context, entry, clockwise: false));
|
_rotate(context, entry, clockwise: false);
|
||||||
break;
|
break;
|
||||||
case EntryAction.rotateCW:
|
case EntryAction.rotateCW:
|
||||||
unawaited(_rotate(context, entry, clockwise: true));
|
_rotate(context, entry, clockwise: true);
|
||||||
break;
|
break;
|
||||||
case EntryAction.flip:
|
case EntryAction.flip:
|
||||||
unawaited(_flip(context, entry));
|
_flip(context, entry);
|
||||||
break;
|
break;
|
||||||
case EntryAction.setAs:
|
case EntryAction.setAs:
|
||||||
unawaited(AndroidAppService.setAs(entry.uri, entry.mimeType));
|
AndroidAppService.setAs(entry.uri, entry.mimeType);
|
||||||
break;
|
break;
|
||||||
case EntryAction.share:
|
case EntryAction.share:
|
||||||
unawaited(AndroidAppService.share({entry}));
|
AndroidAppService.share({entry});
|
||||||
break;
|
break;
|
||||||
case EntryAction.viewSource:
|
case EntryAction.viewSource:
|
||||||
_goToSourceViewer(context, entry);
|
_goToSourceViewer(context, entry);
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:aves/model/filters/filters.dart';
|
||||||
import 'package:aves/model/settings/settings.dart';
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/model/source/collection_source.dart';
|
import 'package:aves/model/source/collection_source.dart';
|
||||||
import 'package:aves/services/image_file_service.dart';
|
import 'package:aves/services/image_file_service.dart';
|
||||||
import 'package:aves/utils/durations.dart';
|
|
||||||
import 'package:aves/widgets/common/action_delegates/feedback.dart';
|
import 'package:aves/widgets/common/action_delegates/feedback.dart';
|
||||||
import 'package:aves/widgets/common/action_delegates/permission_aware.dart';
|
import 'package:aves/widgets/common/action_delegates/permission_aware.dart';
|
||||||
import 'package:aves/widgets/common/action_delegates/rename_album_dialog.dart';
|
import 'package:aves/widgets/common/action_delegates/rename_album_dialog.dart';
|
||||||
|
@ -11,16 +10,11 @@ import 'package:aves/widgets/common/action_delegates/size_aware.dart';
|
||||||
import 'package:aves/widgets/common/aves_dialog.dart';
|
import 'package:aves/widgets/common/aves_dialog.dart';
|
||||||
import 'package:aves/widgets/filter_grids/common/chip_actions.dart';
|
import 'package:aves/widgets/filter_grids/common/chip_actions.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
|
|
||||||
class ChipActionDelegate {
|
class ChipActionDelegate {
|
||||||
Future<void> onActionSelected(BuildContext context, CollectionFilter filter, ChipAction action) async {
|
void onActionSelected(BuildContext context, CollectionFilter filter, ChipAction action) {
|
||||||
// wait for the popup menu to hide before proceeding with the action
|
|
||||||
await Future.delayed(Durations.popupMenuAnimation * timeDilation);
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ChipAction.pin:
|
case ChipAction.pin:
|
||||||
settings.pinnedFilters = settings.pinnedFilters..add(filter);
|
settings.pinnedFilters = settings.pinnedFilters..add(filter);
|
||||||
|
@ -42,14 +36,14 @@ class AlbumChipActionDelegate extends ChipActionDelegate with FeedbackMixin, Per
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onActionSelected(BuildContext context, CollectionFilter filter, ChipAction action) async {
|
void onActionSelected(BuildContext context, CollectionFilter filter, ChipAction action) {
|
||||||
await super.onActionSelected(context, filter, action);
|
super.onActionSelected(context, filter, action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ChipAction.delete:
|
case ChipAction.delete:
|
||||||
unawaited(_showDeleteDialog(context, filter as AlbumFilter));
|
_showDeleteDialog(context, filter as AlbumFilter);
|
||||||
break;
|
break;
|
||||||
case ChipAction.rename:
|
case ChipAction.rename:
|
||||||
unawaited(_showRenameDialog(context, filter as AlbumFilter));
|
_showRenameDialog(context, filter as AlbumFilter);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2,13 +2,10 @@ 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/model/source/enums.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/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:aves/widgets/stats/stats.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
import 'package:pedantic/pedantic.dart';
|
|
||||||
|
|
||||||
abstract class ChipSetActionDelegate {
|
abstract class ChipSetActionDelegate {
|
||||||
CollectionSource get source;
|
CollectionSource get source;
|
||||||
|
@ -17,16 +14,13 @@ abstract class ChipSetActionDelegate {
|
||||||
|
|
||||||
set sortFactor(ChipSortFactor factor);
|
set sortFactor(ChipSortFactor factor);
|
||||||
|
|
||||||
Future<void> onActionSelected(BuildContext context, ChipSetAction action) async {
|
void onActionSelected(BuildContext context, ChipSetAction action) {
|
||||||
// wait for the popup menu to hide before proceeding with the action
|
|
||||||
await Future.delayed(Durations.popupMenuAnimation * timeDilation);
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ChipSetAction.sort:
|
case ChipSetAction.sort:
|
||||||
await _showSortDialog(context);
|
_showSortDialog(context);
|
||||||
break;
|
break;
|
||||||
case ChipSetAction.refresh:
|
case ChipSetAction.refresh:
|
||||||
unawaited(source.refresh());
|
source.refresh();
|
||||||
break;
|
break;
|
||||||
case ChipSetAction.stats:
|
case ChipSetAction.stats:
|
||||||
_goToStats(context);
|
_goToStats(context);
|
||||||
|
|
|
@ -27,8 +27,8 @@ 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/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.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:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class FilterNavigationPage extends StatelessWidget {
|
class FilterNavigationPage extends StatelessWidget {
|
||||||
|
@ -107,7 +107,8 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
if (selectedAction != null) {
|
if (selectedAction != null) {
|
||||||
unawaited(chipActionDelegate.onActionSelected(context, filter, selectedAction));
|
// wait for the popup menu to hide before proceeding with the action
|
||||||
|
Future.delayed(Durations.popupMenuAnimation * timeDilation, () => chipActionDelegate.onActionSelected(context, filter, selectedAction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +135,10 @@ class FilterNavigationPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onSelected: (action) => chipSetActionDelegate.onActionSelected(context, action),
|
onSelected: (action) {
|
||||||
|
// wait for the popup menu to hide before proceeding with the action
|
||||||
|
Future.delayed(Durations.popupMenuAnimation * timeDilation, () => chipSetActionDelegate.onActionSelected(context, action));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:math';
|
||||||
import 'package:aves/model/favourite_repo.dart';
|
import 'package:aves/model/favourite_repo.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';
|
||||||
|
import 'package:aves/utils/durations.dart';
|
||||||
import 'package:aves/widgets/common/entry_actions.dart';
|
import 'package:aves/widgets/common/entry_actions.dart';
|
||||||
import 'package:aves/widgets/common/fx/sweeper.dart';
|
import 'package:aves/widgets/common/fx/sweeper.dart';
|
||||||
import 'package:aves/widgets/common/icons.dart';
|
import 'package:aves/widgets/common/icons.dart';
|
||||||
|
@ -12,6 +13,7 @@ import 'package:aves/widgets/fullscreen/overlay/common.dart';
|
||||||
import 'package:aves/widgets/fullscreen/overlay/minimap.dart';
|
import 'package:aves/widgets/fullscreen/overlay/minimap.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
|
@ -168,7 +170,10 @@ class _TopOverlayRow extends StatelessWidget {
|
||||||
_buildPopupMenuItem(EntryAction.debug),
|
_buildPopupMenuItem(EntryAction.debug),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
onSelected: onActionSelected,
|
onSelected: (action) {
|
||||||
|
// wait for the popup menu to hide before proceeding with the action
|
||||||
|
Future.delayed(Durations.popupMenuAnimation * timeDilation, () => onActionSelected(action));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -177,7 +182,7 @@ class _TopOverlayRow extends StatelessWidget {
|
||||||
|
|
||||||
Widget _buildOverlayButton(EntryAction action) {
|
Widget _buildOverlayButton(EntryAction action) {
|
||||||
Widget child;
|
Widget child;
|
||||||
void onPressed() => onActionSelected?.call(action);
|
void onPressed() => onActionSelected(action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case EntryAction.toggleFavourite:
|
case EntryAction.toggleFavourite:
|
||||||
child = _FavouriteToggler(
|
child = _FavouriteToggler(
|
||||||
|
|
Loading…
Reference in a new issue