11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_travel_concept/controller/home_controller.dart' ;
23import 'package:flutter_travel_concept/screens/details.dart' ;
34import 'package:flutter_travel_concept/widgets/icon_badge.dart' ;
45import 'package:flutter_travel_concept/util/places.dart' ;
6+ import 'package:provider/provider.dart' ;
57
68class Home extends StatefulWidget {
79 @override
@@ -11,28 +13,37 @@ class Home extends StatefulWidget {
1113class _HomeState extends State <Home > {
1214 final TextEditingController _searchControl = new TextEditingController ();
1315
14-
1516 @override
1617 Widget build (BuildContext context) {
18+ final provider = Provider .of <HomeController >(context);
19+
1720 return Scaffold (
1821 appBar: AppBar (
19- leading: IconButton (
20- icon: Icon (
21- Icons .menu,
22- ),
23- onPressed: (){},
24- ),
25-
2622 actions: < Widget > [
2723 IconButton (
2824 icon: IconBadge (
2925 icon: Icons .notifications_none,
3026 ),
31- onPressed: (){},
27+ onPressed: () {},
3228 ),
3329 ],
3430 ),
35-
31+ drawer: Drawer (
32+ child: Column (
33+ crossAxisAlignment: CrossAxisAlignment .start,
34+ children: < Widget > [
35+ Expanded (
36+ child: Container (),
37+ ),
38+ FlatButton (
39+ child: provider.modeChange ? Text ('Dark mode' ) : Text ('White Mode' ),
40+ onPressed: () {
41+ provider.setModeChange = ! provider.modeChange;
42+ },
43+ ),
44+ ],
45+ ),
46+ ),
3647 body: ListView (
3748 children: < Widget > [
3849 Padding (
@@ -45,8 +56,6 @@ class _HomeState extends State<Home> {
4556 ),
4657 ),
4758 ),
48-
49-
5059 Padding (
5160 padding: EdgeInsets .all (20 ),
5261 child: Container (
@@ -65,10 +74,14 @@ class _HomeState extends State<Home> {
6574 contentPadding: EdgeInsets .all (10.0 ),
6675 border: OutlineInputBorder (
6776 borderRadius: BorderRadius .circular (5.0 ),
68- borderSide: BorderSide (color: Colors .white,),
77+ borderSide: BorderSide (
78+ color: Colors .white,
79+ ),
6980 ),
7081 enabledBorder: OutlineInputBorder (
71- borderSide: BorderSide (color: Colors .white,),
82+ borderSide: BorderSide (
83+ color: Colors .white,
84+ ),
7285 borderRadius: BorderRadius .circular (5.0 ),
7386 ),
7487 hintText: "E.g: New York, United States" ,
@@ -86,7 +99,6 @@ class _HomeState extends State<Home> {
8699 ),
87100 ),
88101 ),
89-
90102 Container (
91103 padding: EdgeInsets .only (top: 10 , left: 20 ),
92104 height: 250 ,
@@ -97,7 +109,6 @@ class _HomeState extends State<Home> {
97109 primary: false ,
98110 itemCount: places == null ? 0 : places.length,
99111 itemBuilder: (BuildContext context, int index) {
100-
101112 Map place = places.reversed.toList ()[index];
102113 return Padding (
103114 padding: const EdgeInsets .only (right: 20 ),
@@ -117,7 +128,6 @@ class _HomeState extends State<Home> {
117128 fit: BoxFit .cover,
118129 ),
119130 ),
120-
121131 SizedBox (height: 7 ),
122132 Container (
123133 alignment: Alignment .centerLeft,
@@ -131,7 +141,6 @@ class _HomeState extends State<Home> {
131141 textAlign: TextAlign .left,
132142 ),
133143 ),
134-
135144 SizedBox (height: 3 ),
136145 Container (
137146 alignment: Alignment .centerLeft,
@@ -146,14 +155,13 @@ class _HomeState extends State<Home> {
146155 textAlign: TextAlign .left,
147156 ),
148157 ),
149-
150158 ],
151159 ),
152160 ),
153- onTap: (){
161+ onTap: () {
154162 Navigator .of (context).push (
155163 MaterialPageRoute (
156- builder: (BuildContext context){
164+ builder: (BuildContext context) {
157165 return Details ();
158166 },
159167 ),
@@ -164,7 +172,6 @@ class _HomeState extends State<Home> {
164172 },
165173 ),
166174 ),
167-
168175 Padding (
169176 padding: EdgeInsets .all (20 ),
170177 child: ListView .builder (
@@ -175,7 +182,7 @@ class _HomeState extends State<Home> {
175182 itemBuilder: (BuildContext context, int index) {
176183 Map place = places[index];
177184 return Padding (
178- padding: const EdgeInsets .only (bottom: 15.0 ),
185+ padding: const EdgeInsets .only (bottom: 15.0 ),
179186 child: InkWell (
180187 child: Container (
181188 height: 70 ,
@@ -191,12 +198,10 @@ class _HomeState extends State<Home> {
191198 fit: BoxFit .cover,
192199 ),
193200 ),
194-
195201 SizedBox (width: 15 ),
196-
197202 Container (
198203 height: 80 ,
199- width: MediaQuery .of (context).size.width- 130 ,
204+ width: MediaQuery .of (context).size.width - 130 ,
200205 child: ListView (
201206 primary: false ,
202207 physics: NeverScrollableScrollPhysics (),
@@ -214,7 +219,6 @@ class _HomeState extends State<Home> {
214219 textAlign: TextAlign .left,
215220 ),
216221 ),
217-
218222 SizedBox (height: 3 ),
219223 Row (
220224 children: < Widget > [
@@ -223,9 +227,7 @@ class _HomeState extends State<Home> {
223227 size: 13 ,
224228 color: Colors .blueGrey[300 ],
225229 ),
226-
227230 SizedBox (width: 3 ),
228-
229231 Container (
230232 alignment: Alignment .centerLeft,
231233 child: Text (
@@ -241,7 +243,6 @@ class _HomeState extends State<Home> {
241243 ),
242244 ],
243245 ),
244-
245246 SizedBox (height: 10 ),
246247 Container (
247248 alignment: Alignment .centerLeft,
@@ -255,19 +256,16 @@ class _HomeState extends State<Home> {
255256 textAlign: TextAlign .left,
256257 ),
257258 ),
258-
259-
260259 ],
261260 ),
262261 ),
263-
264262 ],
265263 ),
266264 ),
267- onTap: (){
265+ onTap: () {
268266 Navigator .of (context).push (
269267 MaterialPageRoute (
270- builder: (BuildContext context){
268+ builder: (BuildContext context) {
271269 return Details ();
272270 },
273271 ),
@@ -278,11 +276,8 @@ class _HomeState extends State<Home> {
278276 },
279277 ),
280278 ),
281-
282-
283279 ],
284280 ),
285-
286281 );
287282 }
288283}
0 commit comments