diff --git a/app/lib/l10n/app_en.arb b/app/lib/l10n/app_en.arb index 3a4739e9..6784ae48 100644 --- a/app/lib/l10n/app_en.arb +++ b/app/lib/l10n/app_en.arb @@ -363,6 +363,14 @@ "@settingsServerAppSectionTitle": { "description": "Enable/disable various server apps" }, + "settingsPhotosDescription": "Customize contents shown in the Photos tab", + "@settingsPhotosDescription": { + "description": "The 'Photos' here means the tab called 'Photos', not literally a photo. The title of this setting will also reuse the label of that tab" + }, + "settingsPhotosPageTitle": "Photos settings", + "@settingsPhotosPageTitle": { + "description": "Dedicated page for settings related to the Photos tab" + }, "settingsViewerTitle": "Viewer", "settingsViewerDescription": "Customize the image/video viewer", "settingsViewerPageTitle": "Viewer settings", diff --git a/app/lib/l10n/untranslated-messages.txt b/app/lib/l10n/untranslated-messages.txt index 22ab3d2f..a72b6dcf 100644 --- a/app/lib/l10n/untranslated-messages.txt +++ b/app/lib/l10n/untranslated-messages.txt @@ -15,6 +15,8 @@ "settingsShareFolderDialogDescription", "settingsShareFolderPickerDescription", "settingsServerAppSectionTitle", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsMapProviderTitle", "settingsAlbumTitle", "settingsAlbumDescription", @@ -166,6 +168,8 @@ "settingsShareFolderDialogDescription", "settingsShareFolderPickerDescription", "settingsServerAppSectionTitle", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsMapProviderTitle", "settingsAlbumTitle", "settingsAlbumDescription", @@ -321,6 +325,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsDoubleTapExitTitle", "enhanceStyleTransferStyleDialogTitle", "doubleTapExitNotification", @@ -362,6 +368,8 @@ "es": [ "settingsLanguageOptionSystemDefaultLabel", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "rootPickerSkipConfirmationDialogContent2", "showAllButtonLabel", "gpsPlaceText", @@ -371,6 +379,8 @@ ], "fi": [ + "settingsPhotosDescription", + "settingsPhotosPageTitle", "gpsPlaceText", "gpsPlaceAboutDialogTitle", "gpsPlaceAboutDialogContent", @@ -384,6 +394,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", @@ -453,6 +465,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", @@ -540,6 +554,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", @@ -606,6 +622,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", @@ -672,6 +690,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", @@ -738,6 +758,8 @@ "settingsExifWifiOnlyFalseSubtitle", "settingsAccountLabelTitle", "settingsAccountLabelDescription", + "settingsPhotosDescription", + "settingsPhotosPageTitle", "settingsPhotoEnhancementTitle", "settingsPhotoEnhancementPageTitle", "settingsEnhanceMaxResolutionTitle", diff --git a/app/lib/widget/settings.dart b/app/lib/widget/settings.dart index 202c3373..aee44a83 100644 --- a/app/lib/widget/settings.dart +++ b/app/lib/widget/settings.dart @@ -72,9 +72,6 @@ class _SettingsState extends State { _isEnableExif = Pref().isEnableExifOr(); _shouldProcessExifWifiOnly = Pref().shouldProcessExifWifiOnlyOr(); - final settings = AccountPref.of(widget.account); - _isEnableMemoryAlbum = settings.isEnableMemoryAlbumOr(true); - _prefUpdatedListener.begin(); } @@ -134,14 +131,6 @@ class _SettingsState extends State { value: _shouldProcessExifWifiOnly, onChanged: _isEnableExif ? _onExifWifiOnlyChanged : null, ), - SwitchListTile( - title: Text(L10n.global().settingsMemoriesTitle), - subtitle: Text(L10n.global().settingsMemoriesSubtitle), - value: _isEnableMemoryAlbum, - onChanged: Pref().isPhotosTabSortByNameOr() - ? null - : _onEnableMemoryAlbumChanged, - ), _buildSubSettings( context, leading: Icon( @@ -151,6 +140,16 @@ class _SettingsState extends State { label: L10n.global().settingsAccountTitle, builder: () => AccountSettingsWidget(account: widget.account), ), + _buildSubSettings( + context, + leading: Icon( + Icons.image_outlined, + color: AppTheme.getUnfocusedIconColor(context), + ), + label: L10n.global().photosTabLabel, + description: L10n.global().settingsPhotosDescription, + builder: () => _PhotosSettings(account: widget.account), + ), _buildSubSettings( context, leading: Icon( @@ -385,24 +384,6 @@ class _SettingsState extends State { } } - Future _onEnableMemoryAlbumChanged(bool value) async { - _log.info("[_onEnableMemoryAlbumChanged] New value: $value"); - final oldValue = _isEnableMemoryAlbum; - setState(() { - _isEnableMemoryAlbum = value; - }); - if (!await AccountPref.of(widget.account).setEnableMemoryAlbum(value)) { - _log.severe("[_onEnableMemoryAlbumChanged] Failed writing pref"); - SnackBarManager().showSnackBar(SnackBar( - content: Text(L10n.global().writePreferenceFailureNotification), - duration: k.snackBarDurationNormal, - )); - setState(() { - _isEnableMemoryAlbum = oldValue; - }); - } - } - Future _onCaptureLogChanged(BuildContext context, bool value) async { if (value) { final result = await showDialog( @@ -472,7 +453,6 @@ class _SettingsState extends State { late bool _isEnableExif; late bool _shouldProcessExifWifiOnly; - late bool _isEnableMemoryAlbum; var _devSettingsUnlockCount = 3; var _isShowDevSettings = false; @@ -818,6 +798,86 @@ class _ShareFolderDialogState extends State<_ShareFolderDialog> { late String _path = widget.initialValue; } +class _PhotosSettings extends StatefulWidget { + const _PhotosSettings({ + Key? key, + required this.account, + }) : super(key: key); + + @override + createState() => _PhotosSettingsState(); + + final Account account; +} + +class _PhotosSettingsState extends State<_PhotosSettings> { + @override + initState() { + super.initState(); + + final settings = AccountPref.of(widget.account); + _isEnableMemoryAlbum = settings.isEnableMemoryAlbumOr(true); + } + + @override + build(BuildContext context) { + return AppTheme( + child: Scaffold( + body: Builder( + builder: (context) => _buildContent(context), + ), + ), + ); + } + + Widget _buildContent(BuildContext context) { + return CustomScrollView( + slivers: [ + SliverAppBar( + pinned: true, + title: Text(L10n.global().settingsPhotosPageTitle), + ), + SliverList( + delegate: SliverChildListDelegate( + [ + SwitchListTile( + title: Text(L10n.global().settingsMemoriesTitle), + subtitle: Text(L10n.global().settingsMemoriesSubtitle), + value: _isEnableMemoryAlbum, + onChanged: Pref().isPhotosTabSortByNameOr() + ? null + : _onEnableMemoryAlbumChanged, + ), + ], + ), + ), + ], + ); + } + + Future _onEnableMemoryAlbumChanged(bool value) async { + _log.info("[_onEnableMemoryAlbumChanged] New value: $value"); + final oldValue = _isEnableMemoryAlbum; + setState(() { + _isEnableMemoryAlbum = value; + }); + if (!await AccountPref.of(widget.account).setEnableMemoryAlbum(value)) { + _log.severe("[_onEnableMemoryAlbumChanged] Failed writing pref"); + SnackBarManager().showSnackBar(SnackBar( + content: Text(L10n.global().writePreferenceFailureNotification), + duration: k.snackBarDurationNormal, + )); + setState(() { + _isEnableMemoryAlbum = oldValue; + }); + } + } + + late bool _isEnableMemoryAlbum; + + static final _log = Logger("widget.settings._PhotosSettingsState"); +} + class _ViewerSettings extends StatefulWidget { @override createState() => _ViewerSettingsState();