theme_model.dart
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import 'package:flutter/material.dart';
class ThemeModel {
String? colorName;
String? colorValueS; //渐变色起始值
String? colorValueM; //渐变色中间值
String? colorValueE; //渐变色结束值
String? liteClass; //小程序classname
String? url; //当前配色对应的图片
ThemeModel();
ThemeModel.fromJson(Map<String, dynamic> json) {
colorName = json['color_name'];
colorValueS = json['color_value_s'];
colorValueM = json['color_value_m'];
colorValueE = json['color_value_e'];
liteClass = json['lite_class'];
url = json['url'];
}
Map<String, dynamic> toJson() => <String, dynamic>{
"color_name": colorName,
"color_value_s": colorValueS,
"color_value_m": colorValueM,
"color_value_e": colorValueE,
'lite_class': liteClass,
'url': url
};
}
class ThemeSunModel {
String? name; //模版名称
String? id; //模版编号
String? url; //模版示意图
List<ThemeModel>? colors; //当前模版的可用色值
String? themeColorDefault; //模版默认主题色
ThemeSunModel();
ThemeSunModel.fromJson(Map<String, dynamic> json) {
name = json["name"];
id = json["id"];
url = json['url'];
colors = <ThemeModel>[];
if (json['colors'] != null) {
json['colors'].forEach((v) {
if (v is ThemeModel) {
colors!.add(v);
} else {
colors!.add(new ThemeModel.fromJson(v));
}
});
}
if (colors!.length > 0) {
themeColorDefault = colors![0].colorName;
}
}
Map<String, dynamic> toJson() =>
<String, dynamic>{"name": name, "id": id, "colors": colors, 'url': url};
}