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
d0dda92c
Commit
d0dda92c
authored
Nov 15, 2022
by
ayodyabanuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create schedule screen
parent
00a24151
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
233 additions
and
27 deletions
+233
-27
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
+229
-22
lib/AB/Utils/NotificationService.dart
lib/AB/Utils/NotificationService.dart
+0
-1
lib/AB/Utils/ThemeProvider.dart
lib/AB/Utils/ThemeProvider.dart
+2
-2
pubspec.lock
pubspec.lock
+1
-1
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
View file @
d0dda92c
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_datetime_picker/flutter_datetime_picker.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
...
...
@@ -10,11 +11,27 @@ class FoodBucketSchedule extends StatefulWidget {
State
<
FoodBucketSchedule
>
createState
()
=>
_FoodBucketScheduleState
();
}
TextEditingController
dateandtime
=
TextEditingController
();
TextEditingController
dateController
=
TextEditingController
();
TextEditingController
timeController
=
TextEditingController
();
List
dateList
=
[];
List
timeList
=
[];
List
buckets
=
[];
List
bucketsMap
=
[];
class
_FoodBucketScheduleState
extends
State
<
FoodBucketSchedule
>
{
@override
void
initState
()
{
buckets
.
clear
();
print
(
buckets
);
// TODO: implement initState
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
final
Stream
<
QuerySnapshot
>
bucketref
=
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
return
Padding
(
padding:
const
EdgeInsets
.
all
(
25
),
child:
Column
(
...
...
@@ -50,44 +67,234 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
child:
TextFormField
(
readOnly:
true
,
onTap:
()
{
DatePicker
.
showDate
Time
Picker
(
context
,
DatePicker
.
showDatePicker
(
context
,
showTitleActions:
true
,
minTime:
DateTime
(
2022
,
11
,
5
),
maxTime:
DateTime
(
2019
,
6
,
7
),
onChanged:
(
date
)
{
print
(
'change
${DateFormat('yyyy-MM-dd kk:mm').format(date)}
'
);
minTime:
DateTime
(
2022
,
1
,
1
),
maxTime:
DateTime
(
2030
,
12
,
31
),
onChanged:
(
date
)
{
print
(
'change
${DateFormat('yyyy-MM-dd').format(date)}
'
);
},
onConfirm:
(
date
)
{
print
(
'confirm
${DateFormat('yyyy-MM-dd kk:mm').format(date)}
'
);
print
(
'confirm
${DateFormat('yyyy-MM-dd').format(date)}
'
);
setState
(()
{
dateController
.
text
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
date
);
});
},
currentTime:
DateTime
.
now
(),
locale:
LocaleType
.
en
);
},
controller:
dateController
,
style:
const
TextStyle
(
color:
Color
.
fromARGB
(
255
,
255
,
255
,
255
)),
cursorColor:
const
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
decoration:
const
InputDecoration
(
suffixIcon:
Icon
(
Icons
.
calendar_month
,
color:
Colors
.
white
,
),
hintText:
"Pick Date"
,
border:
InputBorder
.
none
,
hintStyle:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
255
,
255
,
255
))),
),
),
),
const
SizedBox
(
height:
10
,
),
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
15
),
color:
cardColor
),
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
),
child:
TextFormField
(
readOnly:
true
,
onTap:
()
{
DatePicker
.
showTimePicker
(
context
,
showTitleActions:
true
,
onChanged:
(
time
)
{
print
(
'change
${DateFormat('kk:mm').format(time)}
'
);
},
onConfirm:
(
time
)
{
print
(
'confirm
${DateFormat('kk:mm').format(time)}
'
);
setState
(()
{
dateandtime
.
text
=
DateFormat
(
'yyyy-MM-dd – kk:mm'
).
format
(
date
);
timeController
.
text
=
DateFormat
(
'kk:mm'
).
format
(
time
);
});
},
currentTime:
DateTime
.
now
(),
locale:
LocaleType
.
en
);
},
controller:
dateandtime
,
controller:
timeController
,
style:
const
TextStyle
(
color:
Color
.
fromARGB
(
255
,
255
,
255
,
255
)),
cursorColor:
const
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
decoration:
const
InputDecoration
(
hintText:
"Pick Date and Time"
,
suffixIcon:
Icon
(
Icons
.
timer
,
color:
Colors
.
white
,
),
hintText:
"Pick Time"
,
border:
InputBorder
.
none
,
hintStyle:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
255
,
255
,
255
))),
),
),
),
const
SizedBox
(
height:
10
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
GestureDetector
(
onTap:
()
{
setState
(()
{
timeController
.
clear
();
dateController
.
clear
();
});
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
yellowButton
),
borderRadius:
BorderRadius
.
circular
(
10
)),
child:
const
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
5
,
vertical:
1
),
child:
Text
(
'Cancel'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontFamily:
'poppins'
),
),
),
)),
const
SizedBox
(
width:
10
,
),
GestureDetector
(
onTap:
()
{
if
(
dateController
.
text
.
isNotEmpty
&&
timeController
.
text
.
isNotEmpty
)
{
setState
(()
{
dateList
.
add
(
dateController
.
text
);
timeList
.
add
(
timeController
.
text
);
dateController
.
clear
();
timeController
.
clear
();
});
}
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
color:
yellowButton
,
borderRadius:
BorderRadius
.
circular
(
10
)),
child:
const
Padding
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
5
,
vertical:
1
),
child:
Text
(
'Schedule'
,
style:
TextStyle
(
fontFamily:
'poppins'
,
color:
blacktxtColor
),
),
),
)),
],
),
const
SizedBox
(
height:
20
,
),
Row
(
children:
const
[
Text
(
"Scheduled List"
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
fontSize:
18
),
),
],
),
const
SizedBox
(
height:
10
,
),
Expanded
(
child:
ListView
.
builder
(
itemCount:
2
,
child:
dateList
.
isEmpty
?
const
Center
(
child:
Text
(
"No Scheduled Data"
,
style:
TextStyle
(
color:
subtextColor
),
),
)
:
ListView
.
builder
(
itemCount:
dateList
.
length
,
itemBuilder:
(
context
,
index
)
{
return
Container
(
margin:
const
EdgeInsets
.
symmetric
(
vertical:
5
),
padding:
const
EdgeInsets
.
all
(
15
),
decoration:
BoxDecoration
(
color:
cardColor
,
borderRadius:
BorderRadius
.
circular
(
15
)),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
"Date:
${dateList[index]}
Time:
${timeList[index]}
"
,
style:
const
TextStyle
(
color:
Colors
.
white
),
),
IconButton
(
onPressed:
()
{
setState
(()
{
dateList
.
remove
(
dateList
[
index
]);
timeList
.
remove
(
timeList
[
index
]);
});
},
icon:
const
Icon
(
Icons
.
delete
,
color:
Colors
.
red
,
))
],
),
);
}))
})),
Visibility
(
visible:
true
,
child:
Container
(
height:
0
,
child:
StreamBuilder
<
QuerySnapshot
>(
stream:
bucketref
,
builder:
(
BuildContext
context
,
AsyncSnapshot
<
QuerySnapshot
>
snapshot
)
{
if
(
snapshot
.
hasError
)
{
return
const
Text
(
'Something went wrong'
);
}
if
(
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
Center
(
child:
CircularProgressIndicator
());
}
snapshot
.
data
.
docs
.
map
((
DocumentSnapshot
document
)
{
Map
a
=
document
.
data
()
as
Map
<
String
,
dynamic
>;
buckets
.
clear
();
bucketsMap
.
add
(
a
);
for
(
var
i
=
0
;
i
<
bucketsMap
[
0
][
'Buckets'
].
length
;
i
++)
{
buckets
.
add
(
bucketsMap
[
0
][
'Buckets'
][
i
]);
}
print
(
buckets
);
}).
toList
();
return
bucketsMap
[
0
][
'Buckets'
].
isEmpty
?
const
Center
(
child:
Text
(
'Add bucket'
,
style:
TextStyle
(
color:
textColor
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
))
:
ListView
.
builder
(
itemCount:
bucketsMap
[
0
][
'Buckets'
].
length
,
itemBuilder:
(
context
,
index
)
{
return
Container
();
});
},
)),
)
],
),
);
...
...
lib/AB/Utils/NotificationService.dart
View file @
d0dda92c
...
...
@@ -44,7 +44,6 @@ class NotificationService {
const
NotificationDetails
(
android:
AndroidNotificationDetails
(
'main_channel'
,
'Main Channel'
,
'Main channel notifications'
,
playSound:
false
,
importance:
Importance
.
max
,
priority:
Priority
.
max
,
icon:
'@drawable/ifarm_icon_blue'
),
...
...
lib/AB/Utils/ThemeProvider.dart
View file @
d0dda92c
...
...
@@ -25,7 +25,7 @@ class MyThemes {
primaryColor:
backgroundColor
,
brightness:
Brightness
.
light
,
scaffoldBackgroundColor:
backgroundColor
,
floatingActionButtonTheme:
FloatingActionButtonThemeData
(
floatingActionButtonTheme:
const
FloatingActionButtonThemeData
(
backgroundColor:
naviconUnselectedColor
),
appBarTheme:
const
AppBarTheme
(
backgroundColor:
backgroundColor
,
elevation:
0
),
...
...
@@ -37,7 +37,7 @@ class MyThemes {
static
final
darkTheme
=
ThemeData
(
primaryColor:
backgroundColorDark
,
brightness:
Brightness
.
dark
,
floatingActionButtonTheme:
FloatingActionButtonThemeData
(
floatingActionButtonTheme:
const
FloatingActionButtonThemeData
(
backgroundColor:
naviconUnselectedColorDark
),
appBarTheme:
const
AppBarTheme
(
backgroundColor:
backgroundColorDark
,
elevation:
0
),
...
...
pubspec.lock
View file @
d0dda92c
...
...
@@ -346,7 +346,7 @@ packages:
source: hosted
version: "3.1.3"
intl:
dependency:
transitive
dependency:
"direct main"
description:
name: intl
url: "https://pub.dartlang.org"
...
...
pubspec.yaml
View file @
d0dda92c
...
...
@@ -36,7 +36,7 @@ dependencies:
flutter_native_timezone
:
^2.0.0
cron
:
^0.5.0
flutter_datetime_picker
:
^1.5.1
intl
:
^0.1
5.7
intl
:
^0.1
7.0
dev_dependencies
:
...
...
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