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';
import
'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'
;
import
'package:ifarm/AB/Screens/FoodBucket/SingleFoodBucketData.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:ifarm/functions/firebaseFunctions.dart'
;
import
'package:provider/provider.dart'
;
class
foodbuckets
extends
StatefulWidget
{
foodbuckets
({
Key
key
})
:
super
(
key:
key
);
...
...
@@ -29,13 +31,14 @@ class _foodbucketsState extends State<foodbuckets> {
@override
Widget
build
(
BuildContext
context
)
{
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
final
Stream
<
QuerySnapshot
>
bucketref
=
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
return
Scaffold
(
backgroundColor:
const
Color
(
0xff024F8E
),
appBar:
AppBar
(
backgroundColor:
const
Color
(
0xff024F8E
),
backgroundColor:
themeProvider
.
isDarkMode
?
backgroundColor
:
backgroundColorDark
,
elevation:
0
,
),
body:
Container
(
...
...
@@ -43,12 +46,17 @@ class _foodbucketsState extends State<foodbuckets> {
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
'Food'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
fontSize:
40
),
const
SizedBox
(
height:
20
,
),
const
Center
(
child:
Text
(
'Your Food Bucket list'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
fontSize:
20
),
),
),
const
SizedBox
(
height:
20
,
...
...
@@ -76,7 +84,7 @@ class _foodbucketsState extends State<foodbuckets> {
child:
Text
(
'Add bucket'
,
style:
TextStyle
(
color:
Colors
.
white
,
color:
textColor
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
))
...
...
@@ -109,21 +117,17 @@ class _foodbucketsState extends State<foodbuckets> {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
'Bucket
:
'
,
style:
TextStyle
(
color:
Colors
.
black
,
Text
(
'Bucket
${storedata[0]['Buckets'][index]}
'
,
style:
const
TextStyle
(
color:
textColor
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
),
Text
(
storedata
[
0
][
'Buckets'
][
index
],
style:
const
TextStyle
(
color:
Colors
.
black
,
fontSize:
15
))
]),
const
Icon
(
Icons
.
arrow_right
,
color:
Colors
.
black
,
color:
textColor
,
)
],
),
...
...
@@ -139,10 +143,11 @@ class _foodbucketsState extends State<foodbuckets> {
onPressed:
()
{
scanQRCode
();
},
backgroundColor:
Colors
.
white
,
backgroundColor:
themeProvider
.
isDarkMode
?
naviconUnselectedColor
:
naviconUnselectedColorDark
,
child:
const
Icon
(
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:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
...
...
@@ -61,7 +59,6 @@ class _HomeState extends State<Home> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
backgroundColor:
backgroundColor
,
body:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
15
),
child:
Column
(
...
...
lib/AB/Screens/NavBar/Navbar.dart
View file @
5d558f83
...
...
@@ -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/settings.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
class
Navbar
extends
StatefulWidget
{
Navbar
({
...
...
@@ -20,8 +22,8 @@ class _NavbarState extends State<Navbar> {
@override
Widget
build
(
BuildContext
context
)
{
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
return
Scaffold
(
backgroundColor:
backgroundColor
,
appBar:
AppBar
(
title:
const
SizedBox
(
width:
100
,
...
...
@@ -44,12 +46,17 @@ class _NavbarState extends State<Navbar> {
],
),
bottomNavigationBar:
BottomNavigationBar
(
backgroundColor:
const
Color
.
fromARGB
(
150
,
6
,
91
,
161
),
backgroundColor:
themeProvider
.
isDarkMode
?
backgroundColor
:
backgroundColorDark
,
type:
BottomNavigationBarType
.
fixed
,
elevation:
1
,
currentIndex:
_selectedIndex
,
selectedItemColor:
Colors
.
white
,
unselectedItemColor:
Colors
.
grey
,
selectedItemColor:
themeProvider
.
isDarkMode
?
naviconSelectedColor
:
naviconSelectedColorDark
,
unselectedItemColor:
themeProvider
.
isDarkMode
?
naviconUnselectedColor
:
naviconUnselectedColorDark
,
showSelectedLabels:
false
,
showUnselectedLabels:
false
,
items:
const
[
...
...
lib/AB/Screens/NavBar/settings.dart
View file @
5d558f83
import
'package:firebase_auth/firebase_auth.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:switcher_button/switcher_button.dart'
;
import
'../Common/SplashScreen.dart'
;
class
settings
extends
StatefulWidget
{
...
...
@@ -16,19 +14,7 @@ class settings extends StatefulWidget {
State
<
settings
>
createState
()
=>
_settingsState
();
}
bool
foodswitch
=
false
;
bool
waterswitch
=
false
;
bool
environmentswitch
=
false
;
bool
securityswitch
=
false
;
class
_settingsState
extends
State
<
settings
>
{
@override
void
initState
()
{
getdata
();
// TODO: implement initState
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
...
...
@@ -49,115 +35,18 @@ class _settingsState extends State<settings> {
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
const
Expanded
(
children:
const
[
Expanded
(
child:
Text
(
'Theme'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
17
),
)),
// Switch(
// value: _themeManager.themeMode == ThemeMode.dark,
// onChanged: (value) {
// _themeManager.toggleTheme(value);
// })
ChangeThemeButtonWidget
(),
],
),
const
SizedBox
(
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
(
height:
40
,
),
...
...
@@ -177,7 +66,7 @@ class _settingsState extends State<settings> {
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
,
vertical:
20
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
15
)),
color:
cardColor
,
borderRadius:
BorderRadius
.
circular
(
15
)),
child:
Center
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
...
...
@@ -185,11 +74,11 @@ class _settingsState extends State<settings> {
Expanded
(
child:
Text
(
'Logout'
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
17
),
style:
TextStyle
(
color:
textColor
,
fontSize:
17
),
)),
Icon
(
Icons
.
logout
,
color:
Colors
.
red
,
color:
naviconSelectedColor
,
)
],
),
...
...
@@ -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);
const
backgroundColorDark
=
Color
.
fromARGB
(
255
,
27
,
27
,
27
);
const
cardColor
=
Color
.
fromARGB
(
54
,
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
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
blacktxtColor
=
Color
.
fromARGB
(
255
,
0
,
0
,
0
);
lib/AB/Utils/ThemeProvider.dart
View file @
5d558f83
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
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
(
scaffoldBackgroundColor:
backgroundColor
,
colorScheme:
const
ColorScheme
.
light
(
primary:
backgroundColor
,
class
MyThemes
{
static
final
lightTheme
=
ThemeData
(
primaryColor:
backgroundColor
,
brightness:
Brightness
.
light
,
));
ThemeData
darkTheme
=
ThemeData
(
scaffoldBackgroundColor:
backgroundColorDark
,
colorScheme:
const
ColorScheme
.
dark
(
primary:
backgroundColorDark
,
scaffoldBackgroundColor:
backgroundColor
,
floatingActionButtonTheme:
FloatingActionButtonThemeData
(
backgroundColor:
naviconUnselectedColor
),
appBarTheme:
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
,
));
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:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
class
ChangeThemeButtonWidget
extends
StatelessWidget
{
const
ChangeThemeButtonWidget
({
Key
key
})
:
super
(
key:
key
);
@override
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';
import
'package:firebase_core/firebase_core.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:ifarm/AB/Utils/ThemeProvider.dart'
;
import
'package:provider/provider.dart'
;
import
'AB/Screens/Common/SplashScreen.dart'
;
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
await
Firebase
.
initializeApp
();
await
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
,
DeviceOrientation
.
portraitDown
,
]);
runApp
(
const
MyApp
());
}
...
...
@@ -17,14 +23,18 @@ class MyApp extends StatelessWidget {
const
MyApp
({
Key
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
debugShowCheckedModeBanner:
false
,
title:
'IFarm'
,
theme:
lightTheme
,
darkTheme:
darkTheme
,
themeMode:
ThemeMode
.
system
,
home:
splashScreen
(),
);
}
Widget
build
(
BuildContext
context
)
=>
ChangeNotifierProvider
(
create:
(
context
)
=>
ThemeProvider
(),
builder:
(
context
,
_
)
{
final
themeProvider
=
Provider
.
of
<
ThemeProvider
>(
context
);
return
MaterialApp
(
debugShowCheckedModeBanner:
false
,
title:
'IFarm'
,
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