Skip to content

Commit

Permalink
work on material color theme
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Feb 27, 2024
1 parent 6813193 commit ae7c9c7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 32 deletions.
13 changes: 13 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:isolate';

import 'package:dynamic_color/dynamic_color.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
Expand All @@ -24,6 +25,7 @@ import 'package:get_it/get_it.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sheet/route.dart';
import 'package:system_theme/system_theme.dart';

final getIt = GetIt.instance;

Expand Down Expand Up @@ -102,6 +104,17 @@ void main() async {
if (themeID != null && themeID is int) {
_colorTheme = FredericColorTheme.find(themeID);
}

await SystemTheme.accentColor.load();
final palette = await DynamicColorPlugin.getCorePalette();
_colorTheme = FredericColorTheme.fromColor(palette!);

// DynamicColorPlugin.getCorePalette().then((palette) {
// if (palette != null) {
// _colorTheme = FredericColorTheme.fromColor(palette);
// }
// });

// == Load Startup Preferences == End ==

// == Disable Crashlytics in debug mode
Expand Down
83 changes: 51 additions & 32 deletions lib/theme/frederic_theme.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
import 'package:system_theme/system_theme.dart';

class FredericColorTheme {
FredericColorTheme.blue(
Expand Down Expand Up @@ -326,38 +328,6 @@ class FredericColorTheme {
this.greyTextColor = const Color(0xFFC4C4C4),
this.cardBorderColor = Colors.transparent});

FredericColorTheme.fromColor(Color color, bool dark) {
ColorScheme scheme = ColorScheme.fromSeed(
seedColor: color,
brightness: dark ? Brightness.dark : Brightness.light);
bool colorful = dark || false;
this.name = "Custom";
this.uid = 999;

this.mainColor = scheme.primary;
this.mainColorInText = scheme.primary;
this.mainColorLight = scheme.primary.withAlpha(15);
this.accentColor = scheme.secondary;
this.accentColorLight = scheme.secondary.withAlpha(15);
this.positiveColor = scheme.tertiary;
this.positiveColorLight = scheme.tertiary.withAlpha(15);
this.negativeColor = scheme.error;
this.negativeColorLight = scheme.error.withAlpha(15);
this.dividerColor = scheme.outline;
this.backgroundColor = scheme.background;
this.cardBackgroundColor = scheme.tertiary.withOpacity(0.038);
this.greyColor = scheme.onSurface;
this.disabledGreyColor = const Color(0x66A5A5A5);
this.textColor = scheme.onBackground;
this.textColorBright = Colors.black;
this.textColorColorfulBackground =
colorful ? scheme.onPrimary : scheme.onBackground;
this.isDark = dark;
this.isColorful = colorful;
this.greyTextColor = const Color(0xFFC4C4C4);
this.cardBorderColor = Colors.transparent;
}

FredericColorTheme.red(
{this.name = "Hot Rod Red",
this.uid = 14,
Expand Down Expand Up @@ -433,6 +403,55 @@ class FredericColorTheme {
this.greyTextColor = const Color(0xFFC4C4C4),
this.cardBorderColor = Colors.transparent});

FredericColorTheme.fromColor(CorePalette palette) {
//bool colorful = dark || false;
this.name = "You";
this.uid = 17;

this.mainColor = SystemTheme.accentColor.accent;
this.mainColorInText = SystemTheme.accentColor.dark;
this.mainColorLight = SystemTheme.accentColor.accent.withAlpha(100);
this.accentColor = SystemTheme.accentColor.lighter;
this.accentColorLight = SystemTheme.accentColor.lighter.withAlpha(100);
this.positiveColor = const Color(0xFF1CBB3F);
this.positiveColorLight = const Color(0x1A1CBB3F);
this.negativeColor = const Color(0xFF6A0C0B);
this.negativeColorLight = const Color(0x1A6A0C0B);
this.dividerColor = const Color(0xFFC9C9C9);
this.backgroundColor = Colors.white;
this.cardBackgroundColor = Colors.white;
this.greyColor = const Color(0xFFC4C4C4);
this.disabledGreyColor = const Color(0x66A5A5A5);
this.textColor = const Color(0xFF272727);
this.textColorBright = Colors.white;
this.textColorColorfulBackground = const Color(0xFF272727);
this.isDark = false;
this.isColorful = false;
this.greyTextColor = const Color(0xBF3A3A3A);
this.cardBorderColor = const Color(0xFFE2E2E2);
// this.mainColorInText = scheme.primary;
// this.mainColorLight = scheme.primary.withAlpha(15);
// this.accentColor = scheme.secondary;
// this.accentColorLight = scheme.secondary.withAlpha(15);
// this.positiveColor = scheme.tertiary;
// this.positiveColorLight = scheme.tertiary.withAlpha(15);
// this.negativeColor = scheme.error;
// this.negativeColorLight = scheme.error.withAlpha(15);
// this.dividerColor = scheme.outline;
// this.backgroundColor = scheme.background;
// this.cardBackgroundColor = scheme.tertiary.withOpacity(0.038);
// this.greyColor = scheme.onSurface;
// this.disabledGreyColor = const Color(0x66A5A5A5);
// this.textColor = scheme.onBackground;
// this.textColorBright = Colors.black;
// this.textColorColorfulBackground =
// colorful ? scheme.onPrimary : scheme.onBackground;
// this.isDark = dark;
// this.isColorful = colorful;
// this.greyTextColor = const Color(0xFFC4C4C4);
// this.cardBorderColor = Colors.transparent;
}

static FredericColorTheme find(int id) {
switch (id) {
case 1:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ dependencies:
image_picker: ^1.0.4
url_launcher: ^6.1.14
social_share: ^2.3.1
system_theme: ^2.3.1
dynamic_color: ^1.6.9
auto_size_text: ^3.0.0
in_app_purchase: ^3.1.11
cupertino_icons: ^1.0.6
Expand Down

0 comments on commit ae7c9c7

Please sign in to comment.