fix: Contrast in dark mode

This commit is contained in:
Krille Fear 2021-11-14 22:15:37 +01:00
parent 86566c2584
commit 10480ec408
3 changed files with 12 additions and 15 deletions

View File

@ -132,7 +132,7 @@ abstract class FluffyThemes {
primary: FluffyThemes.lighten(AppConfig.chatColor, 0.33), primary: FluffyThemes.lighten(AppConfig.chatColor, 0.33),
secondary: FluffyThemes.lighten(AppConfig.chatColor, 0.33), secondary: FluffyThemes.lighten(AppConfig.chatColor, 0.33),
secondaryVariant: AppConfig.secondaryColor, secondaryVariant: AppConfig.secondaryColor,
surface: FluffyThemes.darken(AppConfig.chatColor, 0.25, 0.2), surface: FluffyThemes.darken(AppConfig.chatColor, 0.4),
), ),
secondaryHeaderColor: Colors.blueGrey.shade900, secondaryHeaderColor: Colors.blueGrey.shade900,
textTheme: Typography.material2018().white.merge(fallbackTextTheme), textTheme: Typography.material2018().white.merge(fallbackTextTheme),
@ -212,28 +212,21 @@ abstract class FluffyThemes {
? Colors.white ? Colors.white
: Colors.black; : 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); assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(color); final hsl = HSLColor.fromColor(color);
var hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0)); final 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));
}
return hslDark.toColor(); 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); assert(amount >= 0 && amount <= 1);
final hsl = HSLColor.fromColor(color); final hsl = HSLColor.fromColor(color);
var hslLight = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0)); final hslLight =
if (saturation != null) { hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
hslLight = hslLight
.withSaturation((hsl.saturation - saturation).clamp(0.0, 1.0));
}
return hslLight.toColor(); return hslLight.toColor();
} }

View File

@ -59,7 +59,9 @@ class Message extends StatelessWidget {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
final ownMessage = event.senderId == client.userID; final ownMessage = event.senderId == client.userID;
final alignment = ownMessage ? Alignment.topRight : Alignment.topLeft; 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 || final displayTime = event.type == EventTypes.RoomCreate ||
nextEvent == null || nextEvent == null ||
!event.originServerTs.sameEnvironment(nextEvent.originServerTs); !event.originServerTs.sameEnvironment(nextEvent.originServerTs);

View File

@ -31,7 +31,9 @@ class StateMessage extends StatelessWidget {
child: Container( child: Container(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
decoration: BoxDecoration( 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), borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
), ),
child: Column( child: Column(