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
844069e5
Commit
844069e5
authored
Nov 15, 2022
by
ayodyabanuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
530725cc
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
253 additions
and
85 deletions
+253
-85
lib/AB/Screens/Common/Auth/Login.dart
lib/AB/Screens/Common/Auth/Login.dart
+1
-0
lib/AB/Screens/Common/Auth/register.dart
lib/AB/Screens/Common/Auth/register.dart
+4
-0
lib/AB/Screens/FoodBucket/FoodBucketList.dart
lib/AB/Screens/FoodBucket/FoodBucketList.dart
+15
-11
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
+119
-45
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
+114
-29
No files found.
lib/AB/Screens/Common/Auth/Login.dart
View file @
844069e5
...
...
@@ -35,6 +35,7 @@ class _LoginState extends State<Login> {
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
resizeToAvoidBottomInset:
false
,
appBar:
AppBar
(
backgroundColor:
backgroundColor
,
elevation:
0
,
...
...
lib/AB/Screens/Common/Auth/register.dart
View file @
844069e5
...
...
@@ -20,6 +20,7 @@ class _registerState extends State<register> {
Widget
build
(
BuildContext
context
)
{
Size
size
=
MediaQuery
.
of
(
context
).
size
;
return
Scaffold
(
resizeToAvoidBottomInset:
false
,
backgroundColor:
const
Color
(
0xff024F8E
),
appBar:
AppBar
(
backgroundColor:
const
Color
(
0xff024F8E
),
...
...
@@ -117,6 +118,9 @@ class _registerState extends State<register> {
),
),
)),
const
SizedBox
(
width:
20
,
),
GestureDetector
(
onTap:
()
{
print
(
emailController
.
text
);
...
...
lib/AB/Screens/FoodBucket/FoodBucketList.dart
View file @
844069e5
...
...
@@ -160,14 +160,16 @@ class _foodbucketsState extends State<foodbuckets> {
if
(!
mounted
)
return
;
setState
(()
{
getResult
=
qrCode
;
if
(
buckets
.
contains
(
qrCode
)
||
qrCode
==
'-1'
)
{
}
else
{
buckets
.
add
(
qrCode
);
saveQRCodes
();
}
});
if
(
mounted
)
{
setState
(()
{
getResult
=
qrCode
;
if
(
buckets
.
contains
(
qrCode
)
||
qrCode
==
'-1'
)
{
}
else
{
buckets
.
add
(
qrCode
);
saveQRCodes
();
}
});
}
print
(
"QRCode_Result:-"
);
print
(
qrCode
);
}
on
PlatformException
{
...
...
@@ -178,9 +180,11 @@ class _foodbucketsState extends State<foodbuckets> {
saveQRCodes
()
{
final
user
=
FirebaseAuth
.
instance
.
currentUser
;
if
(
user
!=
null
)
{
setState
(()
{
name
=
user
.
displayName
.
toString
();
});
if
(
mounted
)
{
setState
(()
{
name
=
user
.
displayName
.
toString
();
});
}
}
FirestoreServices
.
savefoodbuckets
(
buckets
,
name
);
}
...
...
lib/AB/Screens/FoodBucket/SingleFoodBucketData.dart
View file @
844069e5
This diff is collapsed.
Click to expand it.
lib/AB/Screens/NavBar/FoodBucketSchedule.dart
View file @
844069e5
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:cron/cron.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_datetime_picker/flutter_datetime_picker.dart'
;
import
'package:ifarm/AB/Utils/Colors.dart'
;
...
...
@@ -17,16 +18,15 @@ class FoodBucketSchedule extends StatefulWidget {
TextEditingController
dateController
=
TextEditingController
();
TextEditingController
timeController
=
TextEditingController
();
List
<
String
>
timeList
=
[];
List
buckets
=
[];
List
bucketsMap
=
[];
List
<
String
>
timeList
=
[];
class
_FoodBucketScheduleState
extends
State
<
FoodBucketSchedule
>
{
@override
void
initState
()
{
gettimelist
();
cancelSheduleTask
();
scheduleDispens
();
buckets
.
clear
();
...
...
@@ -80,9 +80,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
print
(
'change
${DateFormat('kk:mm').format(time)}
'
);
},
onConfirm:
(
time
)
{
print
(
'confirm
${DateFormat('kk:mm').format(time)}
'
);
setState
(()
{
timeController
.
text
=
DateFormat
(
'kk:mm'
).
format
(
time
);
});
if
(
mounted
)
{
setState
(()
{
timeController
.
text
=
DateFormat
(
'kk:mm'
).
format
(
time
);
});
}
},
currentTime:
DateTime
.
now
(),
locale:
LocaleType
.
en
);
},
controller:
timeController
,
...
...
@@ -109,9 +111,11 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
children:
[
GestureDetector
(
onTap:
()
{
setState
(()
{
timeController
.
clear
();
});
if
(
mounted
)
{
setState
(()
{
timeController
.
clear
();
});
}
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
...
...
@@ -134,12 +138,14 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
GestureDetector
(
onTap:
()
{
if
(
timeController
.
text
.
isNotEmpty
)
{
setState
(()
{
timeList
.
add
(
timeController
.
text
.
toString
());
savetimelist
();
scheduleDispens
();
timeController
.
clear
();
});
if
(
mounted
)
{
setState
(()
{
timeList
.
add
(
timeController
.
text
.
toString
());
savetimelist
();
timeController
.
clear
();
});
}
}
},
child:
Container
(
...
...
@@ -177,7 +183,7 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
height:
10
,
),
Expanded
(
child:
timeList
.
isEmpty
child:
timeList
==
null
?
const
Center
(
child:
Text
(
"No Scheduled Data"
,
...
...
@@ -202,14 +208,12 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
),
IconButton
(
onPressed:
()
{
setState
(()
{
cancelSheduleTask
();
timeList
.
remove
(
timeList
[
index
]);
scheduleDispens
();
savetimelist
();
NotificationService
()
.
cancelNotifications
(
index
);
});
if
(
mounted
)
{
setState
(()
{
timeList
.
remove
(
timeList
[
index
]);
savetimelist
();
});
}
},
icon:
const
Icon
(
Icons
.
delete
,
...
...
@@ -264,6 +268,52 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
});
},
)),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
[
GestureDetector
(
onTap:
()
{
cancelSheduleTask
();
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
yellowButton
),
borderRadius:
BorderRadius
.
circular
(
10
)),
height:
40
,
child:
const
Center
(
child:
Text
(
"Stop Schedule"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
),
),
Visibility
(
visible:
timeList
!=
null
,
child:
GestureDetector
(
onTap:
()
{
scheduleDispens
();
},
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
10
),
decoration:
BoxDecoration
(
color:
yellowButton
,
borderRadius:
BorderRadius
.
circular
(
10
)),
height:
40
,
child:
const
Center
(
child:
Text
(
"Schedule Start"
,
style:
TextStyle
(
color:
Colors
.
black
),
),
),
),
),
),
],
)
],
),
...
...
@@ -271,27 +321,61 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
}
scheduleDispens
()
async
{
if
(
timeList
.
isEmpty
)
{
if
(
timeList
==
null
)
{
cancelSheduleTask
();
NotificationService
().
cancelAllNotifications
();
}
else
{
print
(
timeList
);
print
(
DateFormat
(
'kk:mm'
).
format
(
DateTime
.
now
()));
for
(
var
i
=
0
;
i
<
timeList
.
length
;
i
++)
{
String
hours
=
timeList
[
i
].
toString
().
substring
(
0
,
2
);
String
mins
=
timeList
[
i
].
toString
().
substring
(
3
,
5
);
scheduledTask
=
cron
.
schedule
(
Schedule
.
parse
(
"*/
$mins
*/
$hours
* * *"
),
()
async
{
final
servoref1
=
FirebaseDatabase
.
instance
.
ref
();
for
(
var
k
=
0
;
k
<
buckets
.
length
;
k
++)
{
print
(
"servo run"
);
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
1
,
});
Future
.
delayed
(
const
Duration
(
seconds:
20
),
()
async
{
print
(
"servo closed"
);
await
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
0
,
});
});
}
NotificationService
().
showNotification
(
i
,
1
,
"Food Dispensing"
,
"Food dispensing now
${DateFormat('kk:mm').format(DateTime.now()).toString()}
"
,
1
);
});
print
(
hours
+
mins
);
}
print
(
"start"
);
}
}
dispense
()
async
{
print
(
'start dispensing'
);
for
(
var
k
=
0
;
k
<
buckets
.
length
;
k
++)
{
final
servoref1
=
FirebaseDatabase
.
instance
.
ref
();
print
(
"servo run"
);
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
1
,
});
Future
.
delayed
(
const
Duration
(
seconds:
20
),
()
async
{
await
servoref1
.
update
({
"Food/"
+
buckets
[
k
]
+
"/SERVO"
:
0
,
});
});
}
}
void
cancelSheduleTask
()
async
{
if
(
scheduledTask
!=
null
)
{
scheduledTask
.
cancel
();
...
...
@@ -308,9 +392,10 @@ class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
gettimelist
()
async
{
SharedPreferences
timelist
=
await
SharedPreferences
.
getInstance
();
setState
(()
{
timeList
=
timelist
.
getStringList
(
"timelist"
);
scheduleDispens
();
});
if
(
mounted
)
{
setState
(()
{
timeList
=
timelist
.
getStringList
(
"timelist"
);
});
}
}
}
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