Skip to content

Commit

Permalink
content [nfc]: Add ContentTheme.colorGlobalTimeBackground
Browse files Browse the repository at this point in the history
The dark and light values come from the web app.
  • Loading branch information
chrisbobbe committed Jun 28, 2024
1 parent 60bcc63 commit d5afb4a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/widgets/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
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(),
Expand All @@ -59,6 +60,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
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),
Expand All @@ -81,6 +83,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
ContentTheme._({
required this.colorCodeBlockBackground,
required this.colorDirectMentionBackground,
required this.colorGlobalTimeBackground,
required this.colorMathBlockBorder,
required this.colorMessageMediaContainerBackground,
required this.colorThematicBreak,
Expand All @@ -104,6 +107,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {

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;
Expand Down Expand Up @@ -153,6 +157,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
ContentTheme copyWith({
Color? colorCodeBlockBackground,
Color? colorDirectMentionBackground,
Color? colorGlobalTimeBackground,
Color? colorMathBlockBorder,
Color? colorMessageMediaContainerBackground,
Color? colorThematicBreak,
Expand All @@ -166,6 +171,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
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,
Expand All @@ -186,6 +192,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
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)!,
Expand Down Expand Up @@ -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

Expand All @@ -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(
Expand Down

0 comments on commit d5afb4a

Please sign in to comment.