@@ -9,18 +9,32 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
9
9
declarations.forEach ((property, value) {
10
10
switch (property) {
11
11
case 'background-color' :
12
- style.backgroundColor =
13
- ExpressionMapping .expressionToColor (value.first);
12
+ style.backgroundColor = ExpressionMapping .expressionToColor (value.first);
14
13
break ;
15
14
case 'color' :
16
15
style.color = ExpressionMapping .expressionToColor (value.first);
17
16
break ;
18
- case 'text-align' :
19
- style.textAlign = ExpressionMapping .expressionToTextAlign (value.first);
17
+ case 'direction' :
18
+ style.direction = ExpressionMapping .expressionToDirection (value.first);
19
+ break ;
20
+ case 'display' :
21
+ style.display = ExpressionMapping .expressionToDisplay (value.first);
22
+ break ;
23
+ case 'font-family' :
24
+ style.fontFamily = ExpressionMapping .expressionToFontFamily (value.first);
20
25
break ;
21
26
case 'font-size' :
22
27
style.fontSize = ExpressionMapping .expressionToFontSize (value.first);
23
28
break ;
29
+ case 'font-style' :
30
+ style.fontStyle = ExpressionMapping .expressionToFontStyle (value.first);
31
+ break ;
32
+ case 'font-weight' :
33
+ style.fontWeight = ExpressionMapping .expressionToFontWeight (value.first);
34
+ break ;
35
+ case 'text-align' :
36
+ style.textAlign = ExpressionMapping .expressionToTextAlign (value.first);
37
+ break ;
24
38
}
25
39
});
26
40
return style;
@@ -72,6 +86,36 @@ class ExpressionMapping {
72
86
return null ;
73
87
}
74
88
89
+ static TextDirection expressionToDirection (css.Expression value) {
90
+ if (value is css.LiteralTerm ) {
91
+ switch (value.text) {
92
+ case "ltr" :
93
+ return TextDirection .ltr;
94
+ case "rtl" :
95
+ return TextDirection .rtl;
96
+ }
97
+ }
98
+ return TextDirection .ltr;
99
+ }
100
+
101
+ static Display expressionToDisplay (css.Expression value) {
102
+ if (value is css.LiteralTerm ) {
103
+ switch (value.text) {
104
+ case 'block' :
105
+ return Display .BLOCK ;
106
+ case 'inline-block' :
107
+ return Display .INLINE_BLOCK ;
108
+ case 'inline' :
109
+ return Display .INLINE ;
110
+ case 'list-item' :
111
+ return Display .LIST_ITEM ;
112
+ case 'none' :
113
+ return Display .NONE ;
114
+ }
115
+ }
116
+ return Display .INLINE ;
117
+ }
118
+
75
119
static FontSize expressionToFontSize (css.Expression value) {
76
120
if (value is css.NumberTerm ) {
77
121
return FontSize (double .tryParse (value.text), "" );
@@ -103,6 +147,59 @@ class ExpressionMapping {
103
147
return null ;
104
148
}
105
149
150
+ static FontStyle expressionToFontStyle (css.Expression value) {
151
+ if (value is css.LiteralTerm ) {
152
+ switch (value.text) {
153
+ case "italic" :
154
+ case "oblique" :
155
+ return FontStyle .italic;
156
+ }
157
+ return FontStyle .normal;
158
+ }
159
+ return FontStyle .normal;
160
+ }
161
+
162
+ static FontWeight expressionToFontWeight (css.Expression value) {
163
+ if (value is css.NumberTerm ) {
164
+ switch (value.text) {
165
+ case "100" :
166
+ return FontWeight .w100;
167
+ case "200" :
168
+ return FontWeight .w200;
169
+ case "300" :
170
+ return FontWeight .w300;
171
+ case "400" :
172
+ return FontWeight .w400;
173
+ case "500" :
174
+ return FontWeight .w500;
175
+ case "600" :
176
+ return FontWeight .w600;
177
+ case "700" :
178
+ return FontWeight .w700;
179
+ case "800" :
180
+ return FontWeight .w800;
181
+ case "900" :
182
+ return FontWeight .w900;
183
+ }
184
+ } else if (value is css.LiteralTerm ) {
185
+ switch (value.text) {
186
+ case "bold" :
187
+ return FontWeight .bold;
188
+ case "bolder" :
189
+ return FontWeight .w900;
190
+ case "lighter" :
191
+ return FontWeight .w200;
192
+ }
193
+ return FontWeight .normal;
194
+ }
195
+ return FontWeight .normal;
196
+ }
197
+
198
+ static String expressionToFontFamily (css.Expression value) {
199
+ if (value is css.LiteralTerm ) return value.text;
200
+ return null ;
201
+ }
202
+
106
203
static Color stringToColor (String _text) {
107
204
var text = _text.replaceFirst ('#' , '' );
108
205
if (text.length == 3 )
0 commit comments