Skip to content

Commit

Permalink
feat: disable predictive back by default (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Oct 23, 2024
1 parent 3dc5de1 commit 3523baa
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/i18n/aria/aria.i18n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/strings_en_US.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions lib/model/general_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 25 additions & 3 deletions lib/model/general_settings.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -209,6 +210,7 @@ abstract class $GeneralSettingsCopyWith<$Res> {
bool confirmBeforeFollow,
bool confirmWhenRevealingSensitiveMedia,
LaunchMode launchMode,
bool enablePredictiveBack,
ThemeMode themeMode,
String lightThemeId,
String darkThemeId});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -724,6 +731,7 @@ abstract class _$$GeneralSettingsImplCopyWith<$Res>
bool confirmBeforeFollow,
bool confirmWhenRevealingSensitiveMedia,
LaunchMode launchMode,
bool enablePredictiveBack,
ThemeMode themeMode,
String lightThemeId,
String darkThemeId});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'});
Expand Down Expand Up @@ -1474,6 +1488,9 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
@override
@JsonKey()
final LaunchMode launchMode;
@override
@JsonKey()
final bool enablePredictiveBack;
// Theme
@override
@JsonKey()
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -1688,6 +1706,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
confirmBeforeFollow,
confirmWhenRevealingSensitiveMedia,
launchMode,
enablePredictiveBack,
themeMode,
lightThemeId,
darkThemeId
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/model/general_settings.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/provider/general_settings_notifier_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ class GeneralSettingsNotifier extends _$GeneralSettingsNotifier {
await _save();
}

Future<void> setEnablePredictiveBack(bool enablePredictiveBack) async {
state = state.copyWith(enablePredictiveBack: enablePredictiveBack);
await _save();
}

Future<void> setThemeMode(ThemeMode themeMode) async {
state = state.copyWith(themeMode: themeMode);
await _save();
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/general_settings_notifier_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions lib/provider/theme_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
},
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/theme_data_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions lib/view/page/settings/behavior_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3523baa

Please sign in to comment.