From 74575c384f3bc7c4d2123cd00e9cae0cb362ba67 Mon Sep 17 00:00:00 2001 From: anishsreenivas82 <77966360+anishsreenivas82@users.noreply.github.com> Date: Fri, 30 Jul 2021 20:46:00 +0530 Subject: [PATCH] final working --- lib/pages/verification.dart | 412 +++++++++++++++++----------------- lib/pages/volunteer_page.dart | 146 +++++++----- 2 files changed, 299 insertions(+), 259 deletions(-) diff --git a/lib/pages/verification.dart b/lib/pages/verification.dart index 621535b..ce9c75e 100644 --- a/lib/pages/verification.dart +++ b/lib/pages/verification.dart @@ -1,3 +1,7 @@ + + + + import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -7,11 +11,11 @@ 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; +String qr_code; +var tee; -int x = 0; var name, type, quantity, babyproduct; class VerifcationPage extends StatefulWidget { @@ -22,253 +26,255 @@ class VerifcationPage extends StatefulWidget { } class _VerifcationPageState extends State { - int radio1; int radio2; int radio3; - int i =0 ; - int x = 0; - + int i = 0; + @override void initState() { // TODO: implement initState super.initState(); radio1 = 0; radio2 = 0; - radio3=0; - i =0 ; - + radio3 = 0; + i = 0; + name = ""; + type = ""; + quantity = ""; + babyproduct = ""; + qrscan(); } - // setRadio(value) { - // setState(() { - // radio = value; - // }); - // } + + + + Future getUserInfo() async + { + + +return await FirebaseFirestore.instance.collection("Owners").doc(uid).collection('items').doc(doc).get(); + + } + @override Widget build(BuildContext context) { - + + CollectionReference a = FirebaseFirestore.instance.collection('Shelter'); CollectionReference b = FirebaseFirestore.instance.collection('Owners'); - - if(x==0){qrscan();} doc = qr_code.substring(0, 20); - uid = qr_code.substring(20, qr_code.length); - - // for(int i=0;i<20;i++) - // { - // doc = ''+qrcode[i]; - // } - // for(int i=20;i<48;i++) - // { - // uid = ''+qrcode[i]; - // } - - final 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'); - }); - + uid = qr_code.substring(20); print(qr_code); - TextButton button; - // if(i<3) button = TextButton(onPressed: (){}, child: Text('Reject')); - // if(i>=3) button = TextButton(onPressed: (){}, child: Text('Accept')); + print(doc); + print(name); + print(type); + double width = MediaQuery.of(context).size.width; + double height = MediaQuery.of(context).size.height; - TextButton(onPressed: (){}, child: Text('Accept')); - double width =MediaQuery.of(context).size.width; - return Scaffold( + + return FutureBuilder( + future: getUserInfo(), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + + + return Scaffold( + backgroundColor: Colors.amber[100], appBar: AppBar( - backgroundColor: Colors.blue, + backgroundColor: Colors.black, title: Text('VerifcationPage'), centerTitle: true, ), body: SingleChildScrollView( - child: Column( - children: [ - Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - 'Name', - style: TextStyle(fontSize: 15), - ), - Text( - name, - style: TextStyle(fontSize: 15), - ), - ]), - Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - 'Type', - style: TextStyle(fontSize: 15), - ), - Text( - type, - style: TextStyle(fontSize: 15), - ), - ]), - Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - 'Quantity', - style: TextStyle(fontSize: 15), - ), - Text( - quantity, - style: TextStyle(fontSize: 15), - ), - ]), - Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - 'Baby Product', - style: TextStyle(fontSize: 15), - ), - Text( - babyproduct, - style: TextStyle(fontSize: 15), - ), - ]), - - SizedBox(height:20), - - Row(children: [ - Container(child: Wrap(children: [Text('Are the products sealed?')]),width: width*0.6), + child: Column(children: [ + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Text( + 'Name', + style: TextStyle(fontSize: 22), + ), + Text('-',style: TextStyle(fontSize: 25),), + Text( + snapshot.data['Name'], + style: TextStyle(fontSize: 22), + ), + ]), + SizedBox(height: height*0.05), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Text( + 'Type', + style: TextStyle(fontSize: 22), + ), + Text('-',style: TextStyle(fontSize: 25),), + Text( + snapshot.data['Type'], + style: TextStyle(fontSize: 22), + ), + ]), + SizedBox(height: height*0.05), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Text( + 'Quantity', + style: TextStyle(fontSize: 22), + ),Text('-',style: TextStyle(fontSize: 25),), + Text( + snapshot.data['Quantity'], + style: TextStyle(fontSize: 22), + ), + ]), + SizedBox(height: height*0.05), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Text( + 'Baby Product', + style: TextStyle(fontSize: 22), + ),Text('-',style: TextStyle(fontSize: 25),), + Text( + snapshot.data['Baby'], + style: TextStyle(fontSize: 22), + ), + ]), + + SizedBox(height: 20), + Divider(height: 3,color: Colors.black,), + + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Wrap(children: [Text('Are the products sealed?',style: TextStyle(fontSize: 18),)]), + width: width * 0.8), Radio( value: 1, groupValue: radio1, onChanged: (value) { - setState(() { - radio1 = value; - - i++; - }); - - } - ) - - ],), - SizedBox(height:20), - - Row(children: [ - Container(child: Wrap(children: [Text('Do the products have atleast 2 weeks before expiry')]),width: width*0.6), + setState(() { + radio1 = value; + + i++; + }); + }) + ], + ), + SizedBox(height: 20), + + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Wrap(children: [ + Text('Do the products have atleast 2 weeks before expiry?',style: TextStyle(fontSize: 18),) + ]), + width: width * 0.8), Radio( value: 2, groupValue: radio2, onChanged: (value) { setState(() { radio2 = value; - i++; + i++; }); - - - } - ) - ],), - SizedBox(height:20), + }) + ], + ), + SizedBox(height: 20), - - Row(children: [ - Container(child: Wrap(children: [Text('Do the products match the description above')]),width: width*0.6), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + child: Wrap(children: [ + Text('Do the products match the description above?',style: TextStyle(fontSize: 18),) + ]), + width: width * 0.8), Radio( value: 3, groupValue: radio3, onChanged: (value) { - setState(() { - radio3 = value; - i++; - }); - - } - ) - ],), - SizedBox(height:20), - - Row(children: [ - TextButton(onPressed: (){ a.doc('donations').collection('donations').doc(doc).set({ - 'Name': name, - 'Type': type, - 'Quantity': quantity, - 'Baby': babyproduct, - 'Status': 'Verified', - }); - b.doc(uid).collection('verified items').doc(doc).set({ - 'Name': name, - 'Type': type, - 'Quantity': quantity, - 'Baby': babyproduct, - 'Status': 'Verified', - }); - - b.doc(uid).collection('items').doc(doc).delete(); - Navigator.push(context, - MaterialPageRoute(builder: (context) => Volunteer())); - - }, child: Text('Accept')), - TextButton(onPressed: (){ - b.doc(uid).collection('items').doc(doc).delete(); - Navigator.push(context, - MaterialPageRoute(builder: (context) => Volunteer())); - }, child: Text('Reject')) - ],) - - - - - // Text('Do the products have more than 2 weeks of time before expiry?'), - // Text('Does the product match the description?') + setState(() { + radio3 = value; + i++; + }); + }) + ], + ), + SizedBox(height: 20), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: () { + a.doc('donations').collection('donations').doc(doc).set({ + 'Name': name, + 'Type': type, + 'Quantity': quantity, + 'Baby': babyproduct, + 'Status': 'Verified', + }); + b.doc(uid).collection('verified items').doc(doc).set({ + 'Name': name, + 'Type': type, + 'Quantity': quantity, + 'Baby': babyproduct, + 'Status': 'Verified', + }); + + b.doc(uid).collection('items').doc(doc).delete(); + Navigator.push(context, + MaterialPageRoute(builder: (context) => Volunteer())); + }, + child: Text('Accept',style: TextStyle(fontSize: 25,color: Colors.green),)), + TextButton( - // ]), - // ), - // Column(children: [ - // Radio( - // value: 1, - // groupValue: 0, - // onChanged: (value) { - // setRadio(); - // i++; - // }), - // Radio( - // value: 1, - // groupValue: 0, - // onChanged: (value) { - // setRadio(); - // i++; - // }), - // Radio( - // value: 1, - // groupValue: 0, - // onChanged: (value) { - // setRadio(); - // i++; - // }) - // ],) - // ]), - - - - - - ]), + onPressed: () { + b.doc(uid).collection('items').doc(doc).delete(); + Navigator.push(context, + MaterialPageRoute(builder: (context) => Volunteer())); + }, + child: Text('Reject',style: TextStyle(fontSize: 25,color: Colors.red),)) + ], + ) + + + ]), ), - ); + ) ; + } else if (snapshot.connectionState == ConnectionState.none) { + return Text("No data"); + } + return CircularProgressIndicator(); + }, + ); + + + + + + + } - -} -Future qrscan() async { - try { - qr_code = await FlutterBarcodeScanner.scanBarcode( - '#ff6666', 'Cancel', true, ScanMode.QR); - x=1; - } on PlatformException { - qr_code = 'Error'; + Future qrscan() async { + try { + qr_code = await FlutterBarcodeScanner.scanBarcode( + '#ff6666', 'Cancel', true, ScanMode.QR); + setState(() { + return; + }); + + + } on PlatformException { + qr_code = 'Error'; + } } } + + + + + + diff --git a/lib/pages/volunteer_page.dart b/lib/pages/volunteer_page.dart index e5ad052..5ce139a 100644 --- a/lib/pages/volunteer_page.dart +++ b/lib/pages/volunteer_page.dart @@ -14,6 +14,20 @@ class Volunteer extends StatefulWidget { class _VolunteerState extends State { Future x; + // PageController _pageController; + + + // @override + // void initState() { + // super.initState(); + // _pageController = PageController(); + // } + + // @override + // void dispose() { + // _pageController.dispose(); + // super.dispose(); + // } @@ -25,67 +39,87 @@ class _VolunteerState extends State { MaterialPageRoute(builder: (context) => VerifcationPage()));})]),Text('r'),Text('r')]; return Scaffold( - appBar: AppBar( - title: Text('My Flutter App'), - ), - drawer: Drawer( - child: ListView( - padding: EdgeInsets.zero, - children: [ - DrawerHeader( - child: Text('Here 4 Hygiene'), - decoration: BoxDecoration(color: Colors.blue), - ), - ListTile( - title: Text('Location'), - leading: Icon(Icons.map_outlined), - ), - ListTile( - title: Text('Logout'), - leading: Icon(Icons.logout), - onTap: (){ FirebaseAuth.instance.signOut(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SplashScreen()));} - ) - ], + backgroundColor: Colors.amber[100], + appBar: AppBar( + title: Text('My Flutter App'), + ), + drawer: Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + DrawerHeader( + child: Text('Here 4 Hygiene'), + decoration: BoxDecoration(color: Colors.blue), ), - ), - body: children[currentindex], // new - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - backgroundColor: Colors.blue, - // new - currentIndex: currentindex, // new - items: [ - new BottomNavigationBarItem( - icon: Icon(Icons.home), - label: ('Stats'), - ), - new BottomNavigationBarItem( - icon: Icon(Icons.mail), - label: ('QR Scan'), - ), - new BottomNavigationBarItem( - icon: Icon(Icons.person), - label: ('Previous Ver') - ), - new BottomNavigationBarItem( - icon: Icon(Icons.person), - label: ('Pending ver') - ) - ], - onTap: (index){ - setState(() { - currentindex = index; - }); - }, + ListTile( + title: Text('Location'), + leading: Icon(Icons.map_outlined), + ), + ListTile( + title: Text('Logout'), + leading: Icon(Icons.logout), + onTap: (){ FirebaseAuth.instance.signOut(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SplashScreen()));} + ) + ], + ), + ), + body: children[currentindex], // new + bottomNavigationBar: BottomNavigationBar( + type: BottomNavigationBarType.fixed, + backgroundColor: Colors.black, + selectedItemColor: Colors.amber[200], + unselectedItemColor: Colors.amber[100], + // new + currentIndex: currentindex, // new + items: [ + new BottomNavigationBarItem( + icon: Icon(Icons.pending), + label: ('Peding'), + ), + new BottomNavigationBarItem( + icon: Icon(Icons.qr_code_scanner), + label: ('QR Scan'), ), - ); + // new BottomNavigationBarItem( + // icon: Icon(Icons.person), + // label: ('Previous Ver') + // ), + // new BottomNavigationBarItem( + // icon: Icon(Icons.person), + // label: ('Pending ver') + // ) + ], + onTap: (index){ + setState(() { + currentindex = index; + + // _pageController.animateToPage(index, + // duration: Duration(milliseconds: 500), curve: Curves.easeOut); + }); + }, + ), + ); } + +// void _onItemTapped(int index) { +// setState(() { +// currentindex = index; +// // +// // +// //using this page controller you can make beautiful animation effects +// _pageController.animateToPage(index, +// duration: Duration(milliseconds: 500), curve: Curves.easeOut); +// }); +// } } + + + // var qrcode = ''; // Future qrscan() async{ // try {