Skip to content

Commit de19a89

Browse files
committed
feat:增加颜色切换 优化内容页体验
1 parent 1121e35 commit de19a89

File tree

7 files changed

+202
-16
lines changed

7 files changed

+202
-16
lines changed

lib/components/widgetComp.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,16 @@ class IndexState extends State<Index> {
8888
/* title: Header.Index(
8989
this.title,
9090
), */
91+
elevation: 0,
92+
backgroundColor: Color(AppTheme.secondColor),
9193
actions: this.getActions(
9294
context,
9395
),
96+
leading: IconButton(
97+
icon: Icon(Icons.arrow_back),
98+
color: Color(AppTheme.blackColor),
99+
onPressed: () => Navigator.pop(context),
100+
),
94101
),
95102
body: this.loading ? this.renderLoading() : this.renderWidget(),
96103
);
@@ -127,6 +134,7 @@ class IndexState extends State<Index> {
127134
getActions(context) {
128135
return [
129136
IconButton(
137+
color: Color(AppTheme.blackColor),
130138
icon: Icon(
131139
Icons.insert_link,
132140
),
@@ -137,16 +145,17 @@ class IndexState extends State<Index> {
137145
);
138146
},
139147
),
140-
IconButton(
148+
/* IconButton(
141149
icon: Icon(
142150
Icons.code,
143151
),
144152
onPressed: () async {
145153
this.openPage(context);
146154
},
147-
),
155+
), */
148156
IconButton(
149157
icon: Icon(Icons.share),
158+
color: Color(AppTheme.blackColor),
150159
onPressed: () {
151160
final String msg =
152161
this.model.config.state.env.githubAssetOrigin + this.mdUrl;

lib/config/theme.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
import 'package:flutter/material.dart';
22

3+
/**
4+
* yello #FFEB3B
5+
* red #F44336
6+
* blue #2196F3
7+
*/
8+
39
class AppTheme {
4-
static int mainColor = 0xFFD32F2F;
10+
static int yellow = 0xFFFFEB3B;
11+
static int orange = 0xFFFF9800;
12+
static int amber = 0xFFFFC107;
13+
static int lime = 0xFFCDDC39;
14+
static int lightGreen = 0xFF8BC34A;
15+
static int red = 0xFFF44336;
16+
static int deepOrange = 0xFFFF5722;
17+
static int blue = 0xFF2196F3;
18+
static int pink = 0xFFE91E63;
19+
//static int mainColor = 0xFFD32F2F;
20+
static int mainColor = red;
521
static int secondColor = 0xFFFFFFFF;
622
static int thirdColor = 0xFFFAFAFA;
723
static int greyColor = 0x8A000000;

lib/page/component/tabs.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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;
8+
// import 'package:efox_flutter/components/headerComp.dart' as Header;
99

1010
class Index extends StatefulWidget {
1111
final MainStateModel model;

lib/page/home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:efox_flutter/controller/index.dart' as Controller;
66
//import 'component/index.dart' as TabIndex;
77
// import 'mine/index.dart' as MyIndex;
88
import 'component/tabs.dart' as TabIndex;
9-
import 'mine/index_1.dart' as MyIndex;
9+
import 'mine/index_2.dart' as MyIndex;
1010

1111
class Index extends StatefulWidget {
1212
@override

lib/page/mine/index_1.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class _IndexState extends State<Index> {
6767
child: Wrap(
6868
children: <Widget>[
6969
ListTile(
70-
leading: Icon(Icons.label_outline),
70+
//leading: Icon(Icons.label_outline),
7171
title: Text(
7272
AppLocalizations.$t('common_mine_1.cn'),
7373
),
@@ -77,7 +77,7 @@ class _IndexState extends State<Index> {
7777
},
7878
),
7979
ListTile(
80-
leading: Icon(Icons.label_outline),
80+
//leading: Icon(Icons.label_outline),
8181
title: Text(AppLocalizations.$t('common_mine_1.en')),
8282
onTap: () {
8383
AppLocalizations.changeLanguage(Locale('en'));
@@ -102,7 +102,7 @@ class _IndexState extends State<Index> {
102102
child: Wrap(
103103
children: <Widget>[
104104
ListTile(
105-
leading: Icon(Icons.label_outline),
105+
//leading: Icon(Icons.label_outline),
106106
title: Text(
107107
AppLocalizations.$t('mine.loadNetwork'),
108108
),
@@ -112,7 +112,7 @@ class _IndexState extends State<Index> {
112112
},
113113
),
114114
ListTile(
115-
leading: Icon(Icons.label_outline),
115+
//leading: Icon(Icons.label_outline),
116116
title: Text(AppLocalizations.$t('mine.loadLocal')),
117117
onTap: () {
118118
widget.model.dispatch('config', 'setEnv', false);
@@ -159,13 +159,16 @@ class _IndexState extends State<Index> {
159159
),
160160
opacity: 1,
161161
),
162-
SizedBox(height: 10,),
163-
Text("Flutter-UI",
164-
style: TextStyle(
165-
color: Colors.white,
166-
fontSize: 26,
167-
fontWeight: FontWeight.bold
168-
),)
162+
SizedBox(
163+
height: 10,
164+
),
165+
Text(
166+
"Flutter-UI",
167+
style: TextStyle(
168+
color: Colors.white,
169+
fontSize: 26,
170+
fontWeight: FontWeight.bold),
171+
)
169172
],
170173
),
171174
)

lib/page/mine/index_2.dart

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
}
21+
22+
actionsEvent(int index) {
23+
print('index $index');
24+
switch (index) {
25+
case 0:
26+
this.openLanguageSelectMenu();
27+
break;
28+
}
29+
}
30+
31+
void pop([message]) {
32+
Navigator.pop(context);
33+
if (message != null) {
34+
Scaffold.of(context).showSnackBar(new SnackBar(
35+
content: new Text(message),
36+
));
37+
}
38+
}
39+
40+
/**
41+
* 国际化
42+
*/
43+
void openLanguageSelectMenu() async {
44+
await showModalBottomSheet(
45+
context: context,
46+
builder: (BuildContext bc) {
47+
return Container(
48+
child: Wrap(
49+
children: <Widget>[
50+
ListTile(
51+
//leading: Icon(Icons.label_outline),
52+
title: Text(
53+
AppLocalizations.$t('common_mine_1.cn'),
54+
),
55+
onTap: () {
56+
AppLocalizations.changeLanguage(Locale('zh'));
57+
this.pop(AppLocalizations.$t('common_mine_1.success'));
58+
},
59+
),
60+
ListTile(
61+
//leading: Icon(Icons.label_outline),
62+
title: Text(AppLocalizations.$t('common_mine_1.en')),
63+
onTap: () {
64+
AppLocalizations.changeLanguage(Locale('en'));
65+
this.pop(AppLocalizations.$t('common_mine_1.success'));
66+
},
67+
),
68+
],
69+
),
70+
);
71+
},
72+
);
73+
}
74+
75+
@override
76+
Widget build(BuildContext context) {
77+
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(
104+
color: Color(AppTheme.lineColor),
105+
);
106+
}
107+
},
108+
),
109+
);
110+
}
111+
}
112+
113+
class Index extends StatefulWidget {
114+
final dynamic model;
115+
116+
Index({Key key, this.model}) : super(key: key);
117+
118+
@override
119+
_IndexState createState() => _IndexState();
120+
}

lib/utils/github.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* import 'dart:io';
2+
import 'package:dio/dio.dart';
3+
4+
5+
Dio _dio([Options options]) {
6+
Dio dio = new Dio(BaseOptions(
7+
baseUrl: 'https://api.github.com/graphql',
8+
contentType: ContentType.parse('application/json;charset=UTF-8'),
9+
connectTimeout: 30 * 1000,
10+
receiveTimeout: 30 * 1000,
11+
)); // with default Options
12+
dio.interceptors.add(LogInterceptor(responseBody: true)); // debug
13+
dio.interceptors
14+
.add(InterceptorsWrapper(onRequest: (RequestOptions options) async {
15+
options.headers["Authorization"] = 'Bearer $token';
16+
return options;
17+
}, onResponse: (Response response) {
18+
return response;
19+
}, onError: (DioError e) {
20+
return e;
21+
})); //debug
22+
return dio;
23+
}
24+
25+
Future fetch(String query) async {
26+
Map map = {'query': query};
27+
return _dio().post('', data: map);
28+
}
29+
30+
31+
github.fetch('''
32+
query {
33+
viewer{
34+
login
35+
}
36+
}
37+
''');
38+
*/

0 commit comments

Comments
 (0)