1
1
import 'package:flutter/material.dart' ;
2
- import 'package:flutter_ui_cinemax/src/model/banner_movie.dart' ;
2
+ import 'package:flutter_ui_cinemax/res/color_app.dart' ;
3
+ import 'package:flutter_ui_cinemax/src/model/banner/banner_movie.dart' ;
4
+ import 'package:flutter_ui_cinemax/src/model/category/category.dart' ;
3
5
4
6
class HomeScreen extends StatefulWidget {
5
7
@override
@@ -21,6 +23,8 @@ class _HomeScreenState extends State<HomeScreen> {
21
23
_buildWidgetAppBar (),
22
24
SizedBox (height: 20.0 ),
23
25
_buildWidgetBanner (mediaQuery),
26
+ SizedBox (height: 20.0 ),
27
+ _buildWidgetCategories (mediaQuery),
24
28
],
25
29
),
26
30
),
@@ -136,4 +140,75 @@ class _HomeScreenState extends State<HomeScreen> {
136
140
),
137
141
);
138
142
}
143
+
144
+ Widget _buildWidgetCategories (MediaQueryData mediaQuery) {
145
+ var listCategories = [
146
+ Category (
147
+ title: 'Top Rated' ,
148
+ backdropPath: 'assets/images/top_rated_backdrop_path.jpeg' ),
149
+ Category (
150
+ title: 'Upcoming' ,
151
+ backdropPath: 'assets/images/upcoming_backdrop_path.jpeg' ),
152
+ Category (
153
+ title: 'Now Playing' ,
154
+ backdropPath: 'assets/images/now_playing_backdrop_path.jpeg' ),
155
+ Category (
156
+ title: 'Popular' ,
157
+ backdropPath: 'assets/images/popular_backdrop_path.jpeg' ),
158
+ ];
159
+ return Container (
160
+ width: mediaQuery.size.width,
161
+ height: 60.0 ,
162
+ child: ListView .builder (
163
+ scrollDirection: Axis .horizontal,
164
+ itemBuilder: (BuildContext context, int index) {
165
+ var category = listCategories[index];
166
+ return Padding (
167
+ padding: EdgeInsets .only (
168
+ left: 16.0 ,
169
+ right: index == listCategories.length - 1 ? 16.0 : 0.0 ,
170
+ ),
171
+ child: Container (
172
+ width: 200.0 ,
173
+ decoration: BoxDecoration (
174
+ borderRadius: BorderRadius .circular (4.0 ),
175
+ image: DecorationImage (
176
+ image: AssetImage (
177
+ category.backdropPath,
178
+ ),
179
+ fit: BoxFit .cover,
180
+ ),
181
+ ),
182
+ child: Stack (
183
+ children: < Widget > [
184
+ Opacity (
185
+ opacity: 0.8 ,
186
+ child: Container (
187
+ decoration: BoxDecoration (
188
+ borderRadius: BorderRadius .circular (4.0 ),
189
+ color: ColorApp .primaryDarkColor,
190
+ ),
191
+ ),
192
+ ),
193
+ Align (
194
+ alignment: Alignment .center,
195
+ child: Text (
196
+ category.title.toUpperCase (),
197
+ style: Theme .of (context).textTheme.body1.merge (
198
+ TextStyle (
199
+ color: Colors .white,
200
+ fontWeight: FontWeight .bold,
201
+ ),
202
+ ),
203
+ ),
204
+ ),
205
+ ],
206
+ ),
207
+ ),
208
+ );
209
+ },
210
+ itemCount: listCategories.length,
211
+ ),
212
+ );
213
+ }
139
214
}
0 commit comments