@@ -12,13 +12,15 @@ import 'package:flutter_ui_nice/const/size_const.dart';
12
12
import 'package:flutter_ui_nice/const/images_const.dart' ;
13
13
import 'package:flutter_ui_nice/const/color_const.dart' ;
14
14
import 'package:flutter_ui_nice/util/SizeUtil.dart' ;
15
+ import 'package:flutter_ui_nice/util/GradientUtil.dart' ;
15
16
16
17
class HomePage extends StatelessWidget {
17
18
final _scaffoldState = GlobalKey <ScaffoldState >();
18
19
19
20
Widget _topBar () => SliverAppBar (
20
21
elevation: 1.0 ,
21
22
pinned: true ,
23
+ backgroundColor: BLUE ,
22
24
expandedHeight: 150.0 ,
23
25
flexibleSpace: FlexibleSpaceBar (
24
26
title: Padding (
@@ -33,10 +35,10 @@ class HomePage extends StatelessWidget {
33
35
SizedBox (
34
36
width: 6.0 ,
35
37
),
36
- Text (
37
- StringConst . APP_NAME ,
38
- style : TextStyle ( color: Colors .white) ,
39
- )
38
+ Text (StringConst . APP_NAME ,
39
+ style : TextStyle (
40
+ color: TEXT_BLACK_LIGHT ,
41
+ ) )
40
42
],
41
43
),
42
44
),
@@ -56,12 +58,8 @@ class HomePage extends StatelessWidget {
56
58
return InkWell (
57
59
child: Container (
58
60
padding: EdgeInsets .symmetric (horizontal: 20.0 ),
59
- decoration: BoxDecoration (boxShadow: [
60
- BoxShadow (
61
- color: Colors .grey[800 ],
62
- offset: Offset (0.0 , 2.0 ),
63
- )
64
- ]),
61
+ margin: EdgeInsets .only (bottom: 1.0 ),
62
+ decoration: BoxDecoration (gradient: GradientUtil .greenPurple ()),
65
63
constraints: BoxConstraints .expand (height: 60.0 ),
66
64
child: Column (
67
65
crossAxisAlignment: CrossAxisAlignment .start,
@@ -70,7 +68,7 @@ class HomePage extends StatelessWidget {
70
68
Text (
71
69
item,
72
70
style: TextStyle (
73
- color: Colors .white ,
71
+ color: TEXT_BLACK_LIGHT ,
74
72
fontSize: TEXT_NORMAL_SIZE ,
75
73
fontWeight: FontWeight .w700),
76
74
),
@@ -83,7 +81,7 @@ class HomePage extends StatelessWidget {
83
81
),
84
82
),
85
83
onTap: () {
86
- Navigator .pop (context);
84
+ // Navigator.pop(context);
87
85
Navigator .pushNamed (context, "$item " );
88
86
},
89
87
);
@@ -103,10 +101,7 @@ class HomePage extends StatelessWidget {
103
101
child: Container (
104
102
padding: EdgeInsets .symmetric (horizontal: 20.0 , vertical: 4.0 ),
105
103
decoration: BoxDecoration (
106
- gradient: LinearGradient (colors: [
107
- PURPLE ,
108
- Colors .grey[900 ],
109
- ]),
104
+ gradient: GradientUtil .yellowGreen (),
110
105
),
111
106
constraints: BoxConstraints .expand (height: 80.0 ),
112
107
child: Center (
@@ -121,8 +116,8 @@ class HomePage extends StatelessWidget {
121
116
),
122
117
Text (
123
118
StringConst .CREATE_BY ,
124
- style:
125
- TextStyle ( color: Colors .white , fontSize: TEXT_NORMAL_SIZE ),
119
+ style: TextStyle (
120
+ color: TEXT_BLACK_LIGHT , fontSize: TEXT_NORMAL_SIZE ),
126
121
),
127
122
],
128
123
),
@@ -135,18 +130,22 @@ class HomePage extends StatelessWidget {
135
130
showModalBottomSheet (
136
131
context: context,
137
132
builder: (context) => Material (
138
- color: Colors .white ,
133
+ color: GREEN ,
139
134
clipBehavior: Clip .antiAliasWithSaveLayer,
140
135
shape: RoundedRectangleBorder (
141
- borderRadius: BorderRadius .only (
142
- topLeft: Radius .circular (20.0 ),
143
- topRight: Radius .circular (20.0 ))),
136
+ borderRadius: BorderRadius .only (
137
+ topLeft: Radius .circular (20.0 ),
138
+ topRight: Radius .circular (20.0 ),
139
+ ),
140
+ ),
144
141
child: Column (
145
142
mainAxisAlignment: MainAxisAlignment .spaceAround,
146
143
children: < Widget > [
147
144
_header (),
148
145
Expanded (
149
- child: _menuList (menu),
146
+ child: Container (
147
+ child: _menuList (menu),
148
+ ),
150
149
),
151
150
AboutMeTitle (),
152
151
],
@@ -155,7 +154,41 @@ class HomePage extends StatelessWidget {
155
154
);
156
155
}
157
156
158
- Widget _gridItem (context, Menu menu) => InkWell (
157
+ LinearGradient _itemGradient (index) {
158
+ var gradient = GradientUtil .red (
159
+ begin: AlignmentDirectional .topStart,
160
+ end: AlignmentDirectional .bottomEnd,
161
+ opacity: 0.7 );
162
+ switch (index % 4 ) {
163
+ case 0 :
164
+ gradient = GradientUtil .red (
165
+ begin: AlignmentDirectional .topStart,
166
+ end: AlignmentDirectional .bottomEnd,
167
+ opacity: 0.7 );
168
+ break ;
169
+ case 1 :
170
+ gradient = GradientUtil .greenPurple (
171
+ begin: AlignmentDirectional .topStart,
172
+ end: AlignmentDirectional .bottomEnd,
173
+ opacity: 0.7 );
174
+ break ;
175
+ case 2 :
176
+ gradient = GradientUtil .greenRed (
177
+ begin: AlignmentDirectional .topStart,
178
+ end: AlignmentDirectional .bottomEnd,
179
+ opacity: 0.7 );
180
+ break ;
181
+ case 3 :
182
+ gradient = GradientUtil .yellowBlue (
183
+ begin: AlignmentDirectional .topStart,
184
+ end: AlignmentDirectional .bottomEnd,
185
+ opacity: 0.7 );
186
+ break ;
187
+ }
188
+ return gradient;
189
+ }
190
+
191
+ Widget _gridItem (context, Menu menu, index) => InkWell (
159
192
onTap: () {
160
193
_clickMenu (context, menu);
161
194
},
@@ -168,11 +201,7 @@ class HomePage extends StatelessWidget {
168
201
),
169
202
Container (
170
203
constraints: BoxConstraints .expand (),
171
- decoration: BoxDecoration (
172
- gradient: RadialGradient (
173
- colors: [PURPLE , Colors .grey[850 ].withOpacity (0.9 )],
174
- radius: 0.3 ),
175
- ),
204
+ decoration: BoxDecoration (gradient: _itemGradient (index)),
176
205
),
177
206
Container (
178
207
constraints: BoxConstraints .expand (),
@@ -183,15 +212,18 @@ class HomePage extends StatelessWidget {
183
212
children: < Widget > [
184
213
Icon (
185
214
menu.icon,
186
- color: Colors .white,
215
+ color: TEXT_BLACK_LIGHT ,
216
+ size: 40.0 ,
187
217
),
188
218
SizedBox (
189
219
height: 4.0 ,
190
220
),
191
221
Text (
192
222
menu.title,
193
223
style: TextStyle (
194
- color: Colors .white, fontWeight: FontWeight .w700),
224
+ color: TEXT_BLACK_LIGHT ,
225
+ fontWeight: FontWeight .w700,
226
+ fontSize: 16.0 ),
195
227
)
196
228
],
197
229
),
@@ -205,11 +237,11 @@ class HomePage extends StatelessWidget {
205
237
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount (
206
238
mainAxisSpacing: 4.0 ,
207
239
crossAxisSpacing: 4.0 ,
208
- childAspectRatio: 1.0 ,
240
+ childAspectRatio: 0.8 ,
209
241
crossAxisCount: 2 ),
210
242
delegate: SliverChildBuilderDelegate ((context, index) {
211
243
var menu = list[index];
212
- return _gridItem (context, menu);
244
+ return _gridItem (context, menu, index );
213
245
}, childCount: list.length),
214
246
);
215
247
@@ -242,8 +274,6 @@ class HomePage extends StatelessWidget {
242
274
@override
243
275
Widget build (BuildContext context) {
244
276
SizeUtil .size = MediaQuery .of (context).size;
245
- var size = MediaQuery .of (context).size;
246
- print ("width :${size .width },height:${size .height }" );
247
277
return _showAndroid (context);
248
278
}
249
279
}
0 commit comments