Skip to content

Commit 0e53181

Browse files
committed
feat:优化tab‘
1 parent 81d1cd2 commit 0e53181

File tree

6 files changed

+227
-5
lines changed

6 files changed

+227
-5
lines changed

lib/page/component/tabs.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:efox_flutter/config/theme.dart' show AppTheme;
55
import 'package:efox_flutter/widget/index.dart' as WidgetRoot;
66
import 'package:efox_flutter/router/index.dart' show FluroRouter;
77
import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
8-
import 'package:efox_flutter/components/headerComp.dart' as Header;
98

109
class Index extends StatefulWidget {
1110
final MainStateModel model;

lib/page/home.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import 'package:efox_flutter/store/index.dart' show Store;
44
import 'package:efox_flutter/controller/index.dart' as Controller;
55

66
//import 'component/index.dart' as TabIndex;
7+
// import 'mine/index.dart' as MyIndex;
78
import 'component/tabs.dart' as TabIndex;
8-
import 'mine/index.dart' as MyIndex;
9+
import 'mine/index_1.dart' as MyIndex;
910

1011
class Index extends StatefulWidget {
1112
@override

lib/page/mine/index_1.dart

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/lang/index.dart' show AppLocalizations;
3+
import 'package:efox_flutter/router/index.dart' show FluroRouter;
4+
import 'package:efox_flutter/config/theme.dart' show AppTheme;
5+
6+
class _IndexState extends State<Index> {
7+
@override
8+
void initState() {
9+
super.initState();
10+
}
11+
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+
'name': AppLocalizations.$t('common_mine_1.environment'),
21+
'icon': 57539, // import_export
22+
'index': 1,
23+
},
24+
{
25+
'name': AppLocalizations.$t('common_mine_1.compProgress'),
26+
'icon': 57709, // low_priority
27+
'index': 2
28+
}
29+
];
30+
}
31+
32+
actionsEvent(int index) {
33+
print('index $index');
34+
switch (index) {
35+
case 0:
36+
this.openLanguageSelectMenu();
37+
break;
38+
case 1:
39+
this.openEnvSelectMenu();
40+
break;
41+
case 2:
42+
FluroRouter.router.navigateTo(
43+
context,
44+
'/webview?url=${Uri.encodeComponent(widget.model.config.state.env.githubWeb)}&title=${Uri.encodeComponent(AppLocalizations.$t('common.compProgress'))}',
45+
);
46+
break;
47+
}
48+
}
49+
50+
void pop([message]) {
51+
Navigator.pop(context);
52+
if (message != null) {
53+
Scaffold.of(context).showSnackBar(new SnackBar(
54+
content: new Text(message),
55+
));
56+
}
57+
}
58+
59+
/**
60+
* 国际化
61+
*/
62+
void openLanguageSelectMenu() async {
63+
await showModalBottomSheet(
64+
context: context,
65+
builder: (BuildContext bc) {
66+
return Container(
67+
child: Wrap(
68+
children: <Widget>[
69+
ListTile(
70+
leading: Icon(Icons.label_outline),
71+
title: Text(
72+
AppLocalizations.$t('common_mine_1.cn'),
73+
),
74+
onTap: () {
75+
AppLocalizations.changeLanguage(Locale('zh'));
76+
this.pop(AppLocalizations.$t('common_mine_1.success'));
77+
},
78+
),
79+
ListTile(
80+
leading: Icon(Icons.label_outline),
81+
title: Text(AppLocalizations.$t('common_mine_1.en')),
82+
onTap: () {
83+
AppLocalizations.changeLanguage(Locale('en'));
84+
this.pop(AppLocalizations.$t('common_mine_1.success'));
85+
},
86+
),
87+
],
88+
),
89+
);
90+
},
91+
);
92+
}
93+
94+
/**
95+
* 环境选择
96+
*/
97+
void openEnvSelectMenu() async {
98+
await showModalBottomSheet(
99+
context: context,
100+
builder: (BuildContext bc) {
101+
return Container(
102+
child: Wrap(
103+
children: <Widget>[
104+
ListTile(
105+
leading: Icon(Icons.label_outline),
106+
title: Text(
107+
AppLocalizations.$t('mine.loadNetwork'),
108+
),
109+
onTap: () {
110+
widget.model.dispatch('config', 'setEnv', true);
111+
this.pop(AppLocalizations.$t('common_mine_1.success'));
112+
},
113+
),
114+
ListTile(
115+
leading: Icon(Icons.label_outline),
116+
title: Text(AppLocalizations.$t('mine.loadLocal')),
117+
onTap: () {
118+
widget.model.dispatch('config', 'setEnv', false);
119+
this.pop(AppLocalizations.$t('common_mine_1.success'));
120+
},
121+
),
122+
],
123+
),
124+
);
125+
},
126+
);
127+
}
128+
129+
@override
130+
Widget build(BuildContext context) {
131+
return SingleChildScrollView(
132+
child: Column(
133+
children: <Widget>[
134+
Container(
135+
decoration: BoxDecoration(
136+
borderRadius: BorderRadius.only(
137+
bottomLeft: Radius.circular(10),
138+
bottomRight: Radius.circular(10)
139+
),
140+
color: Colors.red,
141+
),
142+
height: 240,
143+
child: Stack(
144+
alignment: const FractionalOffset(0.8, 0.8),
145+
children: <Widget>[
146+
Row(
147+
children: <Widget>[
148+
Image.network(
149+
'https://raw.githubusercontent.com/efoxTeam/flutter-ui/master/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png',
150+
width: 80.0,
151+
height: 80.0,
152+
fit: BoxFit.cover,
153+
),
154+
SizedBox(
155+
width: 10,
156+
),
157+
Text(
158+
'Hello Guest',
159+
style: TextStyle(color: Colors.white),
160+
)
161+
],
162+
)
163+
],
164+
),
165+
),
166+
ListView.builder(
167+
shrinkWrap: true,
168+
itemCount: _getList().length * 2,
169+
itemBuilder: (context, index) {
170+
double _index = index / 2;
171+
if (index % 2 == 0) {
172+
dynamic item = _getList()[_index.toInt()];
173+
return ListTile(
174+
onTap: () {
175+
actionsEvent(item['index']);
176+
},
177+
leading: Icon(
178+
IconData(
179+
item['icon'],
180+
fontFamily: 'MaterialIcons',
181+
matchTextDirection: true,
182+
),
183+
),
184+
title: Text(item['name']),
185+
);
186+
} else {
187+
return Divider(
188+
color: Color(AppTheme.lineColor),
189+
);
190+
}
191+
},
192+
),
193+
],
194+
),
195+
);
196+
}
197+
}
198+
199+
class Index extends StatefulWidget {
200+
final dynamic model;
201+
202+
Index({Key key, this.model}) : super(key: key);
203+
204+
@override
205+
_IndexState createState() => _IndexState();
206+
}

lib/store/models/config_state_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ConfigModel {
3232

3333
switch (name) {
3434
case 'setEnv':
35-
_appConfigInfo.isPro = !_appConfigInfo.isPro;
35+
_appConfigInfo.isPro = payload;
3636
break;
3737
case 'setVersion':
3838
_appConfigInfo.version = await this.getVersion();

locale/en.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
"changeVersion": "checkVersion",
1212
"compProgress": "Components Progress"
1313
},
14+
"common_mine_1" : {
15+
"cn": "CN",
16+
"en": "EN",
17+
"language": "Select Language",
18+
"environment": "Select Environment",
19+
"compProgress": "Components Progress",
20+
"success": "Success To Change "
21+
},
1422
"mine": {
1523
"loadNetwork": "Load Network Document Resources",
1624
"loadLocal": "Load Local Document Resources"

locale/zh.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111
"changeVersion": "更新版本",
1212
"compProgress": "组件进度"
1313
},
14+
"common_mine_1" : {
15+
"cn": "CN",
16+
"en": "EN",
17+
"language": "选择语言",
18+
"environment": "选择环境",
19+
"compProgress": "组件进度",
20+
"success": "切换成功"
21+
},
1422
"mine": {
15-
"loadNetwork": "加载网络文档资源",
16-
"loadLocal": "加载本地文档资源"
23+
"loadNetwork": "网络优良,可选择加载线上文档资源",
24+
"loadLocal": "网络较差时,可选择加载本地文档资源"
1725
},
1826
"loading": "加载中"
1927
}

0 commit comments

Comments
 (0)