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