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
fd8faf69
Commit
fd8faf69
authored
Nov 14, 2022
by
Yasasdissanayake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final
parent
2d7ffda0
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
240 additions
and
150 deletions
+240
-150
lib/Screens/AB/Home.dart
lib/Screens/AB/Home.dart
+2
-5
lib/Screens/AB/NetworkErrorPage.dart
lib/Screens/AB/NetworkErrorPage.dart
+0
-57
lib/Screens/AB/QRCodeScanner.dart
lib/Screens/AB/QRCodeScanner.dart
+0
-53
lib/Screens/AB/SplashScreen.dart
lib/Screens/AB/SplashScreen.dart
+1
-1
lib/Screens/Yasas/WaterBucket.dart
lib/Screens/Yasas/WaterBucket.dart
+16
-0
lib/Screens/Yasas/WaterFirebaselist.dart
lib/Screens/Yasas/WaterFirebaselist.dart
+2
-2
lib/Screens/Yasas/Waterdata.dart
lib/Screens/Yasas/Waterdata.dart
+196
-0
lib/Screens/Yasas/water.dart
lib/Screens/Yasas/water.dart
+23
-32
No files found.
lib/Screens/AB/Home.dart
View file @
fd8faf69
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:ifarm/Screens/AB/Food.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
...
...
@@ -116,10 +116,7 @@ class _HomeState extends State<Home> {
child:
GestureDetector
(
onTap:
foodswitch
?
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
foodbuckets
()));
}
:
null
,
child:
Container
(
...
...
lib/Screens/AB/NetworkErrorPage.dart
deleted
100644 → 0
View file @
2d7ffda0
import
'package:flutter/material.dart'
;
import
'package:ifarm/Screens/AB/SplashScreen.dart'
;
class
networkError
extends
StatefulWidget
{
networkError
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
networkError
>
createState
()
=>
_networkErrorState
();
}
class
_networkErrorState
extends
State
<
networkError
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
automaticallyImplyLeading:
false
,
elevation:
0
,
backgroundColor:
Color
(
0xffE2E7ED
),
),
body:
Container
(
color:
Color
(
0xffE2E7ED
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Image
.
asset
(
'assets/images/error.jpg'
,
scale:
1
,
),
const
Text
(
'No Connection!'
,
style:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
70
,
70
,
70
),
fontSize:
20
),
),
const
SizedBox
(
height:
20
,
),
GestureDetector
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
splashScreen
()));
},
child:
Container
(
decoration:
BoxDecoration
(
color:
const
Color
(
0xffFEC427
),
borderRadius:
BorderRadius
.
circular
(
15
)),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20
,
horizontal:
25
),
child:
Text
(
'Try Again'
),
),
)
],
),
),
);
}
}
lib/Screens/AB/QRCodeScanner.dart
deleted
100644 → 0
View file @
2d7ffda0
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'
;
class
QRScanner
extends
StatefulWidget
{
QRScanner
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
QRScanner
>
createState
()
=>
_QRScannerState
();
}
var
getResult
=
'QR Code Result'
;
class
_QRScannerState
extends
State
<
QRScanner
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
ElevatedButton
(
onPressed:
()
{
scanQRCode
();
},
child:
const
Text
(
'Scan QR'
)),
const
SizedBox
(
height:
20.0
,
),
Text
(
getResult
),
],
),
));
}
void
scanQRCode
()
async
{
try
{
final
qrCode
=
await
FlutterBarcodeScanner
.
scanBarcode
(
'#ff6666'
,
'Cancel'
,
true
,
ScanMode
.
QR
);
if
(!
mounted
)
return
;
setState
(()
{
getResult
=
qrCode
;
});
print
(
"QRCode_Result:--"
);
print
(
qrCode
);
}
on
PlatformException
{
getResult
=
'Failed to scan QR Code.'
;
}
}
}
lib/Screens/AB/SplashScreen.dart
View file @
fd8faf69
...
...
@@ -5,7 +5,7 @@ import 'package:connectivity_plus/connectivity_plus.dart';
import
'package:flutter/material.dart'
;
import
'package:ifarm/Screens/AB/Login.dart'
;
import
'package:ifarm/Screens/AB/Navbar.dart'
;
import
'package:ifarm/Screens/AB/NetworkErrorPage.dart'
;
import
'package:ifarm/functions/Network.dart'
;
import
'package:provider/provider.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
...
...
lib/Screens/
AB/
Bucket.dart
→
lib/Screens/
Yasas/Water
Bucket.dart
View file @
fd8faf69
import
'package:cloud_firestore/cloud_firestore.dart'
;
class
Bucket
{
final
List
<
String
>?
bucketId
;
class
Water
Bucket
{
final
List
<
String
>?
water
bucketId
;
Bucket
({
this
.
bucketId
});
factory
Bucket
.
fromFirestore
(
WaterBucket
({
this
.
water
bucketId
});
factory
Water
Bucket
.
fromFirestore
(
DocumentSnapshot
<
Map
<
String
,
dynamic
>>
snapshot
,
)
{
final
data
=
snapshot
.
data
();
return
Bucket
(
bucketId:
data
?[
'Buckets'
]
is
Iterable
?
List
.
from
(
data
?[
'regions'
])
:
null
);
return
WaterBucket
(
waterbucketId:
data
?[
'WaterBuckets'
]
is
Iterable
?
List
.
from
(
data
?[
'regions'
])
:
null
);
}
}
lib/Screens/
AB/
Firebaselist.dart
→
lib/Screens/
Yasas/Water
Firebaselist.dart
View file @
fd8faf69
...
...
@@ -14,7 +14,7 @@ class _firebaselistState extends State<firebaselist> {
@override
Widget
build
(
BuildContext
context
)
{
Query
ref
=
firebasedatalist
.
ref
().
child
(
'
Food
'
);
Query
ref
=
firebasedatalist
.
ref
().
child
(
'
Water
'
);
return
Scaffold
(
appBar:
AppBar
(
...
...
@@ -51,7 +51,7 @@ class _firebaselistState extends State<firebaselist> {
onPressed:
()
{
firebasedatalist
.
ref
()
.
child
(
'
Food
'
)
.
child
(
'
Water
'
)
.
child
(
snapshot
.
key
!)
.
remove
();
},
...
...
lib/Screens/Yasas/Waterdata.dart
0 → 100644
View file @
fd8faf69
import
'dart:async'
;
import
'package:animated_toggle_switch/animated_toggle_switch.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:liquid_progress_indicator/liquid_progress_indicator.dart'
;
import
'package:switcher_button/switcher_button.dart'
;
class
datafromfirebasewater
extends
StatefulWidget
{
datafromfirebasewater
({
Key
?
key
,
})
:
super
(
key:
key
);
@override
State
<
datafromfirebasewater
>
createState
()
=>
_datafromfirebasewaterState
();
}
String
p
=
'100'
;
String
ph
=
'250'
;
class
_datafromfirebasewaterState
extends
State
<
datafromfirebasewater
>
{
@override
void
initState
()
{
super
.
initState
();
getData
();
runTimer
();
}
Timer
?
timer
;
void
runTimer
()
{
timer
=
Timer
.
periodic
(
const
Duration
(
seconds:
2
),
(
_
)
{
getData
();
});
}
getData
()
{
FirebaseDatabase
.
instance
.
ref
().
child
(
'Water/ph'
).
onValue
.
listen
((
event
)
{
setState
(()
{
ph
=
event
.
snapshot
.
value
.
toString
();
});
});
FirebaseDatabase
.
instance
.
ref
()
.
child
(
'Water/percentage'
)
.
onValue
.
listen
((
event
)
{
setState
(()
{
p
=
event
.
snapshot
.
value
.
toString
();
});
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
leading:
IconButton
(
icon:
const
Icon
(
Icons
.
arrow_back
,
color:
Colors
.
white
),
onPressed:
()
{
Navigator
.
pop
(
context
);
timer
!.
cancel
();
},
),
backgroundColor:
const
Color
(
0xff024F8E
),
elevation:
0
,
),
backgroundColor:
const
Color
(
0xff024F8E
),
body:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
SizedBox
(
height:
40
,
),
const
Text
(
'Bucket'
,
style:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
fontSize:
30
,
fontFamily:
'poppins'
,
fontWeight:
FontWeight
.
bold
),
),
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
,
vertical:
20
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
SizedBox
(
height:
100
,
width:
310
,
child:
LiquidLinearProgressIndicator
(
value:
double
.
parse
(
p
)
/
100
,
// Defaults to 0.5.
valueColor:
AlwaysStoppedAnimation
(
double
.
parse
(
p
)
>=
10.0
&&
double
.
parse
(
p
)
<=
90.0
?
Colors
.
green
:
Colors
.
red
,
),
backgroundColor:
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
borderRadius:
20
,
direction:
Axis
.
vertical
,
center:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
const
[
FaIcon
(
FontAwesomeIcons
.
fill
,
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
),
SizedBox
(
width:
10
,
),
Text
(
'Water Presentage'
,
style:
TextStyle
(
fontSize:
20
,
color:
Color
.
fromARGB
(
179
,
0
,
0
,
0
),
fontFamily:
'poppins'
,
),
),
],
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
p
,
style:
const
TextStyle
(
fontSize:
20
,
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
fontWeight:
FontWeight
.
bold
),
),
const
Text
(
'%'
,
style:
TextStyle
(
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
fontWeight:
FontWeight
.
bold
),
),
],
),
],
),
),
),
Card
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
15
)),
elevation:
2
,
color:
double
.
parse
(
ph
)
==
0
?
Colors
.
green
:
Colors
.
red
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Column
(
children:
[
const
SizedBox
(
height:
10
,
),
const
Text
(
'PH'
,
style:
TextStyle
(
fontSize:
20
,
color:
Colors
.
white70
,
fontFamily:
'poppins'
,
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
ph
,
style:
const
TextStyle
(
color:
Colors
.
white
,
fontSize:
40
,
fontFamily:
'poppins'
,
),
),
],
),
],
),
),
),
],
),
),
],
),
),
);
}
}
lib/Screens/
AB/Food
.dart
→
lib/Screens/
Yasas/water
.dart
View file @
fd8faf69
...
...
@@ -3,28 +3,28 @@ import 'dart:ffi';
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:firebase_auth/firebase_auth.dart'
;
import
'package:firebase_database/firebase_database.dart'
;
import
'package:firebase_database/ui/firebase_animated_list.dart'
;
//
import 'package:firebase_database/ui/firebase_animated_list.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'
;
import
'package:ifarm/Screens/AB/bucket.dart'
;
//
import 'package:ifarm/Screens/AB/bucket.dart';
import
'package:ifarm/Screens/AB/data.dart'
;
import
'package:ifarm/functions/firebaseFunctions.dart'
;
class
food
buckets
extends
StatefulWidget
{
food
buckets
({
Key
?
key
})
:
super
(
key:
key
);
class
water
buckets
extends
StatefulWidget
{
water
buckets
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
foodbuckets
>
createState
()
=>
_food
bucketsState
();
State
<
waterbuckets
>
createState
()
=>
_water
bucketsState
();
}
String
name
=
""
;
final
firebasedatalist
=
FirebaseDatabase
.
instance
;
var
getResult
=
'QR Code Result'
;
List
buckets
=
[];
List
buckets
=
[
1
];
class
_
foodbucketsState
extends
State
<
food
buckets
>
{
class
_
waterbucketsState
extends
State
<
water
buckets
>
{
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -33,7 +33,7 @@ class _foodbucketsState extends State<foodbuckets> {
@override
Widget
build
(
BuildContext
context
)
{
final
Stream
<
QuerySnapshot
>
bucketref
=
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
FirebaseFirestore
.
instance
.
collection
(
'
water
buckets'
).
snapshots
();
return
Scaffold
(
backgroundColor:
const
Color
(
0xff024F8E
),
...
...
@@ -47,7 +47,7 @@ class _foodbucketsState extends State<foodbuckets> {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
'
Food
'
,
'
Water
'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
...
...
@@ -74,17 +74,8 @@ class _foodbucketsState extends State<foodbuckets> {
storedata
.
add
(
a
);
}).
toList
();
return
storedata
[
0
][
'Buckets'
].
isEmpty
?
const
Center
(
child:
Text
(
'Add bucket'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
20
,
fontWeight:
FontWeight
.
bold
),
))
:
ListView
.
builder
(
itemCount:
storedata
[
0
][
'Buckets'
].
length
,
return
ListView
.
builder
(
itemCount:
storedata
[
0
][
'WaterBuckets'
].
length
,
itemBuilder:
(
context
,
index
)
{
return
GestureDetector
(
onTap:
()
{
...
...
@@ -92,8 +83,8 @@ class _foodbucketsState extends State<foodbuckets> {
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
datafromfirebase
(
bucketId:
storedata
[
0
]
[
'Buckets'
]
[
index
],
bucketId:
storedata
[
0
]
[
'WaterBuckets'
][
index
],
)));
},
child:
Container
(
...
...
@@ -137,16 +128,16 @@ class _foodbucketsState extends State<foodbuckets> {
],
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{
scanQRCode
();
},
backgroundColor:
Colors
.
white
,
child:
const
Icon
(
Icons
.
add
,
color:
Color
(
0xff024F8E
),
),
),
//
floatingActionButton: FloatingActionButton(
//
onPressed: () {
//
scanQRCode();
//
},
//
backgroundColor: Colors.white,
//
child: const Icon(
//
Icons.add,
//
color: Color(0xff024F8E),
//
),
//
),
);
}
...
...
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