Skip to content

Commit 40cb1e0

Browse files
committed
content [nfc]: Add ContentTheme.colorMathBlockBorder
The dark-theme color, like the light-theme one, doesn't have a source in Figma or the web app. I just chose it from some quick testing on my iPhone. (As the comment says, we'll drop the color when we support katex properly, zulip#46.)
1 parent 005a8f3 commit 40cb1e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/widgets/content.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
3535
factory ContentTheme.light(BuildContext context) {
3636
return ContentTheme._(
3737
colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor(),
38+
colorMathBlockBorder: const HSLColor.fromAHSL(0.15, 240, 0.8, 0.5).toColor(),
3839
colorMessageMediaContainerBackground: const Color.fromRGBO(0, 0, 0, 0.03),
3940
colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor(),
4041
textStylePlainParagraph: _plainParagraphCommon(context).copyWith(
@@ -51,6 +52,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
5152
factory ContentTheme.dark(BuildContext context) {
5253
return ContentTheme._(
5354
colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 1).toColor(),
55+
colorMathBlockBorder: const HSLColor.fromAHSL(1, 240, 0.4, 0.4).toColor(),
5456
colorMessageMediaContainerBackground: const HSLColor.fromAHSL(0.03, 0, 0, 1).toColor(),
5557
colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor().withOpacity(0.2),
5658
textStylePlainParagraph: _plainParagraphCommon(context).copyWith(
@@ -66,6 +68,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
6668

6769
ContentTheme._({
6870
required this.colorCodeBlockBackground,
71+
required this.colorMathBlockBorder,
6972
required this.colorMessageMediaContainerBackground,
7073
required this.colorThematicBreak,
7174
required this.textStylePlainParagraph,
@@ -85,6 +88,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
8588
}
8689

8790
final Color colorCodeBlockBackground;
91+
final Color colorMathBlockBorder; // TODO(#46) this won't be needed
8892
final Color colorMessageMediaContainerBackground;
8993
final Color colorThematicBreak;
9094

@@ -118,6 +122,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
118122
@override
119123
ContentTheme copyWith({
120124
Color? colorCodeBlockBackground,
125+
Color? colorMathBlockBorder,
121126
Color? colorMessageMediaContainerBackground,
122127
Color? colorThematicBreak,
123128
TextStyle? textStylePlainParagraph,
@@ -127,6 +132,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
127132
}) {
128133
return ContentTheme._(
129134
colorCodeBlockBackground: colorCodeBlockBackground ?? this.colorCodeBlockBackground,
135+
colorMathBlockBorder: colorMathBlockBorder ?? this.colorMathBlockBorder,
130136
colorMessageMediaContainerBackground: colorMessageMediaContainerBackground ?? this.colorMessageMediaContainerBackground,
131137
colorThematicBreak: colorThematicBreak ?? this.colorThematicBreak,
132138
textStylePlainParagraph: textStylePlainParagraph ?? this.textStylePlainParagraph,
@@ -143,6 +149,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
143149
}
144150
return ContentTheme._(
145151
colorCodeBlockBackground: Color.lerp(colorCodeBlockBackground, other.colorCodeBlockBackground, t)!,
152+
colorMathBlockBorder: Color.lerp(colorMathBlockBorder, other.colorMathBlockBorder, t)!,
146153
colorMessageMediaContainerBackground: Color.lerp(colorMessageMediaContainerBackground, other.colorMessageMediaContainerBackground, t)!,
147154
colorThematicBreak: Color.lerp(colorThematicBreak, other.colorThematicBreak, t)!,
148155
textStylePlainParagraph: TextStyle.lerp(textStylePlainParagraph, other.textStylePlainParagraph, t)!,
@@ -698,12 +705,10 @@ class MathBlock extends StatelessWidget {
698705

699706
final MathBlockNode node;
700707

701-
static final _borderColor = const HSLColor.fromAHSL(0.15, 240, 0.8, 0.5).toColor();
702-
703708
@override
704709
Widget build(BuildContext context) {
705710
return _CodeBlockContainer(
706-
borderColor: _borderColor,
711+
borderColor: ContentTheme.of(context).colorMathBlockBorder,
707712
child: Text.rich(TextSpan(
708713
style: ContentTheme.of(context).codeBlockTextStyles.plain,
709714
children: [TextSpan(text: node.texSource)])));

0 commit comments

Comments
 (0)