Skip to content

Commit

Permalink
qr
Browse files Browse the repository at this point in the history
barely works
  • Loading branch information
pranavsrikanth committed Jul 30, 2021
1 parent c4b0583 commit dfd9559
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
22 changes: 12 additions & 10 deletions lib/pages/donor_dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Donor extends StatefulWidget {
class _DonorState extends State<Donor> {
@override
Widget build(BuildContext context) {
print(uidDonor);
return Scaffold(
appBar: AppBar(
title: Text("Dashboard"),
Expand All @@ -37,14 +38,13 @@ class _DonorState extends State<Donor> {
leading: Icon(Icons.map_outlined),
),
ListTile(
title: Text('Logout'),
leading: Icon(Icons.logout),
onTap: (){ FirebaseAuth.instance.signOut();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SplashScreen()));}
)
title: Text('Logout'),
leading: Icon(Icons.logout),
onTap: () {
FirebaseAuth.instance.signOut();
Navigator.push(context,
MaterialPageRoute(builder: (context) => SplashScreen()));
})
],
),
),
Expand Down Expand Up @@ -109,8 +109,10 @@ class _DonorState extends State<Donor> {
TextButton(
child: const Text('View'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Verified()));
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Verified()));
},
),
const SizedBox(width: 8),
Expand Down
40 changes: 22 additions & 18 deletions lib/pages/verification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import 'package:flutterlogindesign/pages/qr.dart';
import 'package:flutterlogindesign/pages/qrscan.dart';
import 'package:flutterlogindesign/pages/volunteer_page.dart';

String qr_code = '';
String doc;
String uid;

int x = 0;
String qr_code;
var name, type, quantity, babyproduct;

class VerifcationPage extends StatefulWidget {
Expand All @@ -26,7 +24,6 @@ class _VerifcationPageState extends State<VerifcationPage> {
int radio2;
int radio3;
int i = 0;
int x = 0;

@override
void initState() {
Expand All @@ -36,6 +33,10 @@ class _VerifcationPageState extends State<VerifcationPage> {
radio2 = 0;
radio3 = 0;
i = 0;
name = "";
type = "";
quantity = "";
babyproduct = "";
qrscan();
}

Expand All @@ -51,7 +52,7 @@ class _VerifcationPageState extends State<VerifcationPage> {
CollectionReference b = FirebaseFirestore.instance.collection('Owners');

doc = qr_code.substring(0, 20);
uid = qr_code.substring(20, qr_code.length);
uid = qr_code.substring(20);

// for(int i=0;i<20;i++)
// {
Expand All @@ -62,16 +63,20 @@ class _VerifcationPageState extends State<VerifcationPage> {
// uid = ''+qrcode[i];
// }

final info = FirebaseFirestore.instance
var info = FirebaseFirestore.instance
.collection('Owners')
.doc(uid)
.collection('items')
.doc(doc);
info.get().then((DocumentSnapshot documentSnapshot) {
name = documentSnapshot.get('Name');
type = documentSnapshot.get('Type');
quantity = documentSnapshot.get('Quantity');
babyproduct = documentSnapshot.get('Baby');
if (documentSnapshot.exists) {
name = documentSnapshot.get('Name').toString();
type = documentSnapshot.get('Type').toString();
quantity = documentSnapshot.get('Quantity').toString();
babyproduct = documentSnapshot.get('Baby').toString();
} else
CircularProgressIndicator();
print("here");
});

print(qr_code);
Expand Down Expand Up @@ -259,14 +264,13 @@ class _VerifcationPageState extends State<VerifcationPage> {
),
);
}
}

Future<void> qrscan() async {
try {
qr_code = await FlutterBarcodeScanner.scanBarcode(
'#ff6666', 'Cancel', true, ScanMode.QR);
x = 1;
} on PlatformException {
qr_code = 'Error';
Future<void> qrscan() async {
try {
qr_code = await FlutterBarcodeScanner.scanBarcode(
'#ff6666', 'Cancel', true, ScanMode.QR);
} on PlatformException {
qr_code = 'Error';
}
}
}

0 comments on commit dfd9559

Please sign in to comment.