Skip to content

Commit

Permalink
Add an Option for The Old Default Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
MoazSalem committed Apr 11, 2023
1 parent 605d71e commit 5a0b4bb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
53 changes: 34 additions & 19 deletions lib/Services/flex_colors/app_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -271,4 +286,4 @@ class AppColor {
'used as key colors to generate tonal palettes that define '
'the ColorScheme';
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5a0b4bb

Please sign in to comment.