fix: Broken dynamic color palette

This commit is contained in:
Christian Pauly 2022-05-18 12:13:59 +02:00
commit ea17a28519
12 changed files with 111 additions and 215 deletions

View file

@ -12,7 +12,7 @@ abstract class AppConfig {
static double bubbleSizeFactor = 1;
static double fontSizeFactor = 1;
static const Color chatColor = primaryColor;
static Color? colorSchemeSeed;
static Color? colorSchemeSeed = primaryColor;
static const double messageFontSize = 15.75;
static const bool allowOtherHomeservers = true;
static const bool enableRegistration = true;
@ -64,7 +64,7 @@ abstract class AppConfig {
static void loadFromJson(Map<String, dynamic> json) {
if (json['chat_color'] != null) {
try {
colorSchemeSeed = Color(json['application_name']);
colorSchemeSeed = Color(json['chat_color']);
} catch (e) {
Logs().w(
'Invalid color in config.json! Please make sure to define the color in this format: "0xffdd0000"',

View file

@ -74,11 +74,13 @@ abstract class FluffyThemes {
subtitle2: fallbackTextStyle,
);
static ThemeData get light => ThemeData(
static ThemeData light([ColorScheme? colorScheme]) => ThemeData(
visualDensity: VisualDensity.standard,
useMaterial3: true,
brightness: Brightness.light,
colorSchemeSeed: AppConfig.colorSchemeSeed,
colorSchemeSeed: AppConfig.colorSchemeSeed ??
colorScheme?.primary ??
AppConfig.chatColor,
scaffoldBackgroundColor: Colors.white,
textTheme: PlatformInfos.isDesktop
? Typography.material2018().black.merge(fallbackTextTheme)
@ -124,11 +126,13 @@ abstract class FluffyThemes {
),
);
static ThemeData get dark => ThemeData(
static ThemeData dark([ColorScheme? colorScheme]) => ThemeData(
visualDensity: VisualDensity.standard,
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: AppConfig.colorSchemeSeed,
colorSchemeSeed: AppConfig.colorSchemeSeed ??
colorScheme?.primary ??
AppConfig.chatColor,
scaffoldBackgroundColor: Colors.black,
textTheme: PlatformInfos.isDesktop
? Typography.material2018().white.merge(fallbackTextTheme)