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
b6fffd4e
Commit
b6fffd4e
authored
Nov 14, 2022
by
Yasasdissanayake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
fd8faf69
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
184 deletions
+0
-184
lib/Screens/AB/water.dart
lib/Screens/AB/water.dart
+0
-184
No files found.
lib/Screens/AB/water.dart
deleted
100644 → 0
View file @
fd8faf69
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: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/data.dart'
;
import
'package:ifarm/functions/firebaseFunctions.dart'
;
class
waterbuckets
extends
StatefulWidget
{
waterbuckets
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
waterbuckets
>
createState
()
=>
_foodbucketsState
();
}
String
name
=
""
;
final
firebasedatalist
=
FirebaseDatabase
.
instance
;
var
getResult
=
'QR Code Result'
;
List
buckets
=
[];
class
_foodbucketsState
extends
State
<
waterbuckets
>
{
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
final
Stream
<
QuerySnapshot
>
bucketref
=
FirebaseFirestore
.
instance
.
collection
(
'buckets'
).
snapshots
();
return
Scaffold
(
backgroundColor:
const
Color
(
0xff024F8E
),
appBar:
AppBar
(
backgroundColor:
const
Color
(
0xff024F8E
),
elevation:
0
,
),
body:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
15
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
'Water'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontWeight:
FontWeight
.
bold
,
fontSize:
40
),
),
const
SizedBox
(
height:
20
,
),
Expanded
(
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
());
}
final
storedata
=
[];
snapshot
.
data
!.
docs
.
map
((
DocumentSnapshot
document
)
{
Map
a
=
document
.
data
()
as
Map
<
String
,
dynamic
>;
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
,
itemBuilder:
(
context
,
index
)
{
return
GestureDetector
(
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
datafromfirebase
(
bucketId:
storedata
[
0
][
'Buckets'
]
[
index
],
)));
},
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
15
)),
margin:
const
EdgeInsets
.
symmetric
(
vertical:
5
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20
,
horizontal:
25
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
Text
(
'Bucket :'
,
style:
TextStyle
(
color:
Colors
.
black
,
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
,
)
],
),
),
);
});
},
))
],
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{
scanQRCode
();
},
backgroundColor:
Colors
.
white
,
child:
const
Icon
(
Icons
.
add
,
color:
Color
(
0xff024F8E
),
),
),
);
}
void
scanQRCode
()
async
{
try
{
final
qrCode
=
await
FlutterBarcodeScanner
.
scanBarcode
(
'#ff6666'
,
'Cancel'
,
true
,
ScanMode
.
QR
);
if
(!
mounted
)
return
;
setState
(()
{
getResult
=
qrCode
;
if
(
buckets
.
contains
(
qrCode
)
||
qrCode
==
'-1'
)
{
}
else
{
buckets
.
add
(
qrCode
);
saveQRCodes
();
}
});
print
(
"QRCode_Result:-"
);
print
(
qrCode
);
}
on
PlatformException
{
getResult
=
'Failed to scan QR Code.'
;
}
}
saveQRCodes
()
{
final
user
=
FirebaseAuth
.
instance
.
currentUser
;
if
(
user
!=
null
)
{
setState
(()
{
name
=
user
.
displayName
.
toString
();
});
}
FirestoreServices
.
savefoodbuckets
(
buckets
,
name
);
}
}
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