add oled theme support
This commit is contained in:
@@ -41,7 +41,7 @@ final class TabStatesProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabStatesHash() => r'd7efef406dd132a3ef1a67da06c794d18ccb484a';
|
||||
String _$tabStatesHash() => r'04b7f1ea704575e368a0f1186fc1c58f317620b1';
|
||||
|
||||
abstract class _$TabStates extends $Notifier<Map<String, TabState>> {
|
||||
Map<String, TabState> build();
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TabDataRepositoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabDataRepositoryHash() => r'38750c2e0d27b407b1038d324ad22eeb202da6eb';
|
||||
String _$tabDataRepositoryHash() => r'5192e4bb2a373bdef4474fb781eaacc64cc35609';
|
||||
|
||||
abstract class _$TabDataRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
@@ -51,6 +51,13 @@ const List<SettingsSectionDefinition> generalSettingsSections = [
|
||||
keywords: ['light', 'dark', 'theme mode'],
|
||||
child: _ThemeSection(),
|
||||
),
|
||||
SettingsEntryDefinition(
|
||||
title: 'Pure Black (OLED)',
|
||||
subtitle: 'Use true-black surfaces in dark mode to save power on OLED '
|
||||
'screens',
|
||||
keywords: ['oled', 'amoled', 'high contrast', 'black', 'dark'],
|
||||
child: _PureBlackTile(),
|
||||
),
|
||||
SettingsEntryDefinition(
|
||||
title: 'User Interface Zoom',
|
||||
subtitle: 'Make the user interface smaller or larger',
|
||||
@@ -275,6 +282,43 @@ class _ShowModalBarrierTile extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _PureBlackTile extends HookConsumerWidget {
|
||||
const _PureBlackTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final pureBlack = ref.watch(
|
||||
generalSettingsWithDefaultsProvider.select((s) => s.pureBlack),
|
||||
);
|
||||
final themeMode = ref.watch(
|
||||
generalSettingsWithDefaultsProvider.select((s) => s.themeMode),
|
||||
);
|
||||
|
||||
// OLED surfaces only apply to dark mode; disable the toggle when the app
|
||||
// is locked to light mode so the setting can't appear to have no effect.
|
||||
final enabled = themeMode != ThemeMode.light;
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Pure Black (OLED)'),
|
||||
subtitle: const Text(
|
||||
'Use true-black surfaces in dark mode to save power on OLED screens',
|
||||
),
|
||||
secondary: const Icon(Icons.contrast),
|
||||
value: pureBlack,
|
||||
onChanged: enabled
|
||||
? (value) async {
|
||||
await ref
|
||||
.read(saveGeneralSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.pureBlack(value),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ThemeSection extends HookConsumerWidget {
|
||||
const _ThemeSection();
|
||||
|
||||
|
||||
@@ -145,6 +145,10 @@ class GeneralSettings with FastEquatable {
|
||||
/// accept and complete an inline search suggestion. Defaults to false.
|
||||
final bool acceptSuggestionOnSubmit;
|
||||
|
||||
/// Whether dark mode should use pure-black ("OLED"/high-contrast) surfaces.
|
||||
/// Only takes effect when the effective brightness is dark. Defaults to false.
|
||||
final bool pureBlack;
|
||||
|
||||
GeneralSettings({
|
||||
required this.themeMode,
|
||||
required this.uiScaleFactor,
|
||||
@@ -203,6 +207,7 @@ class GeneralSettings with FastEquatable {
|
||||
required this.enableLocalSearchIndex,
|
||||
required this.indexPrivateTabs,
|
||||
required this.acceptSuggestionOnSubmit,
|
||||
required this.pureBlack,
|
||||
});
|
||||
|
||||
GeneralSettings.withDefaults({
|
||||
@@ -263,6 +268,7 @@ class GeneralSettings with FastEquatable {
|
||||
bool? enableLocalSearchIndex,
|
||||
bool? indexPrivateTabs,
|
||||
bool? acceptSuggestionOnSubmit,
|
||||
bool? pureBlack,
|
||||
}) : themeMode = themeMode ?? ThemeMode.dark,
|
||||
uiScaleFactor = uiScaleFactor ?? defaultUiScaleFactor,
|
||||
disableAnimations = disableAnimations ?? false,
|
||||
@@ -331,7 +337,8 @@ class GeneralSettings with FastEquatable {
|
||||
externalAppIntentPolicies = externalAppIntentPolicies ?? const {},
|
||||
enableLocalSearchIndex = enableLocalSearchIndex ?? true,
|
||||
indexPrivateTabs = indexPrivateTabs ?? false,
|
||||
acceptSuggestionOnSubmit = acceptSuggestionOnSubmit ?? false;
|
||||
acceptSuggestionOnSubmit = acceptSuggestionOnSubmit ?? false,
|
||||
pureBlack = pureBlack ?? false;
|
||||
|
||||
factory GeneralSettings.fromJson(Map<String, dynamic> json) {
|
||||
// Migrate legacy `newTabPosition` setting to direction settings.
|
||||
@@ -442,5 +449,6 @@ class GeneralSettings with FastEquatable {
|
||||
enableLocalSearchIndex,
|
||||
indexPrivateTabs,
|
||||
acceptSuggestionOnSubmit,
|
||||
pureBlack,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -143,6 +143,8 @@ abstract class _$GeneralSettingsCWProxy {
|
||||
|
||||
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit);
|
||||
|
||||
GeneralSettings pureBlack(bool pureBlack);
|
||||
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
@@ -208,6 +210,7 @@ abstract class _$GeneralSettingsCWProxy {
|
||||
bool enableLocalSearchIndex,
|
||||
bool indexPrivateTabs,
|
||||
bool acceptSuggestionOnSubmit,
|
||||
bool pureBlack,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -461,6 +464,9 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
GeneralSettings acceptSuggestionOnSubmit(bool acceptSuggestionOnSubmit) =>
|
||||
call(acceptSuggestionOnSubmit: acceptSuggestionOnSubmit);
|
||||
|
||||
@override
|
||||
GeneralSettings pureBlack(bool pureBlack) => call(pureBlack: pureBlack);
|
||||
|
||||
@override
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
|
||||
@@ -528,6 +534,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
Object? enableLocalSearchIndex = const $CopyWithPlaceholder(),
|
||||
Object? indexPrivateTabs = const $CopyWithPlaceholder(),
|
||||
Object? acceptSuggestionOnSubmit = const $CopyWithPlaceholder(),
|
||||
Object? pureBlack = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GeneralSettings(
|
||||
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
|
||||
@@ -866,6 +873,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
? _value.acceptSuggestionOnSubmit
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: acceptSuggestionOnSubmit as bool,
|
||||
pureBlack: pureBlack == const $CopyWithPlaceholder() || pureBlack == null
|
||||
? _value.pureBlack
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: pureBlack as bool,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -992,6 +1003,7 @@ GeneralSettings _$GeneralSettingsFromJson(
|
||||
enableLocalSearchIndex: json['enableLocalSearchIndex'] as bool?,
|
||||
indexPrivateTabs: json['indexPrivateTabs'] as bool?,
|
||||
acceptSuggestionOnSubmit: json['acceptSuggestionOnSubmit'] as bool?,
|
||||
pureBlack: json['pureBlack'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GeneralSettingsToJson(
|
||||
@@ -1067,6 +1079,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
|
||||
'enableLocalSearchIndex': instance.enableLocalSearchIndex,
|
||||
'indexPrivateTabs': instance.indexPrivateTabs,
|
||||
'acceptSuggestionOnSubmit': instance.acceptSuggestionOnSubmit,
|
||||
'pureBlack': instance.pureBlack,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
|
||||
@@ -265,6 +265,10 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
'pureBlack': settings['pureBlack']?.readAs(
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ final class GeneralSettingsRepositoryProvider
|
||||
}
|
||||
|
||||
String _$generalSettingsRepositoryHash() =>
|
||||
r'1e7c7955669933a2dac5a279bcfbac54246672ca';
|
||||
r'5036124c086e35c0e4616a0fd3b2276adb66dd5f';
|
||||
|
||||
abstract class _$GeneralSettingsRepository
|
||||
extends $StreamNotifier<GeneralSettings> {
|
||||
|
||||
Reference in New Issue
Block a user