#401 slideshow: added settings quick action

This commit is contained in:
Thibault Deckers 2023-02-05 19:45:03 +01:00
parent f62c31a46b
commit 8ced40a853
33 changed files with 101 additions and 52 deletions

View file

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Viewer: overlay details expand/collapse on tap
- Viewer: export actions available as quick actions
- Slideshow: added settings quick action
- TV: improved support for Info
### Changed

View file

@ -168,7 +168,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Rychlost přehrávání",
"@videoActionSetSpeed": {},
"videoActionSettings": "Nastavení",
"viewerActionSettings": "Nastavení",
"@videoActionSettings": {},
"slideshowActionResume": "Pokračovat",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Wiedergabegeschwindigkeit",
"@videoActionSetSpeed": {},
"videoActionSettings": "Einstellungen",
"viewerActionSettings": "Einstellungen",
"@videoActionSettings": {},
"slideshowActionResume": "Wiedergabe",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Ταχύτητα αναπαραγωγής",
"@videoActionSetSpeed": {},
"videoActionSettings": "Ρυθμίσεις",
"viewerActionSettings": "Ρυθμίσεις",
"@videoActionSettings": {},
"slideshowActionResume": "Συνέχιση",
"@slideshowActionResume": {},

View file

@ -119,7 +119,8 @@
"videoActionSkip10": "Seek forward 10 seconds",
"videoActionSelectStreams": "Select tracks",
"videoActionSetSpeed": "Playback speed",
"videoActionSettings": "Settings",
"viewerActionSettings": "Settings",
"slideshowActionResume": "Resume",
"slideshowActionShowInCollection": "Show in Collection",

View file

@ -147,7 +147,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Velocidad de reproducción",
"@videoActionSetSpeed": {},
"videoActionSettings": "Ajustes",
"viewerActionSettings": "Ajustes",
"@videoActionSettings": {},
"slideshowActionResume": "Reanudar",
"@slideshowActionResume": {},

View file

@ -393,7 +393,7 @@
"@videoActionPlay": {},
"videoActionReplay10": "10 segundu atzera egin",
"@videoActionReplay10": {},
"videoActionSettings": "Ezarpenak",
"viewerActionSettings": "Ezarpenak",
"@videoActionSettings": {},
"entryInfoActionEditDate": "Data eta ordua editatu",
"@entryInfoActionEditDate": {},

View file

@ -161,7 +161,7 @@
"@videoActionUnmute": {},
"videoActionSkip10": "جلو رفتن 10 ثانیه",
"@videoActionSkip10": {},
"videoActionSettings": "تنظیمات",
"viewerActionSettings": "تنظیمات",
"@videoActionSettings": {},
"entryInfoActionEditRating": "ویرایش رتبه",
"@entryInfoActionEditRating": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Vitesse de lecture",
"@videoActionSetSpeed": {},
"videoActionSettings": "Préférences",
"viewerActionSettings": "Préférences",
"@videoActionSettings": {},
"slideshowActionResume": "Reprendre",
"@slideshowActionResume": {},

View file

@ -119,7 +119,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Velocidade de reprodución",
"@videoActionSetSpeed": {},
"videoActionSettings": "Configuración",
"viewerActionSettings": "Configuración",
"@videoActionSettings": {},
"slideshowActionResume": "Resumo",
"@slideshowActionResume": {},

View file

@ -147,7 +147,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Kecepatan pemutaran",
"@videoActionSetSpeed": {},
"videoActionSettings": "Pengaturan",
"viewerActionSettings": "Pengaturan",
"@videoActionSettings": {},
"slideshowActionResume": "Lanjutkan",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Velocità di riproduzione",
"@videoActionSetSpeed": {},
"videoActionSettings": "Impostazioni",
"viewerActionSettings": "Impostazioni",
"@videoActionSettings": {},
"slideshowActionResume": "Riprendi",
"@slideshowActionResume": {},

View file

@ -147,7 +147,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "再生速度",
"@videoActionSetSpeed": {},
"videoActionSettings": "設定",
"viewerActionSettings": "設定",
"@videoActionSettings": {},
"slideshowActionResume": "再開",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "재생 배속",
"@videoActionSetSpeed": {},
"videoActionSettings": "설정",
"viewerActionSettings": "설정",
"@videoActionSettings": {},
"slideshowActionResume": "이어서",
"@slideshowActionResume": {},

View file

@ -97,7 +97,7 @@
"@videoActionSkip10": {},
"videoActionSetSpeed": "Atkūrimo greitis",
"@videoActionSetSpeed": {},
"videoActionSettings": "Nustatymai",
"viewerActionSettings": "Nustatymai",
"@videoActionSettings": {},
"slideshowActionResume": "Tęsti",
"@slideshowActionResume": {},

View file

@ -76,7 +76,7 @@
"@videoActionSkip10": {},
"videoActionSetSpeed": "Avspillingshastighet",
"@videoActionSetSpeed": {},
"videoActionSettings": "Innstillinger",
"viewerActionSettings": "Innstillinger",
"@videoActionSettings": {},
"entryInfoActionEditTitleDescription": "Rediger navn og beskrivelse",
"@entryInfoActionEditTitleDescription": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Afspeelsnelheid",
"@videoActionSetSpeed": {},
"videoActionSettings": "Instellingen",
"viewerActionSettings": "Instellingen",
"@videoActionSettings": {},
"slideshowActionResume": "Hervatten",
"@slideshowActionResume": {},

View file

@ -170,7 +170,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Avspelingssnøggleik",
"@videoActionSetSpeed": {},
"videoActionSettings": "Innstillingar",
"viewerActionSettings": "Innstillingar",
"@videoActionSettings": {},
"slideshowActionResume": "Hald fram",
"@slideshowActionResume": {},

View file

@ -85,7 +85,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Prędkość odtwarzania",
"@videoActionSetSpeed": {},
"videoActionSettings": "Ustawienia",
"viewerActionSettings": "Ustawienia",
"@videoActionSettings": {},
"slideshowActionResume": "Wznów",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Velocidade de reprodução",
"@videoActionSetSpeed": {},
"videoActionSettings": "Configurações",
"viewerActionSettings": "Configurações",
"@videoActionSettings": {},
"slideshowActionResume": "Retomar",
"@slideshowActionResume": {},

View file

@ -152,7 +152,7 @@
"@videoActionSkip10": {},
"videoActionSelectStreams": "Selectați piese",
"@videoActionSelectStreams": {},
"videoActionSettings": "Setări",
"viewerActionSettings": "Setări",
"@videoActionSettings": {},
"slideshowActionResume": "Reluare",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Скорость вопспроизведения",
"@videoActionSetSpeed": {},
"videoActionSettings": "Настройки",
"viewerActionSettings": "Настройки",
"@videoActionSettings": {},
"slideshowActionResume": "Продолжить",
"@slideshowActionResume": {},

View file

@ -121,7 +121,7 @@
"@videoActionSkip10": {},
"slideshowActionShowInCollection": "แสดงคอลเลกชัน",
"@slideshowActionShowInCollection": {},
"videoActionSettings": "ตั้งค่า",
"viewerActionSettings": "ตั้งค่า",
"@videoActionSettings": {},
"slideshowActionResume": "เล่นต่อ",
"@slideshowActionResume": {},

View file

@ -147,7 +147,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "Oynatma hızı",
"@videoActionSetSpeed": {},
"videoActionSettings": "Ayarlar",
"viewerActionSettings": "Ayarlar",
"@videoActionSettings": {},
"entryInfoActionEditDate": "Tarih ve saati düzenle",
"@entryInfoActionEditDate": {},

View file

@ -126,7 +126,7 @@
"@videoActionSkip10": {},
"videoActionSelectStreams": "Вибрати доріжку",
"@videoActionSelectStreams": {},
"videoActionSettings": "Налаштування",
"viewerActionSettings": "Налаштування",
"@videoActionSettings": {},
"slideshowActionResume": "Продовжити",
"@slideshowActionResume": {},

View file

@ -151,7 +151,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "播放速度",
"@videoActionSetSpeed": {},
"videoActionSettings": "设置",
"viewerActionSettings": "设置",
"@videoActionSettings": {},
"slideshowActionResume": "继续",
"@slideshowActionResume": {},

View file

@ -124,7 +124,7 @@
"@videoActionSelectStreams": {},
"videoActionSetSpeed": "播放速度",
"@videoActionSetSpeed": {},
"videoActionSettings": "設定",
"viewerActionSettings": "設定",
"@videoActionSettings": {},
"slideshowActionResume": "繼續",
"@slideshowActionResume": {},

View file

@ -188,7 +188,7 @@ extension ExtraEntryAction on EntryAction {
case EntryAction.videoSetSpeed:
return context.l10n.videoActionSetSpeed;
case EntryAction.videoSettings:
return context.l10n.videoActionSettings;
return context.l10n.viewerActionSettings;
case EntryAction.videoTogglePlay:
// different data depending on toggle state
return context.l10n.videoActionPlay;

View file

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
enum SlideshowAction {
resume,
showInCollection,
settings,
}
extension ExtraSlideshowAction on SlideshowAction {
@ -14,6 +15,8 @@ extension ExtraSlideshowAction on SlideshowAction {
return context.l10n.slideshowActionResume;
case SlideshowAction.showInCollection:
return context.l10n.slideshowActionShowInCollection;
case SlideshowAction.settings:
return context.l10n.viewerActionSettings;
}
}
@ -25,6 +28,8 @@ extension ExtraSlideshowAction on SlideshowAction {
return AIcons.play;
case SlideshowAction.showInCollection:
return AIcons.allCollection;
case SlideshowAction.settings:
return AIcons.settings;
}
}
}

View file

@ -260,6 +260,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
return [];
case AppMode.slideshow:
return [
_buildViewerTopOverlay(availableSize),
_buildSlideshowBottomOverlay(availableSize),
];
default:

View file

@ -29,6 +29,7 @@ class _SlideshowButtonsState extends State<SlideshowButtons> {
static const List<SlideshowAction> _actions = [
SlideshowAction.resume,
SlideshowAction.showInCollection,
SlideshowAction.settings,
];
static const double _padding = ViewerButtonRowContent.padding;

View file

@ -1,21 +1,26 @@
import 'package:aves/app_mode.dart';
import 'package:aves/model/actions/slideshow_actions.dart';
import 'package:aves/model/entry.dart';
import 'package:aves/model/filters/album.dart';
import 'package:aves/model/filters/mime.dart';
import 'package:aves/model/settings/enums/enums.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/theme/icons.dart';
import 'package:aves/widgets/collection/collection_page.dart';
import 'package:aves/widgets/common/basic/scaffold.dart';
import 'package:aves/widgets/common/extensions/build_context.dart';
import 'package:aves/widgets/common/identity/empty.dart';
import 'package:aves/widgets/settings/viewer/slideshow.dart';
import 'package:aves/widgets/viewer/controller.dart';
import 'package:aves/widgets/viewer/entry_viewer_page.dart';
import 'package:aves/widgets/viewer/entry_viewer_stack.dart';
import 'package:aves_magnifier/aves_magnifier.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';
class SlideshowPage extends StatefulWidget {
static const routeName = '/collection/slideshow';
@ -32,36 +37,33 @@ class SlideshowPage extends StatefulWidget {
}
class _SlideshowPageState extends State<SlideshowPage> {
late final ViewerController _viewerController;
late final CollectionLens _slideshowCollection;
late ViewerController _viewerController;
late CollectionLens _slideshowCollection;
AvesEntry? _initialEntry;
CollectionSource get source => widget.collection.source;
@override
void initState() {
super.initState();
_viewerController = ViewerController(
initialScale: ScaleLevel(ref: settings.slideshowFillScreen ? ScaleReference.covered : ScaleReference.contained),
transition: settings.slideshowTransition,
repeat: settings.slideshowRepeat,
autopilot: true,
autopilotInterval: Duration(seconds: settings.slideshowInterval),
autopilotAnimatedZoom: settings.slideshowAnimatedZoomEffect,
);
_initViewerController(autopilot: true);
_initSlideshowCollection();
_initialEntry = _slideshowCollection.sortedEntries.firstOrNull;
}
@override
void dispose() {
_viewerController.dispose();
_disposeViewerController();
super.dispose();
}
@override
Widget build(BuildContext context) {
final entries = _slideshowCollection.sortedEntries;
final initialEntry = _initialEntry;
return ListenableProvider<ValueNotifier<AppMode>>.value(
value: ValueNotifier(AppMode.slideshow),
child: AvesScaffold(
body: entries.isEmpty
body: initialEntry == null
? EmptyContent(
icon: AIcons.image,
text: context.l10n.collectionEmptyImages,
@ -76,8 +78,9 @@ class _SlideshowPageState extends State<SlideshowPage> {
return true;
},
child: EntryViewerStack(
key: ValueKey(_viewerController),
collection: _slideshowCollection,
initialEntry: entries.first,
initialEntry: initialEntry,
viewerController: _viewerController,
),
),
@ -88,9 +91,21 @@ class _SlideshowPageState extends State<SlideshowPage> {
);
}
void _initViewerController({required bool autopilot}) {
_viewerController = ViewerController(
initialScale: ScaleLevel(ref: settings.slideshowFillScreen ? ScaleReference.covered : ScaleReference.contained),
transition: settings.slideshowTransition,
repeat: settings.slideshowRepeat,
autopilot: autopilot,
autopilotInterval: Duration(seconds: settings.slideshowInterval),
autopilotAnimatedZoom: settings.slideshowAnimatedZoomEffect,
);
}
void _disposeViewerController() => _viewerController.dispose();
void _initSlideshowCollection() {
final originalCollection = widget.collection;
var entries = originalCollection.sortedEntries;
var entries = List.of(widget.collection.sortedEntries);
if (settings.slideshowVideoPlayback == SlideshowVideoPlayback.skip) {
entries = entries.where((entry) => !MimeFilter.video.test(entry)).toList();
}
@ -98,7 +113,7 @@ class _SlideshowPageState extends State<SlideshowPage> {
entries.shuffle();
}
_slideshowCollection = CollectionLens(
source: originalCollection.source,
source: source,
listenToSource: false,
fixedSort: true,
fixedSelection: entries,
@ -113,16 +128,18 @@ class _SlideshowPageState extends State<SlideshowPage> {
case SlideshowAction.showInCollection:
_showInCollection();
break;
case SlideshowAction.settings:
_showSettings(context);
break;
}
}
void _showInCollection() {
final entry = _viewerController.entryNotifier.value;
if (entry == null) return;
final currentEntry = _viewerController.entryNotifier.value;
if (currentEntry == null) return;
final source = _slideshowCollection.source;
final album = entry.directory;
final uri = entry.uri;
final album = currentEntry.directory;
final uri = currentEntry.uri;
Navigator.maybeOf(context)?.pushAndRemoveUntil(
MaterialPageRoute(
@ -136,6 +153,29 @@ class _SlideshowPageState extends State<SlideshowPage> {
(route) => false,
);
}
Tuple2<bool, bool> get collectionSettings => Tuple2(settings.slideshowShuffle, settings.slideshowVideoPlayback == SlideshowVideoPlayback.skip);
Future<void> _showSettings(BuildContext context) async {
final oldCollectionSettings = collectionSettings;
final currentEntry = _viewerController.entryNotifier.value;
await Navigator.maybeOf(context)?.push(
MaterialPageRoute(
settings: const RouteSettings(name: ViewerSlideshowPage.routeName),
builder: (context) => const ViewerSlideshowPage(),
),
);
_disposeViewerController();
_initViewerController(autopilot: false);
if (oldCollectionSettings != collectionSettings) {
_initSlideshowCollection();
}
final slideshowEntries = _slideshowCollection.sortedEntries;
_initialEntry = slideshowEntries.contains(currentEntry) ? currentEntry : slideshowEntries.firstOrNull;
setState(() {});
}
}
class SlideshowActionNotification extends Notification {

View file

@ -57,7 +57,7 @@
"videoActionSkip10",
"videoActionSelectStreams",
"videoActionSetSpeed",
"videoActionSettings",
"viewerActionSettings",
"slideshowActionResume",
"slideshowActionShowInCollection",
"entryInfoActionEditDate",
@ -1822,7 +1822,7 @@
"videoActionSkip10",
"videoActionSelectStreams",
"videoActionSetSpeed",
"videoActionSettings",
"viewerActionSettings",
"slideshowActionResume",
"slideshowActionShowInCollection",
"entryInfoActionEditDate",
@ -2755,7 +2755,7 @@
"videoActionSkip10",
"videoActionSelectStreams",
"videoActionSetSpeed",
"videoActionSettings",
"viewerActionSettings",
"slideshowActionResume",
"slideshowActionShowInCollection",
"entryInfoActionEditDate",