parent
							
								
									7dc0d0f426
								
							
						
					
					
						commit
						233a8bf7e5
					
				
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -0,0 +1,283 @@ | |||||||
|  | import 'dart:convert'; | ||||||
|  | 
 | ||||||
|  | import 'package:flutter/material.dart'; | ||||||
|  | import 'package:healthcare_user/Reports/allreports.dart'; | ||||||
|  | import 'package:healthcare_user/Reports/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'; | ||||||
|  | import 'package:image_picker/image_picker.dart'; | ||||||
|  | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||||
|  | 
 | ||||||
|  | class PrescriptionImages extends StatefulWidget { | ||||||
|  |   var imageDetails; | ||||||
|  |   var recordId; | ||||||
|  |   var familyDetails; | ||||||
|  | 
 | ||||||
|  |   PrescriptionImages({this.imageDetails, this.recordId,this.familyDetails}); | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   State<PrescriptionImages> createState() => _PrescriptionImagesState(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class _PrescriptionImagesState extends State<PrescriptionImages> { | ||||||
|  |   final ImagePicker imagePicker = ImagePicker(); | ||||||
|  |   List imageFileList = []; | ||||||
|  |   List uiPrescriptionImages = []; | ||||||
|  | 
 | ||||||
|  |   Future pickImageFromGallery() async { | ||||||
|  |     imageFileList = []; | ||||||
|  |     final List<XFile>? selectedImages = await imagePicker.pickMultiImage(); | ||||||
|  |     AppSettings.preLoaderDialog(context); | ||||||
|  |     if (selectedImages!.isNotEmpty) { | ||||||
|  |       imageFileList.addAll(selectedImages); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     var res = await AppSettings.uploadImageForPrescriptions(imageFileList); | ||||||
|  |     print(jsonDecode(res)); | ||||||
|  |     Navigator.of(context, rootNavigator: true).pop(); | ||||||
|  |     setState(() { | ||||||
|  |       widget.imageDetails = jsonDecode(res)['findings']; | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   Widget renderUi() { | ||||||
|  |     if (widget.imageDetails.length != 0) { | ||||||
|  |       return Column( | ||||||
|  |         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: 'Prescripitons', | ||||||
|  |                                 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 { | ||||||
|  |                               AppSettings.preLoaderDialog(context); | ||||||
|  | 
 | ||||||
|  |                               String fileName = widget.imageDetails[index] | ||||||
|  |                                       ['url'] | ||||||
|  |                                   .split('/') | ||||||
|  |                                   .last; | ||||||
|  | 
 | ||||||
|  |                               var payload = new Map<String, dynamic>(); | ||||||
|  |                               payload["urlType"] = 'prescriptions'; | ||||||
|  |                               payload["url"] = | ||||||
|  |                                   widget.imageDetails[index]['url']; | ||||||
|  | 
 | ||||||
|  |                               bool deleteStatus = | ||||||
|  |                                   await AppSettings.deleteRecords( | ||||||
|  |                                       payload, widget.recordId); | ||||||
|  | 
 | ||||||
|  |                               if (deleteStatus) { | ||||||
|  |                                 Navigator.of(context, rootNavigator: true) | ||||||
|  |                                     .pop(); | ||||||
|  |                                 AppSettings.longSuccessToast( | ||||||
|  |                                     "Image deleted Successfully"); | ||||||
|  |                                 //AllReportsState().getAllRecords(); | ||||||
|  |                                 Navigator.pop(context); | ||||||
|  |                               } else { | ||||||
|  |                                 Navigator.of(context, rootNavigator: true) | ||||||
|  |                                     .pop(); | ||||||
|  |                                 AppSettings.longFailedToast( | ||||||
|  |                                     "Image deletion failed"); | ||||||
|  |                               } | ||||||
|  |                             }, | ||||||
|  |                           ), | ||||||
|  |                         ), | ||||||
|  |                       ) | ||||||
|  |                     ]), | ||||||
|  |                   ), | ||||||
|  | 
 | ||||||
|  |                   //Image.network(widget.imageDetails[index]['url']), | ||||||
|  |                 ); | ||||||
|  |               }, | ||||||
|  |             ), | ||||||
|  |           ), | ||||||
|  |           TextButton( | ||||||
|  |             child: const Text( | ||||||
|  |               'Order Medicines', | ||||||
|  |               style: TextStyle(color: primaryColor), | ||||||
|  |             ), | ||||||
|  |             onPressed: () { | ||||||
|  | 
 | ||||||
|  |               Navigator.push( | ||||||
|  |                   context, | ||||||
|  |                   new MaterialPageRoute( | ||||||
|  |                       builder: (__) => new OrderMedicinesPrescriptions(prescriptionDetails:widget.imageDetails,familyDetails: widget.familyDetails,))); | ||||||
|  |               //signup screen | ||||||
|  |             }, | ||||||
|  |           ) | ||||||
|  | 
 | ||||||
|  |         ], | ||||||
|  |       ); | ||||||
|  |     } 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<void>( | ||||||
|  |                       context: context, | ||||||
|  |                       builder: (BuildContext context) { | ||||||
|  |                         return SizedBox( | ||||||
|  |                           height: 200, | ||||||
|  |                           child: Center( | ||||||
|  |                             child: Row( | ||||||
|  |                               mainAxisAlignment: MainAxisAlignment.center, | ||||||
|  |                               children: <Widget>[ | ||||||
|  |                                 GestureDetector( | ||||||
|  |                                   child: Icon( | ||||||
|  |                                     Icons.camera_alt_outlined, | ||||||
|  |                                     size: 100, | ||||||
|  |                                     color: primaryColor, | ||||||
|  |                                   ), | ||||||
|  |                                   onTap: () async { | ||||||
|  |                                     //await takeImageFromCamera(); | ||||||
|  |                                     Navigator.pop(context); | ||||||
|  |                                   }, | ||||||
|  |                                 ), | ||||||
|  |                                 SizedBox( | ||||||
|  |                                   width: | ||||||
|  |                                       MediaQuery.of(context).size.width * .20, | ||||||
|  |                                 ), | ||||||
|  |                                 GestureDetector( | ||||||
|  |                                   child: Icon( | ||||||
|  |                                     Icons.photo, | ||||||
|  |                                     size: 100, | ||||||
|  |                                     color: primaryColor, | ||||||
|  |                                   ), | ||||||
|  |                                   onTap: () async { | ||||||
|  |                                     await pickImageFromGallery(); | ||||||
|  |                                     Navigator.pop(context); | ||||||
|  |                                   }, | ||||||
|  |                                 ), | ||||||
|  |                               ], | ||||||
|  |                             ), | ||||||
|  |                           ), | ||||||
|  |                         ); | ||||||
|  |                       }); | ||||||
|  |                 }, | ||||||
|  |               ), | ||||||
|  |             ) | ||||||
|  |           ], | ||||||
|  |         ), | ||||||
|  |       )); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   @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<void>( | ||||||
|  |                     context: context, | ||||||
|  |                     builder: (BuildContext context) { | ||||||
|  |                       return SizedBox( | ||||||
|  |                         height: 200, | ||||||
|  |                         child: Center( | ||||||
|  |                           child: Row( | ||||||
|  |                             mainAxisAlignment: MainAxisAlignment.center, | ||||||
|  |                             children: <Widget>[ | ||||||
|  |                               GestureDetector( | ||||||
|  |                                 child: Icon( | ||||||
|  |                                   Icons.camera_alt_outlined, | ||||||
|  |                                   size: 100, | ||||||
|  |                                   color: primaryColor, | ||||||
|  |                                 ), | ||||||
|  |                                 onTap: () async { | ||||||
|  |                                   //await takeImageFromCamera(); | ||||||
|  |                                   Navigator.pop(context); | ||||||
|  |                                 }, | ||||||
|  |                               ), | ||||||
|  |                               SizedBox( | ||||||
|  |                                 width: MediaQuery.of(context).size.width * .20, | ||||||
|  |                               ), | ||||||
|  |                               GestureDetector( | ||||||
|  |                                 child: Icon( | ||||||
|  |                                   Icons.photo, | ||||||
|  |                                   size: 100, | ||||||
|  |                                   color: primaryColor, | ||||||
|  |                                 ), | ||||||
|  |                                 onTap: () async { | ||||||
|  |                                   await pickImageFromGallery(); | ||||||
|  |                                   Navigator.pop(context); | ||||||
|  |                                 }, | ||||||
|  |                               ), | ||||||
|  |                             ], | ||||||
|  |                           ), | ||||||
|  |                         ), | ||||||
|  |                       ); | ||||||
|  |                     }); | ||||||
|  |               }, | ||||||
|  |             ), | ||||||
|  |           ) | ||||||
|  |         ], | ||||||
|  |       ), | ||||||
|  |       body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in new issue