From 39942335acf0d1dca267bf04dafbbcf63fac323e Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 14 May 2023 15:48:30 +0200 Subject: [PATCH 1/2] Customization and ZenitUI Theme - Added Zenit to pubspec - switched to a Zenit based theme - removed laucherIcon, fontFamily and compactLauncher from CustomizationService - addded a .gitignore... smh --- .gitignore | 98 ++++++++++++++++++++++ lib/services/customization.dart | 61 +++----------- lib/utils/theme.dart | 140 +++++--------------------------- pubspec.yaml | 5 ++ 4 files changed, 136 insertions(+), 168 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcc86e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,98 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +pubspec.lock +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ +/ios/ +/android/ +/test# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +pubspec.lock +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ +/ios/ +/android/ +/test + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/lib/services/customization.dart b/lib/services/customization.dart index 4135a84..631a04e 100644 --- a/lib/services/customization.dart +++ b/lib/services/customization.dart @@ -1,12 +1,11 @@ import 'dart:async'; -import 'package:dsettings/dsettings.dart'; import 'package:dahlia_shared/services/preferences.dart'; import 'package:dahlia_shared/services/service.dart'; import 'package:dahlia_shared/utils/resource.dart'; +import 'package:dsettings/dsettings.dart'; -abstract class CustomizationService - extends ListenableService { +abstract class CustomizationService extends ListenableService { CustomizationService(); static CustomizationService get current { @@ -22,11 +21,8 @@ abstract class CustomizationService bool get enableEffects; List get pinnedApps; List get recentWallpapers; - IconResource get launcherIcon; ColorResource get accentColor; - String get fontFamily; ImageResource get wallpaper; - bool get compactLauncher; double get volume; bool get muteVolume; double get brightness; @@ -42,11 +38,8 @@ abstract class CustomizationService set enableEffects(bool? value); set pinnedApps(List? value); set recentWallpapers(List? value); - set launcherIcon(IconResource value); set accentColor(ColorResource? value); - set fontFamily(String? value); set wallpaper(ImageResource? value); - set compactLauncher(bool? value); set volume(double? value); set muteVolume(bool? value); set brightness(double? value); @@ -78,26 +71,13 @@ class _CustomizationServiceImpl extends CustomizationService { List get pinnedApps => _get(Preference.pinnedApps); @override - List get recentWallpapers => - _getAsResourceList(Preference.recentWallpapers); - - @override - IconResource get launcherIcon => - _getAsResource(Preference.launcherIcon); - - @override - ColorResource get accentColor => - _getAsResource(Preference.accentColor); - - @override - String get fontFamily => _get(Preference.fontFamily); + List get recentWallpapers => _getAsResourceList(Preference.recentWallpapers); @override - ImageResource get wallpaper => - _getAsResource(Preference.wallpaper); + ColorResource get accentColor => _getAsResource(Preference.accentColor); @override - bool get compactLauncher => _get(Preference.compactLauncher); + ImageResource get wallpaper => _getAsResource(Preference.wallpaper); @override double get volume => _get(Preference.volume); @@ -131,8 +111,7 @@ class _CustomizationServiceImpl extends CustomizationService { set locale(String? value) => _set(Preference.locale, value); @override - set showWelcomeScreen(bool? value) => - _set(Preference.showWelcomeScreen, value); + set showWelcomeScreen(bool? value) => _set(Preference.showWelcomeScreen, value); @override set enableEffects(bool? value) => _set(Preference.enableEffects, value); @@ -147,22 +126,10 @@ class _CustomizationServiceImpl extends CustomizationService { ); @override - set launcherIcon(IconResource? value) => - _set(Preference.launcherIcon, value?.toString()); - - @override - set accentColor(ColorResource? value) => - _set(Preference.accentColor, value?.toString()); - - @override - set fontFamily(String? value) => _set(Preference.fontFamily, value); - - @override - set wallpaper(ImageResource? value) => - _set(Preference.wallpaper, value?.toString()); + set accentColor(ColorResource? value) => _set(Preference.accentColor, value?.toString()); @override - set compactLauncher(bool? value) => _set(Preference.compactLauncher, value); + set wallpaper(ImageResource? value) => _set(Preference.wallpaper, value?.toString()); @override set volume(double? value) => _set(Preference.volume, value); @@ -183,12 +150,10 @@ class _CustomizationServiceImpl extends CustomizationService { set enableBluetooth(bool? value) => _set(Preference.enableBluetooth, value); @override - set enableAirplaneMode(bool? value) => - _set(Preference.enableAirplaneMode, value); + set enableAirplaneMode(bool? value) => _set(Preference.enableAirplaneMode, value); @override - set recentSearchResults(List? value) => - _set(Preference.recentSearchResults, value); + set recentSearchResults(List? value) => _set(Preference.recentSearchResults, value); @override Future start() async { @@ -196,8 +161,7 @@ class _CustomizationServiceImpl extends CustomizationService { await ServiceManager.waitForService(); logger.info("Preference service is good to go"); - final int? rawDatabaseVersion = - PreferencesService.current.get(Preference.databaseVersion.key); + final int? rawDatabaseVersion = PreferencesService.current.get(Preference.databaseVersion.key); if (rawDatabaseVersion == null || rawDatabaseVersion < 2) { PreferencesService.current.clear(); @@ -271,11 +235,8 @@ enum Preference { enableEffects("enable_effects", true), pinnedApps>("pinned_apps", []), recentWallpapers>("recent_wallpapers", []), - launcherIcon("launcher_icon", "icon:dahlia#launcher_1"), accentColor("accent_color", "color:dahlia#orange"), - fontFamily("font_family", "Roboto"), wallpaper("wallpaper", "image:dahlia#images/wallpapers/modern.png"), - compactLauncher("compact_launcher", false), volume("volume", 0.5), muteVolume("mute_volume", false), brightness("brightness", 0.5), diff --git a/lib/utils/theme.dart b/lib/utils/theme.dart index 9e12146..b22944b 100644 --- a/lib/utils/theme.dart +++ b/lib/utils/theme.dart @@ -14,129 +14,33 @@ See the License for the specific language governing permissions and limitations under the License. */ -import 'package:animations/animations.dart'; -import 'package:flutter/material.dart'; import 'package:dahlia_shared/services/customization.dart'; import 'package:dahlia_shared/utils/constants.dart'; -import 'package:dahlia_shared/utils/extensions.dart'; +import 'package:flutter/material.dart'; +import 'package:zenit_ui/zenit_ui.dart'; -ThemeData buildDahliaTheme(BuildContext context) { +ThemeData get dahliaLightTheme { final CustomizationService customization = CustomizationService.current; - - final bool darkMode = customization.darkMode; - - final Color accentColor = - customization.accentColor.resolve() ?? BuiltinColor.orange.value; - final Color foregroundColor = context.theme.foregroundColor; - final Color backgroundColor = darkMode ? Colors.black : Colors.white; - final Color surfaceForegroundColor = darkMode ? Colors.white : Colors.black; - final Color surfaceColor = Color(darkMode ? 0xff1E1E1E : 0xffffffff); - final Color cardColor = Color(darkMode ? 0xFF2c2c2c : 0xFFEBEBEB); - - final String fontFamily = customization.fontFamily; - - final Brightness brightness = darkMode ? Brightness.dark : Brightness.light; - - return ThemeData( - pageTransitionsTheme: const PageTransitionsTheme( - builders: { - TargetPlatform.android: - FadeThroughPageTransitionsBuilder(fillColor: Colors.transparent), - }, - ), - hoverColor: context.theme.colorScheme.surface.withOpacity(0.25), - floatingActionButtonTheme: FloatingActionButtonThemeData( - elevation: 0.0, - hoverElevation: 0.0, - focusElevation: 0.0, - highlightElevation: 0.0, - foregroundColor: foregroundColor, - ), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - accentColor, - ), - elevation: MaterialStateProperty.all(0.0), - foregroundColor: MaterialStateProperty.all( - foregroundColor, - ), - ), - ), - appBarTheme: AppBarTheme( - color: accentColor, - elevation: 0.0, - iconTheme: IconThemeData(color: foregroundColor), - ), - fontFamily: fontFamily, - canvasColor: surfaceColor, + final Color accentColor = customization.accentColor.resolve() ?? BuiltinColor.orange.value; + return ThemeEngine.create( + variant: ThemeVariant.light, primaryColor: accentColor, - primaryColorDark: accentColor, - cardColor: cardColor, - scaffoldBackgroundColor: surfaceColor, - inputDecorationTheme: InputDecorationTheme( - labelStyle: TextStyle( - color: accentColor, - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: accentColor, - width: 2, - ), - ), - ), - listTileTheme: ListTileThemeData( - dense: true, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - //TODO Text Theme - textTheme: const TextTheme( - labelLarge: TextStyle(fontSize: 13), - /* displaySmall: TextStyle(fontSize: 11), - displayMedium: TextStyle(fontSize: 12), - displayLarge: TextStyle(fontSize: 13), - //body - bodySmall: TextStyle(fontSize: 11), - bodyMedium: TextStyle(fontSize: 12), - bodyLarge: TextStyle(fontSize: 13), - //label - labelSmall: TextStyle(fontSize: 11), - labelMedium: TextStyle(fontSize: 12), - labelLarge: TextStyle(fontSize: 13), - //title - titleSmall: TextStyle(fontSize: 11), - titleMedium: TextStyle(fontSize: 12), - titleLarge: TextStyle(fontSize: 13), + backgroundColor: const Color(0xFFFAFAFA), + surfaceColor: const Color(0xFFE5E5E7), + cardColor: const Color(0xFFFFFFFF), + textColor: Colors.black, + ); +} - //headline - headlineSmall: TextStyle(fontSize: 11), - headlineMedium: TextStyle(fontSize: 12), - headlineLarge: TextStyle(fontSize: 13), */ - ), - dialogBackgroundColor: backgroundColor, - platform: TargetPlatform.fuchsia, - sliderTheme: SliderThemeData( - overlayColor: accentColor.op(0.1), - thumbColor: accentColor, - activeTrackColor: accentColor, - inactiveTrackColor: accentColor.op(0.5), - activeTickMarkColor: Colors.white.op(0.2), - inactiveTickMarkColor: Colors.white.op(0.2), - ), - iconTheme: IconThemeData( - color: surfaceForegroundColor, - ), - colorScheme: ColorScheme.fromSeed( - brightness: brightness, - seedColor: accentColor, - secondary: accentColor, - background: backgroundColor, - ), +ThemeData get dahliaDarkTheme { + final CustomizationService customization = CustomizationService.current; + final Color accentColor = customization.accentColor.resolve() ?? BuiltinColor.orange.value; + return ThemeEngine.create( + variant: ThemeVariant.dark, + primaryColor: accentColor, + backgroundColor: const Color(0xFF1C1C1E), + surfaceColor: const Color(0xFF353535), + cardColor: const Color(0xFF252528), + textColor: Colors.white, ); } diff --git a/pubspec.yaml b/pubspec.yaml index 122079c..24e55c6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,11 @@ dependencies: url: https://github.com/HrX03/yatl path: yatl_gen + zenit_ui: + git: + url: https://github.com/dahliaOS/zenit_ui.git + ref: Version-0.0.11 + dev_dependencies: flutter_test: sdk: flutter From 368cc744bad5b1f1f444ed8dab63fdbe1433f718 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 4 Jul 2023 18:25:51 +0200 Subject: [PATCH 2/2] delete theme from shared --- lib/utils/theme.dart | 46 -------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 lib/utils/theme.dart diff --git a/lib/utils/theme.dart b/lib/utils/theme.dart deleted file mode 100644 index b22944b..0000000 --- a/lib/utils/theme.dart +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 2021 The dahliaOS Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import 'package:dahlia_shared/services/customization.dart'; -import 'package:dahlia_shared/utils/constants.dart'; -import 'package:flutter/material.dart'; -import 'package:zenit_ui/zenit_ui.dart'; - -ThemeData get dahliaLightTheme { - final CustomizationService customization = CustomizationService.current; - final Color accentColor = customization.accentColor.resolve() ?? BuiltinColor.orange.value; - return ThemeEngine.create( - variant: ThemeVariant.light, - primaryColor: accentColor, - backgroundColor: const Color(0xFFFAFAFA), - surfaceColor: const Color(0xFFE5E5E7), - cardColor: const Color(0xFFFFFFFF), - textColor: Colors.black, - ); -} - -ThemeData get dahliaDarkTheme { - final CustomizationService customization = CustomizationService.current; - final Color accentColor = customization.accentColor.resolve() ?? BuiltinColor.orange.value; - return ThemeEngine.create( - variant: ThemeVariant.dark, - primaryColor: accentColor, - backgroundColor: const Color(0xFF1C1C1E), - surfaceColor: const Color(0xFF353535), - cardColor: const Color(0xFF252528), - textColor: Colors.white, - ); -}