Skip to content

Commit 62ef216

Browse files
authored
Merge pull request JideGuru#11 from JideGuru/revert-8-revert-5-travel-choice-theme
Revert "Revert "activation drawer n switch button darkmode/lightmode""
2 parents 78d9573 + 1d417fe commit 62ef216

File tree

4 files changed

+69
-61
lines changed

4 files changed

+69
-61
lines changed

lib/main.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3+
import 'package:flutter_travel_concept/controller/home_controller.dart';
34
import 'package:flutter_travel_concept/screens/main_screen.dart';
45
import 'package:flutter_travel_concept/util/const.dart';
6+
import 'package:provider/provider.dart';
57

6-
7-
void main() async{
8-
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_) {
8+
void main() async {
9+
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
10+
.then((_) {
911
runApp(MyApp());
1012
});
1113
}
1214

13-
1415
class MyApp extends StatefulWidget {
1516
@override
1617
_MyAppState createState() => _MyAppState();
@@ -25,19 +26,23 @@ class _MyAppState extends State<MyApp> {
2526
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
2627
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
2728
statusBarColor: isDark ? Constants.darkPrimary : Constants.lightPrimary,
28-
statusBarIconBrightness: isDark?Brightness.light:Brightness.dark,
29+
statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
2930
));
3031
}
3132

32-
3333
@override
3434
Widget build(BuildContext context) {
35-
return MaterialApp(
36-
debugShowCheckedModeBanner: false,
37-
title: Constants.appName,
38-
theme: isDark ? Constants.darkTheme : Constants.lightTheme,
39-
home: MainScreen(),
40-
);
35+
return ChangeNotifierProvider(
36+
builder: (_) => HomeController(),
37+
child: Consumer<HomeController>(
38+
builder: (_, value, child) {
39+
return MaterialApp(
40+
debugShowCheckedModeBanner: false,
41+
title: Constants.appName,
42+
theme: value.modeChange ? Constants.darkTheme : Constants.lightTheme,
43+
home: MainScreen(),
44+
);
45+
},
46+
));
4147
}
4248
}
43-

lib/screens/home.dart

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_travel_concept/controller/home_controller.dart';
23
import 'package:flutter_travel_concept/screens/details.dart';
34
import 'package:flutter_travel_concept/widgets/icon_badge.dart';
45
import 'package:flutter_travel_concept/util/places.dart';
6+
import 'package:provider/provider.dart';
57

68
class Home extends StatefulWidget {
79
@override
@@ -11,28 +13,37 @@ class Home extends StatefulWidget {
1113
class _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
}

pubspec.lock

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Generated by pub
2-
# See https://www.dartlang.org/tools/pub/glossary#lockfile
2+
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
44
async:
55
dependency: transitive
66
description:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.1.0"
10+
version: "2.3.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.0.4"
17+
version: "1.0.5"
1818
charcode:
1919
dependency: transitive
2020
description:
@@ -59,28 +59,35 @@ packages:
5959
name: meta
6060
url: "https://pub.dartlang.org"
6161
source: hosted
62-
version: "1.1.6"
62+
version: "1.1.7"
6363
path:
6464
dependency: transitive
6565
description:
6666
name: path
6767
url: "https://pub.dartlang.org"
6868
source: hosted
69-
version: "1.6.2"
69+
version: "1.6.4"
7070
pedantic:
7171
dependency: transitive
7272
description:
7373
name: pedantic
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "1.5.0"
76+
version: "1.8.0+1"
77+
provider:
78+
dependency: "direct main"
79+
description:
80+
name: provider
81+
url: "https://pub.dartlang.org"
82+
source: hosted
83+
version: "3.1.0+1"
7784
quiver:
7885
dependency: transitive
7986
description:
8087
name: quiver
8188
url: "https://pub.dartlang.org"
8289
source: hosted
83-
version: "2.0.2"
90+
version: "2.0.5"
8491
sky_engine:
8592
dependency: transitive
8693
description: flutter
@@ -113,7 +120,7 @@ packages:
113120
name: string_scanner
114121
url: "https://pub.dartlang.org"
115122
source: hosted
116-
version: "1.0.4"
123+
version: "1.0.5"
117124
term_glyph:
118125
dependency: transitive
119126
description:
@@ -127,7 +134,7 @@ packages:
127134
name: test_api
128135
url: "https://pub.dartlang.org"
129136
source: hosted
130-
version: "0.2.4"
137+
version: "0.2.5"
131138
typed_data:
132139
dependency: transitive
133140
description:
@@ -143,4 +150,4 @@ packages:
143150
source: hosted
144151
version: "2.0.8"
145152
sdks:
146-
dart: ">=2.2.0 <3.0.0"
153+
dart: ">=2.2.2 <3.0.0"

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
# The following adds the Cupertino Icons font to your application.
2424
# Use with the CupertinoIcons class for iOS style icons.
2525
cupertino_icons: ^0.1.2
26+
provider: ^3.1.0+1
2627

2728
dev_dependencies:
2829
flutter_test:

0 commit comments

Comments
 (0)