@@ -18,6 +18,7 @@ import 'dialog.dart';
18
18
import 'icons.dart' ;
19
19
import 'lightbox.dart' ;
20
20
import 'message_list.dart' ;
21
+ import 'poll.dart' ;
21
22
import 'store.dart' ;
22
23
import 'text.dart' ;
23
24
@@ -41,6 +42,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
41
42
colorGlobalTimeBorder: const HSLColor .fromAHSL (1 , 0 , 0 , 0.8 ).toColor (),
42
43
colorMathBlockBorder: const HSLColor .fromAHSL (0.15 , 240 , 0.8 , 0.5 ).toColor (),
43
44
colorMessageMediaContainerBackground: const Color .fromRGBO (0 , 0 , 0 , 0.03 ),
45
+ colorPollNames: const HSLColor .fromAHSL (1 , 0 , 0 , .45 ).toColor (),
46
+ colorPollVoteCountBackground: const HSLColor .fromAHSL (1 , 0 , 0 , 1 ).toColor (),
47
+ colorPollVoteCountBorder: const HSLColor .fromAHSL (1 , 156 , 0.28 , 0.7 ).toColor (),
48
+ colorPollVoteCountText: const HSLColor .fromAHSL (1 , 156 , 0.41 , 0.4 ).toColor (),
44
49
colorThematicBreak: const HSLColor .fromAHSL (1 , 0 , 0 , .87 ).toColor (),
45
50
textStylePlainParagraph: _plainParagraphCommon (context).copyWith (
46
51
color: const HSLColor .fromAHSL (1 , 0 , 0 , 0.15 ).toColor (),
@@ -66,6 +71,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
66
71
colorGlobalTimeBorder: const HSLColor .fromAHSL (0.4 , 0 , 0 , 0 ).toColor (),
67
72
colorMathBlockBorder: const HSLColor .fromAHSL (1 , 240 , 0.4 , 0.4 ).toColor (),
68
73
colorMessageMediaContainerBackground: const HSLColor .fromAHSL (0.03 , 0 , 0 , 1 ).toColor (),
74
+ colorPollNames: const HSLColor .fromAHSL (1 , 236 , .15 , .7 ).toColor (),
75
+ colorPollVoteCountBackground: const HSLColor .fromAHSL (0.2 , 0 , 0 , 0 ).toColor (),
76
+ colorPollVoteCountBorder: const HSLColor .fromAHSL (1 , 185 , 0.35 , 0.35 ).toColor (),
77
+ colorPollVoteCountText: const HSLColor .fromAHSL (1 , 185 , 0.35 , 0.65 ).toColor (),
69
78
colorThematicBreak: const HSLColor .fromAHSL (1 , 0 , 0 , .87 ).toColor ().withOpacity (0.2 ),
70
79
textStylePlainParagraph: _plainParagraphCommon (context).copyWith (
71
80
color: const HSLColor .fromAHSL (0.75 , 0 , 0 , 1 ).toColor (),
@@ -90,6 +99,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
90
99
required this .colorGlobalTimeBorder,
91
100
required this .colorMathBlockBorder,
92
101
required this .colorMessageMediaContainerBackground,
102
+ required this .colorPollNames,
103
+ required this .colorPollVoteCountBackground,
104
+ required this .colorPollVoteCountBorder,
105
+ required this .colorPollVoteCountText,
93
106
required this .colorThematicBreak,
94
107
required this .textStylePlainParagraph,
95
108
required this .codeBlockTextStyles,
@@ -115,6 +128,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
115
128
final Color colorGlobalTimeBorder;
116
129
final Color colorMathBlockBorder; // TODO(#46) this won't be needed
117
130
final Color colorMessageMediaContainerBackground;
131
+ final Color colorPollNames;
132
+ final Color colorPollVoteCountBackground;
133
+ final Color colorPollVoteCountBorder;
134
+ final Color colorPollVoteCountText;
118
135
final Color colorThematicBreak;
119
136
120
137
/// The complete [TextStyle] we use for plain, unstyled paragraphs.
@@ -166,6 +183,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
166
183
Color ? colorGlobalTimeBorder,
167
184
Color ? colorMathBlockBorder,
168
185
Color ? colorMessageMediaContainerBackground,
186
+ Color ? colorPollNames,
187
+ Color ? colorPollVoteCountBackground,
188
+ Color ? colorPollVoteCountBorder,
189
+ Color ? colorPollVoteCountText,
169
190
Color ? colorThematicBreak,
170
191
TextStyle ? textStylePlainParagraph,
171
192
CodeBlockTextStyles ? codeBlockTextStyles,
@@ -181,6 +202,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
181
202
colorGlobalTimeBorder: colorGlobalTimeBorder ?? this .colorGlobalTimeBorder,
182
203
colorMathBlockBorder: colorMathBlockBorder ?? this .colorMathBlockBorder,
183
204
colorMessageMediaContainerBackground: colorMessageMediaContainerBackground ?? this .colorMessageMediaContainerBackground,
205
+ colorPollNames: colorPollNames ?? this .colorPollNames,
206
+ colorPollVoteCountBackground: colorPollVoteCountBackground ?? this .colorPollVoteCountBackground,
207
+ colorPollVoteCountBorder: colorPollVoteCountBorder ?? this .colorPollVoteCountBorder,
208
+ colorPollVoteCountText: colorPollVoteCountText ?? this .colorPollVoteCountText,
184
209
colorThematicBreak: colorThematicBreak ?? this .colorThematicBreak,
185
210
textStylePlainParagraph: textStylePlainParagraph ?? this .textStylePlainParagraph,
186
211
codeBlockTextStyles: codeBlockTextStyles ?? this .codeBlockTextStyles,
@@ -204,6 +229,10 @@ class ContentTheme extends ThemeExtension<ContentTheme> {
204
229
colorMathBlockBorder: Color .lerp (colorMathBlockBorder, other.colorMathBlockBorder, t)! ,
205
230
colorMessageMediaContainerBackground: Color .lerp (colorMessageMediaContainerBackground, other.colorMessageMediaContainerBackground, t)! ,
206
231
colorThematicBreak: Color .lerp (colorThematicBreak, other.colorThematicBreak, t)! ,
232
+ colorPollNames: Color .lerp (colorPollNames, other.colorPollNames, t)! ,
233
+ colorPollVoteCountBackground: Color .lerp (colorPollVoteCountBackground, other.colorPollVoteCountBackground, t)! ,
234
+ colorPollVoteCountBorder: Color .lerp (colorPollVoteCountBorder, other.colorPollVoteCountBorder, t)! ,
235
+ colorPollVoteCountText: Color .lerp (colorPollVoteCountText, other.colorPollVoteCountText, t)! ,
207
236
textStylePlainParagraph: TextStyle .lerp (textStylePlainParagraph, other.textStylePlainParagraph, t)! ,
208
237
codeBlockTextStyles: CodeBlockTextStyles .lerp (codeBlockTextStyles, other.codeBlockTextStyles, t),
209
238
textStyleError: TextStyle .lerp (textStyleError, other.textStyleError, t)! ,
@@ -222,17 +251,20 @@ const double kBaseFontSize = 17;
222
251
/// This does not include metadata like the sender's name and avatar, the time,
223
252
/// or the message's status as starred or edited.
224
253
class MessageContent extends StatelessWidget {
225
- const MessageContent ({super .key, required this .message, required this . content});
254
+ const MessageContent ({super .key, required this .message, required ZulipMessageContent content}) : _content = content ;
226
255
227
256
final Message message;
228
- final ZulipContent content ;
257
+ final ZulipMessageContent _content ;
229
258
230
259
@override
231
260
Widget build (BuildContext context) {
232
261
return InheritedMessage (message: message,
233
262
child: DefaultTextStyle (
234
263
style: ContentTheme .of (context).textStylePlainParagraph,
235
- child: BlockContentList (nodes: content.nodes)));
264
+ child: switch (_content) {
265
+ ZulipContent () => BlockContentList (nodes: _content.nodes),
266
+ PollContent () => PollWidget (poll: message.poll! ),
267
+ }));
236
268
}
237
269
}
238
270
0 commit comments