From d5afb4ad4567ad52da2fbefc92489f4394a79688 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 25 Jun 2024 22:27:18 -0700 Subject: [PATCH] content [nfc]: Add ContentTheme.colorGlobalTimeBackground The dark and light values come from the web app. --- lib/widgets/content.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/widgets/content.dart b/lib/widgets/content.dart index 8f63d9b76c..1715d41e7b 100644 --- a/lib/widgets/content.dart +++ b/lib/widgets/content.dart @@ -36,6 +36,7 @@ class ContentTheme extends ThemeExtension { return ContentTheme._( colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor(), colorDirectMentionBackground: const HSLColor.fromAHSL(0.2, 240, 0.7, 0.7).toColor(), + colorGlobalTimeBackground: const HSLColor.fromAHSL(1, 0, 0, 0.93).toColor(), colorMathBlockBorder: const HSLColor.fromAHSL(0.15, 240, 0.8, 0.5).toColor(), colorMessageMediaContainerBackground: const Color.fromRGBO(0, 0, 0, 0.03), colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor(), @@ -59,6 +60,7 @@ class ContentTheme extends ThemeExtension { return ContentTheme._( colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 1).toColor(), colorDirectMentionBackground: const HSLColor.fromAHSL(0.25, 240, 0.52, 0.6).toColor(), + colorGlobalTimeBackground: const HSLColor.fromAHSL(0.2, 0, 0, 0).toColor(), colorMathBlockBorder: const HSLColor.fromAHSL(1, 240, 0.4, 0.4).toColor(), colorMessageMediaContainerBackground: const HSLColor.fromAHSL(0.03, 0, 0, 1).toColor(), colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor().withOpacity(0.2), @@ -81,6 +83,7 @@ class ContentTheme extends ThemeExtension { ContentTheme._({ required this.colorCodeBlockBackground, required this.colorDirectMentionBackground, + required this.colorGlobalTimeBackground, required this.colorMathBlockBorder, required this.colorMessageMediaContainerBackground, required this.colorThematicBreak, @@ -104,6 +107,7 @@ class ContentTheme extends ThemeExtension { final Color colorCodeBlockBackground; final Color colorDirectMentionBackground; + final Color colorGlobalTimeBackground; final Color colorMathBlockBorder; // TODO(#46) this won't be needed final Color colorMessageMediaContainerBackground; final Color colorThematicBreak; @@ -153,6 +157,7 @@ class ContentTheme extends ThemeExtension { ContentTheme copyWith({ Color? colorCodeBlockBackground, Color? colorDirectMentionBackground, + Color? colorGlobalTimeBackground, Color? colorMathBlockBorder, Color? colorMessageMediaContainerBackground, Color? colorThematicBreak, @@ -166,6 +171,7 @@ class ContentTheme extends ThemeExtension { return ContentTheme._( colorCodeBlockBackground: colorCodeBlockBackground ?? this.colorCodeBlockBackground, colorDirectMentionBackground: colorDirectMentionBackground ?? this.colorDirectMentionBackground, + colorGlobalTimeBackground: colorGlobalTimeBackground ?? this.colorGlobalTimeBackground, colorMathBlockBorder: colorMathBlockBorder ?? this.colorMathBlockBorder, colorMessageMediaContainerBackground: colorMessageMediaContainerBackground ?? this.colorMessageMediaContainerBackground, colorThematicBreak: colorThematicBreak ?? this.colorThematicBreak, @@ -186,6 +192,7 @@ class ContentTheme extends ThemeExtension { return ContentTheme._( colorCodeBlockBackground: Color.lerp(colorCodeBlockBackground, other.colorCodeBlockBackground, t)!, colorDirectMentionBackground: Color.lerp(colorDirectMentionBackground, other.colorDirectMentionBackground, t)!, + colorGlobalTimeBackground: Color.lerp(colorGlobalTimeBackground, other.colorGlobalTimeBackground, t)!, colorMathBlockBorder: Color.lerp(colorMathBlockBorder, other.colorMathBlockBorder, t)!, colorMessageMediaContainerBackground: Color.lerp(colorMessageMediaContainerBackground, other.colorMessageMediaContainerBackground, t)!, colorThematicBreak: Color.lerp(colorThematicBreak, other.colorThematicBreak, t)!, @@ -1117,7 +1124,6 @@ class GlobalTime extends StatelessWidget { final GlobalTimeNode node; final TextStyle ambientTextStyle; - static final _backgroundColor = const HSLColor.fromAHSL(1, 0, 0, 0.93).toColor(); static final _borderColor = const HSLColor.fromAHSL(1, 0, 0, 0.8).toColor(); static final _dateFormat = DateFormat('EEE, MMM d, y, h:mm a'); // TODO(intl): localize date @@ -1126,11 +1132,12 @@ class GlobalTime extends StatelessWidget { // Design taken from css for `.rendered_markdown & time` in web, // see zulip:web/styles/rendered_markdown.css . final text = _dateFormat.format(node.datetime.toLocal()); + final contentTheme = ContentTheme.of(context); return Padding( padding: const EdgeInsets.symmetric(horizontal: 2), child: DecoratedBox( decoration: BoxDecoration( - color: _backgroundColor, + color: contentTheme.colorGlobalTimeBackground, border: Border.all(width: 1, color: _borderColor), borderRadius: BorderRadius.circular(3)), child: Padding(