diff --git a/commet/lib/ui/atoms/emoji_reaction.dart b/commet/lib/ui/atoms/emoji_reaction.dart index fdcbd3f0..2e8afaf4 100644 --- a/commet/lib/ui/atoms/emoji_reaction.dart +++ b/commet/lib/ui/atoms/emoji_reaction.dart @@ -23,7 +23,7 @@ class EmojiReaction extends StatelessWidget { @override Widget build(BuildContext context) { - var bgColor = material.Theme.of(context).colorScheme.primary; + var bgColor = material.Theme.of(context).colorScheme.tertiary; if (!highlighted) { bgColor = material.Theme.of(context).colorScheme.surfaceContainerLow; diff --git a/commet/pubspec.lock b/commet/pubspec.lock index 8e3bf1e5..87485bb1 100644 --- a/commet/pubspec.lock +++ b/commet/pubspec.lock @@ -366,7 +366,7 @@ packages: description: path: "packages/dynamic_color" ref: HEAD - resolved-ref: c23b9658c1ada18021bb1356b921f574217d0668 + resolved-ref: f8a2817197fb68bac47bd1067152c46a4ab56cab url: "https://github.com/Airyzz/material-flutter-packages.git" source: git version: "1.7.0" diff --git a/tiamat/lib/atoms/button.dart b/tiamat/lib/atoms/button.dart index e5cacd14..1f5351c8 100644 --- a/tiamat/lib/atoms/button.dart +++ b/tiamat/lib/atoms/button.dart @@ -96,10 +96,10 @@ class Button extends StatelessWidget { switch (type) { case ButtonType.primary: style = Theme.of(context).elevatedButtonTheme.style!.copyWith( - foregroundColor: WidgetStatePropertyAll( - Theme.of(context).colorScheme.onPrimaryContainer), - backgroundColor: WidgetStatePropertyAll( - Theme.of(context).colorScheme.primaryContainer)); + foregroundColor: + WidgetStatePropertyAll(Theme.of(context).colorScheme.onPrimary), + backgroundColor: + WidgetStatePropertyAll(Theme.of(context).colorScheme.primary)); break; case ButtonType.secondary: style = Theme.of(context).elevatedButtonTheme.style!.copyWith( diff --git a/tiamat/lib/atoms/circle_button.dart b/tiamat/lib/atoms/circle_button.dart index 6bb840d0..8fa1a747 100644 --- a/tiamat/lib/atoms/circle_button.dart +++ b/tiamat/lib/atoms/circle_button.dart @@ -26,7 +26,7 @@ class CircleButton extends StatelessWidget { clipBehavior: Clip.antiAlias, child: ClipOval( child: Material( - color: Theme.of(context).colorScheme.tertiaryContainer, + color: Theme.of(context).colorScheme.secondaryContainer, borderRadius: BorderRadius.circular(radius), child: InkWell( splashColor: Theme.of(context).highlightColor, // Splash color @@ -40,7 +40,7 @@ class CircleButton extends StatelessWidget { ? Align( alignment: Alignment.center, child: Icon( - color: Theme.of(context).colorScheme.tertiary, + color: Theme.of(context).colorScheme.secondary, icon, size: radius, )) diff --git a/tiamat/lib/config/style/theme_amoled.dart b/tiamat/lib/config/style/theme_amoled.dart index a740b0b8..3e04add8 100644 --- a/tiamat/lib/config/style/theme_amoled.dart +++ b/tiamat/lib/config/style/theme_amoled.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:tiamat/config/style/theme_base.dart'; import 'package:tiamat/config/style/theme_common.dart'; import 'package:tiamat/config/style/theme_extensions.dart'; import 'dart:io' show Platform; @@ -21,62 +22,23 @@ class ThemeAmoledColors { } class ThemeAmoled { - static ThemeData get theme => ThemeData( - brightness: Brightness.dark, - fontFamily: "RobotoCustom", - fontFamilyFallback: ThemeCommon.fontFamilyFallback(), - useMaterial3: true, - extensions: const [ - ThemeSettings(caulkBorders: true, caulkStrokeThickness: 1) - ], - colorScheme: const ColorScheme( - primary: Colors.white, - secondary: ThemeAmoledColors.secondary, - secondaryContainer: Color.fromARGB(255, 40, 40, 40), - surface: ThemeAmoledColors.surface, - error: Color.fromARGB(255, 255, 124, 124), - onPrimary: Colors.white, - onSecondary: ThemeAmoledColors.onSurface, - onSurface: Colors.white, - onError: Colors.white, - tertiaryContainer: Colors.black, - brightness: Brightness.dark, - outline: ThemeAmoledColors.surfaceHigh1), - listTileTheme: const ListTileThemeData( - tileColor: ThemeAmoledColors.surface, - ), - canvasColor: ThemeAmoledColors.surface, - iconTheme: const IconThemeData(color: ThemeAmoledColors.secondary), - shadowColor: Colors.black.withAlpha(100), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - backgroundColor: - WidgetStatePropertyAll(ThemeAmoledColors.primary), - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - ))), - dividerTheme: - const DividerThemeData(color: ThemeAmoledColors.surfaceHigh1), - sliderTheme: SliderThemeData( - inactiveTrackColor: ThemeAmoledColors.primary.withAlpha(100), - ), - dialogTheme: const DialogTheme( - backgroundColor: ThemeAmoledColors.surface, - shadowColor: Colors.black), - dialogBackgroundColor: ThemeAmoledColors.highlightColor, - switchTheme: const SwitchThemeData( - thumbColor: WidgetStatePropertyAll(ThemeAmoledColors.secondary)), - dividerColor: ThemeAmoledColors.outlineColor, - textButtonTheme: TextButtonThemeData( - style: ButtonStyle( - overlayColor: const WidgetStatePropertyAll(Colors.white10), - foregroundColor: WidgetStatePropertyAll(Colors.grey.shade300), - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), - textStyle: const WidgetStatePropertyAll( - TextStyle( - color: Colors.white, - ), - ), - ))); + static ThemeData get theme => ThemeBase.theme(const ColorScheme( + primary: Colors.white, + secondary: ThemeAmoledColors.secondary, + secondaryContainer: Color.fromARGB(255, 40, 40, 40), + surface: ThemeAmoledColors.surface, + error: Color.fromARGB(255, 255, 124, 124), + onPrimary: Colors.white, + onSecondary: ThemeAmoledColors.onSurface, + onSurface: Colors.white, + onError: Colors.white, + tertiaryContainer: Colors.black, + brightness: Brightness.dark, + outline: ThemeAmoledColors.surfaceHigh1)) + .copyWith(extensions: [ + const ExtraColors( + codeHighlight: Color(0xffc678dd), + linkColor: Color.fromARGB(255, 120, 120, 255)), + const ThemeSettings(caulkBorders: true, caulkStrokeThickness: 1) + ]); } diff --git a/tiamat/lib/config/style/theme_base.dart b/tiamat/lib/config/style/theme_base.dart new file mode 100644 index 00000000..46f6ba95 --- /dev/null +++ b/tiamat/lib/config/style/theme_base.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:tiamat/config/style/theme_common.dart'; +import 'package:tiamat/config/style/theme_extensions.dart'; + +class ThemeBase { + static ThemeData theme(ColorScheme scheme) => ThemeData( + brightness: scheme.brightness, + fontFamily: "RobotoCustom", + fontFamilyFallback: ThemeCommon.fontFamilyFallback(), + useMaterial3: true, + extensions: const [ + ThemeSettings(caulkBorders: true, caulkBorderRadius: 1), + ExtraColors( + codeHighlight: Color(0xffc678dd), + linkColor: Color.fromARGB(255, 120, 120, 255)) + ], + colorScheme: scheme, + listTileTheme: ListTileThemeData( + tileColor: scheme.surface, + ), + canvasColor: scheme.surface, + iconTheme: IconThemeData(color: scheme.secondary), + shadowColor: Colors.black.withAlpha(100), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ButtonStyle( + shape: WidgetStatePropertyAll( + RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + ))), + dividerTheme: DividerThemeData(color: scheme.surfaceContainerHigh), + sliderTheme: SliderThemeData( + inactiveTrackColor: scheme.primary.withAlpha(100), + ), + dialogTheme: DialogTheme( + backgroundColor: scheme.surface, shadowColor: Colors.black), + switchTheme: + SwitchThemeData(thumbColor: WidgetStatePropertyAll(scheme.secondary)), + dividerColor: scheme.outline, + textButtonTheme: TextButtonThemeData( + style: ButtonStyle( + overlayColor: const WidgetStatePropertyAll(Colors.white10), + foregroundColor: WidgetStatePropertyAll(Colors.grey.shade300), + shape: WidgetStatePropertyAll( + RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), + textStyle: const WidgetStatePropertyAll( + TextStyle( + color: Colors.white, + ), + ), + ))); +} diff --git a/tiamat/lib/config/style/theme_dark.dart b/tiamat/lib/config/style/theme_dark.dart index 165fde9a..5ec4cde9 100644 --- a/tiamat/lib/config/style/theme_dark.dart +++ b/tiamat/lib/config/style/theme_dark.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:tiamat/config/style/theme_base.dart'; import 'package:tiamat/config/style/theme_common.dart'; import 'package:tiamat/config/style/theme_extensions.dart'; import 'dart:io' show Platform; @@ -21,67 +22,33 @@ class ThemeDarkColors { } class ThemeDark { - static ThemeData get theme => ThemeData( - brightness: Brightness.dark, - fontFamily: "RobotoCustom", - fontFamilyFallback: ThemeCommon.fontFamilyFallback(), - useMaterial3: true, - extensions: const [ - ThemeSettings(caulkBorders: true, caulkBorderRadius: 1), - ExtraColors( - codeHighlight: Color(0xffc678dd), - linkColor: Color.fromARGB(255, 120, 120, 255)) - ], - colorScheme: ColorScheme.fromSeed( - seedColor: const Color.fromARGB(255, 106, 141, 255), - secondary: ThemeDarkColors.secondary, - surface: ThemeDarkColors.surface, - surfaceContainer: ThemeDarkColors.surfaceContainer, - surfaceContainerLow: ThemeDarkColors.surfaceContainerLow, - surfaceContainerLowest: ThemeDarkColors.surfaceContainerLowest, - surfaceContainerHigh: ThemeDarkColors.surfaceContainerHigh, - surfaceContainerHighest: ThemeDarkColors.surfaceContainerHigh, - primaryContainer: ThemeDarkColors.primary, - onPrimaryContainer: Colors.white, - onPrimary: Colors.white, - onSecondary: ThemeDarkColors.onSurface, - onSurface: Colors.white, - brightness: Brightness.dark, - tertiaryContainer: ThemeDarkColors.surface, - onTertiaryContainer: Colors.white, - tertiary: Colors.white, - outline: ThemeDarkColors.surfaceContainerHigh), - listTileTheme: const ListTileThemeData( - tileColor: ThemeDarkColors.surface, - ), - canvasColor: ThemeDarkColors.surface, - iconTheme: const IconThemeData(color: ThemeDarkColors.secondary), - shadowColor: Colors.black.withAlpha(100), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - ))), - dividerTheme: - const DividerThemeData(color: ThemeDarkColors.surfaceContainerHigh), - sliderTheme: SliderThemeData( - inactiveTrackColor: ThemeDarkColors.primary.withAlpha(100), - ), - dialogTheme: const DialogTheme( - backgroundColor: ThemeDarkColors.surface, shadowColor: Colors.black), - switchTheme: const SwitchThemeData( - thumbColor: WidgetStatePropertyAll(ThemeDarkColors.secondary)), - dividerColor: ThemeDarkColors.outlineColor, - textButtonTheme: TextButtonThemeData( - style: ButtonStyle( - overlayColor: const WidgetStatePropertyAll(Colors.white10), - foregroundColor: WidgetStatePropertyAll(Colors.grey.shade300), - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), - textStyle: const WidgetStatePropertyAll( - TextStyle( - color: Colors.white, - ), - ), - ))); + static ThemeData get theme { + var scheme = ColorScheme.fromSeed( + seedColor: const Color.fromARGB(255, 106, 141, 255), + secondary: ThemeDarkColors.secondary, + surface: ThemeDarkColors.surface, + surfaceContainer: ThemeDarkColors.surfaceContainer, + surfaceContainerLow: ThemeDarkColors.surfaceContainerLow, + surfaceContainerLowest: ThemeDarkColors.surfaceContainerLowest, + surfaceContainerHigh: ThemeDarkColors.surfaceContainerHigh, + surfaceContainerHighest: ThemeDarkColors.surfaceContainerHigh, + primaryContainer: ThemeDarkColors.primary, + onPrimaryContainer: Colors.white, + onPrimary: Colors.white, + onSecondary: ThemeDarkColors.onSurface, + onSurface: Colors.white, + brightness: Brightness.dark, + tertiaryContainer: ThemeDarkColors.surface, + onTertiaryContainer: Colors.white, + tertiary: Colors.white, + outline: ThemeDarkColors.surfaceContainerHigh); + + return ThemeBase.theme(scheme).copyWith(extensions: [ + const ThemeSettings(caulkBorders: true, caulkBorderRadius: 1), + FoundationSettings(color: scheme.surfaceDim), + const ExtraColors( + codeHighlight: Color(0xffc678dd), + linkColor: Color.fromARGB(255, 120, 120, 255)) + ]); + } } diff --git a/tiamat/lib/config/style/theme_light.dart b/tiamat/lib/config/style/theme_light.dart index 90420a42..aec6a3c0 100644 --- a/tiamat/lib/config/style/theme_light.dart +++ b/tiamat/lib/config/style/theme_light.dart @@ -1,3 +1,4 @@ +import 'package:tiamat/config/style/theme_base.dart'; import 'package:tiamat/config/style/theme_common.dart'; import 'package:tiamat/config/style/theme_extensions.dart'; import 'package:flutter/material.dart'; @@ -25,51 +26,21 @@ class ThemeLightColors { } class ThemeLight { - static ThemeData get theme => ThemeData( - brightness: Brightness.light, - useMaterial3: true, - fontFamily: "RobotoCustom", - extensions: const [ - ThemeSettings(), - ExtraColors( - codeHighlight: Color(0xffc678dd), - linkColor: Color.fromARGB(255, 80, 80, 255)) - ], - fontFamilyFallback: ThemeCommon.fontFamilyFallback(), - colorScheme: ColorScheme.fromSeed( - seedColor: Colors.white, - brightness: Brightness.light, - primaryContainer: ThemeLightColors.primary, - onPrimaryContainer: Colors.white, - outline: Colors.white, - primary: ThemeLightColors.primary), - shadowColor: Colors.black.withAlpha(100), - sliderTheme: SliderThemeData( - inactiveTrackColor: ThemeLightColors.primary.withAlpha(100)), - listTileTheme: const ListTileThemeData( - tileColor: ThemeLightColors.surface, - ), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), - ))), - iconTheme: const IconThemeData(color: ThemeLightColors.secondary), - dividerColor: ThemeLightColors.outlineColor, - dialogBackgroundColor: ThemeLightColors.surface, - dividerTheme: - const DividerThemeData(color: ThemeLightColors.outlineColor), - dialogTheme: const DialogTheme( - backgroundColor: ThemeLightColors.surface, shadowColor: Colors.black), - textButtonTheme: TextButtonThemeData( - style: ButtonStyle( - overlayColor: const WidgetStatePropertyAll(Colors.black12), - foregroundColor: - const WidgetStatePropertyAll(ThemeLightColors.secondary), - shape: WidgetStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), - textStyle: const WidgetStatePropertyAll( - TextStyle(color: Colors.white), - ), - ))); + static ThemeData get theme { + var scheme = ColorScheme.fromSeed( + seedColor: Colors.white, + brightness: Brightness.light, + primaryContainer: ThemeLightColors.primary, + onPrimaryContainer: Colors.white, + outline: Colors.white, + primary: ThemeLightColors.primary); + + return ThemeBase.theme(scheme).copyWith(extensions: [ + const ThemeSettings(), + FoundationSettings(color: scheme.surfaceDim), + const ExtraColors( + codeHighlight: Color(0xffc678dd), + linkColor: Color.fromARGB(255, 80, 80, 255)) + ]); + } } diff --git a/tiamat/lib/config/style/theme_you.dart b/tiamat/lib/config/style/theme_you.dart index 4696dab6..f5447e24 100644 --- a/tiamat/lib/config/style/theme_you.dart +++ b/tiamat/lib/config/style/theme_you.dart @@ -1,17 +1,15 @@ import 'package:dynamic_color/dynamic_color.dart'; import 'package:flutter/material.dart'; +import 'package:tiamat/config/style/theme_base.dart'; import 'package:tiamat/config/style/theme_common.dart'; import 'package:tiamat/config/style/theme_extensions.dart'; import 'package:tiamat/config/style/theme_light.dart'; class ThemeYou { static Future theme(Brightness brightness) async { - var palette = await DynamicColorPlugin.getCorePalette(); ColorScheme? scheme; - - if (palette != null) { - scheme = palette.toColorScheme(brightness: brightness); - } + scheme = (await DynamicColorPlugin.getColorScheme())?[ + brightness == Brightness.light ? 0 : 1]; if (scheme == null) { var color = await DynamicColorPlugin.getAccentColor(); @@ -20,48 +18,10 @@ class ThemeYou { } } - return ThemeData( - brightness: brightness, - useMaterial3: true, - fontFamily: "RobotoCustom", - extensions: [ - ThemeSettings(), - if (scheme != null) ExtraColors.fromScheme(scheme) - ], - fontFamilyFallback: ThemeCommon.fontFamilyFallback(), - colorScheme: scheme, - shadowColor: Colors.black.withAlpha(100), - sliderTheme: SliderThemeData( - inactiveTrackColor: ThemeLightColors.primary.withAlpha(100)), - listTileTheme: const ListTileThemeData( - tileColor: ThemeLightColors.surface, - ), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - backgroundColor: - MaterialStatePropertyAll(ThemeLightColors.primary), - shape: MaterialStatePropertyAll( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10)), - ))), - iconTheme: const IconThemeData(color: ThemeLightColors.secondary), - dividerColor: ThemeLightColors.outlineColor, - dialogBackgroundColor: ThemeLightColors.surface, - dividerTheme: - const DividerThemeData(color: ThemeLightColors.outlineColor), - dialogTheme: const DialogTheme( - backgroundColor: ThemeLightColors.surface, - shadowColor: Colors.black), - textButtonTheme: TextButtonThemeData( - style: ButtonStyle( - overlayColor: const MaterialStatePropertyAll(Colors.black12), - foregroundColor: - const MaterialStatePropertyAll(ThemeLightColors.secondary), - shape: MaterialStatePropertyAll( - RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))), - textStyle: const MaterialStatePropertyAll( - TextStyle(color: Colors.white), - ), - ))); + return ThemeBase.theme(scheme!).copyWith(extensions: [ + const ThemeSettings(), + ExtraColors.fromScheme(scheme), + FoundationSettings(color: scheme.surfaceDim) + ]); } } diff --git a/tiamat/pubspec.lock b/tiamat/pubspec.lock index 5e3c6066..3ebc2d3f 100644 --- a/tiamat/pubspec.lock +++ b/tiamat/pubspec.lock @@ -206,7 +206,7 @@ packages: description: path: "packages/dynamic_color" ref: HEAD - resolved-ref: c23b9658c1ada18021bb1356b921f574217d0668 + resolved-ref: f8a2817197fb68bac47bd1067152c46a4ab56cab url: "https://github.com/Airyzz/material-flutter-packages.git" source: git version: "1.7.0"