From a1ce8686f0b2e3e34c81a5a0629ed23de859f7ad Mon Sep 17 00:00:00 2001 From: JHubi1 Date: Tue, 18 Jun 2024 17:42:17 +0200 Subject: [PATCH] Improvements --- lib/main.dart | 12 ++++++------ lib/screen_settings.dart | 26 +++++++++++--------------- lib/screen_welcome.dart | 2 ++ lib/settings/about.dart | 2 +- lib/settings/behavior.dart | 4 ++-- lib/settings/export.dart | 4 ++-- lib/settings/interface.dart | 2 +- lib/settings/voice.dart | 4 ++-- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 07b928d..61bf95a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -137,12 +137,9 @@ class _AppState extends State { Widget build(BuildContext context) { return DynamicColorBuilder( builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) { - if ((prefs?.getBool("useDeviceTheme") ?? false) && - lightDynamic != null && - darkDynamic != null) { - theme = ThemeData.from(colorScheme: lightDynamic); - themeDark = ThemeData.from(colorScheme: darkDynamic); - } else { + if (!(prefs?.getBool("useDeviceTheme") ?? false) || + lightDynamic == null || + darkDynamic == null) { theme = ThemeData.from( colorScheme: const ColorScheme( brightness: Brightness.light, @@ -165,6 +162,9 @@ class _AppState extends State { onError: Colors.black, surface: Colors.black, onSurface: Colors.white)); + } else { + theme = ThemeData.from(colorScheme: lightDynamic); + themeDark = ThemeData.from(colorScheme: darkDynamic); } WidgetsBinding.instance.addPostFrameCallback((_) { diff --git a/lib/screen_settings.dart b/lib/screen_settings.dart index 19c007a..6c44af9 100644 --- a/lib/screen_settings.dart +++ b/lib/screen_settings.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'main.dart'; import 'worker/haptic.dart'; +import 'worker/update.dart'; import 'package:ollama_app/worker/setter.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -89,9 +90,7 @@ Widget toggle(BuildContext context, String text, bool value, ? WidgetStatePropertyAll(Theme.of(context) .colorScheme .primary - .withAlpha(150) - .harmonizeWith( - Theme.of(context).colorScheme.primary)) + .withAlpha(150)) : null, thumbColor: disabled ? WidgetStatePropertyAll(Theme.of(context) @@ -235,6 +234,7 @@ class _ScreenSettingsState extends State { super.initState(); WidgetsFlutterBinding.ensureInitialized(); checkHost(); + updatesSupported(setState, true); } @override @@ -302,7 +302,7 @@ class _ScreenSettingsState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - const SizedBox(height: 16), + const SizedBox(height: 8), TextField( controller: hostInputController, keyboardType: TextInputType.url, @@ -377,11 +377,9 @@ class _ScreenSettingsState extends State { child: Row( children: [ Icon(Icons.error_rounded, - color: Colors.red - .harmonizeWith( - Theme.of(context) - .colorScheme - .primary)), + color: Theme.of(context) + .colorScheme + .error), const SizedBox(width: 8), Text( AppLocalizations.of(context)! @@ -390,11 +388,9 @@ class _ScreenSettingsState extends State { ? "host" : "url"), style: TextStyle( - color: Colors.red - .harmonizeWith( - Theme.of(context) - .colorScheme - .primary))) + color: Theme.of(context) + .colorScheme + .error)) ], )) : null, @@ -504,7 +500,7 @@ class _ScreenSettingsState extends State { }) ]), ), - const SizedBox(height: 16), + const SizedBox(height: 8), button( AppLocalizations.of(context)! .settingsSavedAutomatically, diff --git a/lib/screen_welcome.dart b/lib/screen_welcome.dart index 0e6e3e0..e1bacfd 100644 --- a/lib/screen_welcome.dart +++ b/lib/screen_welcome.dart @@ -49,6 +49,7 @@ class _ScreenWelcomeState extends State { SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( systemNavigationBarColor: (prefs!.getString("brightness") ?? "system") == "system" + // ignore: use_build_context_synchronously ? ((MediaQuery.of(context).platformBrightness == Brightness.light) ? Colors.grey[100] @@ -58,6 +59,7 @@ class _ScreenWelcomeState extends State { : Colors.grey[100]), systemNavigationBarIconBrightness: (((prefs!.getString("brightness") ?? "system") == "system" && + // ignore: use_build_context_synchronously MediaQuery.of(context).platformBrightness == Brightness.light) || prefs!.getString("brightness") == "light") diff --git a/lib/settings/about.dart b/lib/settings/about.dart index f157468..9d083bf 100644 --- a/lib/settings/about.dart +++ b/lib/settings/about.dart @@ -84,7 +84,7 @@ class _ScreenSettingsAboutState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - // const SizedBox(height: 16), + // const SizedBox(height: 8), button( AppLocalizations.of(context)! .settingsVersion(currentVersion ?? ""), diff --git a/lib/settings/behavior.dart b/lib/settings/behavior.dart index c3f8589..2cd833f 100644 --- a/lib/settings/behavior.dart +++ b/lib/settings/behavior.dart @@ -79,7 +79,7 @@ class _ScreenSettingsBehaviorState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - const SizedBox(height: 16), + const SizedBox(height: 8), TextField( controller: systemInputController, keyboardType: TextInputType.multiline, @@ -111,7 +111,7 @@ class _ScreenSettingsBehaviorState extends State { }) ]), ), - const SizedBox(height: 16), + const SizedBox(height: 8), button( AppLocalizations.of(context)! .settingsBehaviorNotUpdatedForOlderChats, diff --git a/lib/settings/export.dart b/lib/settings/export.dart index c4effaa..aa0ec27 100644 --- a/lib/settings/export.dart +++ b/lib/settings/export.dart @@ -73,7 +73,7 @@ class _ScreenSettingsExportState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - // const SizedBox(height: 16), + // const SizedBox(height: 8), button(AppLocalizations.of(context)!.settingsExportChats, Icons.upload_rounded, () async { selectionHaptic(); @@ -167,7 +167,7 @@ class _ScreenSettingsExportState extends State { }) ]), ), - const SizedBox(height: 16), + const SizedBox(height: 8), button(AppLocalizations.of(context)!.settingsExportInfo, Icons.info_rounded, null, color: Colors.grey diff --git a/lib/settings/interface.dart b/lib/settings/interface.dart index 3f1085d..6d608aa 100644 --- a/lib/settings/interface.dart +++ b/lib/settings/interface.dart @@ -72,7 +72,7 @@ class _ScreenSettingsInterfaceState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - // const SizedBox(height: 16), + // const SizedBox(height: 8), toggle( context, AppLocalizations.of(context)!.settingsShowModelTags, diff --git a/lib/settings/voice.dart b/lib/settings/voice.dart index b39a516..7f2a300 100644 --- a/lib/settings/voice.dart +++ b/lib/settings/voice.dart @@ -56,7 +56,7 @@ class _ScreenSettingsVoiceState extends State { child: Column(children: [ Expanded( child: ListView(children: [ - // const SizedBox(height: 16), + // const SizedBox(height: 8), ((prefs!.getBool("voiceModeEnabled") ?? false) || permissionLoading || (permissionBluetooth && @@ -324,7 +324,7 @@ class _ScreenSettingsVoiceState extends State { !(prefs!.getBool("voiceModeEnabled") ?? false))) ]), ), - const SizedBox(height: 16), + const SizedBox(height: 8), button( AppLocalizations.of(context)! .settingsExperimentalBetaFeature,