Add settings page #46
4 changed files with 7 additions and 40 deletions
undo tests
commit
accb2fc3ea
|
|
@ -1,7 +1,7 @@
|
|||
import "package:flutter/material.dart";
|
||||
|
||||
extension SchemeToTheme on ColorScheme {
|
||||
ThemeData getTheme(bool useSystemFont) => .from(colorScheme: this).copyWith(
|
||||
ThemeData get theme => .from(colorScheme: this).copyWith(
|
||||
cardTheme: .new(color: primaryContainer),
|
||||
popupMenuTheme: .new(
|
||||
shape: RoundedRectangleBorder(borderRadius: .circular(16)),
|
||||
|
|
@ -11,12 +11,10 @@ extension SchemeToTheme on ColorScheme {
|
|||
titleSpacing: 0,
|
||||
backgroundColor: surfaceContainerLow,
|
||||
),
|
||||
textTheme: useSystemFont
|
||||
? ThemeData(
|
||||
fontFamilyFallback: ["sans", "emoji", "fallback-emoji"],
|
||||
textTheme: ThemeData(
|
||||
fontFamilyFallback: ["sans", "emoji"],
|
||||
brightness: brightness,
|
||||
).textTheme
|
||||
: null,
|
||||
).textTheme,
|
||||
inputDecorationTheme: const InputDecorationTheme(
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -105,14 +105,7 @@ class App extends StatelessWidget {
|
|||
settings.useDynamicTheming ? lightDynamic : null,
|
||||
) ??
|
||||
ColorScheme.fromSeed(seedColor: Colors.indigo))
|
||||
.getTheme(
|
||||
ref
|
||||
.watch(SettingsController.provider)
|
||||
.maybeWhen(
|
||||
orElse: () => true,
|
||||
data: (settings) => settings.useSystemFont,
|
||||
),
|
||||
),
|
||||
.theme,
|
||||
darkTheme:
|
||||
(ref
|
||||
.watch(SettingsController.provider)
|
||||
|
|
@ -125,14 +118,7 @@ class App extends StatelessWidget {
|
|||
seedColor: Colors.indigo,
|
||||
brightness: Brightness.dark,
|
||||
))
|
||||
.getTheme(
|
||||
ref
|
||||
.watch(SettingsController.provider)
|
||||
.maybeWhen(
|
||||
orElse: () => true,
|
||||
data: (settings) => settings.useSystemFont,
|
||||
),
|
||||
),
|
||||
.theme,
|
||||
themeMode: ref
|
||||
.watch(SettingsController.provider)
|
||||
.maybeWhen(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ abstract class Settings with _$Settings {
|
|||
const factory Settings({
|
||||
@Default(ThemeMode.system) ThemeMode theme,
|
||||
@Default(true) bool useDynamicTheming,
|
||||
@Default(true) bool useSystemFont,
|
||||
}) = _Settings;
|
||||
|
||||
factory Settings.fromJson(Map<String, Object?> json) =>
|
||||
|
|
|
|||
|
|
@ -75,22 +75,6 @@ class SettingsPage extends ConsumerWidget {
|
|||
: 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