1
- import 'dart:io' show Platform;
2
-
3
1
import 'package:flutter/cupertino.dart' ;
4
2
import 'package:flutter/material.dart' ;
5
3
import 'package:food_recipe/src/blocs/home_bloc.dart' ;
6
4
import 'package:food_recipe/src/models/categories/categories.dart' ;
7
5
import 'package:food_recipe/src/models/latest/latest_meals.dart' ;
6
+ import 'package:food_recipe/src/utils/utils.dart' ;
8
7
import 'package:food_recipe/values/color_assets.dart' ;
9
8
10
9
class HomeScreen extends StatefulWidget {
@@ -13,8 +12,6 @@ class HomeScreen extends StatefulWidget {
13
12
}
14
13
15
14
class _HomeScreenState extends State <HomeScreen > {
16
- String result = "-" ;
17
-
18
15
@override
19
16
void dispose () {
20
17
homeBloc.dispose ();
@@ -26,7 +23,11 @@ class _HomeScreenState extends State<HomeScreen> {
26
23
return Stack (
27
24
children: < Widget > [
28
25
_buildWidgetBackground (),
29
- _buildWidgetContent (),
26
+ ListView (
27
+ children: < Widget > [
28
+ _buildWidgetContent (),
29
+ ],
30
+ ),
30
31
],
31
32
);
32
33
}
@@ -35,6 +36,7 @@ class _HomeScreenState extends State<HomeScreen> {
35
36
return Column (
36
37
children: < Widget > [
37
38
Expanded (
39
+ flex: 2 ,
38
40
child: Container (
39
41
color: ColorAssets .primarySwatchColor,
40
42
),
@@ -111,34 +113,41 @@ class _HomeScreenState extends State<HomeScreen> {
111
113
width: 136.0 ,
112
114
child: Padding (
113
115
padding: const EdgeInsets .only (right: 4.0 ),
114
- child: Card (
115
- shape: RoundedRectangleBorder (
116
- borderRadius: BorderRadius .circular (16.0 )),
117
- color: _setColorItemCategory (numberItem),
118
- child: Padding (
119
- padding: const EdgeInsets .symmetric (horizontal: 8.0 , vertical: 12.0 ),
120
- child: Column (
121
- children: < Widget > [
122
- Text (
123
- category.strCategory,
124
- textAlign: TextAlign .center,
125
- style: TextStyle (
126
- color: Colors .white,
116
+ child: GestureDetector (
117
+ onTap: () {
118
+ // TODO: do something in here
119
+ },
120
+ child: Card (
121
+ shape: RoundedRectangleBorder (
122
+ borderRadius: BorderRadius .circular (16.0 )),
123
+ color: _setColorItemCategory (numberItem),
124
+ child: Padding (
125
+ padding: const EdgeInsets .symmetric (
126
+ horizontal: 8.0 , vertical: 12.0 ),
127
+ child: Column (
128
+ children: < Widget > [
129
+ Text (
130
+ category.strCategory,
131
+ textAlign: TextAlign .center,
132
+ style: TextStyle (
133
+ color: Colors .white,
134
+ ),
127
135
),
128
- ),
129
- Padding (padding: const EdgeInsets .only (top: 8.0 )),
130
- Container (
131
- width: 136.0 ,
132
- height: 72.0 ,
133
- child: FadeInImage (
134
- fit: BoxFit .cover,
135
- image: NetworkImage (
136
- category.strCategoryThumb,
136
+ Padding (padding: const EdgeInsets .only (top: 8.0 )),
137
+ Container (
138
+ width: 136.0 ,
139
+ height: 72.0 ,
140
+ child: FadeInImage (
141
+ fit: BoxFit .cover,
142
+ image: NetworkImage (
143
+ category.strCategoryThumb,
144
+ ),
145
+ placeholder: AssetImage (
146
+ "assets/images/img_placeholder.jpg" ),
137
147
),
138
- placeholder: AssetImage ("assets/images/img_placeholder.jpg" ),
139
148
),
140
- ) ,
141
- ] ,
149
+ ] ,
150
+ ) ,
142
151
),
143
152
),
144
153
),
@@ -150,7 +159,7 @@ class _HomeScreenState extends State<HomeScreen> {
150
159
} else if (snapshot.hasError) {
151
160
return Text (snapshot.error.toString ());
152
161
}
153
- return Center (child: _buildCircularProgressIndicator ());
162
+ return Center (child: buildCircularProgressIndicator ());
154
163
},
155
164
);
156
165
}
@@ -162,7 +171,7 @@ class _HomeScreenState extends State<HomeScreen> {
162
171
if (snapshot.hasData) {
163
172
var latestMeals = snapshot.data;
164
173
return Container (
165
- height: 256.0 ,
174
+ height: mediaQuery.size.width / 2 + 64.0 , // 256.0
166
175
child: ListView .builder (
167
176
scrollDirection: Axis .horizontal,
168
177
itemCount: latestMeals.latestMealsItems.length,
@@ -171,6 +180,7 @@ class _HomeScreenState extends State<HomeScreen> {
171
180
return Padding (
172
181
padding: const EdgeInsets .only (right: 8.0 ),
173
182
child: Card (
183
+ elevation: 4.0 ,
174
184
shape: RoundedRectangleBorder (
175
185
borderRadius: BorderRadius .circular (16.0 )),
176
186
child: ClipRRect (
@@ -192,7 +202,7 @@ class _HomeScreenState extends State<HomeScreen> {
192
202
fit: BoxFit .cover,
193
203
),
194
204
width: mediaQuery.size.width - 96.0 ,
195
- height: 192.0 ,
205
+ height: mediaQuery.size.width / 2 , // 192.0
196
206
),
197
207
Padding (
198
208
padding: const EdgeInsets .all (8.0 ),
@@ -214,7 +224,7 @@ class _HomeScreenState extends State<HomeScreen> {
214
224
return Container (
215
225
height: 128.0 ,
216
226
child: Center (
217
- child: _buildCircularProgressIndicator (),
227
+ child: buildCircularProgressIndicator (),
218
228
),
219
229
);
220
230
},
@@ -257,14 +267,6 @@ class _HomeScreenState extends State<HomeScreen> {
257
267
);
258
268
}
259
269
260
- Widget _buildCircularProgressIndicator () {
261
- if (Platform .isIOS) {
262
- return CupertinoActivityIndicator ();
263
- } else {
264
- return CircularProgressIndicator ();
265
- }
266
- }
267
-
268
270
Color _setColorItemCategory (int number) {
269
271
if (number == 1 ) {
270
272
return ColorAssets .accentColor;
0 commit comments