Skip to content

Commit 005a8f3

Browse files
committed
content [nfc]: Add ContentTheme.colorCodeBlockBackground
The dark and light values come from the web app.
1 parent aa2d1da commit 005a8f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/widgets/content.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import 'text.dart';
3434
class ContentTheme extends ThemeExtension<ContentTheme> {
3535
factory ContentTheme.light(BuildContext context) {
3636
return ContentTheme._(
37+
colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor(),
3738
colorMessageMediaContainerBackground: const Color.fromRGBO(0, 0, 0, 0.03),
3839
colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor(),
3940
textStylePlainParagraph: _plainParagraphCommon(context).copyWith(
@@ -49,6 +50,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
4950

5051
factory ContentTheme.dark(BuildContext context) {
5152
return ContentTheme._(
53+
colorCodeBlockBackground: const HSLColor.fromAHSL(0.04, 0, 0, 1).toColor(),
5254
colorMessageMediaContainerBackground: const HSLColor.fromAHSL(0.03, 0, 0, 1).toColor(),
5355
colorThematicBreak: const HSLColor.fromAHSL(1, 0, 0, .87).toColor().withOpacity(0.2),
5456
textStylePlainParagraph: _plainParagraphCommon(context).copyWith(
@@ -63,6 +65,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
6365
}
6466

6567
ContentTheme._({
68+
required this.colorCodeBlockBackground,
6669
required this.colorMessageMediaContainerBackground,
6770
required this.colorThematicBreak,
6871
required this.textStylePlainParagraph,
@@ -81,6 +84,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
8184
return extension!;
8285
}
8386

87+
final Color colorCodeBlockBackground;
8488
final Color colorMessageMediaContainerBackground;
8589
final Color colorThematicBreak;
8690

@@ -113,6 +117,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
113117

114118
@override
115119
ContentTheme copyWith({
120+
Color? colorCodeBlockBackground,
116121
Color? colorMessageMediaContainerBackground,
117122
Color? colorThematicBreak,
118123
TextStyle? textStylePlainParagraph,
@@ -121,6 +126,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
121126
TextStyle? textStyleErrorCode,
122127
}) {
123128
return ContentTheme._(
129+
colorCodeBlockBackground: colorCodeBlockBackground ?? this.colorCodeBlockBackground,
124130
colorMessageMediaContainerBackground: colorMessageMediaContainerBackground ?? this.colorMessageMediaContainerBackground,
125131
colorThematicBreak: colorThematicBreak ?? this.colorThematicBreak,
126132
textStylePlainParagraph: textStylePlainParagraph ?? this.textStylePlainParagraph,
@@ -136,6 +142,7 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
136142
return this;
137143
}
138144
return ContentTheme._(
145+
colorCodeBlockBackground: Color.lerp(colorCodeBlockBackground, other.colorCodeBlockBackground, t)!,
139146
colorMessageMediaContainerBackground: Color.lerp(colorMessageMediaContainerBackground, other.colorMessageMediaContainerBackground, t)!,
140147
colorThematicBreak: Color.lerp(colorThematicBreak, other.colorThematicBreak, t)!,
141148
textStylePlainParagraph: TextStyle.lerp(textStylePlainParagraph, other.textStylePlainParagraph, t)!,
@@ -646,7 +653,7 @@ class _CodeBlockContainer extends StatelessWidget {
646653
Widget build(BuildContext context) {
647654
return Container(
648655
decoration: BoxDecoration(
649-
color: const HSLColor.fromAHSL(0.04, 0, 0, 0).toColor(),
656+
color: ContentTheme.of(context).colorCodeBlockBackground,
650657
border: Border.all(
651658
width: 1,
652659
color: borderColor),

0 commit comments

Comments
 (0)