From 10480ec408171f0108b842ba81b5c72a511e6a55 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Sun, 14 Nov 2021 22:15:37 +0100 Subject: [PATCH] fix: Contrast in dark mode --- lib/config/themes.dart | 19 ++++++------------- lib/pages/chat/events/message.dart | 4 +++- lib/pages/chat/events/state_message.dart | 4 +++- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/config/themes.dart b/lib/config/themes.dart index 202b3734..fa0ea34b 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -132,7 +132,7 @@ abstract class FluffyThemes { primary: FluffyThemes.lighten(AppConfig.chatColor, 0.33), secondary: FluffyThemes.lighten(AppConfig.chatColor, 0.33), secondaryVariant: AppConfig.secondaryColor, - surface: FluffyThemes.darken(AppConfig.chatColor, 0.25, 0.2), + surface: FluffyThemes.darken(AppConfig.chatColor, 0.4), ), secondaryHeaderColor: Colors.blueGrey.shade900, textTheme: Typography.material2018().white.merge(fallbackTextTheme), @@ -212,28 +212,21 @@ abstract class FluffyThemes { ? Colors.white : Colors.black; - static Color darken(Color color, [double amount = .1, double saturation]) { + static Color darken(Color color, [double amount = .1]) { assert(amount >= 0 && amount <= 1); final hsl = HSLColor.fromColor(color); - var hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0)); - if (saturation != null) { - hslDark = - hslDark.withSaturation((hsl.saturation - saturation).clamp(0.0, 1.0)); - } + final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0)); return hslDark.toColor(); } - static Color lighten(Color color, [double amount = .1, double saturation]) { + static Color lighten(Color color, [double amount = .1]) { assert(amount >= 0 && amount <= 1); final hsl = HSLColor.fromColor(color); - var hslLight = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0)); - if (saturation != null) { - hslLight = hslLight - .withSaturation((hsl.saturation - saturation).clamp(0.0, 1.0)); - } + final hslLight = + hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0)); return hslLight.toColor(); } diff --git a/lib/pages/chat/events/message.dart b/lib/pages/chat/events/message.dart index 4c94ec19..c2d0d475 100644 --- a/lib/pages/chat/events/message.dart +++ b/lib/pages/chat/events/message.dart @@ -59,7 +59,9 @@ class Message extends StatelessWidget { final client = Matrix.of(context).client; final ownMessage = event.senderId == client.userID; final alignment = ownMessage ? Alignment.topRight : Alignment.topLeft; - var color = Theme.of(context).scaffoldBackgroundColor; + var color = Theme.of(context).brightness == Brightness.light + ? Colors.white + : Colors.grey.shade900; final displayTime = event.type == EventTypes.RoomCreate || nextEvent == null || !event.originServerTs.sameEnvironment(nextEvent.originServerTs); diff --git a/lib/pages/chat/events/state_message.dart b/lib/pages/chat/events/state_message.dart index 2da0e777..70cf2146 100644 --- a/lib/pages/chat/events/state_message.dart +++ b/lib/pages/chat/events/state_message.dart @@ -31,7 +31,9 @@ class StateMessage extends StatelessWidget { child: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, + color: Theme.of(context).brightness == Brightness.light + ? Colors.white + : Colors.grey.shade900, borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), ), child: Column(