diff --git a/lib/i18n/aria/aria.i18n.yaml b/lib/i18n/aria/aria.i18n.yaml index 31401a831..9ad1cd284 100644 --- a/lib/i18n/aria/aria.i18n.yaml +++ b/lib/i18n/aria/aria.i18n.yaml @@ -38,6 +38,7 @@ emojiPickerScale: "Emoji picker scale" emojiPickerUseDialog: "Display emoji picker as dialog" enableEmojiFadeIn: "Enable fade-in animations for custom emojis" enableFederation: "Enable federation" +enablePredictiveBack: "Enable predictive back animations" endpoint: "Endpoint" expandNote: "Expand note" extraMentionsWarning: "This note includes mentions that are not included in the target note of reply" diff --git a/lib/i18n/strings.g.dart b/lib/i18n/strings.g.dart index a6a1f1379..3c99df4fd 100644 --- a/lib/i18n/strings.g.dart +++ b/lib/i18n/strings.g.dart @@ -4,7 +4,7 @@ /// To regenerate, run: `dart run slang` /// /// Locales: 31 -/// Strings: 54608 (1761 per locale) +/// Strings: 54609 (1761 per locale) // coverage:ignore-file // ignore_for_file: type=lint, unused_import diff --git a/lib/i18n/strings_en_US.g.dart b/lib/i18n/strings_en_US.g.dart index 69085e2bb..6a8406d7c 100644 --- a/lib/i18n/strings_en_US.g.dart +++ b/lib/i18n/strings_en_US.g.dart @@ -92,6 +92,7 @@ class TranslationsAriaEnUs { String get emojiPickerUseDialog => 'Display emoji picker as dialog'; String get enableEmojiFadeIn => 'Enable fade-in animations for custom emojis'; String get enableFederation => 'Enable federation'; + String get enablePredictiveBack => 'Enable predictive back animations'; String get endpoint => 'Endpoint'; String get expandNote => 'Expand note'; String get extraMentionsWarning => 'This note includes mentions that are not included in the target note of reply'; diff --git a/lib/model/general_settings.dart b/lib/model/general_settings.dart index 453110f99..6642e47f5 100644 --- a/lib/model/general_settings.dart +++ b/lib/model/general_settings.dart @@ -119,6 +119,7 @@ class GeneralSettings with _$GeneralSettings { @Default(true) bool confirmBeforeFollow, @Default(false) bool confirmWhenRevealingSensitiveMedia, @Default(LaunchMode.externalApplication) LaunchMode launchMode, + @Default(false) bool enablePredictiveBack, // Theme @Default(ThemeMode.system) ThemeMode themeMode, diff --git a/lib/model/general_settings.freezed.dart b/lib/model/general_settings.freezed.dart index ad54ce15a..fe064fb6c 100644 --- a/lib/model/general_settings.freezed.dart +++ b/lib/model/general_settings.freezed.dart @@ -109,7 +109,8 @@ mixin _$GeneralSettings { bool get confirmBeforeFollow => throw _privateConstructorUsedError; bool get confirmWhenRevealingSensitiveMedia => throw _privateConstructorUsedError; - LaunchMode get launchMode => throw _privateConstructorUsedError; // Theme + LaunchMode get launchMode => throw _privateConstructorUsedError; + bool get enablePredictiveBack => throw _privateConstructorUsedError; // Theme ThemeMode get themeMode => throw _privateConstructorUsedError; String get lightThemeId => throw _privateConstructorUsedError; String get darkThemeId => throw _privateConstructorUsedError; @@ -209,6 +210,7 @@ abstract class $GeneralSettingsCopyWith<$Res> { bool confirmBeforeFollow, bool confirmWhenRevealingSensitiveMedia, LaunchMode launchMode, + bool enablePredictiveBack, ThemeMode themeMode, String lightThemeId, String darkThemeId}); @@ -306,6 +308,7 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings> Object? confirmBeforeFollow = null, Object? confirmWhenRevealingSensitiveMedia = null, Object? launchMode = null, + Object? enablePredictiveBack = null, Object? themeMode = null, Object? lightThemeId = null, Object? darkThemeId = null, @@ -621,6 +624,10 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings> ? _value.launchMode : launchMode // ignore: cast_nullable_to_non_nullable as LaunchMode, + enablePredictiveBack: null == enablePredictiveBack + ? _value.enablePredictiveBack + : enablePredictiveBack // ignore: cast_nullable_to_non_nullable + as bool, themeMode: null == themeMode ? _value.themeMode : themeMode // ignore: cast_nullable_to_non_nullable @@ -724,6 +731,7 @@ abstract class _$$GeneralSettingsImplCopyWith<$Res> bool confirmBeforeFollow, bool confirmWhenRevealingSensitiveMedia, LaunchMode launchMode, + bool enablePredictiveBack, ThemeMode themeMode, String lightThemeId, String darkThemeId}); @@ -819,6 +827,7 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res> Object? confirmBeforeFollow = null, Object? confirmWhenRevealingSensitiveMedia = null, Object? launchMode = null, + Object? enablePredictiveBack = null, Object? themeMode = null, Object? lightThemeId = null, Object? darkThemeId = null, @@ -1134,6 +1143,10 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res> ? _value.launchMode : launchMode // ignore: cast_nullable_to_non_nullable as LaunchMode, + enablePredictiveBack: null == enablePredictiveBack + ? _value.enablePredictiveBack + : enablePredictiveBack // ignore: cast_nullable_to_non_nullable + as bool, themeMode: null == themeMode ? _value.themeMode : themeMode // ignore: cast_nullable_to_non_nullable @@ -1232,6 +1245,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings { this.confirmBeforeFollow = true, this.confirmWhenRevealingSensitiveMedia = false, this.launchMode = LaunchMode.externalApplication, + this.enablePredictiveBack = false, this.themeMode = ThemeMode.system, this.lightThemeId = 'a58a0abb-ff8c-476a-8dec-0ad7837e7e96', this.darkThemeId = '66e7e5a9-cd43-42cd-837d-12f47841fa34'}); @@ -1474,6 +1488,9 @@ class _$GeneralSettingsImpl implements _GeneralSettings { @override @JsonKey() final LaunchMode launchMode; + @override + @JsonKey() + final bool enablePredictiveBack; // Theme @override @JsonKey() @@ -1487,7 +1504,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings { @override String toString() { - return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, alwaysExpandCw: $alwaysExpandCw, alwaysExpandLongNote: $alwaysExpandLongNote, alwaysExpandMediaInSubNote: $alwaysExpandMediaInSubNote, mediaListWithOneImageAppearance: $mediaListWithOneImageAppearance, thumbnailBoxFit: $thumbnailBoxFit, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, publicNoteBackgroundColor: $publicNoteBackgroundColor, homeNoteBackgroundColor: $homeNoteBackgroundColor, followersNoteBackgroundColor: $followersNoteBackgroundColor, specifiedNoteBackgroundColor: $specifiedNoteBackgroundColor, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, reduceAnimation: $reduceAnimation, disableShowingAnimatedImages: $disableShowingAnimatedImages, enableEmojiFadeIn: $enableEmojiFadeIn, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarAtBottom: $showTimelineTabBarAtBottom, showMenuButtonInTabBar: $showMenuButtonInTabBar, showHomeFAB: $showHomeFAB, showNotificationsFAB: $showNotificationsFAB, showShowPostFormFAB: $showShowPostFormFAB, showTabHeaderInOneLine: $showTabHeaderInOneLine, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, showPopupOnNewNote: $showPopupOnNewNote, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, confirmWhenRevealingSensitiveMedia: $confirmWhenRevealingSensitiveMedia, launchMode: $launchMode, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)'; + return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, alwaysExpandCw: $alwaysExpandCw, alwaysExpandLongNote: $alwaysExpandLongNote, alwaysExpandMediaInSubNote: $alwaysExpandMediaInSubNote, mediaListWithOneImageAppearance: $mediaListWithOneImageAppearance, thumbnailBoxFit: $thumbnailBoxFit, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, publicNoteBackgroundColor: $publicNoteBackgroundColor, homeNoteBackgroundColor: $homeNoteBackgroundColor, followersNoteBackgroundColor: $followersNoteBackgroundColor, specifiedNoteBackgroundColor: $specifiedNoteBackgroundColor, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, reduceAnimation: $reduceAnimation, disableShowingAnimatedImages: $disableShowingAnimatedImages, enableEmojiFadeIn: $enableEmojiFadeIn, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarAtBottom: $showTimelineTabBarAtBottom, showMenuButtonInTabBar: $showMenuButtonInTabBar, showHomeFAB: $showHomeFAB, showNotificationsFAB: $showNotificationsFAB, showShowPostFormFAB: $showShowPostFormFAB, showTabHeaderInOneLine: $showTabHeaderInOneLine, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, showPopupOnNewNote: $showPopupOnNewNote, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, confirmWhenRevealingSensitiveMedia: $confirmWhenRevealingSensitiveMedia, launchMode: $launchMode, enablePredictiveBack: $enablePredictiveBack, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)'; } @override @@ -1602,6 +1619,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings { (identical(other.confirmBeforeFollow, confirmBeforeFollow) || other.confirmBeforeFollow == confirmBeforeFollow) && (identical(other.confirmWhenRevealingSensitiveMedia, confirmWhenRevealingSensitiveMedia) || other.confirmWhenRevealingSensitiveMedia == confirmWhenRevealingSensitiveMedia) && (identical(other.launchMode, launchMode) || other.launchMode == launchMode) && + (identical(other.enablePredictiveBack, enablePredictiveBack) || other.enablePredictiveBack == enablePredictiveBack) && (identical(other.themeMode, themeMode) || other.themeMode == themeMode) && (identical(other.lightThemeId, lightThemeId) || other.lightThemeId == lightThemeId) && (identical(other.darkThemeId, darkThemeId) || other.darkThemeId == darkThemeId)); @@ -1688,6 +1706,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings { confirmBeforeFollow, confirmWhenRevealingSensitiveMedia, launchMode, + enablePredictiveBack, themeMode, lightThemeId, darkThemeId @@ -1790,6 +1809,7 @@ abstract class _GeneralSettings implements GeneralSettings { final bool confirmBeforeFollow, final bool confirmWhenRevealingSensitiveMedia, final LaunchMode launchMode, + final bool enablePredictiveBack, final ThemeMode themeMode, final String lightThemeId, final String darkThemeId}) = _$GeneralSettingsImpl; @@ -1957,7 +1977,9 @@ abstract class _GeneralSettings implements GeneralSettings { @override bool get confirmWhenRevealingSensitiveMedia; @override - LaunchMode get launchMode; // Theme + LaunchMode get launchMode; + @override + bool get enablePredictiveBack; // Theme @override ThemeMode get themeMode; @override diff --git a/lib/model/general_settings.g.dart b/lib/model/general_settings.g.dart index 0fc3485c8..07e576f59 100644 --- a/lib/model/general_settings.g.dart +++ b/lib/model/general_settings.g.dart @@ -130,6 +130,7 @@ _$GeneralSettingsImpl _$$GeneralSettingsImplFromJson( launchMode: $enumDecodeNullable(_$LaunchModeEnumMap, json['launchMode']) ?? LaunchMode.externalApplication, + enablePredictiveBack: json['enablePredictiveBack'] as bool? ?? false, themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ?? ThemeMode.system, lightThemeId: json['lightThemeId'] as String? ?? @@ -244,6 +245,7 @@ Map _$$GeneralSettingsImplToJson( val['confirmWhenRevealingSensitiveMedia'] = instance.confirmWhenRevealingSensitiveMedia; val['launchMode'] = _$LaunchModeEnumMap[instance.launchMode]!; + val['enablePredictiveBack'] = instance.enablePredictiveBack; val['themeMode'] = _$ThemeModeEnumMap[instance.themeMode]!; val['lightThemeId'] = instance.lightThemeId; val['darkThemeId'] = instance.darkThemeId; diff --git a/lib/provider/general_settings_notifier_provider.dart b/lib/provider/general_settings_notifier_provider.dart index 52c140e4a..5ea3dec99 100644 --- a/lib/provider/general_settings_notifier_provider.dart +++ b/lib/provider/general_settings_notifier_provider.dart @@ -485,6 +485,11 @@ class GeneralSettingsNotifier extends _$GeneralSettingsNotifier { await _save(); } + Future setEnablePredictiveBack(bool enablePredictiveBack) async { + state = state.copyWith(enablePredictiveBack: enablePredictiveBack); + await _save(); + } + Future setThemeMode(ThemeMode themeMode) async { state = state.copyWith(themeMode: themeMode); await _save(); diff --git a/lib/provider/general_settings_notifier_provider.g.dart b/lib/provider/general_settings_notifier_provider.g.dart index 0517aae2b..43917375b 100644 --- a/lib/provider/general_settings_notifier_provider.g.dart +++ b/lib/provider/general_settings_notifier_provider.g.dart @@ -7,7 +7,7 @@ part of 'general_settings_notifier_provider.dart'; // ************************************************************************** String _$generalSettingsNotifierHash() => - r'2144e1d7d9cd3846f6b1943848e0a6d4673019c3'; + r'dcd0837658085a5c5334a06fcbe4a5538f5e360d'; /// See also [GeneralSettingsNotifier]. @ProviderFor(GeneralSettingsNotifier) diff --git a/lib/provider/theme_data_provider.dart b/lib/provider/theme_data_provider.dart index e483b7aeb..6afc65638 100644 --- a/lib/provider/theme_data_provider.dart +++ b/lib/provider/theme_data_provider.dart @@ -20,6 +20,11 @@ ThemeData themeData(Ref ref, Brightness brightness) { final height = ref.watch( generalSettingsNotifierProvider.select((settings) => settings.lineHeight), ); + final enablePredictiveBack = ref.watch( + generalSettingsNotifierProvider + .select((settings) => settings.enablePredictiveBack), + ); + return ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: colors.accent, @@ -98,11 +103,13 @@ ThemeData themeData(Ref ref, Brightness brightness) { ), sliderTheme: const SliderThemeData(showValueIndicator: ShowValueIndicator.always), - pageTransitionsTheme: const PageTransitionsTheme( + pageTransitionsTheme: PageTransitionsTheme( builders: { - TargetPlatform.android: PredictiveBackPageTransitionsBuilder(), - TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.android: enablePredictiveBack + ? const PredictiveBackPageTransitionsBuilder() + : const ZoomPageTransitionsBuilder(), + TargetPlatform.iOS: const CupertinoPageTransitionsBuilder(), + TargetPlatform.macOS: const CupertinoPageTransitionsBuilder(), }, ), ); diff --git a/lib/provider/theme_data_provider.g.dart b/lib/provider/theme_data_provider.g.dart index e12907360..101791471 100644 --- a/lib/provider/theme_data_provider.g.dart +++ b/lib/provider/theme_data_provider.g.dart @@ -6,7 +6,7 @@ part of 'theme_data_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$themeDataHash() => r'2af87794dfce6284c88fa63c14ffee0d4b0903e8'; +String _$themeDataHash() => r'ca83d1e8f17a5c1b567a01b2ddbcbae6cc04d62f'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/view/page/settings/behavior_page.dart b/lib/view/page/settings/behavior_page.dart index 2c9472bf5..39d15a69b 100644 --- a/lib/view/page/settings/behavior_page.dart +++ b/lib/view/page/settings/behavior_page.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -213,6 +214,14 @@ class BehaviorPage extends ConsumerWidget { } }, ), + if (defaultTargetPlatform == TargetPlatform.android) + SwitchListTile( + title: Text(t.aria.enablePredictiveBack), + value: settings.enablePredictiveBack, + onChanged: (value) => ref + .read(generalSettingsNotifierProvider.notifier) + .setEnablePredictiveBack(value), + ), ], ), selectedDestination: GeneralSettingsDestination.behavior,