diff options
| author | Rishi-k-s <rishikrishna.sr@gmail.com> | 2021-08-18 11:59:31 +0530 |
|---|---|---|
| committer | Rishi-k-s <rishikrishna.sr@gmail.com> | 2021-08-18 11:59:31 +0530 |
| commit | 09618ff16421f55f465cddf89eff9e4edf5a7b17 (patch) | |
| tree | 03433b6caa0f42734d6fe887fd1e31470c583e74 | |
| parent | 56daf49aee4eb3347eca7b5fd7d55664d111f496 (diff) | |
| -rw-r--r-- | lib/CheckDocPatient.dart | 1 | ||||
| -rw-r--r-- | lib/auth/RegisterPage.dart | 75 | ||||
| -rw-r--r-- | lib/main_UI/Doctor/doctorDashboard.dart | 5 | ||||
| -rw-r--r-- | lib/main_UI/Patient/PatientDashboard.dart | 1 | ||||
| -rw-r--r-- | lib/main_UI/Patient/PatientDetails.dart | 33 | ||||
| -rw-r--r-- | lib/main_UI/Patient/searchDoc.dart | 64 | ||||
| -rw-r--r-- | lib/services/authService.dart | 4 | ||||
| -rw-r--r-- | lib/services/database.dart | 53 |
8 files changed, 224 insertions, 12 deletions
diff --git a/lib/CheckDocPatient.dart b/lib/CheckDocPatient.dart index c7d1071..2b793a8 100644 --- a/lib/CheckDocPatient.dart +++ b/lib/CheckDocPatient.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:healthtastic/auth/LoginPage.dart'; import 'package:healthtastic/main_UI/Patient/PatientDashboard.dart'; import 'package:healthtastic/main_UI/Doctor/doctorDashboard.dart'; +import 'package:healthtastic/main_UI/Patient/PatientDetails.dart'; import 'package:healthtastic/services/authService.dart'; import 'package:healthtastic/services/database.dart'; diff --git a/lib/auth/RegisterPage.dart b/lib/auth/RegisterPage.dart index ed1fb06..82faa57 100644 --- a/lib/auth/RegisterPage.dart +++ b/lib/auth/RegisterPage.dart @@ -19,12 +19,14 @@ class _RegisterPageState extends State<RegisterPage> { String error = ''; String email = ''; String name = ''; - String? role; + String type = ''; + String minCost = ''; + String role = 'Patient'; String aadhaar = ''; String password = ''; - String dropdownValue = 'Patient'; bool hiddenPassword = true; bool loading = false; + bool docVisibility = false; void _togglePasswordView() { setState(() { @@ -64,7 +66,7 @@ class _RegisterPageState extends State<RegisterPage> { setState(() => name = val); }, decoration: InputDecoration( - prefixIcon: Icon(Icons.email), + prefixIcon: Icon(Icons.person_add), hintText: 'Name', hintStyle: commontextstyle, fillColor: Colors.white, @@ -128,7 +130,6 @@ class _RegisterPageState extends State<RegisterPage> { setState(() => aadhaar = val); }, decoration: InputDecoration( - prefixIcon: Icon(Icons.email), hintText: 'Enter your Aadhaar number', hintStyle: commontextstyle, fillColor: Colors.white, @@ -140,7 +141,7 @@ class _RegisterPageState extends State<RegisterPage> { height: 10.0, ), DropdownButton<String>( - value: dropdownValue, + value: role, icon: const Icon(Icons.arrow_downward), iconSize: 24, elevation: 16, @@ -151,7 +152,16 @@ class _RegisterPageState extends State<RegisterPage> { ), onChanged: (String? newValue) { setState(() { - dropdownValue = newValue!; + role = newValue!; + if (newValue == 'Patient') { + setState(() { + docVisibility = false; + }); + } else { + setState(() { + docVisibility = true; + }); + } }); }, items: <String>['Patient', 'Doctor'].map<DropdownMenuItem<String>>((String value) { @@ -161,6 +171,51 @@ class _RegisterPageState extends State<RegisterPage> { ); }).toList(), ), + Visibility( + visible: docVisibility, + child: Container( + child: Column( + children: [ + Container( + // height: 56.9, + child: TextFormField( + keyboardType: TextInputType.text, + style: commontextstyle, + validator: (val) => val!.isEmpty ? 'Required' : null, + onChanged: (val) { + setState(() => type = val); + }, + decoration: InputDecoration( + hintText: 'Speciality', + hintStyle: commontextstyle, + fillColor: Colors.white, + filled: true, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + // height: 56.9, + child: TextFormField( + keyboardType: TextInputType.numberWithOptions(), + style: commontextstyle, + validator: (val) => val!.isEmpty ? 'Required' : null, + onChanged: (val) { + setState(() => minCost = val); + }, + decoration: InputDecoration( + hintText: 'Minimum fees', + hintStyle: commontextstyle, + fillColor: Colors.white, + filled: true, + ), + ), + ), + ], + ), + )), SizedBox( height: 17.0, ), @@ -176,7 +231,13 @@ class _RegisterPageState extends State<RegisterPage> { if (_formKey.currentState!.validate()) { setState(() => loading = true); dynamic result = await _auth.registerWithEmailPasswordStudent( - email: email, password: password, aadar: aadhaar, name: name, role: role); + email: email, + password: password, + aadar: aadhaar, + name: name, + role: role, + docType: type, + minCost: 'Rs.' + minCost); if (result == null) { setState(() { loading = false; diff --git a/lib/main_UI/Doctor/doctorDashboard.dart b/lib/main_UI/Doctor/doctorDashboard.dart index 47c597e..6928bce 100644 --- a/lib/main_UI/Doctor/doctorDashboard.dart +++ b/lib/main_UI/Doctor/doctorDashboard.dart @@ -1,6 +1,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:healthtastic/gogl%20cal/calDatabase.dart'; +import 'package:healthtastic/main_UI/Doctor/DocDetails.dart'; import 'package:healthtastic/main_UI/Patient/PatientDetails.dart'; import 'package:healthtastic/main_UI/Patient/createP2P.dart'; import 'package:healthtastic/models/calModel.dart'; @@ -27,7 +28,7 @@ class _DoctorDashboardState extends State<DoctorDashboard> { elevation: 0, backgroundColor: Colors.white, iconTheme: IconThemeData( - color: Colors.grey, //change your color here + color: Colors.grey, ), title: Text( 'Event Details', @@ -250,7 +251,7 @@ class _DoctorDashboardState extends State<DoctorDashboard> { if (index == 2) { Navigator.of(context).push( MaterialPageRoute( - builder: (context) => PatientDetalsScreen(), + builder: (context) => DoctorDetailsPage(), ), ); } diff --git a/lib/main_UI/Patient/PatientDashboard.dart b/lib/main_UI/Patient/PatientDashboard.dart index 8eb0273..d578958 100644 --- a/lib/main_UI/Patient/PatientDashboard.dart +++ b/lib/main_UI/Patient/PatientDashboard.dart @@ -4,6 +4,7 @@ import 'package:healthtastic/common/textstyles.dart'; import 'package:healthtastic/gogl%20cal/calDatabase.dart'; import 'package:healthtastic/main_UI/Patient/PatientDetails.dart'; import 'package:healthtastic/main_UI/Patient/createP2P.dart'; +import 'package:healthtastic/main_UI/Patient/searchDoc.dart'; import 'package:healthtastic/models/calModel.dart'; import 'package:healthtastic/services/authService.dart'; import 'package:healthtastic/gogl%20cal/calhelper.dart'; diff --git a/lib/main_UI/Patient/PatientDetails.dart b/lib/main_UI/Patient/PatientDetails.dart index 8aedac3..e2d0d3e 100644 --- a/lib/main_UI/Patient/PatientDetails.dart +++ b/lib/main_UI/Patient/PatientDetails.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:healthtastic/common/textstyles.dart'; import 'package:healthtastic/main_UI/Patient/PatientDashboard.dart'; import 'package:healthtastic/main_UI/Patient/createP2P.dart'; import 'package:healthtastic/services/authService.dart'; @@ -12,8 +13,13 @@ class PatientDetalsScreen extends StatefulWidget { } class _PatientDetalsScreenState extends State<PatientDetalsScreen> { - int _currentIndex = 2; + String? name; + String? aadaar; + String? allergies; + String? history; + int _currentIndex = 2; + final _formKey = GlobalKey<FormState>(); @override Widget build(BuildContext context) { return Scaffold( @@ -32,6 +38,31 @@ class _PatientDetalsScreenState extends State<PatientDetalsScreen> { SizedBox( height: 20.0, ), + Form( + key: _formKey, + child: (Column( + children: [ + TextFormField( + keyboardType: TextInputType.emailAddress, + style: commontextstyle, + validator: (val) => val!.isEmpty ? 'Required' : null, + onChanged: (val) { + setState(() => name = val); + }, + decoration: InputDecoration( + prefixIcon: Icon(Icons.email), + hintText: 'Name', + hintStyle: commontextstyle, + fillColor: Colors.white, + filled: true, + ), + ), + SizedBox( + height: 10, + ), + Text('$aadaar') + ], + ))) ], ), ); diff --git a/lib/main_UI/Patient/searchDoc.dart b/lib/main_UI/Patient/searchDoc.dart new file mode 100644 index 0000000..58e7e02 --- /dev/null +++ b/lib/main_UI/Patient/searchDoc.dart @@ -0,0 +1,64 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:googleapis/compute/v1.dart'; +import 'package:googleapis/serviceconsumermanagement/v1.dart'; +import 'package:healthtastic/main_UI/Patient/createP2P.dart'; +import 'package:provider/provider.dart'; +import 'package:healthtastic/services/database.dart'; + +class SearchDoctors extends StatefulWidget { + const SearchDoctors({Key? key}) : super(key: key); + + @override + _SearchDoctorsState createState() => _SearchDoctorsState(); +} + +class _SearchDoctorsState extends State<SearchDoctors> { + List doctorProfileList = []; + + @override + void initState() { + // TODO: implement initState + super.initState(); + fetchDoctorList(); + } + + fetchDoctorList() async { + dynamic result = await DocDetals().getUserDetals(); + + if (result == null) { + print('No doctors in your area'); + } else { + setState(() { + doctorProfileList = result; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(), + body: Container( + child: ListView.builder( + itemCount: doctorProfileList.length, + itemBuilder: (context, index) { + return Card( + child: ListTile( + title: Text(doctorProfileList[index]['name']), + subtitle: Text(doctorProfileList[index]['type']), + trailing: Text(doctorProfileList[index]['minCost']), + ), + ); + }), + ), + floatingActionButton: FloatingActionButton(onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => CreateAppoin(), + ), + ); + }), + ); + } +} diff --git a/lib/services/authService.dart b/lib/services/authService.dart index 16380ad..ddc58fc 100644 --- a/lib/services/authService.dart +++ b/lib/services/authService.dart @@ -30,13 +30,15 @@ class AuthService { String? name, String? aadar, String? role, + String? docType, + String? minCost, }) async { FirebaseAuth auth = FirebaseAuth.instance; final User? user = auth.currentUser; try { UserCredential result = await _auth.createUserWithEmailAndPassword(email: email!, password: password!); - await UserHelper(uid: result.user!.uid).addUserRegisToFirebase(name!, email, aadar!, result.user!.uid, role!); + await UserHelper(uid: result.user!.uid).addUserRegisToFirebase(name!, email, aadar!, result.user!.uid, role!, docType!, minCost!); // add role to firebase return 'SignedUp'; } on FirebaseAuthException catch (e) { diff --git a/lib/services/database.dart b/lib/services/database.dart index c160111..fe6cdbb 100644 --- a/lib/services/database.dart +++ b/lib/services/database.dart @@ -11,14 +11,19 @@ class UserHelper { static FirebaseAuth auth = FirebaseAuth.instance; static FirebaseFirestore _database = FirebaseFirestore.instance; + final CollectionReference userCollection = _database.collection('users'); - Future<void> addUserRegisToFirebase(String name, String email, String aadar, String uid, String role) async { + Future<void> addUserRegisToFirebase(String name, String email, String aadar, String uid, String role, String docType, String minCost) async { + final User user = auth.currentUser!; + final uid = user.uid; return await _database.collection('users').doc(uid).set({ "name": name, "email": email, "uid": uid, "aadar": aadar, "Role": role, + "type": docType, + "minCost": minCost, }); } @@ -49,8 +54,54 @@ class UserHelper { print('uvvvvvv +$uidList'); return uidList; } catch (e) { + print(e); print('uvvvvvv + null'); return null; } } + + // Stream<QuerySnapshot> get doctors { + // return userCollection.snapshots(); + // } + + // Future getUserDetals() async { + // List itemsList = []; + // try { + // await userCollection.get().then((querySnapshot) { + // querySnapshot.docs.forEach((element) { + // if(element.data()!['']){} + // itemsList.add(element.data()); + // }); + // }); + // } catch (e) { + // print(e.toString()); + // return null; + // } + // } + +} + +class DocDetals { + static FirebaseAuth auth = FirebaseAuth.instance; + static FirebaseFirestore _database = FirebaseFirestore.instance; + final CollectionReference userCollection = _database.collection('users'); + + Future getUserDetals() async { + List itemsList = []; + try { + await userCollection.get().then((QuerySnapshot querySnapshot) { + querySnapshot.docs.forEach((doc) { + if (doc['Role'] == 'Doctor') { + itemsList.add(doc.data()); + } else { + itemsList.add('NoDoc'); + } + }); + }); + return itemsList; + } catch (e) { + print(e.toString()); + return null; + } + } } |
