Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ifarm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-2022-009
ifarm
Commits
5d558f83
Commit
5d558f83
authored
Nov 15, 2022
by
ayodyabanuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dark mode added
parent
406e76f6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
121 additions
and
211 deletions
+121
-211
lib/AB/Screens/FoodBucket/FoodBucketList.dart
lib/AB/Screens/FoodBucket/FoodBucketList.dart
+25
-20
lib/AB/Screens/NavBar/Home.dart
lib/AB/Screens/NavBar/Home.dart
+0
-3
lib/AB/Screens/NavBar/Navbar.dart
lib/AB/Screens/NavBar/Navbar.dart
+11
-4
lib/AB/Screens/NavBar/settings.dart
lib/AB/Screens/NavBar/settings.dart
+8
-159
lib/AB/Utils/Colors.dart
lib/AB/Utils/Colors.dart
+4
-2
lib/AB/Utils/ThemeProvider.dart
lib/AB/Utils/ThemeProvider.dart
+41
-12
lib/AB/widget/ChangeThemeButtonWidget.dart
lib/AB/widget/ChangeThemeButtonWidget.dart
+12
-1
lib/main.dart
lib/main.dart
+20
-10
No files found.
lib/AB/Screens/FoodBucket/FoodBucketList.dart
View file @
5d558f83
...
@@ -6,7 +6,9 @@ import 'package:flutter/services.dart';
...
@@ -6,7 +6,9 @@ import 'package:flutter/services.dart';
import
'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'
;
import
'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'
;
import
'package:ifarm/AB/Screens/FoodBucket/SingleFoodBucketData.dart'
;
import
'package:ifarm/AB/Screens/FoodBucket/SingleFoodBucketData.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:ifarm/functions/firebaseFunctions.dart'
;
import
'package:ifarm/functions/firebaseFunctions.dart'
;
import
'package:provider/provider.dart'
;
class
foodbuckets
extends
StatefulWidget
{
class
foodbuckets
extends
StatefulWidget
{
foodbuckets
({
Key
key
})
:
super
(
key:
key
);
foodbuckets
({
Key
key
})
:
super
(
key:
key
);
...
@@ -29,13 +31,14 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -29,13 +31,14 @@ class _foodbucketsState extends State<foodbuckets> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
final
Stream
<
QuerySnapshot
>
bucketref
=
final
Stream
<
QuerySnapshot
>
bucketref
=
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
return
Scaffold
(
return
Scaffold
(
backgroundColor:
const
Color
(
0xff024F8E
),
appBar:
AppBar
(
appBar:
AppBar
(
backgroundColor:
const
Color
(
0xff024F8E
),
backgroundColor:
themeProvider
.
isDarkMode
?
backgroundColor
:
backgroundColorDark
,
elevation:
0
,
elevation:
0
,
),
),
body:
Container
(
body:
Container
(
...
@@ -43,12 +46,17 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -43,12 +46,17 @@ class _foodbucketsState extends State<foodbuckets> {
child:
Column
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
children:
[
const
Text
(
const
SizedBox
(
'Food'
,
height:
20
,
style:
TextStyle
(
),
color:
Colors
.
white
,
const
Center
(
fontWeight:
FontWeight
.
bold
,
child:
Text
(
fontSize:
40
),
'Your Food Bucket list'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
fontSize:
20
),
),
),
),
const
SizedBox
(
const
SizedBox
(
height:
20
,
height:
20
,
...
@@ -76,7 +84,7 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -76,7 +84,7 @@ class _foodbucketsState extends State<foodbuckets> {
child:
Text
(
child:
Text
(
'Add bucket'
,
'Add bucket'
,
style:
TextStyle
(
style:
TextStyle
(
color:
Colors
.
white
,
color:
textColor
,
fontSize:
20
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
fontWeight:
FontWeight
.
bold
),
))
))
...
@@ -109,21 +117,17 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -109,21 +117,17 @@ class _foodbucketsState extends State<foodbuckets> {
crossAxisAlignment:
crossAxisAlignment:
CrossAxisAlignment
.
start
,
CrossAxisAlignment
.
start
,
children:
[
children:
[
const
Text
(
Text
(
'Bucket
:
'
,
'Bucket
${storedata[0]['Buckets'][index]}
'
,
style:
TextStyle
(
style:
const
TextStyle
(
color:
Colors
.
black
,
color:
textColor
,
fontSize:
20
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
fontWeight:
FontWeight
.
bold
),
),
),
Text
(
storedata
[
0
][
'Buckets'
][
index
],
style:
const
TextStyle
(
color:
Colors
.
black
,
fontSize:
15
))
]),
]),
const
Icon
(
const
Icon
(
Icons
.
arrow_right
,
Icons
.
arrow_right
,
color:
Colors
.
black
,
color:
textColor
,
)
)
],
],
),
),
...
@@ -139,10 +143,11 @@ class _foodbucketsState extends State<foodbuckets> {
...
@@ -139,10 +143,11 @@ class _foodbucketsState extends State<foodbuckets> {
onPressed:
()
{
onPressed:
()
{
scanQRCode
();
scanQRCode
();
},
},
backgroundColor:
Colors
.
white
,
backgroundColor:
themeProvider
.
isDarkMode
?
naviconUnselectedColor
:
naviconUnselectedColorDark
,
child:
const
Icon
(
child:
const
Icon
(
Icons
.
add
,
Icons
.
add
,
color:
Color
(
0xff024F8E
),
),
),
),
),
);
);
...
...
lib/AB/Screens/NavBar/Home.dart
View file @
5d558f83
import
'dart:async'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
...
@@ -61,7 +59,6 @@ class _HomeState extends State<Home> {
...
@@ -61,7 +59,6 @@ class _HomeState extends State<Home> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
backgroundColor:
backgroundColor
,
body:
Container
(
body:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
15
),
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
15
),
child:
Column
(
child:
Column
(
...
...
lib/AB/Screens/NavBar/Navbar.dart
View file @
5d558f83
...
@@ -5,6 +5,8 @@ import 'package:ifarm/AB/Screens/NavBar/Home.dart';
...
@@ -5,6 +5,8 @@ import 'package:ifarm/AB/Screens/NavBar/Home.dart';
import
'package:ifarm/AB/Screens/NavBar/Profile.dart'
;
import
'package:ifarm/AB/Screens/NavBar/Profile.dart'
;
import
'package:ifarm/AB/Screens/NavBar/settings.dart'
;
import
'package:ifarm/AB/Screens/NavBar/settings.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
class
Navbar
extends
StatefulWidget
{
class
Navbar
extends
StatefulWidget
{
Navbar
({
Navbar
({
...
@@ -20,8 +22,8 @@ class _NavbarState extends State<Navbar> {
...
@@ -20,8 +22,8 @@ class _NavbarState extends State<Navbar> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
return
Scaffold
(
return
Scaffold
(
backgroundColor:
backgroundColor
,
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
SizedBox
(
title:
const
SizedBox
(
width:
100
,
width:
100
,
...
@@ -44,12 +46,17 @@ class _NavbarState extends State<Navbar> {
...
@@ -44,12 +46,17 @@ class _NavbarState extends State<Navbar> {
],
],
),
),
bottomNavigationBar:
BottomNavigationBar
(
bottomNavigationBar:
BottomNavigationBar
(
backgroundColor:
const
Color
.
fromARGB
(
150
,
6
,
91
,
161
),
backgroundColor:
themeProvider
.
isDarkMode
?
backgroundColor
:
backgroundColorDark
,
type:
BottomNavigationBarType
.
fixed
,
type:
BottomNavigationBarType
.
fixed
,
elevation:
1
,
elevation:
1
,
currentIndex:
_selectedIndex
,
currentIndex:
_selectedIndex
,
selectedItemColor:
Colors
.
white
,
selectedItemColor:
themeProvider
.
isDarkMode
unselectedItemColor:
Colors
.
grey
,
?
naviconSelectedColor
:
naviconSelectedColorDark
,
unselectedItemColor:
themeProvider
.
isDarkMode
?
naviconUnselectedColor
:
naviconUnselectedColorDark
,
showSelectedLabels:
false
,
showSelectedLabels:
false
,
showUnselectedLabels:
false
,
showUnselectedLabels:
false
,
items:
const
[
items:
const
[
...
...
lib/AB/Screens/NavBar/settings.dart
View file @
5d558f83
import
'package:firebase_auth/firebase_auth.dart'
;
import
'package:firebase_auth/firebase_auth.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:ifarm/AB/Utils/
ThemeProvider
.dart'
;
import
'package:ifarm/AB/Utils/
Colors
.dart'
;
import
'package:ifarm/AB/widget/ChangeThemeButtonWidget.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
import
'../Common/SplashScreen.dart'
;
import
'../Common/SplashScreen.dart'
;
class
settings
extends
StatefulWidget
{
class
settings
extends
StatefulWidget
{
...
@@ -16,19 +14,7 @@ class settings extends StatefulWidget {
...
@@ -16,19 +14,7 @@ class settings extends StatefulWidget {
State
<
settings
>
createState
()
=>
_settingsState
();
State
<
settings
>
createState
()
=>
_settingsState
();
}
}
bool
foodswitch
=
false
;
bool
waterswitch
=
false
;
bool
environmentswitch
=
false
;
bool
securityswitch
=
false
;
class
_settingsState
extends
State
<
settings
>
{
class
_settingsState
extends
State
<
settings
>
{
@override
void
initState
()
{
getdata
();
// TODO: implement initState
super
.
initState
();
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
...
@@ -49,115 +35,18 @@ class _settingsState extends State<settings> {
...
@@ -49,115 +35,18 @@ class _settingsState extends State<settings> {
),
),
Row
(
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
children:
const
[
const
Expanded
(
Expanded
(
child:
Text
(
child:
Text
(
'Theme'
,
'Theme'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
)),
// Switch(
ChangeThemeButtonWidget
(),
// value: _themeManager.themeMode == ThemeMode.dark,
// onChanged: (value) {
// _themeManager.toggleTheme(value);
// })
],
],
),
),
const
SizedBox
(
const
SizedBox
(
height:
40
,
height:
40
,
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
const
Expanded
(
child:
Text
(
'Food Sensors'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
SwitcherButton
(
value:
foodswitch
,
onChange:
(
value
)
{
setState
(()
{
foodswitch
=
value
;
save_datafood
(
value
);
print
(
value
);
});
},
)
],
),
const
SizedBox
(
height:
20
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
const
Expanded
(
child:
Text
(
'Water Sensors'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
SwitcherButton
(
value:
waterswitch
,
onChange:
(
value
)
{
setState
(()
{
waterswitch
=
value
;
save_datawater
(
value
);
print
(
value
);
});
},
)
],
),
const
SizedBox
(
height:
20
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
const
Expanded
(
child:
Text
(
'Environment Sensors'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
SwitcherButton
(
value:
environmentswitch
,
onChange:
(
value
)
{
setState
(()
{
environmentswitch
=
value
;
save_dataenv
(
value
);
print
(
value
);
});
},
)
],
),
const
SizedBox
(
height:
20
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
const
Expanded
(
child:
Text
(
'Security Sensors'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
SwitcherButton
(
value:
securityswitch
,
onChange:
(
value
)
{
setState
(()
{
securityswitch
=
value
;
save_datasecurity
(
value
);
print
(
value
);
});
},
)
],
),
const
SizedBox
(
const
SizedBox
(
height:
40
,
height:
40
,
),
),
...
@@ -177,7 +66,7 @@ class _settingsState extends State<settings> {
...
@@ -177,7 +66,7 @@ class _settingsState extends State<settings> {
child:
Container
(
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
,
vertical:
20
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
,
vertical:
20
),
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
15
)),
color:
cardColor
,
borderRadius:
BorderRadius
.
circular
(
15
)),
child:
Center
(
child:
Center
(
child:
Row
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
...
@@ -185,11 +74,11 @@ class _settingsState extends State<settings> {
...
@@ -185,11 +74,11 @@ class _settingsState extends State<settings> {
Expanded
(
Expanded
(
child:
Text
(
child:
Text
(
'Logout'
,
'Logout'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
17
),
style:
TextStyle
(
color:
textColor
,
fontSize:
17
),
)),
)),
Icon
(
Icon
(
Icons
.
logout
,
Icons
.
logout
,
color:
Colors
.
red
,
color:
naviconSelectedColor
,
)
)
],
],
),
),
...
@@ -200,44 +89,4 @@ class _settingsState extends State<settings> {
...
@@ -200,44 +89,4 @@ class _settingsState extends State<settings> {
),
),
);
);
}
}
void
save_datafood
(
bool
value
)
async
{
SharedPreferences
localStorage
=
await
SharedPreferences
.
getInstance
();
localStorage
.
setBool
(
'food'
,
value
);
print
(
'save'
);
}
void
save_datawater
(
bool
value
)
async
{
SharedPreferences
localStorage
=
await
SharedPreferences
.
getInstance
();
localStorage
.
setBool
(
'water'
,
value
);
print
(
'save'
);
}
void
save_dataenv
(
bool
value
)
async
{
SharedPreferences
localStorage
=
await
SharedPreferences
.
getInstance
();
localStorage
.
setBool
(
'env'
,
value
);
print
(
'save'
);
}
void
save_datasecurity
(
bool
value
)
async
{
SharedPreferences
localStorage
=
await
SharedPreferences
.
getInstance
();
localStorage
.
setBool
(
'security'
,
value
);
print
(
'save'
);
}
getdata
()
async
{
print
(
'login'
);
SharedPreferences
localStorage
=
await
SharedPreferences
.
getInstance
();
var
foodswitch1
=
localStorage
.
getBool
(
'food'
)
as
bool
;
var
waterswitch1
=
localStorage
.
getBool
(
'water'
)
as
bool
;
var
environmentswitch1
=
localStorage
.
getBool
(
'env'
)
as
bool
;
var
securityswitch1
=
localStorage
.
getBool
(
'security'
)
as
bool
;
setState
(()
{
foodswitch
=
foodswitch1
;
waterswitch1
=
waterswitch1
;
environmentswitch
=
environmentswitch1
;
securityswitch
=
securityswitch1
;
});
}
}
}
lib/AB/Utils/Colors.dart
View file @
5d558f83
...
@@ -4,8 +4,10 @@ const backgroundColor = Color(0xff024F8E);
...
@@ -4,8 +4,10 @@ const backgroundColor = Color(0xff024F8E);
const
backgroundColorDark
=
Color
.
fromARGB
(
255
,
27
,
27
,
27
);
const
backgroundColorDark
=
Color
.
fromARGB
(
255
,
27
,
27
,
27
);
const
cardColor
=
Color
.
fromARGB
(
54
,
255
,
255
,
255
);
const
cardColor
=
Color
.
fromARGB
(
54
,
255
,
255
,
255
);
const
textColor
=
Color
.
fromARGB
(
255
,
255
,
255
,
255
);
const
textColor
=
Color
.
fromARGB
(
255
,
255
,
255
,
255
);
const
subtextColor
=
Color
.
fromARGB
(
255
,
223
,
223
,
223
);
const
subtextColor
=
Color
.
fromARGB
(
255
,
160
,
160
,
160
);
const
naviconSelectedColor
=
Color
.
fromARGB
(
255
,
255
,
255
,
255
);
const
naviconSelectedColor
=
Color
.
fromARGB
(
255
,
255
,
255
,
255
);
const
naviconUnselectedColor
=
Color
.
fromARGB
(
255
,
170
,
170
,
170
);
const
naviconUnselectedColor
=
Color
.
fromARGB
(
255
,
209
,
209
,
209
);
const
naviconSelectedColorDark
=
Color
.
fromARGB
(
255
,
209
,
209
,
209
);
const
naviconUnselectedColorDark
=
Color
.
fromARGB
(
255
,
63
,
63
,
63
);
const
yellowButton
=
Color
(
0xffFEC427
);
const
yellowButton
=
Color
(
0xffFEC427
);
const
blacktxtColor
=
Color
.
fromARGB
(
255
,
0
,
0
,
0
);
const
blacktxtColor
=
Color
.
fromARGB
(
255
,
0
,
0
,
0
);
lib/AB/Utils/ThemeProvider.dart
View file @
5d558f83
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
class
ThemeProvider
with
ChangeNotifier
{
class
ThemeProvider
with
ChangeNotifier
{
ThemeMode
_
themeMode
=
ThemeMode
.
light
;
ThemeMode
themeMode
=
ThemeMode
.
light
;
bool
get
themeMode
=>
_themeMode
==
ThemeMode
.
light
;
bool
get
isDarkMode
{
if
(
themeMode
==
ThemeMode
.
dark
)
{
final
brightness
=
SchedulerBinding
.
instance
.
window
.
platformBrightness
;
return
brightness
==
Brightness
.
dark
;
}
else
{
return
themeMode
==
ThemeMode
.
light
;
}
}
void
toggleTheme
(
bool
isOn
)
{
themeMode
=
isOn
?
ThemeMode
.
dark
:
ThemeMode
.
light
;
notifyListeners
();
}
}
}
ThemeData
lightTheme
=
ThemeData
(
class
MyThemes
{
scaffoldBackgroundColor:
backgroundColor
,
static
final
lightTheme
=
ThemeData
(
colorScheme:
const
ColorScheme
.
light
(
primaryColor:
backgroundColor
,
primary:
backgroundColor
,
brightness:
Brightness
.
light
,
brightness:
Brightness
.
light
,
));
scaffoldBackgroundColor:
backgroundColor
,
ThemeData
darkTheme
=
ThemeData
(
floatingActionButtonTheme:
FloatingActionButtonThemeData
(
scaffoldBackgroundColor:
backgroundColorDark
,
backgroundColor:
naviconUnselectedColor
),
colorScheme:
const
ColorScheme
.
dark
(
appBarTheme:
primary:
backgroundColorDark
,
const
AppBarTheme
(
backgroundColor:
backgroundColor
,
elevation:
0
),
bottomNavigationBarTheme:
const
BottomNavigationBarThemeData
(
backgroundColor:
backgroundColor
,
selectedItemColor:
naviconSelectedColor
,
unselectedItemColor:
naviconUnselectedColor
),
colorScheme:
const
ColorScheme
.
light
());
static
final
darkTheme
=
ThemeData
(
primaryColor:
backgroundColorDark
,
brightness:
Brightness
.
dark
,
brightness:
Brightness
.
dark
,
));
floatingActionButtonTheme:
FloatingActionButtonThemeData
(
backgroundColor:
naviconUnselectedColorDark
),
appBarTheme:
const
AppBarTheme
(
backgroundColor:
backgroundColorDark
,
elevation:
0
),
scaffoldBackgroundColor:
backgroundColorDark
,
bottomNavigationBarTheme:
const
BottomNavigationBarThemeData
(
backgroundColor:
backgroundColorDark
,
selectedItemColor:
naviconSelectedColor
,
unselectedItemColor:
naviconUnselectedColor
),
colorScheme:
const
ColorScheme
.
dark
());
}
lib/AB/widget/ChangeThemeButtonWidget.dart
View file @
5d558f83
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
class
ChangeThemeButtonWidget
extends
StatelessWidget
{
class
ChangeThemeButtonWidget
extends
StatelessWidget
{
const
ChangeThemeButtonWidget
({
Key
key
})
:
super
(
key:
key
);
const
ChangeThemeButtonWidget
({
Key
key
})
:
super
(
key:
key
);
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
();
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
return
SwitcherButton
(
value:
!
themeProvider
.
isDarkMode
,
onChange:
(
value
)
{
final
provider
=
Provider
.
of
<
ThemeProvider
>(
context
,
listen:
false
);
provider
.
toggleTheme
(
value
);
},
);
}
}
}
}
lib/main.dart
View file @
5d558f83
...
@@ -2,13 +2,19 @@ import 'dart:io';
...
@@ -2,13 +2,19 @@ import 'dart:io';
import
'package:firebase_core/firebase_core.dart'
;
import
'package:firebase_core/firebase_core.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
import
'AB/Screens/Common/SplashScreen.dart'
;
import
'AB/Screens/Common/SplashScreen.dart'
;
void
main
(
)
async
{
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsFlutterBinding
.
ensureInitialized
();
await
Firebase
.
initializeApp
();
await
Firebase
.
initializeApp
();
await
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
,
DeviceOrientation
.
portraitDown
,
]);
runApp
(
const
MyApp
());
runApp
(
const
MyApp
());
}
}
...
@@ -17,14 +23,18 @@ class MyApp extends StatelessWidget {
...
@@ -17,14 +23,18 @@ class MyApp extends StatelessWidget {
const
MyApp
({
Key
key
})
:
super
(
key:
key
);
const
MyApp
({
Key
key
})
:
super
(
key:
key
);
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
=>
ChangeNotifierProvider
(
return
MaterialApp
(
create:
(
context
)
=>
ThemeProvider
(),
debugShowCheckedModeBanner:
false
,
builder:
(
context
,
_
)
{
title:
'IFarm'
,
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
theme:
lightTheme
,
return
MaterialApp
(
darkTheme:
darkTheme
,
debugShowCheckedModeBanner:
false
,
themeMode:
ThemeMode
.
system
,
title:
'IFarm'
,
home:
splashScreen
(),
theme:
MyThemes
.
lightTheme
,
);
darkTheme:
MyThemes
.
darkTheme
,
}
themeMode:
themeProvider
.
themeMode
,
home:
splashScreen
(),
);
},
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment