Skip to content

Commit bcbd230

Browse files
committed
feat:多主题支持
1 parent 204dfe5 commit bcbd230

File tree

3 files changed

+55
-52
lines changed

3 files changed

+55
-52
lines changed

lib/page/mine/index_2.dart

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ class _IndexState extends State<Index> {
99
super.initState();
1010
}
1111

12-
List<dynamic> _getList() {
13-
return [
14-
{
15-
'name': AppLocalizations.$t('common_mine_1.language'),
16-
'icon': 59540, // language
17-
'index': 0
18-
},
19-
];
20-
}
21-
22-
actionsEvent(int index) {
23-
print('index $index');
24-
switch (index) {
25-
case 0:
26-
this.openLanguageSelectMenu();
27-
break;
28-
}
29-
}
30-
3112
void pop([message]) {
3213
Navigator.pop(context);
3314
if (message != null) {
@@ -75,36 +56,56 @@ class _IndexState extends State<Index> {
7556
@override
7657
Widget build(BuildContext context) {
7758
return Scaffold(
78-
appBar: AppBar(
79-
elevation: 0,
80-
centerTitle: true,
81-
title: Text(AppLocalizations.$t('nav_title_1'))),
82-
body: ListView.builder(
83-
shrinkWrap: true,
84-
itemCount: _getList().length * 2,
85-
itemBuilder: (context, index) {
86-
double _index = index / 2;
87-
if (index % 2 == 0) {
88-
dynamic item = _getList()[_index.toInt()];
89-
return ListTile(
90-
onTap: () {
91-
actionsEvent(item['index']);
92-
},
93-
leading: Icon(
94-
IconData(
95-
item['icon'],
96-
fontFamily: 'MaterialIcons',
97-
matchTextDirection: true,
98-
),
99-
),
100-
title: Text(item['name']),
101-
);
102-
} else {
103-
return Divider(
59+
appBar: AppBar(
60+
elevation: 0,
61+
centerTitle: true,
62+
title: Text(AppLocalizations.$t('nav_title_1'))),
63+
body: ListView(
64+
children: <Widget>[
65+
ListTile(
66+
onTap: () => this.openLanguageSelectMenu(),
67+
leading: Icon(Icons.language),
68+
title: Text(AppLocalizations.$t('common_mine_1.language')),
69+
trailing: Container(
70+
child: Row(
71+
mainAxisSize: MainAxisSize.min,
72+
children: <Widget>[
73+
Text(AppLocalizations.languageCode),
74+
Icon(Icons.navigate_next)
75+
],
76+
),
77+
)),
78+
Divider(
10479
color: Color(AppTheme.lineColor),
105-
);
106-
}
107-
},
80+
),
81+
ExpansionTile(
82+
title: Text(AppLocalizations.$t('common_mine_1.theme')),
83+
children: <Widget>[
84+
Wrap(
85+
//crossAxisAlignment: WrapCrossAlignment.start,
86+
alignment: WrapAlignment.spaceEvenly,
87+
runAlignment: WrapAlignment.spaceEvenly,
88+
children: <Widget>[
89+
this.Edage(AppTheme.yellow),
90+
this.Edage(AppTheme.blue),
91+
this.Edage(AppTheme.orange),
92+
this.Edage(AppTheme.lightGreen),
93+
this.Edage(AppTheme.red),
94+
],
95+
)
96+
],
97+
)
98+
],
99+
));
100+
}
101+
102+
Widget Edage(color) {
103+
return GestureDetector(
104+
onTap: () {},
105+
child: Container(
106+
color: Color(color),
107+
height: 30,
108+
width: 30,
108109
),
109110
);
110111
}

locale/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
"changeVersion": "checkVersion",
1212
"compProgress": "Components Progress"
1313
},
14-
"common_mine_1" : {
14+
"common_mine_1": {
1515
"cn": "CN",
1616
"en": "EN",
1717
"language": "Select Language",
1818
"environment": "Select Environment",
1919
"compProgress": "Components Progress",
20-
"success": "Success To Change "
20+
"success": "Success To Change ",
21+
"theme": "Select Theme"
2122
},
2223
"mine": {
2324
"loadNetwork": "Load Network Document Resources",

locale/zh.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
"changeVersion": "更新版本",
1212
"compProgress": "组件进度"
1313
},
14-
"common_mine_1" : {
14+
"common_mine_1": {
1515
"cn": "中文",
1616
"en": "英文",
1717
"language": "选择语言",
1818
"environment": "选择环境",
1919
"compProgress": "组件进度",
20-
"success": "切换成功"
20+
"success": "切换成功",
21+
"theme": "选择主题"
2122
},
2223
"mine": {
2324
"loadNetwork": "网络优良,可选择加载线上文档资源",

0 commit comments

Comments
 (0)