From 5a0b4bb9b7e31d3e7c088c3e604c37001a415660 Mon Sep 17 00:00:00 2001 From: MoazSalem Date: Tue, 11 Apr 2023 17:38:41 +0200 Subject: [PATCH] Add an Option for The Old Default Theme --- lib/Services/flex_colors/app_color.dart | 53 ++++++++++++++++--------- pubspec.yaml | 2 +- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/Services/flex_colors/app_color.dart b/lib/Services/flex_colors/app_color.dart index 04e8b4c..0475003 100644 --- a/lib/Services/flex_colors/app_color.dart +++ b/lib/Services/flex_colors/app_color.dart @@ -28,6 +28,7 @@ class AppColor { appBarColor: Color(0xFFC8DCF8), swapOnMaterial3: true, ); + // Create a corresponding custom flex scheme color for a dark theme. static const FlexSchemeColor _myScheme1Dark = FlexSchemeColor( primary: Color(0xFFB1CFF5), @@ -126,7 +127,22 @@ class AppColor { // to a list of FlexSchemeData, where we can bundle each light and dark // theme that goes together and give it a name and description too. const FlexSchemeData( - name: 'Example Midnight', + name: 'Default Theme', + description: 'Default theme, used in older version of the app, enable Colorful option with this theme', + light: FlexSchemeColor( + primary: Colors.white, + secondary: Colors.amber, + swapOnMaterial3: true, + ), + dark: FlexSchemeColor( + primary: Colors.black, + secondary: Colors.amber, + swapOnMaterial3: true, + ), + ), + + const FlexSchemeData( + name: 'Midnight Blue', description: 'Midnight blue theme, created as an in code example by ' 'using custom color values for all colors in the scheme', // FlexSchemeData holds separate defined color schemes for light and @@ -138,7 +154,7 @@ class AppColor { ), // Do the same for our second custom scheme. FlexSchemeData( - name: 'Example Greens', + name: 'Vivid Greens', description: 'Vivid green theme, created as an in code example from one ' 'primary color in light mode and another primary for dark mode', light: _myScheme2Light, @@ -147,7 +163,7 @@ class AppColor { // We also do the same for our 3rd custom scheme, BUT we create its matching // dark colors, from the light FlexSchemeColor with the toDark method. FlexSchemeData( - name: 'Example Red & Blue', + name: 'Red & Blue', description: 'Classic red and blue, created as an in code example from ' 'only light theme mode primary and secondary colors', light: _myScheme3Light, @@ -212,29 +228,28 @@ class AppColor { /// when controller says we are using that as well, instead of the defined /// dark mode scheme. This simplifies our logic in the MaterialApp /// of example 5 and we get right dark colors in ThemeSelector and Popup too. - static FlexSchemeData schemeAtIndex( - final int index, final ThemeController controller) { + static FlexSchemeData schemeAtIndex(final int index, final ThemeController controller) { if (index == schemes.length - 1) { return controller.customScheme.copyWith( - // TODO(rydmike): Something fishy here! On copy dark to custom. + // TODO(rydmike): Something fishy here! On copy dark to custom. dark: controller.useKeyColors ? - // controller.useDarkColorsForSeed - // ? - controller.customScheme.dark - // : - // controller.customScheme.light + // controller.useDarkColorsForSeed + // ? + controller.customScheme.dark + // : + // controller.customScheme.light : controller.useToDarkMethod - ? controller.customScheme.light.defaultError.toDark( - controller.darkMethodLevel, - controller.toDarkSwapPrimaryAndContainer) - : null); + ? controller.customScheme.light.defaultError + .toDark(controller.darkMethodLevel, controller.toDarkSwapPrimaryAndContainer) + : null); } return schemes[index].copyWith( dark: controller.useToDarkMethod - ? schemes[index].light.defaultError.toDark( - controller.darkMethodLevel, - controller.toDarkSwapPrimaryAndContainer) + ? schemes[index] + .light + .defaultError + .toDark(controller.darkMethodLevel, controller.toDarkSwapPrimaryAndContainer) : null); } @@ -271,4 +286,4 @@ class AppColor { 'used as key colors to generate tonal palettes that define ' 'the ColorScheme'; } -} \ No newline at end of file +} diff --git a/pubspec.yaml b/pubspec.yaml index 6e8afb9..3b2aa6c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.10+4 +version: 1.1.11 environment: sdk: ">=2.18.1 <3.0.0"