make refresh rate selectable

This commit is contained in:
Fabian Freund
2026-06-10 09:22:58 +02:00
parent 73ac6fd400
commit 912c15e063
10 changed files with 281 additions and 4 deletions
@@ -47,6 +47,15 @@ const defaultQuickTabSwitcherHierarchyGlyphs = 2;
const minQuickTabSwitcherHierarchyGlyphs = 0;
const maxQuickTabSwitcherHierarchyGlyphs = 4;
/// Controls the Android display refresh rate the app requests at startup.
///
/// Flutter does not request a high refresh rate by default, so on many devices
/// (Samsung, OnePlus, Xiaomi, …) the app is left at 60Hz even on a 90/120Hz
/// panel. [high] asks the OS for the fastest available mode, [low] for the
/// slowest (battery saving), and [system] leaves the OS-managed default in
/// place. Android-only; ignored on other platforms.
enum RefreshRateMode { system, high, low }
enum TabBarSwipeAction { switchLastOpened, navigateOrderedTabs }
enum QuickTabSwitcherMode { lastUsedTabs, containerTabs }
@@ -79,6 +88,9 @@ class GeneralSettings with FastEquatable {
final ThemeMode themeMode;
final double uiScaleFactor;
final bool disableAnimations;
/// Android display refresh rate requested at startup. See [RefreshRateMode].
final RefreshRateMode refreshRateMode;
final bool showModalBarrier;
final bool enableReadability;
final bool enforceReadability;
@@ -168,6 +180,7 @@ class GeneralSettings with FastEquatable {
required this.themeMode,
required this.uiScaleFactor,
required this.disableAnimations,
required this.refreshRateMode,
required this.showModalBarrier,
required this.enableReadability,
required this.enforceReadability,
@@ -232,6 +245,7 @@ class GeneralSettings with FastEquatable {
ThemeMode? themeMode,
double? uiScaleFactor,
bool? disableAnimations,
RefreshRateMode? refreshRateMode,
bool? showModalBarrier,
bool? enableReadability,
bool? enforceReadability,
@@ -293,6 +307,7 @@ class GeneralSettings with FastEquatable {
}) : themeMode = themeMode ?? ThemeMode.dark,
uiScaleFactor = uiScaleFactor ?? defaultUiScaleFactor,
disableAnimations = disableAnimations ?? false,
refreshRateMode = refreshRateMode ?? RefreshRateMode.high,
showModalBarrier = showModalBarrier ?? true,
enableReadability = enableReadability ?? true,
enforceReadability = enforceReadability ?? false,
@@ -419,6 +434,7 @@ class GeneralSettings with FastEquatable {
themeMode,
uiScaleFactor,
disableAnimations,
refreshRateMode,
showModalBarrier,
enableReadability,
enforceReadability,
@@ -13,6 +13,8 @@ abstract class _$GeneralSettingsCWProxy {
GeneralSettings disableAnimations(bool disableAnimations);
GeneralSettings refreshRateMode(RefreshRateMode refreshRateMode);
GeneralSettings showModalBarrier(bool showModalBarrier);
GeneralSettings enableReadability(bool enableReadability);
@@ -162,6 +164,7 @@ abstract class _$GeneralSettingsCWProxy {
ThemeMode themeMode,
double uiScaleFactor,
bool disableAnimations,
RefreshRateMode refreshRateMode,
bool showModalBarrier,
bool enableReadability,
bool enforceReadability,
@@ -241,6 +244,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
GeneralSettings disableAnimations(bool disableAnimations) =>
call(disableAnimations: disableAnimations);
@override
GeneralSettings refreshRateMode(RefreshRateMode refreshRateMode) =>
call(refreshRateMode: refreshRateMode);
@override
GeneralSettings showModalBarrier(bool showModalBarrier) =>
call(showModalBarrier: showModalBarrier);
@@ -500,6 +507,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
Object? themeMode = const $CopyWithPlaceholder(),
Object? uiScaleFactor = const $CopyWithPlaceholder(),
Object? disableAnimations = const $CopyWithPlaceholder(),
Object? refreshRateMode = const $CopyWithPlaceholder(),
Object? showModalBarrier = const $CopyWithPlaceholder(),
Object? enableReadability = const $CopyWithPlaceholder(),
Object? enforceReadability = const $CopyWithPlaceholder(),
@@ -576,6 +584,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
? _value.disableAnimations
// ignore: cast_nullable_to_non_nullable
: disableAnimations as bool,
refreshRateMode:
refreshRateMode == const $CopyWithPlaceholder() ||
refreshRateMode == null
? _value.refreshRateMode
// ignore: cast_nullable_to_non_nullable
: refreshRateMode as RefreshRateMode,
showModalBarrier:
showModalBarrier == const $CopyWithPlaceholder() ||
showModalBarrier == null
@@ -940,6 +954,10 @@ GeneralSettings _$GeneralSettingsFromJson(
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']),
uiScaleFactor: (json['uiScaleFactor'] as num?)?.toDouble(),
disableAnimations: json['disableAnimations'] as bool?,
refreshRateMode: $enumDecodeNullable(
_$RefreshRateModeEnumMap,
json['refreshRateMode'],
),
showModalBarrier: json['showModalBarrier'] as bool?,
enableReadability: json['enableReadability'] as bool?,
enforceReadability: json['enforceReadability'] as bool?,
@@ -1059,6 +1077,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
'uiScaleFactor': instance.uiScaleFactor,
'disableAnimations': instance.disableAnimations,
'refreshRateMode': _$RefreshRateModeEnumMap[instance.refreshRateMode]!,
'showModalBarrier': instance.showModalBarrier,
'enableReadability': instance.enableReadability,
'enforceReadability': instance.enforceReadability,
@@ -1138,6 +1157,12 @@ const _$ThemeModeEnumMap = {
ThemeMode.dark: 'dark',
};
const _$RefreshRateModeEnumMap = {
RefreshRateMode.system: 'system',
RefreshRateMode.high: 'high',
RefreshRateMode.low: 'low',
};
const _$DeleteBrowsingDataTypeEnumMap = {
DeleteBrowsingDataType.tabs: 'tabs',
DeleteBrowsingDataType.history: 'history',