overlay: reverted quick action selection by most recent usage
This commit is contained in:
parent
fd149c30b3
commit
094078fe53
4 changed files with 12 additions and 27 deletions
|
@ -1,5 +1,4 @@
|
|||
import 'package:aves/model/collection_lens.dart';
|
||||
import 'package:aves/widgets/fullscreen/fullscreen_actions.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -20,7 +19,6 @@ class Settings {
|
|||
static const collectionSortFactorKey = 'collection_sort_factor';
|
||||
static const infoMapZoomKey = 'info_map_zoom';
|
||||
static const catalogTimeZoneKey = 'catalog_time_zone';
|
||||
static const mostRecentFullscreenActionsKey = 'most_recent_fullscreen_actions';
|
||||
|
||||
Future<void> init() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
|
@ -62,17 +60,6 @@ class Settings {
|
|||
|
||||
set collectionSortFactor(SortFactor newValue) => setAndNotify(collectionSortFactorKey, newValue.toString());
|
||||
|
||||
List<FullscreenAction> get mostRecentFullscreenActions => getEnumListOrDefault(
|
||||
mostRecentFullscreenActionsKey,
|
||||
[
|
||||
FullscreenAction.toggleFavourite,
|
||||
FullscreenAction.share,
|
||||
FullscreenAction.delete,
|
||||
],
|
||||
FullscreenAction.values);
|
||||
|
||||
set mostRecentFullscreenActions(List<FullscreenAction> newValue) => setAndNotify(mostRecentFullscreenActionsKey, newValue.map((v) => v.toString()).toList());
|
||||
|
||||
// convenience methods
|
||||
|
||||
bool getBoolOrDefault(String key, bool defaultValue) => prefs.getKeys().contains(key) ? prefs.getBool(key) : defaultValue;
|
||||
|
|
|
@ -51,7 +51,6 @@ class DebugPageState extends State<DebugPage> {
|
|||
Text('collectionGroupFactor: ${settings.collectionGroupFactor}'),
|
||||
Text('collectionSortFactor: ${settings.collectionSortFactor}'),
|
||||
Text('infoMapZoom: ${settings.infoMapZoom}'),
|
||||
Text('mostRecentFullscreenActions: ${settings.mostRecentFullscreenActions}'),
|
||||
const Divider(),
|
||||
Text('Entries: ${entries.length}'),
|
||||
Text('Catalogued: ${catalogued.length}'),
|
||||
|
|
|
@ -26,6 +26,9 @@ class FullscreenActions {
|
|||
static Tuple2<String, IconData> getTextIcon(FullscreenAction action) {
|
||||
switch (action) {
|
||||
// in app actions
|
||||
case FullscreenAction.toggleFavourite:
|
||||
// different data depending on toggle state
|
||||
return null;
|
||||
case FullscreenAction.delete:
|
||||
return const Tuple2('Delete', OMIcons.delete);
|
||||
case FullscreenAction.info:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/model/settings.dart';
|
||||
import 'package:aves/widgets/common/fx/sweeper.dart';
|
||||
import 'package:aves/widgets/common/menu_row.dart';
|
||||
import 'package:aves/widgets/fullscreen/fullscreen_actions.dart';
|
||||
|
@ -27,8 +26,6 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
|
||||
static const int portraitActionCount = 2;
|
||||
|
||||
static const List<FullscreenAction> possibleOverlayActions = FullscreenActions.inApp;
|
||||
|
||||
const FullscreenTopOverlay({
|
||||
Key key,
|
||||
@required this.entries,
|
||||
|
@ -53,10 +50,14 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final availableCount = (constraints.maxWidth / (kMinInteractiveDimension + padding)).floor() - 2;
|
||||
final recentActionCount = min(targetCount, availableCount);
|
||||
final quickActionCount = min(targetCount, availableCount);
|
||||
|
||||
final recentActions = settings.mostRecentFullscreenActions.where(_canDo).take(recentActionCount);
|
||||
final inAppActions = FullscreenActions.inApp.where((action) => !recentActions.contains(action)).where(_canDo);
|
||||
final quickActions = [
|
||||
FullscreenAction.toggleFavourite,
|
||||
FullscreenAction.share,
|
||||
FullscreenAction.delete,
|
||||
].where(_canDo).take(quickActionCount);
|
||||
final inAppActions = FullscreenActions.inApp.where((action) => !quickActions.contains(action)).where(_canDo);
|
||||
final externalAppActions = FullscreenActions.externalApp.where(_canDo);
|
||||
|
||||
return Row(
|
||||
|
@ -66,7 +67,7 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
child: ModalRoute.of(context)?.canPop ?? true ? const BackButton() : const CloseButton(),
|
||||
),
|
||||
const Spacer(),
|
||||
...recentActions.map(_buildOverlayButton),
|
||||
...quickActions.map(_buildOverlayButton),
|
||||
OverlayButton(
|
||||
scale: scale,
|
||||
child: PopupMenuButton<FullscreenAction>(
|
||||
|
@ -75,12 +76,7 @@ class FullscreenTopOverlay extends StatelessWidget {
|
|||
const PopupMenuDivider(),
|
||||
...externalAppActions.map(_buildPopupMenuItem),
|
||||
],
|
||||
onSelected: (action) {
|
||||
if (possibleOverlayActions.contains(action)) {
|
||||
settings.mostRecentFullscreenActions = [action, ...settings.mostRecentFullscreenActions].take(landscapeActionCount).toList();
|
||||
}
|
||||
onActionSelected?.call(action);
|
||||
},
|
||||
onSelected: onActionSelected,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue