diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 2192e01..18d328f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ + diff --git a/android/build.gradle b/android/build.gradle index f33eab0..ea855b6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/lib/Reports/add_reports.dart b/lib/Reports/add_reports.dart index 457d6b6..0d94aaf 100644 --- a/lib/Reports/add_reports.dart +++ b/lib/Reports/add_reports.dart @@ -32,9 +32,15 @@ class _AddReportsState extends State { List uiReportsImages = []; List uiPrescriptionImages = []; + Map findings={}; List images = []; String _error = 'No Error Dectected'; String apiMultiImages = ''; + String findingPictureId = ''; + String reportsPictureId = ''; + String prescriptionPictureId = ''; + Map reports={}; + Map prescriptions={}; String? prescriptionFor; String? gender; @@ -50,7 +56,10 @@ class _AddReportsState extends State { print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiFindingsImages = jsonDecode(res)['findings']; + uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings']; + findings=jsonDecode(res)['findingsPictureUpload']; + findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId']; + }); } @@ -64,12 +73,53 @@ class _AddReportsState extends State { print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiFindingsImages = jsonDecode(res)['findings']; + uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings']; + findings=jsonDecode(res)['findingsPictureUpload']; + findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId']; }); } on PlatformException catch (e) { print('Failed to pick image: $e'); } } + + Future pickImageFromGalleryForAddFindings() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.addFindingsGallery(imageFileList,findingPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings']; + findings=jsonDecode(res)['findingsPictureUpload']; + findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId']; + + }); + } + + Future takeImageFromCameraForAddFindings() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.addFindingsCamera(image,findingPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings']; + findings=jsonDecode(res)['findingsPictureUpload']; + findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + /*Future pickImageFromGalleryForUpdate() async { imageFileList = []; final List? selectedImages = await imagePicker.pickMultiImage(); @@ -109,11 +159,13 @@ class _AddReportsState extends State { if (image == null) return; final imageTemp = File(image.path); AppSettings.preLoaderDialog(context); - var res = await AppSettings.uploadImageForFindingsCamera(image); + var res = await AppSettings.uploadReportsCamera(image); print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiReportsImages = jsonDecode(res)['findings']; + uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports']; + reports=jsonDecode(res)['reportsPictureUpload']; + reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId']; }); } on PlatformException catch (e) { print('Failed to pick image: $e'); @@ -128,14 +180,55 @@ class _AddReportsState extends State { imageFileListReports.addAll(selectedImages); } - var res = await AppSettings.uploadImageForReports(imageFileListReports); + var res = await AppSettings.uploadReportsGallery(imageFileListReports); print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiReportsImages = jsonDecode(res)['reports']; + uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports']; + reports=jsonDecode(res)['reportsPictureUpload']; + reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId']; }); } + Future takeImageFromCameraForAddReports() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.addReportsCamera(image,reportsPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports']; + reports=jsonDecode(res)['reportsPictureUpload']; + reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForAddReports() async { + imageFileListReports = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileListReports.addAll(selectedImages); + } + + var res = await AppSettings.addReportsGallery(imageFileListReports,reportsPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports']; + reports=jsonDecode(res)['reportsPictureUpload']; + reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId']; + }); + } + + + Future takeImageFromCameraForPrescriptions() async { try { final image = await _picker.pickImage(source: ImageSource.camera); @@ -146,7 +239,11 @@ class _AddReportsState extends State { print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiPrescriptionImages = jsonDecode(res)['precription']; + + uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription']; + prescriptions=jsonDecode(res)['prescriptionsPictureUpload']; + prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId']; + }); } on PlatformException catch (e) { print('Failed to pick image: $e'); @@ -166,850 +263,943 @@ class _AddReportsState extends State { print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { - uiPrescriptionImages = jsonDecode(res)['prescription']; + uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription']; + prescriptions=jsonDecode(res)['prescriptionsPictureUpload']; + prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId']??''; }); } + Future takeImageFromCameraForAddPrescriptions() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.addPrescriptionsCamera(image,prescriptionPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription']; + prescriptions=jsonDecode(res)['prescriptionsPictureUpload']; + prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForAddPrescriptions() async { + imageFileListPrescriptions = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileListPrescriptions.addAll(selectedImages); + } + + var res = await AppSettings.addPrescriptionsGallery(imageFileListPrescriptions,prescriptionPictureId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription']; + prescriptions=jsonDecode(res)['prescriptionsPictureUpload']; + prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId']; + }); + } + + Future onWillPop() async { + final shouldPop = await showDialog(context: context, builder: (context) { + return AlertDialog( + title: const Text('Do you want to leave this page', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ); + }, + ); + return shouldPop!; + } + @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppSettings.appBar('Reports'), - body: SingleChildScrollView( - child: Container( - child: Padding( - padding: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: TextFormField( - cursorColor: greyColor, - controller: doctorNameController, - textCapitalization: TextCapitalization.words, - decoration: textFormFieldDecoration( - Icons.person, 'Enter Doctor name'), + return WillPopScope( + onWillPop: () async => onWillPop(), + child: Scaffold( + appBar: AppSettings.appBar('Reports'), + body: SingleChildScrollView( + child: Container( + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: TextFormField( + cursorColor: greyColor, + controller: doctorNameController, + textCapitalization: TextCapitalization.words, + decoration: textFormFieldDecoration( + Icons.person, 'Enter Doctor name'), + ), ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * .02, - ), - Container( - child: TextFormField( - cursorColor: greyColor, - controller: hospitalNameController, - textCapitalization: TextCapitalization.words, - decoration: textFormFieldDecoration( - Icons.location_city_outlined, 'Enter Hospital name'), + SizedBox( + height: MediaQuery.of(context).size.height * .02, ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * .02, - ), - Container( - child: TextFormField( - cursorColor: greyColor, - controller: problemController, - textCapitalization: TextCapitalization.words, - decoration: textFormFieldDecoration( - Icons.report_problem, 'Enter Problem'), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: hospitalNameController, + textCapitalization: TextCapitalization.words, + decoration: textFormFieldDecoration( + Icons.location_city_outlined, 'Enter Hospital name'), + ), ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * .02, - ), - Container( - child: TextFormField( - cursorColor: greyColor, - controller: dateInput, - decoration: textFormFieldDecoration( - Icons.calendar_today, 'Enter Date'), - readOnly: true, - onTap: () async { - DateTime? pickedDate = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(1950), - lastDate: DateTime.now(), - builder: (BuildContext context, Widget? child) { - return Theme( - data: ThemeData.dark().copyWith( - colorScheme: ColorScheme.dark( - primary: buttonColors, - onPrimary: Colors.white, - surface: buttonColors, - onSurface: Colors.white, - ), - dialogBackgroundColor: primaryColor, - ), - child: child!, - ); - }, - ); - - if (pickedDate != null) { - print( - pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 - String formattedDate = - DateFormat('dd-MM-yyyy').format(pickedDate); - print( - formattedDate); //formatted date output using intl package => 2021-03-16 - setState(() { - dateInput.text = - formattedDate; //set output date to TextField value. - }); - } else {} - }, + SizedBox( + height: MediaQuery.of(context).size.height * .02, ), - ), - Row( - children: [ - Expanded( - child: RadioListTile( - title: Text("For Yourself"), - value: "self", - groupValue: prescriptionFor, - activeColor: primaryColor, - onChanged: (value) { - setState(() { - prescriptionFor = value.toString(); - }); - }, - ), - ), - Expanded( - child: RadioListTile( - title: Text("For Family"), - value: "others", - groupValue: prescriptionFor, - activeColor: primaryColor, - onChanged: (value) { - setState(() { - prescriptionFor = value.toString(); - }); - }, - ), - ), - ], - ), - Visibility( - visible: - prescriptionFor.toString().toLowerCase() == 'others', - child: Container( + Container( child: TextFormField( cursorColor: greyColor, - controller: patientNameController, + controller: problemController, + textCapitalization: TextCapitalization.words, decoration: textFormFieldDecoration( - Icons.person, 'Enter patient name'), + Icons.report_problem, 'Enter Problem'), ), ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * .02, - ), - Visibility( - visible: - prescriptionFor.toString().toLowerCase() == 'others', - child: Container( + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( child: TextFormField( cursorColor: greyColor, - keyboardType: TextInputType.number, - controller: patientAgeController, + controller: dateInput, decoration: textFormFieldDecoration( - Icons.person, 'Enter patient age'), + Icons.calendar_today, 'Enter Date'), + readOnly: true, + onTap: () async { + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1950), + lastDate: DateTime.now(), + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); + }, + ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + dateInput.text = + formattedDate; //set output date to TextField value. + }); + } else {} + }, ), ), - ), - Visibility( - visible: - prescriptionFor.toString().toLowerCase() == 'others', - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, + Row( children: [ Expanded( child: RadioListTile( - title: Text("Male", style: TextStyle(fontSize: 10)), - value: "male", - groupValue: gender, - activeColor: primaryColor, - onChanged: (value) { - setState(() { - gender = value.toString(); - }); - }, - ), - ), - Expanded( - child: RadioListTile( - title: Text( - "Female", - style: TextStyle(fontSize: 10), - ), - value: "female", - groupValue: gender, + title: Text("For Yourself"), + value: "self", + groupValue: prescriptionFor, activeColor: primaryColor, onChanged: (value) { setState(() { - gender = value.toString(); + prescriptionFor = value.toString(); }); }, ), ), Expanded( child: RadioListTile( - title: - Text("Others", style: TextStyle(fontSize: 10)), - value: "other", - groupValue: gender, + title: Text("For Family"), + value: "others", + groupValue: prescriptionFor, activeColor: primaryColor, onChanged: (value) { setState(() { - gender = value.toString(); + prescriptionFor = value.toString(); }); }, ), ), ], ), - ), - Visibility( - visible: uiFindingsImages.length == 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Container( + child: TextFormField( + cursorColor: greyColor, + controller: patientNameController, + decoration: textFormFieldDecoration( + Icons.person, 'Enter patient name'), + ), ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Container( + child: TextFormField( + cursorColor: greyColor, + keyboardType: TextInputType.number, + controller: patientAgeController, + decoration: textFormFieldDecoration( + Icons.person, 'Enter patient age'), + ), + ), + ), + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: RadioListTile( + title: Text("Male", style: TextStyle(fontSize: 10)), + value: "male", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: Text( + "Female", + style: TextStyle(fontSize: 10), + ), + value: "female", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: + Text("Others", style: TextStyle(fontSize: 10)), + value: "other", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + ], + ), + ), + /*findings*/ + Visibility( + visible: uiFindingsImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCamera(); + Navigator.pop(context); + }, ), - onTap: () async { - await takeImageFromCamera(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, ), - onTap: () async { - await pickImageFromGallery(); - Navigator.pop(context); - }, - ), - ], + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ); - }); - }, - child: const Text('Select Findings'), + ); + }); + }, + child: const Text('Select Findings'), + ), ), - ), - Visibility( - visible: uiFindingsImages.length > 0, - child: Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .20, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: uiFindingsImages.length, - itemBuilder: (context, index) { - return Column( - children: [ - Card( - child: GestureDetector( - onTap: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:uiFindingsImages[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * - .30, - height: - MediaQuery.of(context).size.height * - .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - uiFindingsImages[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack(children: [ - Positioned( - right: 0, - child: Container( - child: IconButton( - iconSize: 30, - icon: const Icon( - Icons.cancel, - color: Colors.red, + Visibility( + visible: uiFindingsImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiFindingsImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:uiFindingsImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiFindingsImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.cancel, + color: Colors.red, + ), + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = uiFindingsImages[index]['url'].split('/').last; + try{ + var response = await AppSettings.deleteFindings(fileName,findingPictureId); + print(jsonDecode(response)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiFindingsImages = jsonDecode(response)['findingsPictureUpload']['findings']; + }); + } + catch(e){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast('Image deletion failed'); + } + + }, ), - onPressed: () async { - AppSettings.preLoaderDialog(context); - - String fileName = uiFindingsImages[index]['url'].split('/').last; - var response = await AppSettings.deleteFindings(fileName); - print(jsonDecode(response)); - Navigator.of(context, rootNavigator: true).pop(); - setState(() { - uiFindingsImages = jsonDecode(response)['findings']; - }); - - }, ), - ), - ) - ]), + ) + ]), + ), ), ), - ), - /*Expanded(child:IconButton( + /*Expanded(child:IconButton( icon: const Icon(Icons.remove,color: Colors.red,), onPressed: () async{ }, ),)*/ - ], - ); - }), - )), - Visibility( - visible: uiFindingsImages.length != 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: Colors.red, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, + ], + ); + }), + )), + Visibility( + visible: uiFindingsImages.length != 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForAddFindings(); + Navigator.pop(context); + }, ), - onTap: () async { - await takeImageFromCamera(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, ), - onTap: () async { - await pickImageFromGallery(); - Navigator.pop(context); - }, - ), - ], + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForAddFindings(); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ); - }); - }, - child: const Text('Add Findings'), - ), - ), - Visibility( - visible: uiReportsImages.length == 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + ); + }); + }, + child: const Text('Add Findings'), ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, + ), + + /*reports*/ + Visibility( + visible: uiReportsImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForReports(); + Navigator.pop(context); + }, ), - onTap: () async { - await takeImageFromCameraForReports(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, ), - onTap: () async { - await pickImageFromGalleryForReports(); - Navigator.pop(context); - }, - ), - ], + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForReports(); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ); - }); - }, - child: const Text('Select Reports'), + ); + }); + }, + child: const Text('Select Reports'), + ), ), - ), - Visibility( - visible: uiReportsImages.length > 0, - child: Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .20, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: uiReportsImages.length, - itemBuilder: (context, index) { - return Column( - children: [ - Card( - child: GestureDetector( - onTap: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * - .30, - height: - MediaQuery.of(context).size.height * - .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - uiReportsImages[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack(children: [ - Positioned( - right: 0, - child: Container( - child: IconButton( - iconSize: 30, - icon: const Icon( - Icons.cancel, - color: Colors.red, + Visibility( + visible: uiReportsImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiReportsImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiReportsImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.cancel, + color: Colors.red, + ), + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = uiReportsImages[index]['url'].split('/').last; + var response = await AppSettings.deleteReports(fileName,reportsPictureId); + print(jsonDecode(response)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiReportsImages = jsonDecode(response)['reportsPictureUpload']['reports']; + }); + + }, + ), ), - onPressed: () async { - AppSettings.preLoaderDialog(context); - - String fileName = uiReportsImages[index]['url'].split('/').last; - var response = await AppSettings.deleteReports(fileName); - print(jsonDecode(response)); - Navigator.of(context, rootNavigator: true).pop(); - setState(() { - uiReportsImages = jsonDecode(response)['reports']; - }); - - }, - ), - ), - ) - ]), - ), - ) - ), - /*Expanded(child:IconButton( + ) + ]), + ), + ) + ), + /*Expanded(child:IconButton( icon: const Icon(Icons.remove,color: Colors.red,), onPressed: () async{ }, ),)*/ - ], - ); - }), - )), - Visibility( - visible: uiReportsImages.length != 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: Colors.red, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, + ], + ); + }), + )), + Visibility( + visible: uiReportsImages.length != 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForAddReports(); + Navigator.pop(context); + }, ), - onTap: () async { - await takeImageFromCameraForReports(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, ), - onTap: () async { - await pickImageFromGalleryForReports(); - Navigator.pop(context); - }, - ), - ], + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForAddReports(); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ); - }); - }, - child: const Text('Add Reports'), - ), - ), - Visibility( - visible: uiPrescriptionImages.length == 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + ); + }); + }, + child: const Text('Add Reports'), ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, + ), + + /*prescriptions*/ + Visibility( + visible: uiPrescriptionImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForPrescriptions(); + Navigator.pop(context); + }, ), - onTap: () async { - await takeImageFromCameraForPrescriptions(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, ), - onTap: () async { - await pickImageFromGalleryForPrescriptions(); - Navigator.pop(context); - }, - ), - ], + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForPrescriptions(); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ); - }); - }, - child: const Text('Select Prescriptions'), + ); + }); + }, + child: const Text('Select Prescriptions'), + ), ), - ), - Visibility( - visible: uiPrescriptionImages.length > 0, - child: Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .20, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: uiPrescriptionImages.length, - itemBuilder: (context, index) { - return Column( - children: [ - Card( - child: GestureDetector( - onTap: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:uiPrescriptionImages[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * - .30, - height: - MediaQuery.of(context).size.height * - .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - uiPrescriptionImages[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack(children: [ - Positioned( - right: 0, - child: Container( - child: IconButton( - iconSize: 30, - icon: const Icon( - Icons.cancel, - color: Colors.red, + Visibility( + visible: uiPrescriptionImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiPrescriptionImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:uiPrescriptionImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiPrescriptionImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.cancel, + color: Colors.red, + ), + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = uiPrescriptionImages[index]['url'].split('/').last; + var response = await AppSettings.deletePrescriptions(fileName,prescriptionPictureId); + print(jsonDecode(response)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiPrescriptionImages = jsonDecode(response)['prescriptionsPictureUpload']['precription']; + }); + + }, + ), ), - onPressed: () async { - AppSettings.preLoaderDialog(context); - - String fileName = uiPrescriptionImages[index]['url'].split('/').last; - var response = await AppSettings.deletePrescriptions(fileName); - print(jsonDecode(response)); - Navigator.of(context, rootNavigator: true).pop(); - setState(() { - uiPrescriptionImages = jsonDecode(response)['precription']; - }); - - }, - ), - ), - ) - ]), - ), - ) - ), - /*Expanded(child:IconButton( + ) + ]), + ), + ) + ), + /*Expanded(child:IconButton( icon: const Icon(Icons.remove,color: Colors.red,), onPressed: () async{ }, ),)*/ - ], - ); - }), - )), - Visibility( - visible: uiPrescriptionImages.length != 0, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: Colors.red, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, - ), - onTap: () async { - await takeImageFromCameraForPrescriptions(); - Navigator.pop(context); - }, - ), - SizedBox( - width: - MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, - ), - onTap: () async { - await pickImageFromGalleryForPrescriptions(); - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }); - }, - child: const Text('Add Prescriptions'), - ), - ), - Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .06, + ], + ); + }), + )), + Visibility( + visible: uiPrescriptionImages.length != 0, child: ElevatedButton( style: ElevatedButton.styleFrom( primary: buttonColors, // background onPrimary: Colors.black, // foreground ), onPressed: () async { - if (doctorNameController.text != '' && - problemController.text != '' && - dateInput.text != '' && - prescriptionFor != '') { - String _name = ''; - String _age = ''; - String? _gender = ''; - - if (prescriptionFor.toString().toLowerCase() == - 'others') { - if (patientNameController != '' && - patientAgeController.text != '' && - gender != '') { - _name = patientNameController.text; - _age = patientAgeController.text; - _gender = gender; + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForAddPrescriptions(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForAddPrescriptions(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Add Prescriptions'), + ), + ), + Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + if (doctorNameController.text != '' && + problemController.text != '' && + dateInput.text != '' && + prescriptionFor != '') { + String _name = ''; + String _age = ''; + String? _gender = ''; + + if (prescriptionFor.toString().toLowerCase() == + 'others') { + if (patientNameController != '' && + patientAgeController.text != '' && + gender != '') { + _name = patientNameController.text; + _age = patientAgeController.text; + _gender = gender; + } else { + AppSettings.longFailedToast( + 'Please enter details'); + } } else { - AppSettings.longFailedToast( - 'Please enter details'); + _name = AppSettings.userName; + _age = AppSettings.age; + _gender = AppSettings.gender; } - } else { - _name = AppSettings.userName; - _age = AppSettings.age; - _gender = AppSettings.gender; - } - AppSettings.preLoaderDialog(context); - bool isOnline = - await AppSettings.internetConnectivity(); - if (isOnline) { - var payload = new Map(); - payload["problem"] = - problemController.text.toString(); - payload["doctorName"] = - doctorNameController.text.toString(); - payload["hospitalName"] = - hospitalNameController.text.toString(); - payload["date"] = dateInput.text.toString(); - payload["findings_date"] = ''; - payload["reports_date"] = ''; - payload["prescription_date"] = ''; - payload["patientType"] = - prescriptionFor.toString(); - payload["others"] = { - "name": _name, - "age": int.parse(_age), - "gender": _gender.toString().toLowerCase() - }; - payload["findings"] = uiFindingsImages; - payload["reports"] = uiReportsImages; - payload["prescription"] = uiPrescriptionImages; - - bool uploadStatus = - await AppSettings.addRecords(payload); - - try { - if (uploadStatus) { - Navigator.of(context, rootNavigator: true) - .pop(); - AppSettings.longSuccessToast( - 'Record added successfully'); - Navigator.pop(context); - } else { + AppSettings.preLoaderDialog(context); + bool isOnline = + await AppSettings.internetConnectivity(); + if (isOnline) { + var payload = new Map(); + payload["problem"] = + problemController.text.toString(); + payload["doctorName"] = + doctorNameController.text.toString(); + payload["hospitalName"] = + hospitalNameController.text.toString(); + payload["date"] = dateInput.text.toString(); + payload["findings_date"] = ''; + payload["reports_date"] = ''; + payload["prescription_date"] = ''; + payload["patientType"] = + prescriptionFor.toString(); + payload["others"] = { + "name": _name, + "age": int.parse(_age), + "gender": _gender.toString().toLowerCase() + }; + payload["findings"] = uiFindingsImages; + payload["reports"] = uiReportsImages; + payload["prescription"] = uiPrescriptionImages; + + bool uploadStatus = + await AppSettings.addRecords(payload); + + try { + if (uploadStatus) { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longSuccessToast( + 'Record added successfully'); + Navigator.pop(context); + } else { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longFailedToast( + 'Fail to add record details'); + } + } catch (e) { + print(e); Navigator.of(context, rootNavigator: true) .pop(); AppSettings.longFailedToast( 'Fail to add record details'); } - } catch (e) { - print(e); - Navigator.of(context, rootNavigator: true) - .pop(); + } else { AppSettings.longFailedToast( - 'Fail to add record details'); + 'Please check internet'); } } else { AppSettings.longFailedToast( - 'Please check internet'); + 'Please enter valid details'); } - } else { - AppSettings.longFailedToast( - 'Please enter valid details'); - } - }, - child: const Text('Submit'), - )), - ], + }, + child: const Text('Submit'), + )), + ], + ), ), ), - ), - )); + )) + ); + + + } } diff --git a/lib/Reports/all_records_tab.dart b/lib/Reports/all_records_tab.dart new file mode 100644 index 0000000..1bcbfa7 --- /dev/null +++ b/lib/Reports/all_records_tab.dart @@ -0,0 +1,1112 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/services.dart'; +import 'package:healthcare_user/prescriptions/oreder_medicines.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/common/zoom_image.dart'; + +class AllReportsTab extends StatefulWidget { + var recordDetails; + var initialIndex; + + AllReportsTab({this.recordDetails,this.initialIndex}); + + @override + State createState() => _AllReportsTabState(); +} + +class _AllReportsTabState extends State + with TickerProviderStateMixin { + late TabController _controller; + final List topTabs = [ + Tab( + child: Text( + 'Findings', + style: TextStyle(fontSize: 12), + )), + Tab( + child: Text( + 'Reports', + style: TextStyle(fontSize: 12), + )), + Tab( + child: Text( + 'Prescriptions', + style: TextStyle(fontSize: 12), + )), + ]; + final ImagePicker imagePicker = ImagePicker(); + List imageFileList = []; + final ImagePicker _picker = ImagePicker(); + + @override + void initState() { + _controller = + TabController(vsync: this, initialIndex: widget.initialIndex, length: topTabs.length); + super.initState(); + } + + Future pickImageFromGalleryForUpdateFindings() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updateFindingsGallery( + imageFileList, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.findingsImages = jsonDecode(res)['findings']; + }); + } + + Future takeImageFromCameraForUpdateFindings() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updateFindingsCamera( + image, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.findingsImages = jsonDecode(res)['findings']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForUpdateReports() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updateReportsGallery( + imageFileList, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.reportImages = jsonDecode(res)['reports']; + }); + } + + Future takeImageFromCameraForUpdateReports() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updateReportsCamera( + image, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.reportImages = jsonDecode(res)['reports']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForUpdatePrescriptions() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updatePrescriptionsGallery( + imageFileList, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.prescriptionImages = jsonDecode(res)['prescription']; + }); + } + + Future takeImageFromCameraForUpdatePrescriptions() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updatePrescriptionsCamera( + image, widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.recordDetails.prescriptionImages = + jsonDecode(res)['prescription']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Widget renderUiForFindings() { + if (widget.recordDetails.findingsImages.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: GridView.builder( + itemCount: widget.recordDetails.findingsImages.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Findings', + imageDetails: widget.recordDetails + .findingsImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + widget.recordDetails.findingsImages[index] + ['url']) as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = widget.recordDetails + .findingsImages[index]['url'] + .split('/') + .last; + + var payload = new Map(); + payload["urlType"] = 'findings'; + payload["url"] = widget.recordDetails + .findingsImages[index]['url']; + + // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId); + try { + var res = + await AppSettings.deleteRecordsNew( + payload, + widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + widget.recordDetails.findingsImages = + jsonDecode(res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + /* color: Colors.pinkAccent, + width: 35, + height: 35,*/ + ), + ) + ]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + )), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateFindings(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateFindings(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ], + ), + ), + ), + ], + ); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * .25, + ), + Text('Click below icon to add new findings'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateFindings(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateFindings(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); + } + } + + Widget renderUiForReports() { + if (widget.recordDetails.reportImages.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: GridView.builder( + itemCount: widget.recordDetails.reportImages.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Findings', + imageDetails: widget + .recordDetails.reportImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + widget.recordDetails.reportImages[index] + ['url']) as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = widget.recordDetails + .reportImages[index]['url'] + .split('/') + .last; + + var payload = new Map(); + payload["urlType"] = 'reports'; + payload["url"] = widget.recordDetails + .reportImages[index]['url']; + + try { + var res = + await AppSettings.deleteRecordsNew( + payload, + widget.recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + widget.recordDetails.reportImages = + jsonDecode(res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + /* color: Colors.pinkAccent, + width: 35, + height: 35,*/ + ), + ) + ]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + )), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateReports(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateReports(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ], + ), + ), + ), + ], + ); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * .25, + ), + Text('Click below icon to add new Report'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateReports(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateReports(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); + } + } + + Widget renderUiForPrescriptions() { + if (widget.recordDetails.prescriptionImages.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: GridView.builder( + itemCount: widget.recordDetails.prescriptionImages.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Prescripitons', + imageDetails: widget.recordDetails + .prescriptionImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + widget.recordDetails.prescriptionImages[index] + ['url']) as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = widget.recordDetails + .prescriptionImages[index]['url'] + .split('/') + .last; + + var payload = + new Map(); + payload["urlType"] = 'prescription'; + payload["url"] = widget.recordDetails + .prescriptionImages[index]['url']; + + try { + var res = await AppSettings + .deleteRecordsNew( + payload, + widget + .recordDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + widget.recordDetails + .prescriptionImages = + jsonDecode( + res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.shopping_cart, + color: Colors.white, + ), + onPressed: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicines( + prescriptionDetails: widget.recordDetails))); + //signup screen + }, + ), + ], + ), + ), + ), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdatePrescriptions(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdatePrescriptions(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ], + ), + ), + ), + ], + ) + ], + ); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * .25, + ), + Text('Click below icon to add new Prescriptions'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdatePrescriptions(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdatePrescriptions(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Reports'), + backgroundColor: primaryColor, + bottom: TabBar( + controller: _controller, + tabs: topTabs, + indicatorColor: buttonColors, + unselectedLabelColor: Colors.white60, + indicatorWeight: 2, + ), + ), + body: Column( + children: [ + Container( + height: MediaQuery.of(context).size.height * .15, + width: double.infinity, + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Problem: ' + + widget.recordDetails.problem.toString().toUpperCase(), + style: problemTextStyle()), + Text(widget.recordDetails.doctorName.toString().toUpperCase(), + style: valuesTextStyle()), + Text( + widget.recordDetails.hospitalName + .toString() + .toUpperCase(), + style: valuesTextStyle()), + Text(widget.recordDetails.date.toString().toUpperCase(), + style: valuesTextStyle()), + Text('Patient details: ', style: problemTextStyle()), + Text( + widget.recordDetails.patient_name + .toString() + .toUpperCase(), + style: valuesTextStyle()), + Row( + children: [ + Text(widget.recordDetails.gender.toString().toUpperCase(), + style: valuesTextStyle()), + SizedBox( + width: MediaQuery.of(context).size.width * .05, + ), + Text( + widget.recordDetails.age.toString().toUpperCase() + + " Yrs", + style: valuesTextStyle()), + ], + ), + ], + ), + ), + ), + Expanded( + child: TabBarView(controller: _controller, children: [ + Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Findings', style: recordDetailsHeading()), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Expanded( + child: Container( + //color: Colors.lightBlueAccent, + child: renderUiForFindings()), + ) + ], + )), + Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Reports', style: recordDetailsHeading()), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Expanded( + child: Container( + //color: Colors.lightBlueAccent, + child: renderUiForReports()), + ) + ], + )), + Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Prescriptions', style: recordDetailsHeading()), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Expanded( + child: Container( + //color: Colors.lightBlueAccent, + child: renderUiForPrescriptions()), + ) + ], + )), + ]), + ) + ], + ), + ); + } +} diff --git a/lib/Reports/allreports.dart b/lib/Reports/allreports.dart index 671d88c..81cdf2c 100644 --- a/lib/Reports/allreports.dart +++ b/lib/Reports/allreports.dart @@ -2,13 +2,16 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:healthcare_user/Reports/add_reports.dart'; +import 'package:healthcare_user/Reports/all_records_tab.dart'; import 'package:healthcare_user/Reports/finding_images.dart'; import 'package:healthcare_user/Reports/prescription_images.dart'; import 'package:healthcare_user/Reports/report_images.dart'; +import 'package:healthcare_user/Reports/update_report.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/zoom_image.dart'; import 'package:healthcare_user/models/reports_model.dart'; import 'package:photo_view/photo_view.dart'; +import 'package:intl/intl.dart'; class AllReports extends StatefulWidget { const AllReports({Key? key}) : super(key: key); @@ -25,6 +28,7 @@ class _AllReportsState extends State { bool isReportsDataLoading = false; bool isSereverIssue = false; TextEditingController searchController = TextEditingController(); + TextEditingController dateInput = TextEditingController(); String dropdownSearchType = 'Problem'; var typeOfSearchItems = [ 'Problem', @@ -104,6 +108,31 @@ class _AllReportsState extends State { } } + Future getRecordsByDate(var date) async { + + isReportsDataLoading=true; + try { + var response = await AppSettings.getAllRecords(); + + setState(() { + reportsListOriginal = ((jsonDecode(response)) as List) + .map((dynamic model) { + return ReportsModel.fromJson(model); + }).toList(); + reportsList=reportsListOriginal.reversed.toList(); + reportsList= reportsListOriginal.where( + (x) => x.date.toString().toLowerCase().contains(date.toString().toLowerCase()) + ).toList(); + isReportsDataLoading = false; + }); + } catch (e) { + setState(() { + isReportsDataLoading = false; + isSereverIssue = true; + }); + } + } + @override void initState() { getAllRecords(); @@ -308,194 +337,230 @@ class _AllReportsState extends State { padding: EdgeInsets.all(0), itemCount: reportsList.length, itemBuilder: (BuildContext context, int index) { - return Card( - - //color: prescriptionsList[index].cardColor, - child: Padding( - padding:EdgeInsets.all(8) , - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - - Container( - width: MediaQuery.of(context).size.width * .55, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Problem: '+reportsList[index].problem.toString().toUpperCase(),style: problemTextStyle()), - Text(reportsList[index].doctorName.toString().toUpperCase(),style: valuesTextStyle()), - Text(reportsList[index].hospitalName.toString().toUpperCase(),style: valuesTextStyle()), - Text(reportsList[index].date.toString().toUpperCase(),style: valuesTextStyle()), - Text(reportsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()), - Row( - children: [ - Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()), - SizedBox(width:MediaQuery.of(context).size.width * .05,), - Text(reportsList[index].age.toString().toUpperCase()+" Yrs",style: valuesTextStyle()), - ], - ), - - - ], - ), - - - ), - - - Expanded(child:IconButton( - icon: const Icon(Icons.edit,color: primaryColor,), - onPressed: () { + return GestureDetector( + onTap: (){ + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { + getAllRecords(); + }); + }, + child: Card( + + //color: prescriptionsList[index].cardColor, + child: Padding( + padding:EdgeInsets.all(8) , + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + + Container( + width: MediaQuery.of(context).size.width * .55, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Problem: '+reportsList[index].problem.toString().toUpperCase(),style: problemTextStyle()), + Text(reportsList[index].doctorName.toString().toUpperCase(),style: valuesTextStyle()), + Text(reportsList[index].hospitalName.toString().toUpperCase(),style: valuesTextStyle()), + Text(reportsList[index].date.toString().toUpperCase(),style: valuesTextStyle()), + Text('Patient details: ',style: problemTextStyle()), + Text(reportsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()), + Row( + children: [ + Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()), + SizedBox(width:MediaQuery.of(context).size.width * .05,), + Text(reportsList[index].age.toString().toUpperCase()+" Yrs",style: valuesTextStyle()), + ], + ), + + + ], + ), - }, - ),), - Expanded(child:IconButton( - icon: const Icon(Icons.delete,color: primaryColor,), - - onPressed: () async{ - showDialog( - //if set to true allow to close popup by tapping out of the popup - //barrierDismissible: false, - context: context, - builder: (BuildContext context) => AlertDialog( - title: const Text('Do you want to delete Record?', - style: TextStyle( - color: primaryColor, - fontSize: 20, - )), - actionsAlignment: MainAxisAlignment.spaceBetween, - actions: [ - TextButton( - onPressed: ()async { - - bool deleteTankStatus = await AppSettings.deleteRecord(reportsList[index].recordId); + ), - if(deleteTankStatus){ - getAllRecords(); - AppSettings.longSuccessToast('Record deleted successfully'); + Expanded(child:IconButton( + icon: const Icon(Icons.edit,color: primaryColor,), + onPressed: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new UpdateReport(reportDetails:reportsList[index]))).then((value) { + getAllRecords(); + }); + }, + ),), + Expanded(child:IconButton( + icon: const Icon(Icons.delete,color: primaryColor,), + + onPressed: () async{ + showDialog( + //if set to true allow to close popup by tapping out of the popup + //barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Do you want to delete Record?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: ()async { + + bool deleteTankStatus = await AppSettings.deleteRecord(reportsList[index].recordId); + + + if(deleteTankStatus){ + getAllRecords(); + AppSettings.longSuccessToast('Record deleted successfully'); + Navigator.of(context).pop(true); + + } + else{ + AppSettings.longFailedToast('Record deletion failed'); + Navigator.of(context).pop(true); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { Navigator.of(context).pop(true); - - } - else{ - AppSettings.longFailedToast('Record deletion failed'); - Navigator.of(context).pop(true); - } - }, - child: const Text('Yes', - style: TextStyle( - color: primaryColor, - fontSize: 20, - )), - ), - TextButton( - onPressed: () { - Navigator.of(context).pop(true); - }, - child: const Text('No', - style: TextStyle( - color: primaryColor, - fontSize: 20, - )), - ), - ], - ), - ); - - - - }, - ),) - - ], - - ), - - Row( - children: [ - ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + + + + }, + ),) + + ], + + ), + + Row( + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + /*Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { + getAllRecords(); + });*/ + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { + getAllRecords(); + }); + }, + child: Text('Findings: '+reportsList[index].findingsImages.length.toString(),style:textButtonStyleReports(),), + ), + SizedBox( + width:MediaQuery.of(context).size.width * .05, + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + /*Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages,recordId:reportsList[index].recordId ,))).then((value) { + getAllRecords(); + });*/ + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 1,))).then((value) { + getAllRecords(); + }); + + }, + child: Text('Reports: '+reportsList[index].reportImages.length.toString(),style:textButtonStyleReports()), ), - onPressed: () async { - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { - getAllRecords(); - }); - }, - child: Text('Findings: '+reportsList[index].findingsImages.length.toString()), - ), - SizedBox( - width:MediaQuery.of(context).size.width * .05, - ), - ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + SizedBox( + width:MediaQuery.of(context).size.width * .05, ), - onPressed: () async { - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages,recordId:reportsList[index].recordId ,))).then((value) { - getAllRecords(); - }); - - }, - child: Text('Reports: '+reportsList[index].reportImages.length.toString()), - ), - SizedBox( - width:MediaQuery.of(context).size.width * .05, - ), - ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + /*Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index],details:reportsList[index] ,))).then((value) { + getAllRecords(); + });*/ + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 2,))).then((value) { + getAllRecords(); + }); + + }, + child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString(),style:textButtonStyleReports()), ), - onPressed: () async { - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index]))).then((value) { - getAllRecords(); - }); - - }, - child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString()), - ), - ], - ), - - - - Visibility( - visible: false, - child: Text('Findings',style: headingsTextStyle()),), - Visibility( + ], + ), + + + + Visibility( + visible: false, + child: Text('Findings',style: headingsTextStyle()),), + Visibility( + visible: false, + child: findings(reportsList[index])), + Visibility( visible: false, - child: findings(reportsList[index])), - Visibility( - visible: false, - child: Text('Reports',style: headingsTextStyle()),), - Visibility( + child: Text('Reports',style: headingsTextStyle()),), + Visibility( + visible: false, + child:reports(reportsList[index]) ), + Visibility( visible: false, - child:reports(reportsList[index]) ), - Visibility( - visible: false, - child: Text('Prescriptions',style: headingsTextStyle()),), - Visibility( - visible:false, - child:prescriptions(reportsList[index]) ), - ], + child: Text('Prescriptions',style: headingsTextStyle()),), + Visibility( + visible:false, + child:prescriptions(reportsList[index]) ), + ], + ), ), ), ); @@ -602,7 +667,7 @@ class _AllReportsState extends State { Icons.clear, color: greyColor, ),*/ - suffixIcon: IconButton( + suffixIcon: searchController.text!=''?IconButton( icon: Icon( Icons.clear, color: Colors.red, @@ -613,6 +678,13 @@ class _AllReportsState extends State { }); getAllRecords(); }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, ), border: OutlineInputBorder( borderSide: BorderSide(color: primaryColor), @@ -660,7 +732,7 @@ class _AllReportsState extends State { Icons.clear, color: greyColor, ),*/ - suffixIcon: IconButton( + suffixIcon: searchController.text!=''?IconButton( icon: Icon( Icons.clear, color: Colors.red, @@ -671,6 +743,13 @@ class _AllReportsState extends State { }); getAllRecords(); }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, ), border: OutlineInputBorder( borderSide: BorderSide(color: primaryColor), @@ -692,6 +771,106 @@ class _AllReportsState extends State { ), ),) ),), + Visibility( + visible:dropdownSearchType.toString().toLowerCase()=='date' , + child: Container( + height: MediaQuery.of(context).size.height * .07, + padding: EdgeInsets.all(5), + child: Center(child: TextField( + + cursorColor: primaryColor, + controller: searchController, + onChanged: (string) { + if(string.length>=1){ + getRecordsByDate(string); + } + else{ + getAllRecords(); + } + }, + onTap: () async { + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1950), + lastDate: DateTime.now(), + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); + }, + ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + searchController.text = formattedDate; //set output date to TextField value. + }); + getRecordsByDate(searchController.text); + } else {} + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.search, + color: primaryColor, + ), + suffixIcon: searchController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + searchController.text=''; + }); + getAllRecords(); + }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + //labelText: 'Search by phone number', + hintText: 'Search by date', + + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ),) + ), + + + ), Expanded(child: _filtereddata()), Padding( padding: EdgeInsets.fromLTRB(8, 8, 8, 8), @@ -775,7 +954,7 @@ class _AllReportsState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppSettings.appBar('Reports'), + appBar: AppSettings.appBar('Records'), body: isReportsDataLoading?Center( child: CircularProgressIndicator( color: primaryColor, diff --git a/lib/Reports/finding_images.dart b/lib/Reports/finding_images.dart index 951ad3a..3156e1b 100644 --- a/lib/Reports/finding_images.dart +++ b/lib/Reports/finding_images.dart @@ -13,21 +13,19 @@ class FindingImages extends StatefulWidget { var imageDetails; var recordId; - FindingImages({this.imageDetails,this.recordId}); - + FindingImages({this.imageDetails, this.recordId}); @override State createState() => _FindingImagesState(); } class _FindingImagesState extends State { - final ImagePicker imagePicker = ImagePicker(); List imageFileList = []; List uiFindingsImages = []; final ImagePicker _picker = ImagePicker(); - /* Future pickImageFromGallery() async { + /* Future pickImageFromGallery() async { imageFileList = []; final List? selectedImages = await imagePicker.pickMultiImage(); AppSettings.preLoaderDialog(context); @@ -68,7 +66,8 @@ class _FindingImagesState extends State { imageFileList.addAll(selectedImages); } - var res = await AppSettings.updateFindingsGallery(imageFileList,widget.recordId); + var res = + await AppSettings.updateFindingsGallery(imageFileList, widget.recordId); print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { @@ -82,7 +81,7 @@ class _FindingImagesState extends State { if (image == null) return; final imageTemp = File(image.path); AppSettings.preLoaderDialog(context); - var res = await AppSettings.updateFindingsCamera(image,widget.recordId); + var res = await AppSettings.updateFindingsCamera(image, widget.recordId); print(jsonDecode(res)); Navigator.of(context, rootNavigator: true).pop(); setState(() { @@ -93,231 +92,277 @@ class _FindingImagesState extends State { } } - - - - Widget renderUi() { - - if(widget.imageDetails.length!=0){ - return GridView.builder( - itemCount:widget.imageDetails.length, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - crossAxisSpacing: 2.0, - mainAxisSpacing: 2.0, - ), - itemBuilder: (BuildContext context, int index) { - return GestureDetector( - onTap: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:widget.imageDetails[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * .30, - height: MediaQuery.of(context).size.height * .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - widget.imageDetails[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack( - children: [ + if (widget.imageDetails.length != 0) { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: GridView.builder( + itemCount: widget.imageDetails.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Findings', + imageDetails: widget.imageDetails[index] + ['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage(widget.imageDetails[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ Positioned( right: 0, child: Container( child: IconButton( iconSize: 30, icon: const Icon( - Icons.cancel, + Icons.delete, color: Colors.red, ), onPressed: () async { - - AppSettings.preLoaderDialog(context); - - String fileName = widget.imageDetails[index]['url'].split('/').last; - - var payload = new Map(); - payload["urlType"] = 'findings'; - payload["url"] = widget.imageDetails[index]['url']; - - // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId); - try{ - var res = await AppSettings.deleteRecordsNew(payload,widget.recordId); - print(jsonDecode(res)); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longSuccessToast("Image deleted Successfully"); - setState(() { - widget.imageDetails = jsonDecode(res)['remainingUrls']; - }); - } - catch(e){ - print(e); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast("Image deletion failed"); - } + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = widget + .imageDetails[index]['url'] + .split('/') + .last; + + var payload = new Map(); + payload["urlType"] = 'findings'; + payload["url"] = + widget.imageDetails[index]['url']; + + // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId); + try { + var res = + await AppSettings.deleteRecordsNew( + payload, widget.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + widget.imageDetails = + jsonDecode(res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); }, ), /* color: Colors.pinkAccent, width: 35, height: 35,*/ ), - )]), - ), - - //Image.network(widget.imageDetails[index]['url']), - ); - }, - ); - } - else{ - return Center( - child: Padding( - padding: EdgeInsets.fromLTRB(0, 40, 0, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(height: MediaQuery.of(context).size.height * .25,), - Text('Click below icon to add new findings'), - SizedBox( - height: 20, + ) + ]), ), - CircleAvatar( - backgroundColor: primaryColor, - radius: 40, - child: IconButton( + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + )), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( iconSize: 40, icon: const Icon( Icons.add, color: Colors.white, ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, - ), - onTap: () async { - await takeImageFromCameraForUpdate(); - Navigator.pop(context); - }, - ), - SizedBox( - width: MediaQuery.of(context).size.width * - .20, + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, - ), - onTap: () async { - await pickImageFromGalleryForUpdate(); - Navigator.pop(context); - }, + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, ), - ], - ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], ), - ); - }); - }, + ), + ); + }); + }, ), - ) - ], + ], + ), ), - ) + ), + ], ); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * .25, + ), + Text('Click below icon to add new findings'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); } - } - - @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - backgroundColor: primaryColor, - title: Text("Finding Images"), - actions: [ - Visibility( - visible: widget.imageDetails.length>0, - child: IconButton( - iconSize: 30, - icon: Icon( - Icons.add_task, - color: Colors.white, - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, - ), - onTap: () async { - await takeImageFromCameraForUpdate(); - Navigator.pop(context); - }, - ), - SizedBox( - width: MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, - ), - onTap: () async { - await pickImageFromGalleryForUpdate(); - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }); - - - - }, - ),) - ], - ), - body:Container( - padding: EdgeInsets.all(12.0), - child: renderUi()), + appBar: AppSettings.appBar('Findings'), + body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), ); } } diff --git a/lib/Reports/prescription_images.dart b/lib/Reports/prescription_images.dart index a994852..69269fc 100644 --- a/lib/Reports/prescription_images.dart +++ b/lib/Reports/prescription_images.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:healthcare_user/Reports/allreports.dart'; -import 'package:healthcare_user/Reports/order_medicines_new.dart'; +import 'package:healthcare_user/trash/order_medicines_new.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/zoom_image.dart'; import 'package:healthcare_user/prescriptions/oreder_medicines.dart'; @@ -15,8 +15,9 @@ class PrescriptionImages extends StatefulWidget { var imageDetails; var recordId; var familyDetails; + var details; - PrescriptionImages({this.imageDetails, this.recordId,this.familyDetails}); + PrescriptionImages({this.imageDetails, this.recordId,this.familyDetails,this.details}); @override State createState() => _PrescriptionImagesState(); @@ -98,6 +99,7 @@ class _PrescriptionImagesState extends State { Widget renderUi() { if (widget.imageDetails.length != 0) { return Column( + crossAxisAlignment: CrossAxisAlignment.end, children: [ Expanded( child: GridView.builder( @@ -136,35 +138,72 @@ class _PrescriptionImagesState extends State { child: IconButton( iconSize: 30, icon: const Icon( - Icons.cancel, + Icons.delete, color: Colors.red, ), onPressed: () async { - AppSettings.preLoaderDialog(context); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); - String fileName = widget.imageDetails[index] - ['url'] - .split('/') - .last; + String fileName = widget.imageDetails[index] + ['url'] + .split('/') + .last; - var payload = new Map(); - payload["urlType"] = 'prescription'; - payload["url"] = widget.imageDetails[index]['url']; + var payload = new Map(); + payload["urlType"] = 'prescription'; + payload["url"] = widget.imageDetails[index]['url']; - try{ - var res = await AppSettings.deleteRecordsNew(payload,widget.recordId); - print(jsonDecode(res)); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longSuccessToast("Image deleted Successfully"); - setState(() { - widget.imageDetails = jsonDecode(res)['remainingUrls']; - }); - } - catch(e){ - print(e); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast("Image deletion failed"); - } + try{ + var res = await AppSettings.deleteRecordsNew(payload,widget.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast("Image deleted Successfully"); + setState(() { + widget.imageDetails = jsonDecode(res)['remainingUrls']; + }); + } + catch(e){ + print(e); + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast("Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); }, ), ), @@ -177,21 +216,97 @@ class _PrescriptionImagesState extends State { }, ), ), - TextButton( - child: const Text( - 'Order Medicines', - style: TextStyle(color: primaryColor), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.shopping_cart, + color: Colors.white, + ), + onPressed: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicines(prescriptionDetails:widget.details))); + //signup screen + }, + ), + ], + ), ), - onPressed: () { + ), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new OrderMedicinesPrescriptions(prescriptionDetails:widget.imageDetails,familyDetails: widget.familyDetails,))); - //signup screen - }, - ) + }, + ), + ], + ), + ), + ), ], ); } else { @@ -270,67 +385,7 @@ class _PrescriptionImagesState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - backgroundColor: primaryColor, - title: Text("Prescriptions"), - actions: [ - Visibility( - visible: widget.imageDetails.length > 0, - child: IconButton( - iconSize: 30, - icon: Icon( - Icons.add_task, - color: Colors.white, - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, - ), - onTap: () async { - await takeImageFromCameraForUpdate(); - Navigator.pop(context); - }, - ), - SizedBox( - width: MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, - ), - onTap: () async { - await pickImageFromGalleryForUpdate(); - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }); - - - - }, - ), - ) - ], - ), + appBar:AppSettings.appBar('Prescriptions'), body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), ); } diff --git a/lib/Reports/report_images.dart b/lib/Reports/report_images.dart index 8198213..947f5bd 100644 --- a/lib/Reports/report_images.dart +++ b/lib/Reports/report_images.dart @@ -93,80 +93,186 @@ class _ReportImagesState extends State { Widget renderUi() { if(widget.imageDetails.length!=0){ - return GridView.builder( - itemCount: widget.imageDetails.length, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - crossAxisSpacing: 2.0, - mainAxisSpacing: 2.0, - ), - itemBuilder: (BuildContext context, int index) { - return GestureDetector( - onTap: () { - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage( - imageName: 'Findings', - imageDetails: widget.imageDetails[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * .30, - height: MediaQuery.of(context).size.height * .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage(widget.imageDetails[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack(children: [ - Positioned( - right: 0, - child: Container( - child: IconButton( - iconSize: 30, - icon: const Icon( - Icons.cancel, - color: Colors.red, - ), - onPressed: () async { + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded(child: GridView.builder( + itemCount: widget.imageDetails.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Findings', + imageDetails: widget.imageDetails[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage(widget.imageDetails[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), - AppSettings.preLoaderDialog(context); + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); - String fileName = widget.imageDetails[index]['url'].split('/').last; + String fileName = widget.imageDetails[index]['url'].split('/').last; - var payload = new Map(); - payload["urlType"] = 'reports'; - payload["url"] = widget.imageDetails[index]['url']; + var payload = new Map(); + payload["urlType"] = 'reports'; + payload["url"] = widget.imageDetails[index]['url']; - try{ - var res = await AppSettings.deleteRecordsNew(payload,widget.recordId); - print(jsonDecode(res)); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longSuccessToast("Image deleted Successfully"); - setState(() { - widget.imageDetails = jsonDecode(res)['remainingUrls']; - }); - } - catch(e){ - print(e); - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast("Image deletion failed"); - } - }, - ), - /* color: Colors.pinkAccent, + try{ + var res = await AppSettings.deleteRecordsNew(payload,widget.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast("Image deleted Successfully"); + setState(() { + widget.imageDetails = jsonDecode(res)['remainingUrls']; + }); + } + catch(e){ + print(e); + Navigator.of(context, rootNavigator: true).pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast("Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + /* color: Colors.pinkAccent, width: 35, height: 35,*/ + ), + ) + ]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + )), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + + + + }, ), - ) - ]), + ], + ), ), - - //Image.network(widget.imageDetails[index]['url']), - ); - }, + ), + ], ); } else{ @@ -245,66 +351,7 @@ class _ReportImagesState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar:AppBar( - backgroundColor: primaryColor, - title: Text("Report Images"), - actions: [ - Visibility( - visible: widget.imageDetails.length>0, - child: IconButton( - iconSize: 30, - icon: Icon( - Icons.add_task, - color: Colors.white, - ), - onPressed: () async { - showModalBottomSheet( - context: context, - builder: (BuildContext context) { - return SizedBox( - height: 200, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - child: Icon( - Icons.camera_alt_outlined, - size: 100, - color: primaryColor, - ), - onTap: () async { - await takeImageFromCameraForUpdate(); - Navigator.pop(context); - }, - ), - SizedBox( - width: MediaQuery.of(context).size.width * - .20, - ), - GestureDetector( - child: Icon( - Icons.photo, - size: 100, - color: primaryColor, - ), - onTap: () async { - await pickImageFromGalleryForUpdate(); - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }); - - - - }, - ),) - ], - ), + appBar:AppSettings.appBar('Repoprt Images'), body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), ); } diff --git a/lib/Reports/update_report.dart b/lib/Reports/update_report.dart new file mode 100644 index 0000000..d689455 --- /dev/null +++ b/lib/Reports/update_report.dart @@ -0,0 +1,1191 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/common/zoom_image.dart'; +import 'package:intl/intl.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; + +class UpdateReport extends StatefulWidget { + var reportDetails; + + UpdateReport({this.reportDetails}); + + @override + State createState() => _UpdateReportState(); +} + +class _UpdateReportState extends State { + TextEditingController doctorNameController = TextEditingController(); + TextEditingController hospitalNameController = TextEditingController(); + TextEditingController problemController = TextEditingController(); + TextEditingController dateInput = TextEditingController(); + TextEditingController patientNameController = TextEditingController(); + TextEditingController patientAgeController = TextEditingController(); + final ImagePicker _picker = ImagePicker(); + String Url = ''; + final ImagePicker imagePicker = ImagePicker(); + List imageFileList = []; + List imageFileListReports = []; + List imageFileListPrescriptions = []; + List uiFindingsImages = []; + List uiReportsImages = []; + List uiPrescriptionImages = []; + + List images = []; + String _error = 'No Error Dectected'; + String apiMultiImages = ''; + String? prescriptionFor; + String? gender; + + + Future pickImageFromGalleryForUpdate() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updatePrescriptionsGallery(imageFileList,widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiPrescriptionImages = jsonDecode(res)['prescription']; + }); + } + + Future takeImageFromCameraForUpdate() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updatePrescriptionsCamera(image,widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiPrescriptionImages = jsonDecode(res)['prescription']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForUpdateReports() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updateReportsGallery(imageFileList,widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiReportsImages= jsonDecode(res)['reports']; + }); + } + + Future takeImageFromCameraForUpdateReports() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updateReportsCamera(image,widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiReportsImages = jsonDecode(res)['reports']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future pickImageFromGalleryForUpdateFindings() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = + await AppSettings.updateFindingsGallery(imageFileList, widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiFindingsImages = jsonDecode(res)['findings']; + }); + } + + Future takeImageFromCameraForUpdateFindings() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updateFindingsCamera(image, widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + uiFindingsImages = jsonDecode(res)['findings']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + void detials(){ + prescriptionFor=widget.reportDetails.patient_type; + doctorNameController.text=widget.reportDetails.doctorName; + hospitalNameController.text=widget.reportDetails.hospitalName; + problemController.text = widget.reportDetails.problem; + dateInput.text = widget.reportDetails.date; + patientNameController.text =widget.reportDetails.patient_name; + patientAgeController.text = widget.reportDetails.age; + gender=widget.reportDetails.gender; + uiFindingsImages=widget.reportDetails.findingsImages; + uiReportsImages =widget.reportDetails.reportImages; + uiPrescriptionImages =widget.reportDetails.prescriptionImages; + + } + + + @override + void initState() { + + + detials(); + super.initState(); + } + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Update Report'), + body: SingleChildScrollView( + child: Container( + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: TextFormField( + cursorColor: greyColor, + controller: doctorNameController, + textCapitalization: TextCapitalization.words, + decoration: textFormFieldDecoration( + Icons.person, 'Enter Doctor name'), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: hospitalNameController, + textCapitalization: TextCapitalization.words, + decoration: textFormFieldDecoration( + Icons.location_city_outlined, 'Enter Hospital name'), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: problemController, + textCapitalization: TextCapitalization.words, + decoration: textFormFieldDecoration( + Icons.report_problem, 'Enter Problem'), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: dateInput, + decoration: textFormFieldDecoration( + Icons.calendar_today, 'Enter Date'), + readOnly: true, + onTap: () async { + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1950), + lastDate: DateTime.now(), + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); + }, + ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + dateInput.text = + formattedDate; //set output date to TextField value. + }); + } else {} + }, + ), + ), + Row( + children: [ + Expanded( + child: RadioListTile( + title: Text("For Yourself"), + value: "self", + groupValue: prescriptionFor, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + prescriptionFor = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: Text("For Family"), + value: "others", + groupValue: prescriptionFor, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + prescriptionFor = value.toString(); + }); + }, + ), + ), + ], + ), + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Container( + child: TextFormField( + cursorColor: greyColor, + controller: patientNameController, + decoration: textFormFieldDecoration( + Icons.person, 'Enter patient name'), + ), + ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * .02, + ), + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Container( + child: TextFormField( + cursorColor: greyColor, + keyboardType: TextInputType.number, + controller: patientAgeController, + decoration: textFormFieldDecoration( + Icons.person, 'Enter patient age'), + ), + ), + ), + Visibility( + visible: + prescriptionFor.toString().toLowerCase() == 'others', + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: RadioListTile( + title: Text("Male", style: TextStyle(fontSize: 10)), + value: "male", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: Text( + "Female", + style: TextStyle(fontSize: 10), + ), + value: "female", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: + Text("Others", style: TextStyle(fontSize: 10)), + value: "other", + groupValue: gender, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + gender = value.toString(); + }); + }, + ), + ), + ], + ), + ), + /*findings*/ + Visibility( + visible: uiFindingsImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateFindings(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateFindings(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Select Findings'), + ), + ), + Visibility( + visible: uiFindingsImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiFindingsImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:uiFindingsImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiFindingsImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + + var payload = new Map(); + payload["urlType"] = 'findings'; + payload["url"] = uiFindingsImages[index]['url']; + + // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId); + try { + var res = + await AppSettings.deleteRecordsNew( + payload, + widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + uiFindingsImages = jsonDecode(res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + ), + ), + /*Expanded(child:IconButton( + icon: const Icon(Icons.remove,color: Colors.red,), + + onPressed: () async{ + + }, + ),)*/ + ], + ); + }), + )), + Visibility( + visible: uiFindingsImages.length != 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateFindings(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateFindings(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Add Findings'), + ), + ), + + /*reports*/ + Visibility( + visible: uiReportsImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateReports(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateReports(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Select Reports'), + ), + ), + Visibility( + visible: uiReportsImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiReportsImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiReportsImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + var payload = new Map(); + payload["urlType"] = 'reports'; + payload["url"] = uiReportsImages[index]['url']; + + try { + var res = + await AppSettings.deleteRecordsNew( + payload, + widget.reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + uiReportsImages = + jsonDecode(res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + ) + ), + /*Expanded(child:IconButton( + icon: const Icon(Icons.remove,color: Colors.red,), + + onPressed: () async{ + + }, + ),)*/ + ], + ); + }), + )), + Visibility( + visible: uiReportsImages.length != 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary:buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdateReports(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdateReports(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Add Reports'), + ), + ), + + /*prescriptions*/ + Visibility( + visible: uiPrescriptionImages.length == 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Select Prescriptions'), + ), + ), + Visibility( + visible: uiPrescriptionImages.length > 0, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: uiPrescriptionImages.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:uiPrescriptionImages[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * + .30, + height: + MediaQuery.of(context).size.height * + .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + uiPrescriptionImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); + + + var payload = + new Map(); + payload["urlType"] = 'prescription'; + payload["url"] = uiPrescriptionImages[index]['url']; + + try { + var res = await AppSettings + .deleteRecordsNew( + payload, + widget + .reportDetails.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + uiPrescriptionImages= + jsonDecode( + res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + ) + ), + /*Expanded(child:IconButton( + icon: const Icon(Icons.remove,color: Colors.red,), + + onPressed: () async{ + + }, + ),)*/ + ], + ); + }), + )), + Visibility( + visible: uiPrescriptionImages.length != 0, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + child: const Text('Add Prescriptions'), + ), + ), + + /*button*/ + Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + if (doctorNameController.text != '' && + problemController.text != '' && + dateInput.text != '' && + prescriptionFor != '') { + String _name = ''; + String _age = ''; + String? _gender = ''; + + if (prescriptionFor.toString().toLowerCase() == + 'others') { + if (patientNameController != '' && + patientAgeController.text != '' && + gender != '') { + _name = patientNameController.text; + _age = patientAgeController.text; + _gender = gender; + } else { + AppSettings.longFailedToast( + 'Please enter details'); + } + } else { + _name = AppSettings.userName; + _age = AppSettings.age; + _gender = AppSettings.gender; + } + AppSettings.preLoaderDialog(context); + bool isOnline = + await AppSettings.internetConnectivity(); + if (isOnline) { + + + var payload = new Map(); + payload["problem"] = + problemController.text.toString(); + payload["doctorName"] = + doctorNameController.text.toString(); + payload["hospitalName"] = + hospitalNameController.text.toString(); + payload["date"] = dateInput.text.toString(); + payload["findings_date"] = ''; + payload["reports_date"] = ''; + payload["prescription_date"] = ''; + payload["patientType"] = + prescriptionFor.toString(); + payload["others"] = { + "name": _name, + "age": int.parse(_age), + "gender": _gender.toString().toLowerCase() + }; + payload["findings"] = uiFindingsImages; + payload["reports"] = uiReportsImages; + payload["prescription"] = uiPrescriptionImages; + + bool uploadStatus = + await AppSettings.updateRecord(payload,widget.reportDetails.recordId); + + try { + if (uploadStatus) { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longSuccessToast( + 'Record updated successfully'); + Navigator.pop(context); + } else { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longFailedToast( + 'Fail to update record details'); + } + } catch (e) { + print(e); + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longFailedToast( + 'Fail to add record details'); + } + } else { + AppSettings.longFailedToast( + 'Please check internet'); + } + } else { + AppSettings.longFailedToast( + 'Please enter valid details'); + } + }, + child: const Text('Update Report'), + )), + ], + ), + ), + ), + )); + } +} diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index ed8b3a4..8118f18 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -5,7 +5,7 @@ import 'package:healthcare_user/Reports/allreports.dart'; import 'package:healthcare_user/common/updateprofile.dart'; import 'package:healthcare_user/emergency.dart'; import 'package:healthcare_user/howareufeeling_today.dart'; -import 'package:healthcare_user/invitations.dart'; +import 'package:healthcare_user/invitations/invitations.dart'; import 'package:healthcare_user/medicines.dart'; import 'package:healthcare_user/my_health.dart'; import 'package:healthcare_user/my_medicine_timings.dart'; @@ -14,6 +14,7 @@ import 'package:healthcare_user/report_my_self.dart'; import 'package:healthcare_user/Reports/add_reports.dart'; import 'package:healthcare_user/seekopinion.dart'; import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/updates/update_location.dart'; import 'package:image_picker/image_picker.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'dart:ui' as ui; @@ -280,7 +281,7 @@ class _DashboardState extends State { }, ), Text( - 'Reports', + 'Records', style: dashboardTextStyle(), ), ], @@ -895,7 +896,13 @@ class _DashboardState extends State { style: drawerListItemsTextStyle()), ], ), - onTap: () {}, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const UpdateMyLocation()), + ); + }, ), Divider( color: Colors.grey, diff --git a/lib/common/settings.dart b/lib/common/settings.dart index 670041a..01603df 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -8,7 +8,6 @@ import 'package:http/http.dart' as http; import 'package:http/http.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:intl/intl.dart'; -import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'dart:async'; import 'package:geolocator/geolocator.dart'; import 'package:fluttertoast/fluttertoast.dart'; @@ -35,6 +34,10 @@ TextStyle labelTextStyle() { return TextStyle(color: primaryColor, fontSize: 12); } +TextStyle labelTextStyleOrderMedicine() { + return TextStyle(color: primaryColor, fontSize: 12,fontWeight: FontWeight.bold); +} + TextStyle haveMotorTextStyle() { return TextStyle( color: Colors.red, fontSize: 12, fontWeight: FontWeight.bold); @@ -44,6 +47,10 @@ TextStyle textButtonStyle() { return TextStyle(color: primaryColor, fontSize: 15); } +TextStyle textButtonStyleReports() { + return TextStyle(color: Colors.white, fontSize: 12); +} + TextStyle iconBelowTextStyle() { return TextStyle(fontSize: 10, color: primaryColor); } @@ -55,6 +62,13 @@ TextStyle valuesTextStyle() { ); } +TextStyle recordDetailsHeading() { + return TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + ); +} + TextStyle problemTextStyle() { return TextStyle( fontSize: 12, @@ -133,7 +147,6 @@ TextStyle wrapTextStyleBlack() { TextStyle withoutWrapTextStyle() { return TextStyle( - color: primaryColor, fontSize: 12, fontWeight: FontWeight.bold, ); @@ -230,6 +243,7 @@ class AppSettings { static String sugarCaluculateUrl = host + 'insertSugar'; static String profilePicUrl = host + 'users/profile-picture'; static String updateProfileUrl = host + 'update/currentUser'; + static String updateLocationUrl = host + 'updateLocation'; static String uploadPicUrl = host + 'uploads'; static String getBmiHistoryUrl = host + 'usersbmi'; static String getBpHistoryUrl = host + 'usersbp'; @@ -237,6 +251,9 @@ class AppSettings { static String addMedicineTimingsUrl = host + 'medicine-timing'; static String getMedicineTimingsUrl = host + 'getmedicineztiming'; static String findingsUploadPicUrl = host + 'uploads-findings-prescription'; + static String addFindingsUrl = host + 'update-uploads-findingsPictureId-prescription'; + static String addReportsUrl = host + 'update-uploads-reportsPictureId-prescription'; + static String addPrescriptionsUrl = host + 'update-uploads-prescriptionPictureId-prescription'; static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription'; static String updateReportsUploadPicUrl = host + 'update-uploads-reports-prescription'; static String reportsUploadPicUrl = host + 'uploads-reports-prescription'; @@ -248,14 +265,15 @@ class AppSettings { static String getQuotationUrl = host + 'submitPicture'; static String addPrescriptionUrl = host + 'add-prescription-details'; static String addRecordsUrl = host + 'add-record'; + static String updateRecordsUrl = host + 'records'; static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo'; //static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription'; static String getAllPrescriptionsDataUrl = host + 'getAllPrescriptionDetails'; static String getRecordsDataUrl = host + 'getAllRecords'; static String deleteRecordUrl = host + 'deleteRecord'; - static String deleteFindingsUrl = host + 'uploads-findings-prescription'; - static String deletePrescriptionsUrl = host + 'uploads-prescription-prescription'; - static String deleteReportsUrl = host + 'uploads-reports-prescription'; + static String deleteFindingsUrl = host + 'delete-uploads-findings'; + static String deletePrescriptionsUrl = host + 'delete-prescription'; + static String deleteReportsUrl = host + 'delete-report'; static String deleteRecordsUrl = host + 'delete-url'; @@ -620,6 +638,25 @@ class AppSettings { } } + static Future updateLocation(payload) async { + var uri = Uri.parse(updateLocationUrl + '/' + customerId); + try { + var response = await http.put(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + var _response = json.decode(response.body); + + return true; + } else { + return false; + } + } catch (e) { + print(e); + return false; + } + } + static Future getBmiHistory() async { var uri = Uri.parse(getBmiHistoryUrl + '/' + customerId); @@ -748,6 +785,28 @@ class AppSettings { return response.body; } + static Future addFindingsGallery(file,pictureId) async { + + var request = http.MultipartRequest( + 'PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId)); + if (file.length > 0) { + for (var i = 0; i < file.length; i++) { + request.files.add(await http.MultipartFile.fromPath('picture', file[i].path)); + }} + // request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']',''))); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + static Future addFindingsCamera(file,pictureId) async { + var request = http.MultipartRequest('PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + static Future updateFindingsGallery(file,var recordId) async { var request = http.MultipartRequest( @@ -797,6 +856,28 @@ class AppSettings { return response.body; } + static Future addReportsGallery(file,pictureId) async { + + var request = http.MultipartRequest( + 'PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId)); + if (file.length > 0) { + for (var i = 0; i < file.length; i++) { + request.files.add(await http.MultipartFile.fromPath('picture', file[i].path)); + }} + // request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']',''))); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + static Future addReportsCamera(file,pictureId) async { + var request = http.MultipartRequest('PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + static Future updateReportsGallery(file,var recordId) async { var request = http.MultipartRequest( @@ -846,6 +927,28 @@ class AppSettings { return response.body; } + static Future addPrescriptionsGallery(file,pictureId) async { + + var request = http.MultipartRequest( + 'PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId)); + if (file.length > 0) { + for (var i = 0; i < file.length; i++) { + request.files.add(await http.MultipartFile.fromPath('picture', file[i].path)); + }} + // request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']',''))); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + static Future addPrescriptionsCamera(file,pictureId) async { + var request = http.MultipartRequest('PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + static Future updatePrescriptionsGallery(file,var recordId) async { var request = http.MultipartRequest( @@ -1107,6 +1210,38 @@ class AppSettings { } } + static Future updateRecord(payload,recordId) async { + var uri = Uri.parse(updateRecordsUrl + '/' + recordId); + var response = await http.put(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + try { + var _response = json.decode(response.body); + print(_response); + return true; + } catch (e) { + print(e); + return false; + } + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.put(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + static Future getAllPrescriptions() async { var uri = Uri.parse(getAllPrescriptionsDataUrl + '/' + customerId); //uri = uri.replace(query: 'customerId=$customerId'); @@ -1187,8 +1322,8 @@ class AppSettings { } - static Future deleteFindings(fileName) async { - var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+fileName); + static Future deleteFindings(fileName,findingsId) async { + var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+findingsId+'/'+fileName); try { var response = await http.delete(uri, headers: await buildRequestHeaders()); @@ -1216,8 +1351,8 @@ class AppSettings { } } - static Future deletePrescriptions(fileName) async { - var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+fileName); + static Future deletePrescriptions(fileName,prescriptionId) async { + var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+prescriptionId+'/'+fileName); try { var response = await http.delete(uri, headers: await buildRequestHeaders()); @@ -1245,8 +1380,8 @@ class AppSettings { } } - static Future deleteReports(fileName) async { - var uri = Uri.parse(deleteReportsUrl + '/' + customerId+'/'+fileName); + static Future deleteReports(fileName,reportsId) async { + var uri = Uri.parse(deleteReportsUrl + '/' + customerId+'/'+reportsId+'/'+fileName); try { var response = await http.delete(uri, headers: await buildRequestHeaders()); @@ -1418,20 +1553,6 @@ class AppSettings { gender = await getData('gender', 'STRING'); } - static void longFailedStyledToast(String message, context) { - showToast( - message, - context: context, - animation: StyledToastAnimation.scale, - reverseAnimation: StyledToastAnimation.fade, - position: StyledToastPosition.bottom, - animDuration: Duration(seconds: 1), - duration: Duration(seconds: 6), - curve: Curves.elasticOut, - reverseCurve: Curves.linear, - backgroundColor: Colors.red, - ); - } static void longSuccessToast(String message) { Fluttertoast.showToast( diff --git a/lib/invitations.dart b/lib/invitations.dart deleted file mode 100644 index ce69cef..0000000 --- a/lib/invitations.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:healthcare_user/common/settings.dart'; - -class Invitations extends StatefulWidget { - const Invitations({Key? key}) : super(key: key); - - @override - State createState() => _InvitationsState(); -} - -class _InvitationsState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppSettings.appBar('Invitations'), - body: Container(), - ); - } -} diff --git a/lib/invitations/invitations.dart b/lib/invitations/invitations.dart new file mode 100644 index 0000000..74dd7aa --- /dev/null +++ b/lib/invitations/invitations.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; + + +class Invitations extends StatefulWidget { + const Invitations({Key? key}) : super(key: key); + + @override + State createState() => _InvitationsState(); +} + +class _InvitationsState extends State { + + TextEditingController mobileNumberController = TextEditingController(); + TextEditingController nameController = TextEditingController(); + + final FlutterContactPicker _contactPicker = new FlutterContactPicker(); + Contact? _contact; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Invitations'), + body: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: SafeArea( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: TextFormField( + cursorColor: greyColor, + controller: nameController, + decoration: textFormFieldDecoration(Icons.phone,'Enter Name'), + + ), + ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + Container( + child: TextFormField( + cursorColor: greyColor, + controller: mobileNumberController, + keyboardType: TextInputType.number, + decoration: textFormFieldDecoration(Icons.phone,'Enter MobileNumber'), + + ), + ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + Container( + child: Text('Or',style: TextStyle(color: primaryColor,fontWeight: FontWeight.bold,fontSize: 20),), + ), + SizedBox(height:MediaQuery.of(context).size.height * .02,), + TextButton( + child: const Text( + 'Select from contacts', + style: TextStyle(decoration: TextDecoration.underline,color: primaryColor,fontSize: 20), + ), + onPressed: () async{ + Contact? contact = await _contactPicker.selectContact(); + setState(() { + _contact = contact; + }); + }, + ) + ], + ) + ))))); + } +} diff --git a/lib/prescriptions/oreder_medicines.dart b/lib/prescriptions/oreder_medicines.dart index db484a3..7e98174 100644 --- a/lib/prescriptions/oreder_medicines.dart +++ b/lib/prescriptions/oreder_medicines.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:healthcare_user/common/settings.dart'; @@ -14,7 +15,6 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'package:healthcare_user/prescriptions/get_quotations_request_list.dart'; import 'package:location/location.dart' as locationmap; - class OrderMedicines extends StatefulWidget { var prescriptionDetails; OrderMedicines({this.prescriptionDetails}); @@ -71,7 +71,7 @@ class _OrderMedicinesState extends State { Future getAllPharmaciesData(var distance) async { isLoading = true; - selectedPharmacies=[]; + selectedPharmacies = []; try { var pharmacyResponse = await AppSettings.getAllpharmacies(); @@ -113,21 +113,22 @@ class _OrderMedicinesState extends State { } } - - - showSelectedPharmaciesDialog(){ + showSelectedPharmaciesDialog() { return showDialog( barrierDismissible: false, context: context, builder: (BuildContext context) { - return StatefulBuilder(builder: (context, setState) { + return StatefulBuilder(builder: (context, setState) { return AlertDialog( title: Text('Selected Pharmacies'), content: Container( - height: MediaQuery.of(context).size.height * .50, + height: MediaQuery.of(context).size.height * .50, width: MediaQuery.of(context).size.width * .70, - child:ListView.separated( - separatorBuilder: (context, index) => const Divider(height: 4.0,color: Colors.black,), + child: ListView.separated( + separatorBuilder: (context, index) => const Divider( + height: 4.0, + color: Colors.black, + ), itemCount: selectedPharmacies.length, itemBuilder: (BuildContext context, int index) { return ListTile( @@ -156,11 +157,13 @@ class _OrderMedicinesState extends State { ),*/ Expanded( child: Container( - width: MediaQuery.of(context).size.width * .70, + width: MediaQuery.of(context).size.width * + .70, child: Column( mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( selectedPharmacies[index] @@ -184,15 +187,17 @@ class _OrderMedicinesState extends State { .toUpperCase(), style: wrapTextStyleBlack()), Visibility( - visible: - selectedPharmacies[index].description != '', + visible: selectedPharmacies[index] + .description != + '', child: SizedBox( height: 10, ), ), Visibility( - visible: - selectedPharmacies[index].description != '', + visible: selectedPharmacies[index] + .description != + '', child: Text( selectedPharmacies[index] .description @@ -209,20 +214,24 @@ class _OrderMedicinesState extends State { )), checkColor: Colors.white, activeColor: primaryColor, - value: selectedPharmacies[index].isPharmacyInDialogChecked, + value: + selectedPharmacies[index].isPharmacyInDialogChecked, onChanged: (val) { setState( - () { - selectedPharmacies[index].isPharmacyInDialogChecked = val!; + () { + selectedPharmacies[index] + .isPharmacyInDialogChecked = val!; }, ); - if (selectedPharmacies[index].isPharmacyInDialogChecked) { + if (selectedPharmacies[index] + .isPharmacyInDialogChecked) { pharmaciesCheckboxesInDialog.add({ - 'pharmacyId': selectedPharmacies[index].pharmacy_id, + 'pharmacyId': + selectedPharmacies[index].pharmacy_id, }); } else { pharmaciesCheckboxesInDialog.removeWhere((e) => - e['pharmacyId'].toString().toUpperCase() == + e['pharmacyId'].toString().toUpperCase() == selectedPharmacies[index] .pharmacy_id .toString() @@ -351,7 +360,6 @@ class _OrderMedicinesState extends State { ), ), actions: [ - Container( width: double.infinity, height: MediaQuery.of(context).size.height * .06, @@ -365,77 +373,91 @@ class _OrderMedicinesState extends State { primary: buttonColors, // background onPrimary: Colors.black, // foreground ), - onPressed: () async{ + onPressed: () async { Navigator.pop(context); }, child: const Text('Cancel'), ), - SizedBox(width: 10,), + SizedBox( + width: 10, + ), ElevatedButton( style: ElevatedButton.styleFrom( primary: buttonColors, // background onPrimary: Colors.black, // foreground ), - onPressed: () async{ - if(pharmaciesCheckboxesInDialog.length==3){ + onPressed: () async { + if (pharmaciesCheckboxesInDialog.length == 3) { AppSettings.preLoaderDialog(context); var payload = new Map(); - payload["prescriptionPictures"]=widget.prescriptionDetails.prescriptionImages; - payload["pharmacies"] = pharmaciesCheckboxesInDialog; + payload["prescriptionPictures"] = + widget.prescriptionDetails.prescriptionImages; + payload["pharmacies"] = + pharmaciesCheckboxesInDialog; payload["familyDetails"] = { - "patient_name": widget.prescriptionDetails.patient_name.toString(), - "patient_age": int.parse(widget.prescriptionDetails.age.toString()), - "patient_gender": widget.prescriptionDetails.gender.toString().toLowerCase(), + "patient_name": widget + .prescriptionDetails.patient_name + .toString(), + "patient_age": int.parse( + widget.prescriptionDetails.age.toString()), + "patient_gender": widget + .prescriptionDetails.gender + .toString() + .toLowerCase(), "patient_address": userAddress }; - bool status = await AppSettings.getQuotation(payload); + bool status = + await AppSettings.getQuotation(payload); - if(status){ - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longSuccessToast('Quotation request sent successfully'); + if (status) { + Navigator.of(context, rootNavigator: true) + .pop(); + Navigator.pop(context); + AppSettings.longSuccessToast( + 'Quotation request sent successfully'); pharmaciesCheckboxesInDialog.clear(); + getAllPharmaciesData(dropdownArea); Navigator.push( context, MaterialPageRoute( - builder: (context) => const GetQuotationRequestsList()), + builder: (context) => + const GetQuotationRequestsList()), ); + } else { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longFailedToast( + 'Get quotation failed try after some time'); } - else{ - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast('Get quotation failed try after some time'); - } - - - } - else if(pharmaciesCheckboxesInDialog.length>3){ - AppSettings.longFailedToast('Please select only three pharmacies to get quotation'); + } else if (pharmaciesCheckboxesInDialog.length > + 3) { + AppSettings.longFailedToast( + 'Please select only three pharmacies to get quotation'); + } else { + AppSettings.longFailedToast( + 'Please select at least three pharmacies to get quotation'); } - else{ - AppSettings.longFailedToast('Please select at least three pharmacies to get quotation'); - } - - }, child: const Text('Get quote'), ) ], )), - - ], ); }); - }); } Widget setupAlertDialoadContainer() { return Container( - height: MediaQuery.of(context).size.height * .50, + height: MediaQuery.of(context).size.height * .50, width: MediaQuery.of(context).size.width * .70, - child:ListView.separated( - separatorBuilder: (context, index) => const Divider(height: 4.0,color: Colors.black,), + child: ListView.separated( + separatorBuilder: (context, index) => const Divider( + height: 4.0, + color: Colors.black, + ), itemCount: selectedPharmacies.length, itemBuilder: (BuildContext context, int index) { return ListTile( @@ -456,8 +478,8 @@ class _OrderMedicinesState extends State { image: selectedPharmacies[index].picture == '' ? AssetImage("images/logo.png") : NetworkImage( - selectedPharmacies[index].picture) - as ImageProvider, // picked file + selectedPharmacies[index].picture) + as ImageProvider, // picked file fit: BoxFit.contain)), ), SizedBox( @@ -468,7 +490,7 @@ class _OrderMedicinesState extends State { width: MediaQuery.of(context).size.width * .70, child: Column( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( @@ -494,14 +516,16 @@ class _OrderMedicinesState extends State { style: wrapTextStyleBlack()), Visibility( visible: - selectedPharmacies[index].description != '', + selectedPharmacies[index].description != + '', child: SizedBox( height: 10, ), ), Visibility( visible: - selectedPharmacies[index].description != '', + selectedPharmacies[index].description != + '', child: Text( selectedPharmacies[index] .description @@ -524,35 +548,39 @@ class _OrderMedicinesState extends State { crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ - Visibility( - visible:selectedPharmacies[index].isPharmacyInDialogChecked==false, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async{ - selectedPharmacies[index].isPharmacyInDialogChecked=true; - }, - child: const Text('Select'), - ),), - SizedBox(width: 10,), Visibility( - visible: selectedPharmacies[index].isPharmacyInDialogChecked==true, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground + visible: selectedPharmacies[index] + .isPharmacyInDialogChecked == + false, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async { + selectedPharmacies[index] + .isPharmacyInDialogChecked = true; + }, + child: const Text('Select'), ), - onPressed: () async{ - - - }, - child: const Text('Deselect'), - )) + ), + SizedBox( + width: 10, + ), + Visibility( + visible: selectedPharmacies[index] + .isPharmacyInDialogChecked == + true, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async {}, + child: const Text('Deselect'), + )) ], )), - ], )), ); @@ -561,249 +589,385 @@ class _OrderMedicinesState extends State { ); } + modelBottomSheet(var obj) { + showModalBottomSheet( + context: context, + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)), + ), + isScrollControlled: true, + builder: (BuildContext context) { + return SizedBox( + height: MediaQuery.of(context).size.height * .800, + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: obj.picture == '' + ? AssetImage("images/logo.png") + : NetworkImage(obj.picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: MediaQuery.of(context).size.width * .02, + ), + Expanded( + child: Container( + width: MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Pharmacy Name:', + style: labelTextStyleOrderMedicine(), + ), + Text(obj.pharmacy_name.toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: MediaQuery.of(context).size.height * + .01, + ), + Text( + 'Contact Number:', + style: labelTextStyleOrderMedicine(), + ), + Text(obj.contact_number.toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: MediaQuery.of(context).size.height * + .01, + ), + Text( + 'Address:', + style: labelTextStyleOrderMedicine(), + ), + Text(obj.pharmacy_address.toUpperCase(), + style: withoutWrapTextStyle()), + Visibility( + visible: obj.description != '', + child: SizedBox( + height: + MediaQuery.of(context).size.height * + .01, + ), + ), + Visibility( + visible: obj.description != '', + child: Text( + 'Description:', + style: labelTextStyleOrderMedicine(), + ), + ), + Visibility( + visible: obj.description != '', + child: Text(obj.description.toUpperCase(), + style: withoutWrapTextStyle()), + ), + ], + )), + ), + ], + ) + ], + ))); + }, + ); + } + Widget _pharamciesData() { if (FilteredList.length != 0) { - return - Container( - color: secondaryColor, - child: Column(crossAxisAlignment: CrossAxisAlignment.end, children: [ - Expanded( - child: GridView.builder( - itemCount: FilteredList.length, - itemBuilder: (context, index) { - return Card( - elevation: 2.0, - child: CheckboxListTile( - title: Padding( - padding: EdgeInsets.fromLTRB(0, 10, 0, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: MediaQuery.of(context).size.width * .18, - height: MediaQuery.of(context).size.height * .10, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: FilteredList[index].picture == '' - ? AssetImage("images/logo.png") - : NetworkImage( - FilteredList[index].picture) - as ImageProvider, // picked file - fit: BoxFit.contain)), - ), - SizedBox( - width: 5, - ), - Expanded( - child: Container( - width: MediaQuery.of(context).size.width * .70, - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - FilteredList[index] - .pharmacy_name - .toUpperCase(), - style: wrapTextStyleBlack()), - SizedBox( - height: 10, - ), - Text( - FilteredList[index] - .contact_number - .toUpperCase(), - style: wrapTextStyleBlack()), - SizedBox( + return Container( + color: secondaryColor, + child: Column(crossAxisAlignment: CrossAxisAlignment.end, children: [ + Expanded( + child: GridView.builder( + itemCount: FilteredList.length, + itemBuilder: (context, index) { + return Card( + elevation: 2.0, + child: CheckboxListTile( + title: Padding( + padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + children: [ + Expanded( + child: Container( + width: + MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * + .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: FilteredList[index] + .picture == + '' + ? AssetImage("images/logo.png") + : NetworkImage(FilteredList[ + index] + .picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + ), + TextButton( + onPressed: () { + modelBottomSheet(FilteredList[index]); + }, + child: const Text('More details', + style: TextStyle( + color: primaryColor, + fontSize: 12, + )), + ) + ], + ), + SizedBox( + width: 5, + ), + Expanded( + child: Container( + width: + MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + FilteredList[index] + .pharmacy_name + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .contact_number + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .pharmacy_address + .toUpperCase(), + style: wrapTextStyleBlack()), + Visibility( + visible: + FilteredList[index].description != + '', + child: SizedBox( height: 10, ), - Text( + ), + Visibility( + visible: + FilteredList[index].description != + '', + child: Text( FilteredList[index] - .pharmacy_address + .description .toUpperCase(), style: wrapTextStyleBlack()), - Visibility( - visible: - FilteredList[index].description != '', - child: SizedBox( - height: 10, - ), - ), - Visibility( - visible: - FilteredList[index].description != '', - child: Text( - FilteredList[index] - .description - .toUpperCase(), - style: wrapTextStyleBlack()), - ), - SizedBox( - height: 10, - ), - ], - )), - ), - ], - )), - checkColor: Colors.white, - activeColor: primaryColor, - value: FilteredList[index].isChecked, - onChanged: (val) { - setState( - () { - FilteredList[index].isChecked = val!; - }, - ); - if (FilteredList[index].isChecked) { - pharmaciesCheckboxes.add({ - 'pharmacyId': FilteredList[index].pharmacy_id, - }); - selectedPharmacies.add(FilteredList[index]); - } else { - pharmaciesCheckboxes.removeWhere((e) => - e['pharmacyId'].toString().toUpperCase() == - FilteredList[index] - .pharmacy_id - .toString() - .toUpperCase()); - selectedPharmacies.remove(FilteredList[index]); - } - }, - ), - ); - }, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 1, //.size.width * .33, - childAspectRatio: MediaQuery.of(context).size.width / - (MediaQuery.of(context).size.height / 7)), - ), - ), - Padding( - padding: EdgeInsets.all(0), - child: Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .06, - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: buttonColors, // background - onPrimary: Colors.black, // foreground - ), - onPressed: () async { - - - if(pharmaciesCheckboxes.length==3){ - AppSettings.preLoaderDialog(context); - var payload = new Map(); - - payload["prescriptionPictures"]=widget.prescriptionDetails.prescriptionImages; - payload["pharmacies"] = pharmaciesCheckboxes; - payload["familyDetails"] = { - "patient_name": widget.prescriptionDetails.patient_name.toString()??'', - "patient_age": int.parse(widget.prescriptionDetails.age.toString())??0, - "patient_gender": widget.prescriptionDetails.gender.toString().toLowerCase()??'', - "patient_address": userAddress??'' - }; - bool status = await AppSettings.getQuotation(payload); - - if(status){ - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longSuccessToast('Quotation request sent successfully'); - pharmaciesCheckboxes.clear(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const GetQuotationRequestsList()), - ); - } - else{ - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast('Get quotation failed try after some time'); - } - + ), + SizedBox( + height: 10, + ), + ], + )), + ), + ], + )), + checkColor: Colors.white, + activeColor: primaryColor, + value: FilteredList[index].isChecked, + onChanged: (val) { + setState( + () { + FilteredList[index].isChecked = val!; + }, + ); + if (FilteredList[index].isChecked) { + pharmaciesCheckboxes.add({ + 'pharmacyId': FilteredList[index].pharmacy_id, + }); + selectedPharmacies.add(FilteredList[index]); + } else { + pharmaciesCheckboxes.removeWhere((e) => + e['pharmacyId'].toString().toUpperCase() == + FilteredList[index] + .pharmacy_id + .toString() + .toUpperCase()); + selectedPharmacies.remove(FilteredList[index]); } - else if(pharmaciesCheckboxes.length>3){ + }, + ), + ); + }, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 1, //.size.width * .33, + childAspectRatio: MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 7)), + ), + ), + Padding( + padding: EdgeInsets.all(0), + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + if (pharmaciesCheckboxes.length == 3) { + AppSettings.preLoaderDialog(context); + var payload = new Map(); - showSelectedPharmaciesDialog(); + payload["prescriptionPictures"] = + widget.prescriptionDetails.prescriptionImages; + payload["pharmacies"] = pharmaciesCheckboxes; + payload["familyDetails"] = { + "patient_name": widget.prescriptionDetails.patient_name + .toString() ?? + '', + "patient_age": int.parse( + widget.prescriptionDetails.age.toString()) ?? + 0, + "patient_gender": widget.prescriptionDetails.gender + .toString() + .toLowerCase() ?? + '', + "patient_address": userAddress ?? '' + }; + bool status = await AppSettings.getQuotation(payload); + if (status) { + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast( + 'Quotation request sent successfully'); + pharmaciesCheckboxes.clear(); + getAllPharmaciesData(dropdownArea); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const GetQuotationRequestsList()), + ); + } else { + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast( + 'Get quotation failed try after some time'); } - else{ - AppSettings.longFailedToast('Please select at least three pharmacies to get quotation'); - } - - - }, - child: Text('Get quote'), - )), - ), - ]), - ); - } - else { + } else if (pharmaciesCheckboxes.length > 3) { + showSelectedPharmaciesDialog(); + } else { + AppSettings.longFailedToast( + 'Please select at least three pharmacies to get quotation'); + } + }, + child: Text('Get quote'), + )), + ), + ]), + ); + } else { return Center( child: Padding( - padding: EdgeInsets.fromLTRB(0, 40, 0, 0), - child: isSereverIssue - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image( - image: AssetImage('images/serverissue.png'), - // height: MediaQuery.of(context).size.height * .10, - ), - SizedBox( - height: 20, - ), - Text( - 'There is an issue at server please try after some time',style:serverIssueTextStyle() ,), - ], - ) - : userAddress==''?Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - /*Image( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: isSereverIssue + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('images/serverissue.png'), + // height: MediaQuery.of(context).size.height * .10, + ), + SizedBox( + height: 20, + ), + Text( + 'There is an issue at server please try after some time', + style: serverIssueTextStyle(), + ), + ], + ) + : userAddress == '' + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( image: AssetImage('images/resourceblue.pngs'), // height: MediaQuery.of(context).size.height * .10, ),*/ - Icon(Icons.location_on_outlined,color: primaryColor,size: 40,), - SizedBox( - height: 20, - ), - Text( - 'Please select location to see near by tankers',style:TextStyle( - color: primaryColor, - fontWeight: FontWeight.bold, - ),), - ], - ): - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - /*Image( + Icon( + Icons.location_on_outlined, + color: primaryColor, + size: 40, + ), + SizedBox( + height: 20, + ), + Text( + 'Please select location to see near by tankers', + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ], + ) + : Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( image: AssetImage('images/resourceblue.pngs'), // height: MediaQuery.of(context).size.height * .10, ),*/ - Icon( - Icons.info, - color: primaryColor, - size: 40, - ), - SizedBox( - height: 20, - ), - Text( - 'No pharmacies near to your selected locaton', - style: TextStyle( - color: primaryColor, - fontWeight: FontWeight.bold, - ), - ), - ], - ) - )); + Icon( + Icons.info, + color: primaryColor, + size: 40, + ), + SizedBox( + height: 20, + ), + Text( + 'No pharmacies near to your selected locaton', + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ], + ))); } } @@ -816,9 +980,7 @@ class _OrderMedicinesState extends State { super.initState(); } - - Widget prescriptions(var obj){ - + Widget prescriptions(var obj) { return Container( width: double.infinity, height: MediaQuery.of(context).size.height * .20, @@ -830,15 +992,15 @@ class _OrderMedicinesState extends State { children: [ Card( child: GestureDetector( - onTap: (){ + onTap: () { //showPicDialog(obj.prescriptionImages[index]['url']); Navigator.push( context, new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url']))); - - - + builder: (__) => new ImageZoomPage( + imageName: 'Prescriptions', + imageDetails: obj.prescriptionImages[index] + ['url']))); }, child: Container( width: MediaQuery.of(context).size.width * .30, @@ -847,9 +1009,8 @@ class _OrderMedicinesState extends State { shape: BoxShape.rectangle, image: DecorationImage( image: NetworkImage( - obj.prescriptionImages[index] - ['url']) - as ImageProvider, // picked file + obj.prescriptionImages[index]['url']) + as ImageProvider, // picked file fit: BoxFit.fill)), ), ), @@ -865,7 +1026,6 @@ class _OrderMedicinesState extends State { ); }), ); - } @override @@ -876,41 +1036,44 @@ class _OrderMedicinesState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.all(10), - child: prescriptions(widget.prescriptionDetails),), Padding( padding: EdgeInsets.all(10), - child: Row( - children: [ - TextButton( - onPressed: () {}, - child: const Text( - 'Want to order non prescribed items?', - style: TextStyle( - fontSize: 15, - decoration: TextDecoration.underline, - color: primaryColor), - )), - SizedBox(width: 5,), - TextButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const GetQuotationRequestsList()), - ); - }, - child: const Text( - 'Requests', - style: TextStyle( - fontSize: 15, - decoration: TextDecoration.underline, - color: primaryColor), - )), - ], - ) + child: prescriptions(widget.prescriptionDetails), ), + Padding( + padding: EdgeInsets.all(10), + child: Row( + children: [ + TextButton( + onPressed: () {}, + child: const Text( + 'Want to order non prescribed items?', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + )), + SizedBox( + width: 5, + ), + TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const GetQuotationRequestsList()), + ); + }, + child: const Text( + 'Requests', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + )), + ], + )), Padding( padding: EdgeInsets.all(10), child: Row( @@ -1083,7 +1246,7 @@ class _OrderMedicinesState extends State { enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: greyColor), ), - labelText: 'distance', + labelText: 'distance in Kms', labelStyle: TextStyle( color: greyColor, //<-- SEE HERE ), @@ -1097,7 +1260,7 @@ class _OrderMedicinesState extends State { items: AreaItems.map((String items) { return DropdownMenuItem( value: items, - child: Text(items), + child: Text(items,style: TextStyle(fontSize: 12),), ); }).toList(), // After selecting the desired option,it will diff --git a/lib/prescriptions/prescriptions.dart b/lib/prescriptions/prescriptions.dart index 1c06ec1..36e1661 100644 --- a/lib/prescriptions/prescriptions.dart +++ b/lib/prescriptions/prescriptions.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:geolocator/geolocator.dart'; +import 'package:healthcare_user/Reports/add_reports.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/zoom_image.dart'; import 'package:healthcare_user/models/pharmacies_model.dart'; @@ -12,6 +13,7 @@ import 'package:healthcare_user/prescriptions/oreder_medicines.dart'; import 'package:image_picker/image_picker.dart'; import 'package:photo_view/photo_view.dart'; import 'package:healthcare_user/models/prescriptions_model.dart'; +import 'package:intl/intl.dart'; class Prescriptions extends StatefulWidget { const Prescriptions({Key? key}) : super(key: key); @@ -38,6 +40,17 @@ class _PrescriptionsState extends State { var AreaItems = ['2', '5', '10', '25', '50', '100']; List pharmaciesCheckboxes = []; bool isLoading=false; + final ImagePicker imagePicker = ImagePicker(); + List imageFileList = []; + List uiPrescriptionImages = []; + TextEditingController searchController = TextEditingController(); + TextEditingController dateInput = TextEditingController(); + String dropdownSearchType = 'Problem'; + var typeOfSearchItems = [ + 'Problem', + 'Doctor', + 'Date', + ]; Future getAllPharmaciesData(var distance) async { isPharmacyDataLoading=true; @@ -125,6 +138,81 @@ class _PrescriptionsState extends State { } } + Future getRecordsByProblemName(var problem) async { + + isPrescriptionsDataLoading=true; + try { + var response = await AppSettings.getAllRecords(); + + setState(() { + reportsListOriginal = ((jsonDecode(response)) as List) + .map((dynamic model) { + return ReportsModel.fromJson(model); + }).toList(); + reportsList=reportsListOriginal.reversed.toList(); + reportsList= reportsListOriginal.where( + (x) => x.problem.toString().toLowerCase().contains(problem.toString().toLowerCase()) + ).toList(); + isPrescriptionsDataLoading = false; + }); + } catch (e) { + setState(() { + isPrescriptionsDataLoading = false; + isSereverIssue = true; + }); + } + } + + Future getRecordsByDoctorName(var doctor) async { + + isPrescriptionsDataLoading=true; + try { + var response = await AppSettings.getAllRecords(); + + setState(() { + reportsListOriginal = ((jsonDecode(response)) as List) + .map((dynamic model) { + return ReportsModel.fromJson(model); + }).toList(); + reportsList=reportsListOriginal.reversed.toList(); + reportsList= reportsListOriginal.where( + (x) => x.doctorName.toString().toLowerCase().contains(doctor.toString().toLowerCase()) + ).toList(); + isPrescriptionsDataLoading = false; + }); + } catch (e) { + setState(() { + isPrescriptionsDataLoading = false; + isSereverIssue = true; + }); + } + } + + Future getRecordsByDate(var date) async { + + isPrescriptionsDataLoading=true; + try { + var response = await AppSettings.getAllRecords(); + + setState(() { + reportsListOriginal = ((jsonDecode(response)) as List) + .map((dynamic model) { + return ReportsModel.fromJson(model); + }).toList(); + reportsList=reportsListOriginal.reversed.toList(); + reportsList= reportsListOriginal.where( + (x) => x.date.toString().toLowerCase().contains(date.toString().toLowerCase()) + ).toList(); + isPrescriptionsDataLoading = false; + }); + } catch (e) { + setState(() { + isPrescriptionsDataLoading = false; + isSereverIssue = true; + }); + } + } + @override void initState() { lat = AppSettings.userLatitude; @@ -170,6 +258,37 @@ class _PrescriptionsState extends State { } } + + Future pickImageFromGalleryForUpdate(var recordId) async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.updatePrescriptionsGallery(imageFileList,recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + getAllRecords(); + } + + Future takeImageFromCameraForUpdate(var recordId) async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.updatePrescriptionsCamera(image,recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + getAllRecords(); + + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + Widget _pharamciesData() { if (FilteredList.length != 0) { return Column( @@ -468,50 +587,254 @@ class _PrescriptionsState extends State { } Widget prescriptions(var obj){ + if(obj.prescriptionImages.length!=0){ + return Container( + //color: secondaryColor, + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: Row( + children: [ + Expanded(child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: obj.prescriptionImages.length, + itemBuilder: (context, index) { + return Row( + children: [ + Card( + child: GestureDetector( + onTap: (){ + //showPicDialog(obj.prescriptionImages[index]['url']); + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url'])));}, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + obj.prescriptionImages[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.delete, + color: Colors.red, + ), + onPressed: () async { + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: + const Text('Do you want to delete image?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: + MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: () async { + AppSettings.preLoaderDialog(context); - return Container( - width: double.infinity, - height: MediaQuery.of(context).size.height * .20, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: obj.prescriptionImages.length, - itemBuilder: (context, index) { - return Column( - children: [ - Card( - child: GestureDetector( - onTap: (){ - //showPicDialog(obj.prescriptionImages[index]['url']); - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url']))); + String fileName = obj.prescriptionImages[index]['url'] + .split('/') + .last; + var payload = + new Map(); + payload["urlType"] = 'prescription'; + payload["url"] = obj.prescriptionImages[index]['url']; + + try { + var res = await AppSettings + .deleteRecordsNew( + payload, + obj.recordId); + print(jsonDecode(res)); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + setState(() { + obj.prescriptionImages = + jsonDecode( + res)['remainingUrls']; + }); + } catch (e) { + print(e); + Navigator.of(context, + rootNavigator: true) + .pop(); + Navigator.of(context).pop(true); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + ), + ) + + ], + ); + }),), + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.green, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(obj.recordId); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(obj.recordId); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + + + + }, + ) + + ], + ) + ); + } + else{ + return Row( + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.green, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(obj.recordId); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(obj.recordId); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + + + + }, + ), + Text('Add Prescriptions',style: textButtonStyle(),) + ], + ); + } - }, - child: Container( - width: MediaQuery.of(context).size.width * .30, - height: MediaQuery.of(context).size.height * .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - obj.prescriptionImages[index] - ['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - ), - ), - ), - ], - ); - }), - ); } - Widget _allPrescriptions(){ + Widget _filtereddata(){ if (reportsList.length != 0) { return Column( crossAxisAlignment: CrossAxisAlignment.end, @@ -521,7 +844,7 @@ class _PrescriptionsState extends State { itemCount: reportsList.length, itemBuilder: (BuildContext context, int index) { return Visibility( - visible: reportsList[index].prescriptionImages.length!=0, + visible: true, child: Card( //color: prescriptionsList[index].cardColor, @@ -567,19 +890,27 @@ class _PrescriptionsState extends State { SizedBox(height:MediaQuery.of(context).size.height * .02,), prescriptions(reportsList[index]), - TextButton( - child: const Text( - 'Order Medicines', - style: TextStyle(color: primaryColor), - ), - onPressed: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new OrderMedicines(prescriptionDetails:reportsList[index]))); - //signup screen - }, + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon( + Icons.shopping_cart, + color: primaryColor, + ), + TextButton( + child: Text( + 'Order Medicines / Other Products', + style: textButtonStyle(), + ), + onPressed: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicines(prescriptionDetails:reportsList[index]))); + //signup screen + }, + )], ) ], ), @@ -587,6 +918,350 @@ class _PrescriptionsState extends State { )); }) ), ]); + } + else{ + return Padding(padding: EdgeInsets.fromLTRB(60,10,60,10), + child: Column( + children: [ + Text('No prescriptions found related to your search'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: Colors.red, + radius: 30, + child: const Icon( + Icons.info, + color: Colors.white, + ), + ) + ], + ),); + } + } + + Widget _allPrescriptions(){ + + if(reportsListOriginal.length!=0){ + + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), + child: DropdownButtonFormField( + // Initial Value + value: dropdownSearchType, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.search, + color: greyColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'Search By', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + hint: Text('Select Search Type'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: typeOfSearchItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownSearchType = newValue!; + }); + }, + ), + ), + Visibility( + visible:dropdownSearchType.toString().toLowerCase()=='problem' , + child: Container( + height: MediaQuery.of(context).size.height * .07, + padding: EdgeInsets.all(5), + child: Center(child: TextField( + + cursorColor: primaryColor, + controller: searchController, + onChanged: (string) { + if(string.length>=1){ + getRecordsByProblemName(string); + } + else{ + getAllRecords(); + } + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.search, + color: primaryColor, + ), + /*suffixIcon: Icon( + Icons.clear, + color: greyColor, + ),*/ + suffixIcon: searchController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + searchController.text=''; + }); + getAllRecords(); + }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + //labelText: 'Search by phone number', + hintText: 'Search by problem', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ),) + ),), + Visibility( + visible:dropdownSearchType.toString().toLowerCase()=='doctor' , + child: Container( + height: MediaQuery.of(context).size.height * .07, + padding: EdgeInsets.all(5), + child: Center(child: TextField( + + cursorColor: primaryColor, + controller: searchController, + onChanged: (string) { + if(string.length>=1){ + getRecordsByDoctorName(string); + } + else{ + getAllRecords(); + } + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.search, + color: primaryColor, + ), + /*suffixIcon: Icon( + Icons.clear, + color: greyColor, + ),*/ + suffixIcon: searchController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + searchController.text=''; + }); + getAllRecords(); + }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + //labelText: 'Search by phone number', + hintText: 'Search by doctor', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ),) + ),), + Visibility( + visible:dropdownSearchType.toString().toLowerCase()=='date' , + child: Container( + height: MediaQuery.of(context).size.height * .07, + padding: EdgeInsets.all(5), + child: Center(child: TextField( + + cursorColor: primaryColor, + controller: searchController, + onChanged: (string) { + if(string.length>=1){ + getRecordsByDate(string); + } + else{ + getAllRecords(); + } + }, + onTap: () async { + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(1950), + lastDate: DateTime.now(), + builder: (BuildContext context, Widget? child) { + return Theme( + data: ThemeData.dark().copyWith( + colorScheme: ColorScheme.dark( + primary: buttonColors, + onPrimary: Colors.white, + surface: buttonColors, + onSurface: Colors.white, + ), + dialogBackgroundColor: primaryColor, + ), + child: child!, + ); + }, + ); + + if (pickedDate != null) { + print( + pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000 + String formattedDate = + DateFormat('dd-MM-yyyy').format(pickedDate); + print( + formattedDate); //formatted date output using intl package => 2021-03-16 + setState(() { + searchController.text = formattedDate; //set output date to TextField value. + }); + getRecordsByDate(searchController.text); + } else {} + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.search, + color: primaryColor, + ), + suffixIcon: searchController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + searchController.text=''; + }); + getAllRecords(); + }, + ):IconButton( + icon: Icon( + Icons.clear, + color: Colors.transparent, + ), + onPressed: () { + }, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: primaryColor), + borderRadius: BorderRadius.circular(30), + ), + //labelText: 'Search by phone number', + hintText: 'Search by date', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ),) + ), + + + ), + Expanded(child: _filtereddata()), + Padding( + padding: EdgeInsets.fromLTRB(8, 8, 8, 8), + child: CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async{ + /*await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AddPrescription()), + );*/ + Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) { + getAllRecords(); + }); + //showBoreAddingDialog(); + }, + ), + /* Padding( + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), + child: Text( + 'Add Tanks ', + style: TextStyle(color: Colors.white), + ), + )*/ + ], + ), + ), + ), + ]); + + } else{ return Center( @@ -596,7 +1271,7 @@ class _PrescriptionsState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: MediaQuery.of(context).size.height * .25,), - Text('No prescriptions added as of now'), + Text('Click below icon to add new Record'), SizedBox( height: 20, ), @@ -606,10 +1281,13 @@ class _PrescriptionsState extends State { child: IconButton( iconSize: 40, icon: const Icon( - Icons.info, + Icons.add, color: Colors.white, ), onPressed: () async { + Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) { + getAllRecords(); + }); }, ), ) @@ -618,6 +1296,8 @@ class _PrescriptionsState extends State { ) ); } + + } /**/ diff --git a/lib/Reports/order_medicines_new.dart b/lib/trash/order_medicines_new.dart similarity index 100% rename from lib/Reports/order_medicines_new.dart rename to lib/trash/order_medicines_new.dart diff --git a/lib/updates/update_location.dart b/lib/updates/update_location.dart new file mode 100644 index 0000000..d058850 --- /dev/null +++ b/lib/updates/update_location.dart @@ -0,0 +1,214 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'package:location/location.dart' as locationmap; +import '../google_maps_place_picker_mb/src/models/pick_result.dart'; +import '../google_maps_place_picker_mb/src/place_picker.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:healthcare_user/google_maps_place_picker_mb/google_maps_place_picker.dart'; +import 'package:healthcare_user/keys.dart'; + + + +class UpdateMyLocation extends StatefulWidget { + const UpdateMyLocation({Key? key}) : super(key: key); + + @override + State createState() => _UpdateMyLocationState(); +} + +class _UpdateMyLocationState extends State { + + PickResult? selectedPlace; + bool _mapsInitialized = false; + final String _mapsRenderer = "latest"; + var kInitialPosition = const LatLng(15.462477, 78.717401); + locationmap.Location location = locationmap.Location(); + final GoogleMapsFlutterPlatform mapsImplementation = GoogleMapsFlutterPlatform.instance; + double lat=0; + double lng=0; + + void initRenderer() { + if (_mapsInitialized) return; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + switch (_mapsRenderer) { + case "legacy": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.legacy); + break; + case "latest": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.latest); + break; + } + } + setState(() { + _mapsInitialized = true; + }); + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Update My Location'), + body: Padding( + padding: EdgeInsets.all(10), + child: Column( + children: [ + Container( + child: Row( + children: [ + Text('Current Location :',style: labelTextStyle(),), + SizedBox(width:MediaQuery.of(context).size.width * .02,), + Text(AppSettings.userAddress,style:wrapTextStyleBlack(),) + ], + ), + ), + SizedBox(height:MediaQuery.of(context).size.height * .04,), + Container( + width:double.infinity, + height: MediaQuery.of(context).size.height * .05, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async{ + + + //============================================================================================= + + location.serviceEnabled().then((value) { + if (value) { + initRenderer(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return PlacePicker( + resizeToAvoidBottomInset: false, + hintText: "Find a place ...", + searchingText: "Please wait ...", + selectText: "Select place", + outsideOfPickAreaText: "Place not in area", + initialPosition: kInitialPosition, + useCurrentLocation: true, + selectInitialPosition: true, + usePinPointingSearch: true, + usePlaceDetailSearch: true, + zoomGesturesEnabled: true, + zoomControlsEnabled: true, + onMapCreated: (GoogleMapController controller) {}, + onPlacePicked: (PickResult result) async { + + + setState(() { + selectedPlace = result; + lat=selectedPlace!.geometry!.location.lat; + lng=selectedPlace!.geometry!.location.lng; + + + /*if(selectedPlace!.types!.length==1){ + userAddressCapturingController.text = + selectedPlace!.formattedAddress!; + } + else{ + userAddressCapturingController.text =selectedPlace!.name!+', '+selectedPlace!.formattedAddress!; + }*/ + Navigator.of(context).pop(); + }); + + var payload = new Map(); + payload["latitude"] = lat; + payload["longitude"] = lng; + bool updateStatus = await AppSettings.updateLocation(payload); + if(updateStatus){ + setState(() { + if(selectedPlace!.types!.length==1){ + AppSettings.userAddress = + selectedPlace!.formattedAddress!; + } + else{ + AppSettings.userAddress=selectedPlace!.name!+', '+selectedPlace!.formattedAddress!; + } + }); + + } + else{ + AppSettings.longFailedToast( + "Failed to update location"); + } + + }, + onMapTypeChanged: (MapType mapType) {}, + apiKey: Platform.isAndroid + ? APIKeys.androidApiKey + : APIKeys.iosApiKey, + forceAndroidLocationManager: true, + ); + }, + ), + ); + } else { + showGeneralDialog( + context: context, + pageBuilder: (context, x, y) { + return Scaffold( + backgroundColor: Colors.grey.withOpacity(.5), + body: Center( + child: Container( + width: double.infinity, + height: 150, + padding: + const EdgeInsets.symmetric(horizontal: 20), + child: Card( + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + "Please enable the location", + style: TextStyle( + fontSize:18, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox( + height: 20, + ), + ElevatedButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Cancel"), + ), + ], + ), + ), + ), + ), + ), + ); + }, + ); + } + }); + + }, + child: const Text('Update My Location'), + )), + + + + ], + ), + ) + ); + + } +} diff --git a/lib/updates/update_pin.dart b/lib/updates/update_pin.dart new file mode 100644 index 0000000..bf6b05c --- /dev/null +++ b/lib/updates/update_pin.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:healthcare_user/common/settings.dart'; + +class UpdatePin extends StatefulWidget { + const UpdatePin({Key? key}) : super(key: key); + + @override + State createState() => _UpdatePinState(); +} + +class _UpdatePinState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Update Pin'), + body: Container(), + ); + + } +} diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index f6f23bf..7299b5c 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,9 +6,13 @@ #include "generated_plugin_registrant.h" +#include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index f16b4c3..786ff5c 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + file_selector_linux url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 1952d66..0a6c0bb 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,7 @@ import Foundation import cloud_firestore import device_info_plus_macos +import file_selector_macos import firebase_core import firebase_messaging import flutter_local_notifications @@ -19,6 +20,7 @@ import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 14bcec6..16425da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _flutterfire_internals url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "1.3.6" archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.3.7" + version: "3.4.2" args: dependency: transitive description: @@ -98,21 +98,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "4.8.0" + version: "4.9.2" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "5.15.0" + version: "5.16.1" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "3.6.0" + version: "3.7.1" cloudinary_public: dependency: "direct dev" description: @@ -175,14 +175,14 @@ packages: name: day_night_time_picker url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.0+1" dbus: dependency: transitive description: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.3" + version: "0.7.4" device_info_plus: dependency: "direct dev" description: @@ -238,7 +238,7 @@ packages: name: dio url: "https://pub.dartlang.org" source: hosted - version: "5.2.0+1" + version: "5.3.3" dots_indicator: dependency: "direct dev" description: @@ -267,13 +267,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.4" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.2" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.3+1" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.6.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.3" firebase_core: dependency: transitive description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "2.13.1" + version: "2.16.0" firebase_core_platform_interface: dependency: transitive description: @@ -287,28 +315,28 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.0" firebase_messaging: dependency: "direct dev" description: name: firebase_messaging url: "https://pub.dartlang.org" source: hosted - version: "14.6.2" + version: "14.6.8" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.5.2" + version: "4.5.7" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web url: "https://pub.dartlang.org" source: hosted - version: "3.5.2" + version: "3.5.7" flutter: dependency: "direct main" description: flutter @@ -348,7 +376,7 @@ packages: name: flutter_lints url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_local_notifications: dependency: "direct dev" description: @@ -370,11 +398,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.0" - flutter_localizations: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" + flutter_native_contact_picker: + dependency: "direct dev" + description: + name: flutter_native_contact_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -389,20 +419,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - flutter_styled_toast: - dependency: "direct dev" - description: - name: flutter_styled_toast - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" flutter_svg: dependency: "direct main" description: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.1.6" flutter_svg_provider: dependency: "direct main" description: @@ -440,7 +463,7 @@ packages: name: geocoding_android url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" geocoding_ios: dependency: transitive description: @@ -468,35 +491,35 @@ packages: name: geolocator_android url: "https://pub.dartlang.org" source: hosted - version: "4.1.8" + version: "4.3.1" geolocator_apple: dependency: transitive description: name: geolocator_apple url: "https://pub.dartlang.org" source: hosted - version: "2.2.6" + version: "2.3.2" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.7" + version: "4.1.0" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.6" + version: "2.2.0" geolocator_windows: dependency: transitive description: name: geolocator_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.1" + version: "0.1.3" get: dependency: "direct dev" description: @@ -531,7 +554,7 @@ packages: name: google_maps_flutter_android url: "https://pub.dartlang.org" source: hosted - version: "2.4.15" + version: "2.4.16" google_maps_flutter_ios: dependency: transitive description: @@ -545,14 +568,14 @@ packages: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.2.7" + version: "2.4.0" google_maps_flutter_web: dependency: transitive description: name: google_maps_flutter_web url: "https://pub.dartlang.org" source: hosted - version: "0.5.0+1" + version: "0.5.3" google_maps_place_picker_mb: dependency: "direct dev" description: @@ -594,49 +617,63 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.3.0" image_picker: dependency: "direct dev" description: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.7+5" + version: "0.8.9" image_picker_android: dependency: transitive description: name: image_picker_android url: "https://pub.dartlang.org" source: hosted - version: "0.8.6+19" + version: "0.8.7+4" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.12" + version: "2.2.0" image_picker_ios: dependency: transitive description: name: image_picker_ios url: "https://pub.dartlang.org" source: hosted - version: "0.8.7+4" + version: "0.8.8" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" image_picker_platform_interface: dependency: transitive description: name: image_picker_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.6.4" - imei_plugin: - dependency: "direct dev" + version: "2.9.0" + image_picker_windows: + dependency: transitive description: - name: imei_plugin + name: image_picker_windows url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "0.2.1" intl: dependency: "direct dev" description: @@ -721,6 +758,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" multi_image_picker: dependency: "direct dev" description: @@ -811,14 +855,14 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.11" + version: "2.2.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.0" path_provider_windows: dependency: transitive description: @@ -832,35 +876,35 @@ packages: name: permission_handler url: "https://pub.dartlang.org" source: hosted - version: "10.3.0" + version: "10.4.5" permission_handler_android: dependency: transitive description: name: permission_handler_android url: "https://pub.dartlang.org" source: hosted - version: "10.2.3" + version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple url: "https://pub.dartlang.org" source: hosted - version: "9.1.0" + version: "9.1.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.10.0" + version: "3.11.5" permission_handler_windows: dependency: transitive description: name: permission_handler_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.3" petitparser: dependency: transitive description: @@ -888,14 +932,14 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.5" pointycastle: dependency: transitive description: @@ -923,56 +967,56 @@ packages: name: sanitize_html url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" shared_preferences: dependency: "direct dev" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.2.0" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.2.0" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation url: "https://pub.dartlang.org" source: hosted - version: "2.2.2" + version: "2.3.3" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.3.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.3.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.3.0" sizer: dependency: "direct dev" description: @@ -1047,7 +1091,7 @@ packages: name: tuple url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" typed_data: dependency: transitive description: @@ -1075,7 +1119,7 @@ packages: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.35" + version: "6.0.38" url_launcher_ios: dependency: transitive description: @@ -1096,28 +1140,28 @@ packages: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "3.0.5" + version: "3.0.6" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.17" + version: "2.0.18" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "3.0.6" + version: "3.0.7" uuid: dependency: "direct main" description: @@ -1152,7 +1196,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.4.1" + version: "6.1.0" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e5feb3a..abcb80b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,7 +38,6 @@ dev_dependencies: url_launcher: ^6.1.9 intl: ^0.17.0 flutter_svg: ^1.0.1 - flutter_styled_toast: ^2.1.3 google_maps_place_picker_mb: ^2.0.0-mb.22 flutter_datetime_picker: ^1.5.1 date_time_picker: ^2.1.0 @@ -48,7 +47,6 @@ dev_dependencies: flutter_local_notifications: ^9.0.2 cloud_firestore: ^4.5.2 flutter_device_type: ^0.4.0 - imei_plugin: ^1.2.0 device_information: ^0.0.4 device_info_plus: ^3.2.4 overlay_support: ^2.1.0 @@ -67,6 +65,7 @@ dev_dependencies: dots_indicator: ^3.0.0 multi_image_picker: ^4.8.1 charts_flutter: ^0.12.0 + flutter_native_contact_picker: ^0.0.4 flutter_icons: image_path_ios: 'images/appicon.png' diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 2cd4f25..5d27235 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,12 +6,15 @@ #include "generated_plugin_registrant.h" +#include #include #include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); FirebaseCorePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); GeolocatorWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 8ae151b..ec01e6b 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + file_selector_windows firebase_core geolocator_windows permission_handler_windows