undo tests
This commit is contained in:
parent
46f04ca74f
commit
accb2fc3ea
4 changed files with 7 additions and 40 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
|
||||||
extension SchemeToTheme on ColorScheme {
|
extension SchemeToTheme on ColorScheme {
|
||||||
ThemeData getTheme(bool useSystemFont) => .from(colorScheme: this).copyWith(
|
ThemeData get theme => .from(colorScheme: this).copyWith(
|
||||||
cardTheme: .new(color: primaryContainer),
|
cardTheme: .new(color: primaryContainer),
|
||||||
popupMenuTheme: .new(
|
popupMenuTheme: .new(
|
||||||
shape: RoundedRectangleBorder(borderRadius: .circular(16)),
|
shape: RoundedRectangleBorder(borderRadius: .circular(16)),
|
||||||
|
|
@ -11,12 +11,10 @@ extension SchemeToTheme on ColorScheme {
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
backgroundColor: surfaceContainerLow,
|
backgroundColor: surfaceContainerLow,
|
||||||
),
|
),
|
||||||
textTheme: useSystemFont
|
textTheme: ThemeData(
|
||||||
? ThemeData(
|
fontFamilyFallback: ["sans", "emoji"],
|
||||||
fontFamilyFallback: ["sans", "emoji", "fallback-emoji"],
|
|
||||||
brightness: brightness,
|
brightness: brightness,
|
||||||
).textTheme
|
).textTheme,
|
||||||
: null,
|
|
||||||
inputDecorationTheme: const InputDecorationTheme(
|
inputDecorationTheme: const InputDecorationTheme(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,7 @@ class App extends StatelessWidget {
|
||||||
settings.useDynamicTheming ? lightDynamic : null,
|
settings.useDynamicTheming ? lightDynamic : null,
|
||||||
) ??
|
) ??
|
||||||
ColorScheme.fromSeed(seedColor: Colors.indigo))
|
ColorScheme.fromSeed(seedColor: Colors.indigo))
|
||||||
.getTheme(
|
.theme,
|
||||||
ref
|
|
||||||
.watch(SettingsController.provider)
|
|
||||||
.maybeWhen(
|
|
||||||
orElse: () => true,
|
|
||||||
data: (settings) => settings.useSystemFont,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
darkTheme:
|
darkTheme:
|
||||||
(ref
|
(ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
|
|
@ -125,14 +118,7 @@ class App extends StatelessWidget {
|
||||||
seedColor: Colors.indigo,
|
seedColor: Colors.indigo,
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
))
|
))
|
||||||
.getTheme(
|
.theme,
|
||||||
ref
|
|
||||||
.watch(SettingsController.provider)
|
|
||||||
.maybeWhen(
|
|
||||||
orElse: () => true,
|
|
||||||
data: (settings) => settings.useSystemFont,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
themeMode: ref
|
themeMode: ref
|
||||||
.watch(SettingsController.provider)
|
.watch(SettingsController.provider)
|
||||||
.maybeWhen(
|
.maybeWhen(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ abstract class Settings with _$Settings {
|
||||||
const factory Settings({
|
const factory Settings({
|
||||||
@Default(ThemeMode.system) ThemeMode theme,
|
@Default(ThemeMode.system) ThemeMode theme,
|
||||||
@Default(true) bool useDynamicTheming,
|
@Default(true) bool useDynamicTheming,
|
||||||
@Default(true) bool useSystemFont,
|
|
||||||
}) = _Settings;
|
}) = _Settings;
|
||||||
|
|
||||||
factory Settings.fromJson(Map<String, Object?> json) =>
|
factory Settings.fromJson(Map<String, Object?> json) =>
|
||||||
|
|
|
||||||
|
|
@ -75,22 +75,6 @@ class SettingsPage extends ConsumerWidget {
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Setting(
|
|
||||||
title: "Use System Font",
|
|
||||||
icon: Icons.abc,
|
|
||||||
description:
|
|
||||||
"Use the system's sans and emoji fonts, instead of Flutter's bundled fonts. Turn this off if you are having issues rendering emoji.",
|
|
||||||
builder: (title, description, icon) => SwitchListTile(
|
|
||||||
title: Text(title),
|
|
||||||
subtitle: Text(description),
|
|
||||||
secondary: Icon(icon),
|
|
||||||
value: settings.useSystemFont,
|
|
||||||
onChanged: (value) => ref
|
|
||||||
.watch(SettingsController.provider.notifier)
|
|
||||||
.set(settings.copyWith(useSystemFont: value))
|
|
||||||
.onError(showError),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue