From c331f12bccd0b6a717bac890b4836bef113ee82c Mon Sep 17 00:00:00 2001 From: Sneha Date: Tue, 31 Oct 2023 15:34:56 +0530 Subject: [PATCH] qr code generator and share completed --- lib/Reports/allreports.dart | 428 +++- lib/common/dashboard.dart | 256 ++- lib/common/qrcode_display.dart | 124 ++ lib/common/settings.dart | 44 +- lib/common/signup.dart | 2 +- lib/edit_medicine_timings.dart | 162 +- lib/invitations/invitations.dart | 2 +- lib/models/reports_model.dart | 3 + lib/my_connections/all_connections.dart | 19 + lib/my_medicine_timings.dart | 284 +-- lib/prescriptions/prescriptions.dart | 1 + .../all-records_onclick_new.dart | 1813 +++++++++++++++++ pubspec.lock | 28 + pubspec.yaml | 3 + 14 files changed, 2769 insertions(+), 400 deletions(-) create mode 100644 lib/common/qrcode_display.dart create mode 100644 lib/my_connections/all_connections.dart create mode 100644 lib/report_problem/all-records_onclick_new.dart diff --git a/lib/Reports/allreports.dart b/lib/Reports/allreports.dart index 81cdf2c..a8f7b23 100644 --- a/lib/Reports/allreports.dart +++ b/lib/Reports/allreports.dart @@ -10,6 +10,7 @@ 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:healthcare_user/report_problem/all-records_onclick_new.dart'; import 'package:photo_view/photo_view.dart'; import 'package:intl/intl.dart'; @@ -29,7 +30,11 @@ class _AllReportsState extends State { bool isSereverIssue = false; TextEditingController searchController = TextEditingController(); TextEditingController dateInput = TextEditingController(); + TextEditingController fromdateController = TextEditingController(); + TextEditingController todateController = TextEditingController(); + DateTime fromDate=DateTime.now(); String dropdownSearchType = 'Problem'; + String? searchBy; var typeOfSearchItems = [ 'Problem', 'Doctor', @@ -133,9 +138,57 @@ class _AllReportsState extends State { } } + + Future getRecordsByDateRange(var fromDate,var toDate) 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(); + var dateToCheck = DateTime.now().add(Duration(days: -1)); + + reportsList = reportsListOriginal.reversed.where((product) { + final date = product.dateForFilter; + final startDate =DateFormat('dd-MM-yyyy').parse(fromDate); + final endDate = DateFormat('dd-MM-yyyy').parse(toDate); + return date.isAfter(startDate) && date.isBefore(endDate); + + //reportsList=reportsListOriginal.reversed.toList(); + }).toList(); + + /*if( dateToCheck.isAfter(startDate) && dateToCheck.isBefore(endDate)) + { + print("dateToCheck is between now and lastYear"); + } + else + { + print("dateToCheck is not between now and lastYear"); + }*/ + + + isReportsDataLoading = false; + }); + } catch (e) { + setState(() { + isReportsDataLoading = false; + isSereverIssue = true; + }); + } + } + @override void initState() { getAllRecords(); + var now = new DateTime.now(); + String formattedDate = DateFormat('dd-MM-yyyy').format(now); + fromdateController.text=formattedDate; + todateController.text=formattedDate; super.initState(); } @@ -333,6 +386,7 @@ class _AllReportsState extends State { Widget _filtereddata(){ if(reportsList.length!=0){ + reportsList.sort((a, b) => b.date.compareTo(a.date)); return ListView.builder( padding: EdgeInsets.all(0), itemCount: reportsList.length, @@ -343,7 +397,7 @@ class _AllReportsState extends State { Navigator.push( context, new MaterialPageRoute( - builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { + builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { getAllRecords(); }); }, @@ -470,18 +524,18 @@ class _AllReportsState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async { - /*Navigator.push( + Navigator.push( context, new MaterialPageRoute( - builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { + builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { getAllRecords(); - });*/ - Navigator.push( + }); + /*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(),), ), @@ -494,18 +548,18 @@ class _AllReportsState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async { - /*Navigator.push( + Navigator.push( context, new MaterialPageRoute( - builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages,recordId:reportsList[index].recordId ,))).then((value) { + builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { getAllRecords(); - });*/ - Navigator.push( + }); + /*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()), @@ -519,19 +573,19 @@ class _AllReportsState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async { - /*Navigator.push( + Navigator.push( context, new MaterialPageRoute( - builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index],details:reportsList[index] ,))).then((value) { + builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) { getAllRecords(); - });*/ + }); - Navigator.push( + /*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()), @@ -596,7 +650,7 @@ class _AllReportsState extends State { return Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ - Container( + /*Container( padding: const EdgeInsets.fromLTRB(10, 10, 10, 0), child: DropdownButtonFormField( // Initial Value @@ -640,9 +694,69 @@ class _AllReportsState extends State { }); }, ), + ),*/ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding(padding: EdgeInsets.fromLTRB(10,10,0,0), + child: Text('Please select search option',style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 16),),), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: RadioListTile( + title: Text("Problem", style: TextStyle(fontSize: 10)), + value: "problem", + groupValue: searchBy, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + searchBy = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: Text( + "Doctor", + style: TextStyle(fontSize: 10), + ), + value: "doctor", + groupValue: searchBy, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + searchBy = value.toString(); + }); + }, + ), + ), + Expanded( + child: RadioListTile( + title: + Text("Date", style: TextStyle(fontSize: 10)), + value: "date", + groupValue: searchBy, + activeColor: primaryColor, + onChanged: (value) { + setState(() { + searchBy = value.toString(); + }); + }, + ), + ), + ], + ), + ], + ) + ), Visibility( - visible:dropdownSearchType.toString().toLowerCase()=='problem' , + visible:searchBy.toString().toLowerCase()=='problem' , child: Container( height: MediaQuery.of(context).size.height * .07, padding: EdgeInsets.all(5), @@ -707,7 +821,7 @@ class _AllReportsState extends State { ),) ),), Visibility( - visible:dropdownSearchType.toString().toLowerCase()=='doctor' , + visible:searchBy.toString().toLowerCase()=='doctor' , child: Container( height: MediaQuery.of(context).size.height * .07, padding: EdgeInsets.all(5), @@ -772,7 +886,204 @@ class _AllReportsState extends State { ),) ),), Visibility( - visible:dropdownSearchType.toString().toLowerCase()=='date' , + visible:searchBy.toString().toLowerCase()=='date', + child: Container( + //height: 60, + padding: EdgeInsets.all(5), + child: Row( + children: [ + Expanded( + child: TextField( + + cursorColor: primaryColor, + controller: fromdateController, + 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(() { + fromDate=pickedDate; + fromdateController.text = formattedDate; //set output date to TextField value. + }); + getRecordsByDateRange(fromdateController.text,todateController.text); + } else {} + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.calendar_month, + color: primaryColor, + ), + suffixIcon: fromdateController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + fromdateController.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: 'From date', + + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + SizedBox(width: 5), + Expanded( + child: TextField( + + cursorColor: primaryColor, + controller: todateController, + onChanged: (string) { + if(string.length>=1){ + //getRecordsByDate(string); + } + else{ + getAllRecords(); + } + }, + onTap: () async { + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: fromDate, + 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(() { + todateController.text = formattedDate; //set output date to TextField value. + }); + getRecordsByDateRange(fromdateController.text,todateController.text); + } else {} + }, + decoration: InputDecoration( + prefixIcon: Icon( + Icons.calendar_month, + color: primaryColor, + ), + suffixIcon: todateController.text!=''?IconButton( + icon: Icon( + Icons.clear, + color: Colors.red, + ), + onPressed: () { + setState(() { + todateController.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: 'To date', + + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + ), + ), + SizedBox(width: 5), + + ], + ), + ),), + /*Visibility( + visible:searchBy.toString().toLowerCase()=='date' , child: Container( height: MediaQuery.of(context).size.height * .07, padding: EdgeInsets.all(5), @@ -870,45 +1181,9 @@ class _AllReportsState extends State { ), - ), + ),*/ 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), - ), - )*/ - ], - ), - ), - ), + ]); @@ -961,6 +1236,43 @@ class _AllReportsState extends State { strokeWidth: 5.0, ), ): _allreports(), + floatingActionButton: Visibility( + visible:reportsListOriginal.length!=0, + child: CircleAvatar( + backgroundColor: buttonColors, + radius: 40, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.black, + ), + 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), + ), + )*/ + ], + ), + ), + ), ); } } diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index 78dde5f..d84d1ae 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -2,11 +2,13 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:healthcare_user/Reports/allreports.dart'; +import 'package:healthcare_user/common/qrcode_display.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/invitations.dart'; import 'package:healthcare_user/medicines.dart'; +import 'package:healthcare_user/my_connections/all_connections.dart'; import 'package:healthcare_user/my_health.dart'; import 'package:healthcare_user/my_medicine_timings.dart'; import 'package:healthcare_user/prescriptions/prescriptions.dart'; @@ -376,7 +378,11 @@ class _DashboardState extends State { fit: BoxFit.fitWidth)), ), onTap: () { - + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AllConnections()), + ); }, ), Text( @@ -556,116 +562,178 @@ class _DashboardState extends State { decoration: const BoxDecoration( color: buttonColors, ), - child: Row( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Column( + Expanded(child: Row( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - child: GestureDetector( - child: Container( - width: MediaQuery.of(context).size.width * .20, - height: - MediaQuery.of(context).size.height * .15, - decoration: BoxDecoration( - shape: BoxShape.circle, - image: DecorationImage( - image: (AppSettings.profilePictureUrl != - '' && - AppSettings.profilePictureUrl != - 'null') - ? NetworkImage(AppSettings - .profilePictureUrl) - as ImageProvider - : AssetImage( - "images/profile_pic.png"), // picked file - fit: BoxFit.fitWidth)), + GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .20, + height: + MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + + shape: BoxShape.circle, + image: DecorationImage( + image: (AppSettings.profilePictureUrl != + '' && + AppSettings.profilePictureUrl != + 'null') + ? NetworkImage(AppSettings + .profilePictureUrl) + as ImageProvider + : AssetImage( + "images/profile_pic.png"), + + fit:BoxFit.fitWidth // picked file + ), ), - onTap: () { - 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); - }, - ), - SizedBox( - width: MediaQuery.of(context) - .size - .width * - .20, + ), + onTap: () { + 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 pickImageFromGallery(); - 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, ), - ], - ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], ), - ); - }); + ), + ); + }); + }, + ), + Container( + + /*height:MediaQuery.of(context).size.height * 2.500, + width: MediaQuery.of(context).size.height * .05,*/ + child: AppSettings.qrCode==''?TextButton( + child: Text( + 'GetQR', + style: TextStyle( + fontSize: 15, + color: Colors.white, + decoration: TextDecoration.underline, + ), + ), + onPressed: () async{ + AppSettings.preLoaderDialog(context); + + try{ + var value = await AppSettings.generateQRCode(); + var valueResponse = jsonDecode(value); + String dataUri = jsonDecode(value)['qrCodeData']; + +// Split the data URI at the comma to extract the Base64 part + List parts = dataUri.split(","); + String? base64String = parts.length == 2 ? parts[1] : null; + + if (base64String != null) { + // Now, you have the Base64-encoded image data in the 'base64String' variable + // You can use this 'base64String' in your Flutter code as needed + print(base64String); + AppSettings.qrCode=base64String; + } else { + print("Invalid data URI"); + } + Navigator.of(context, rootNavigator: true).pop(); + } + catch(e){ + Navigator.of(context, rootNavigator: true).pop(); + } + + + }, + ):GestureDetector( + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const DisplayQrCode()), + ); + }, + child: Container( + height:MediaQuery.of(context).size.height * .20, + width:MediaQuery.of(context).size.width * .1, + child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode))), + ), + ), + + ) + ], + ),), + Text( + AppSettings.userName, + style: drawerHeaderTextStyleNew(), + ), + Text( + AppSettings.phoneNumber, + style: drawerHeaderTextStyleNew(), + ), + Visibility( + visible: AppSettings.email != '', + child: Text( + AppSettings.email, + style: drawerHeaderTextStyleNew(), + ), + ), + Row( + children: [ + Visibility( + visible: AppSettings.age != '', + child: Text( + AppSettings.age + ' Yrs, ', + style: drawerHeaderTextStyleNew(), ), - ), - Text( - AppSettings.userName, - style: drawerHeaderTextStyleNew(), - ), - Text( - AppSettings.phoneNumber, - style: drawerHeaderTextStyleNew(), ), Visibility( - visible: AppSettings.email != '', + visible: AppSettings.gender != '', child: Text( - AppSettings.email, + AppSettings.gender, style: drawerHeaderTextStyleNew(), ), ), - Row( - children: [ - Visibility( - visible: AppSettings.age != '', - child: Text( - AppSettings.age + ' Yrs, ', - style: drawerHeaderTextStyleNew(), - ), - ), - Visibility( - visible: AppSettings.gender != '', - child: Text( - AppSettings.gender, - style: drawerHeaderTextStyleNew(), - ), - ), - ], - ) ], - ), - Container() + ) ], - )), + ),), ListTile( title: Row( children: [ diff --git a/lib/common/qrcode_display.dart b/lib/common/qrcode_display.dart new file mode 100644 index 0000000..f6ea1b5 --- /dev/null +++ b/lib/common/qrcode_display.dart @@ -0,0 +1,124 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:ui'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:flutter_share/flutter_share.dart'; +import 'package:share/share.dart'; +import 'dart:typed_data'; +import 'package:path_provider/path_provider.dart'; +import 'package:http/http.dart' as http; +import 'package:qr_flutter/qr_flutter.dart'; + + + +class DisplayQrCode extends StatefulWidget { + const DisplayQrCode({Key? key}) : super(key: key); + + @override + State createState() => _DisplayQrCodeState(); +} + +class _DisplayQrCodeState extends State { + + + + Future share(var qr) async { + await FlutterShare.share( + title: 'Example share', + text: 'Example share text', + linkUrl: qr, + chooserTitle: 'Example Chooser Title'); + } + + Future shareQRCodeImage1(qrData) async { + + final tempDir = await getTemporaryDirectory(); + final file = File('${tempDir.path}/qr_code.png'); + await file.writeAsBytes(Uint8List.fromList(base64.decode(qrData))); + + // Share the image using the share package + Share.shareFiles([file.path], text: 'Check out this QR code'); + + } + + String imagePath = ''; + + Future downloadQRImage() async { + final response = await http.get(Uri.parse(AppSettings.qrCode)); + + if (response.statusCode == 200) { + final directory = await getApplicationDocumentsDirectory(); + final filePath = '${directory.path}/qr_image.png'; + + final File file = File(filePath); + await file.writeAsBytes(response.bodyBytes); + + setState(() { + imagePath = filePath; + }); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Qr Code'), + body: Container( + child: Padding(padding: EdgeInsets.all(10), + child: Column( + children: [ + Center( + child: Container( + padding: EdgeInsets.fromLTRB(0, 20, 0, 0), + width: MediaQuery.of(context).size.width * .60, // Set the desired width + height: MediaQuery.of(context).size.height * .35, // Set the desired height + child: + Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),), + fit: BoxFit.fill), + ), + ), + SizedBox( + height:MediaQuery.of(context).size.height * .05, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + onPressed: () { + //share(AppSettings.qrCode); + shareQRCodeImage1(AppSettings.qrCode); + }, + icon: Icon( + Icons.share, + color: primaryColor, + size: 40, + ), + ), + /*IconButton( + onPressed: () { + downloadQRImage(); + }, + icon: Icon( + Icons.download, + color: primaryColor, + size: 40, + ), + ),*/ + ], + ) + /*Container( + padding: EdgeInsets.fromLTRB(0, 20, 0, 0), + child: Center(child: Image.memory(Uint8List.fromList(base64.decode(AppSettings.qrCode),),),), + )*/ + + ], + ),), + ), + ); + + } +} diff --git a/lib/common/settings.dart b/lib/common/settings.dart index c07e997..46733c8 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -228,6 +228,7 @@ class AppSettings { SharedPreferences.getInstance() as SharedPreferences; static String userName = ''; static String userAddress = ''; + static String detailedAddress = ''; static String email = ''; static String age = ''; static String gender = ''; @@ -249,6 +250,8 @@ class AppSettings { static String long = "", lat = ""; late StreamSubscription positionStream; static String fcmId = ''; + static String originalQrCode = ''; + static String qrCode = ''; static String serverToken = 'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO'; @@ -256,6 +259,7 @@ class AppSettings { static String host = 'http://35.200.129.165:4000/api/'; static String loginUrl = host + 'login'; static String signUpUrl = host + 'users'; + static String generateQRCodeUrl = host + 'generate-qrcode'; static String sendSmsUrl = host + 'sendSms'; static String phoneVerificationUrl = host + 'phone'; static String verifyPhnUrl = host + 'phone'; @@ -471,6 +475,30 @@ class AppSettings { } } + static Future generateQRCode() async { + var uri = Uri.parse(generateQRCodeUrl + '/' + customerId); + + var response = await http.post(uri, headers: await buildPutRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.post(uri, headers: await buildPutRequestHeaders()); + if (response.statusCode == 200) { + return response.body; + } else { + return ''; + } + } else { + return ''; + } + } else { + return ''; + } + } + + static Future sendSms(payload) async { var response = await http.post(Uri.parse(sendSmsUrl), body: json.encode(payload), @@ -481,7 +509,6 @@ class AppSettings { return false; } } - static Future phoneVerification(payload) async { var response = await http.post(Uri.parse(phoneVerificationUrl), body: json.encode(payload), @@ -1789,11 +1816,13 @@ class AppSettings { await saveData('customerId', input['simplydata']['customerId'], 'STRING'); await saveData('profile', input['simplydata']['picture'], 'STRING'); await saveData('user_address', input['simplydata']['address1'], 'STRING'); + await saveData('detailedAddress', input['simplydata']['address2'], 'STRING'); await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE'); await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE'); await saveData('fcmId', input['simplydata']['fcmId'], 'STRING'); await saveData('age', input['simplydata']['age'], 'STRING'); await saveData('gender', input['simplydata']['gender'], 'STRING'); + await saveData('qrCode', input['simplydata']['qrCode'], 'STRING'); //await saveData('age', input['simplydata']['age'], 'STRING'); //latitude,longitude await loadDataFromMemory(); @@ -1814,6 +1843,7 @@ class AppSettings { accessToken = await getData('access_token', 'STRING'); email = await getData('email', 'STRING'); userAddress = await getData('user_address', 'STRING'); + detailedAddress= await getData('detailedAddress', 'STRING'); phoneNumber = await getData('phone', 'STRING'); customerId = await getData('customerId', 'STRING'); userLatitude = await getData('latitude', 'DOUBLE'); @@ -1822,6 +1852,18 @@ class AppSettings { fcmId = await getData('fcmId', 'STRING'); age = await getData('age', 'STRING'); gender = await getData('gender', 'STRING'); + originalQrCode = await getData('qrCode', 'STRING'); + String dataUri = originalQrCode; + +// Split the data URI at the comma to extract the Base64 part + List parts = dataUri.split(","); + String? base64String = parts.length == 2 ? parts[1] : null; + + if (base64String != null) { + qrCode=base64String; + } else { + print("Invalid data URI"); + } } diff --git a/lib/common/signup.dart b/lib/common/signup.dart index ec29a4f..2d5679e 100644 --- a/lib/common/signup.dart +++ b/lib/common/signup.dart @@ -441,7 +441,7 @@ class _SignUpState extends State { ]; payload["lastName"] = ''; payload["address1"] = userAddressCapturingController.text; - payload["address2"] = ''; + payload["address2"] = userAddressDescriptionController.text; payload["city"] = ''; payload["state"] = ''; payload["zip"] = ''; diff --git a/lib/edit_medicine_timings.dart b/lib/edit_medicine_timings.dart index d158974..d808d79 100644 --- a/lib/edit_medicine_timings.dart +++ b/lib/edit_medicine_timings.dart @@ -284,64 +284,74 @@ class _EditMedicineTimingsState extends State { child: ListView.separated( separatorBuilder: (context, index) => const Divider( height: 4.0, - color: primaryColor, + color: Colors.transparent, ), //padding: EdgeInsets.all(8), itemCount: timings.length, itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(10), - child: Container( - padding: EdgeInsets.fromLTRB(8, 8, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - width: - MediaQuery.of(context).size.width * .40, - child: Text( - timings[index]['name'], - style: wrapTextStyle(), - ), - ), - GestureDetector( - onTap: () { - Navigator.of(context).push( - showPicker( - showSecondSelector: true, - context: context, - value: _time, - //onChange: onTimeChanged, - onChange: (val) { - onTimeChanged(val, index); - }, - is24HrFormat: false, - sunrise: TimeOfDay( - hour: 6, minute: 0), // optional - sunset: TimeOfDay(hour: 18, minute: 0), - minuteInterval: TimePickerInterval.FIVE, - // Optional onChange to receive value as DateTime - onChangeDateTime: (DateTime dateTime) { + return GestureDetector( + onTap: () { + Navigator.of(context).push( + showPicker( + showSecondSelector: true, + accentColor: primaryColor, + okStyle: TextStyle(color: primaryColor,fontWeight: FontWeight.bold), + cancelStyle: TextStyle(color: Colors.red,fontWeight: FontWeight.bold), + barrierDismissible: false, + blurredBackground: true, + borderRadius: 20, + disableAutoFocusToNextInput: true, + displayHeader: true, + context: context, + value: _time, + //onChange: onTimeChanged, + onChange: (val) { + onTimeChanged(val, index); + }, + is24HrFormat: false, + sunrise: TimeOfDay( + hour: 6, minute: 0), // optional + sunset: TimeOfDay(hour: 18, minute: 0), + minuteInterval: TimePickerInterval.FIVE, + // Optional onChange to receive value as DateTime + onChangeDateTime: (DateTime dateTime) { - _selectedDateWithTime(dateTime,index); - }, + _selectedDateWithTime(dateTime,index); + }, + ), + ); + }, + child: Card( + child: Padding( + padding: EdgeInsets.all(10), + child: Container( + padding: EdgeInsets.fromLTRB(8, 8, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: + MediaQuery.of(context).size.width * .40, + child: Text( + timings[index]['name'], + style: wrapTextStyle(), ), - ); - }, - child: Image( - image: AssetImage('images/time.png'), - width: 30, - height: 30, - ), + ), + Image( + image: AssetImage('images/time.png'), + width: 30, + height: 30, + ), + textForSelectedTime(index) + ], ), - textForSelectedTime(index) ], - ), - ], - )), + )), + ), + ), ); })), Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40), @@ -400,16 +410,54 @@ class _EditMedicineTimingsState extends State { ); } + 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('Edit Medicine Timings'), - body: Container( - child: //Text(widget.medicineTimings.toString()) - renderTimings(), - ) + return WillPopScope( + onWillPop: () async => onWillPop(), + child:Scaffold( + appBar: AppSettings.appBar('Edit Medicine Timings'), + body: Container( + child: //Text(widget.medicineTimings.toString()) + renderTimings(), + ) //medicineTimings.length==0?renderUi():renderTimings(), - ); + ) ,); } } diff --git a/lib/invitations/invitations.dart b/lib/invitations/invitations.dart index 3339308..ff2307d 100644 --- a/lib/invitations/invitations.dart +++ b/lib/invitations/invitations.dart @@ -36,7 +36,7 @@ class _InvitationsState extends State { cursorColor: greyColor, controller: nameController, decoration: textFormFieldDecoration( - Icons.phone, 'Enter Name'), + Icons.person, 'Enter Name'), ), ), SizedBox( diff --git a/lib/models/reports_model.dart b/lib/models/reports_model.dart index 7882c67..fde5aa8 100644 --- a/lib/models/reports_model.dart +++ b/lib/models/reports_model.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:healthcare_user/common/settings.dart'; +import 'package:intl/intl.dart'; class ReportsModel { String patient_name=''; @@ -14,6 +15,7 @@ class ReportsModel { List findingsImages = []; List reportImages = []; List prescriptionImages = []; + DateTime dateForFilter=new DateTime.now(); ReportsModel(); @@ -29,6 +31,7 @@ class ReportsModel { rtvm.findingsImages = json['findings'] ?? []; rtvm.reportImages = json['reports'] ?? []; rtvm.prescriptionImages = json['prescription'] ?? []; + rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.date); if(rtvm.patient_type.toString().toLowerCase()=='self'){ rtvm.age=AppSettings.age; diff --git a/lib/my_connections/all_connections.dart b/lib/my_connections/all_connections.dart new file mode 100644 index 0000000..79767e2 --- /dev/null +++ b/lib/my_connections/all_connections.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:healthcare_user/common/settings.dart'; + +class AllConnections extends StatefulWidget { + const AllConnections({Key? key}) : super(key: key); + + @override + State createState() => _AllConnectionsState(); +} + +class _AllConnectionsState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('My Connections'), + body: Container(), + ); + } +} diff --git a/lib/my_medicine_timings.dart b/lib/my_medicine_timings.dart index b76c879..d116d83 100644 --- a/lib/my_medicine_timings.dart +++ b/lib/my_medicine_timings.dart @@ -317,47 +317,51 @@ class _MyMedicineTimingsState extends State { child: ListView.separated( separatorBuilder: (context, index) => const Divider( height: 4.0, - color: primaryColor, + color: Colors.transparent, ), //padding: EdgeInsets.all(8), itemCount: timings.length, itemBuilder: (BuildContext context, int index) { return GestureDetector( onTap: (){ - AppSettings.longSuccessToast('Please click on edit button'); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('Please click on edit button'),)); + //AppSettings.longSuccessToast(''); }, - child: Padding( - padding: EdgeInsets.all(10), - child: Container( - padding: EdgeInsets.fromLTRB(8, 8, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - width: - MediaQuery.of(context).size.width * .40, - child: Text( - timings[index]['name'], - style: wrapTextStyle(), - ), - ), - GestureDetector( - onTap: () { - }, - child: Image( - image: AssetImage('images/time.png'), - width: 30, - height: 30, + child: Card( + child: Padding( + padding: EdgeInsets.all(10), + child: Container( + padding: EdgeInsets.fromLTRB(8, 8, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: + MediaQuery.of(context).size.width * .40, + child: Text( + timings[index]['name'], + style: wrapTextStyle(), + ), ), - ), - textForSelectedTime(index) - ], - ), - ], - )), + /* GestureDetector( + onTap: () { + }, + child: Image( + image: AssetImage('images/time.png'), + width: 30, + height: 30, + ), + ),*/ + textForSelectedTime(index) + ], + ), + ], + )), + ), ), ); })), @@ -389,112 +393,6 @@ class _MyMedicineTimingsState extends State { ); } - editTimingsDialog(){ - - return showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return StatefulBuilder( - builder: (BuildContext context, StateSetter setState) { - return AlertDialog( - title: const Text('Edit Timings'), - content: SingleChildScrollView( - child: Container( - width: double.maxFinite, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ConstrainedBox( - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * 0.4, - ), - child: ListView.separated( - separatorBuilder: (context, index) => const Divider( - height: 4.0, - color: primaryColor, - ), - //padding: EdgeInsets.all(8), - itemCount: timings.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(10), - child: Container( - padding: EdgeInsets.fromLTRB(8, 8, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - width: - MediaQuery.of(context).size.width * .25, - child: Text( - timings[index]['name'], - style: wrapTextStyle(), - ), - ), - GestureDetector( - onTap: () { - Navigator.of(context).push( - showPicker( - showSecondSelector: true, - context: context, - value: _time, - //onChange: onTimeChanged, - onChange: (val) { - onTimeChanged(val, index); - }, - is24HrFormat: false, - sunrise: TimeOfDay( - hour: 6, minute: 0), // optional - sunset: TimeOfDay(hour: 18, minute: 0), - minuteInterval: TimePickerInterval.FIVE, - // Optional onChange to receive value as DateTime - onChangeDateTime: (DateTime dateTime) { - - _selectedDateWithTime(dateTime,index); - }, - ), - ); - }, - child: Image( - image: AssetImage('images/time.png'), - width: 30, - height: 30, - ), - ), - textForSelectedTime(index) - ], - ), - ], - )), - ); - }) - ), - ]), - )), - actions: [ - TextButton( - child: Text('Cancel', style: textButtonStyle()), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - TextButton( - child: Text('Save', style: textButtonStyle()), - onPressed: () async { - - }, - ), - ], - ); - }); - }, - ); - } - Widget renderUi() { return Column( children: [ @@ -502,64 +400,74 @@ class _MyMedicineTimingsState extends State { child: ListView.separated( separatorBuilder: (context, index) => const Divider( height: 4.0, - color: primaryColor, + color: Colors.transparent, ), //padding: EdgeInsets.all(8), itemCount: timings.length, itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(10), - child: Container( - padding: EdgeInsets.fromLTRB(8, 8, 0, 0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + return GestureDetector( + onTap: () { + Navigator.of(context).push( + showPicker( + showSecondSelector: true, + accentColor: primaryColor, + okStyle: TextStyle(color: primaryColor,fontWeight: FontWeight.bold), + cancelStyle: TextStyle(color: Colors.red,fontWeight: FontWeight.bold), + barrierDismissible: false, + blurredBackground: true, + borderRadius: 20, + disableAutoFocusToNextInput: true, + displayHeader: true, + context: context, + value: _time, + //onChange: onTimeChanged, + onChange: (val) { + onTimeChanged(val, index); + }, + is24HrFormat: false, + sunrise: TimeOfDay( + hour: 6, minute: 0), // optional + sunset: TimeOfDay(hour: 18, minute: 0), + minuteInterval: TimePickerInterval.FIVE, + // Optional onChange to receive value as DateTime + onChangeDateTime: (DateTime dateTime) { + + _selectedDateWithTime(dateTime,index); + }, + ), + ); + }, + child: Card( + child: Padding( + padding: EdgeInsets.all(10), + child: Container( + padding: EdgeInsets.fromLTRB(8, 8, 0, 0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * .40, - child: Text( - timings[index]['name'], - style: wrapTextStyle(), - ), - ), - GestureDetector( - onTap: () { - Navigator.of(context).push( - showPicker( - showSecondSelector: true, - context: context, - value: _time, - //onChange: onTimeChanged, - onChange: (val) { - onTimeChanged(val, index); - }, - is24HrFormat: false, - sunrise: TimeOfDay( - hour: 6, minute: 0), // optional - sunset: TimeOfDay(hour: 18, minute: 0), - minuteInterval: TimePickerInterval.FIVE, - // Optional onChange to receive value as DateTime - onChangeDateTime: (DateTime dateTime) { - - _selectedDateWithTime(dateTime,index); - }, + child: Text( + timings[index]['name'], + style: wrapTextStyle(), ), - ); - }, - child: Image( - image: AssetImage('images/time.png'), - width: 30, - height: 30, - ), + ), + Image( + image: AssetImage('images/time.png'), + width: 30, + height: 30, + ), + textForSelectedTime(index) + ], ), - textForSelectedTime(index) ], - ), - ], - )), + )), + ), + ), ); })), Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40), diff --git a/lib/prescriptions/prescriptions.dart b/lib/prescriptions/prescriptions.dart index d4f687f..19ebc09 100644 --- a/lib/prescriptions/prescriptions.dart +++ b/lib/prescriptions/prescriptions.dart @@ -545,6 +545,7 @@ class _PrescriptionsState extends State { )); } } + showPicDialog(var imageUrl){ return showDialog( context: context, diff --git a/lib/report_problem/all-records_onclick_new.dart b/lib/report_problem/all-records_onclick_new.dart new file mode 100644 index 0000000..2ac49f2 --- /dev/null +++ b/lib/report_problem/all-records_onclick_new.dart @@ -0,0 +1,1813 @@ +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 AllRecordsOnClick extends StatefulWidget { + var recordDetails; + var initialIndex; + + AllRecordsOnClick({this.recordDetails,this.initialIndex}); + + @override + State createState() => _AllRecordsOnClickState(); +} + +class _AllRecordsOnClickState 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); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); + } + } + + 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); + + 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, + )), + ), + ], + ), + ); + }, + ), + ), + ) + ]), + ), + ), + ) + + ], + ); + }),), + Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + 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 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); + }, + ), + ], + ), + ), + ); + }); + + + + }, + ), + IconButton( + iconSize: 40, + icon: const Icon( + Icons.shopping_cart, + color: primaryColor, + ), + onPressed: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicines( + prescriptionDetails: widget.recordDetails))); + //signup screen + }, + ), + ], + ) + + ], + ) + ); + } + else{ + return GestureDetector( + onTap: (){ + 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); + }, + ), + ], + ), + ), + ); + }); + }, + child: Row( + children: [ + Icon( + Icons.add, + color: Colors.green, + size: 40, + ), + Text('Add Prescriptions',style: textButtonStyle(),) + ], + ), + ); + } + + + + } + + Widget findings(var obj){ + if(obj.findingsImages.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.findingsImages.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:'Findings',imageDetails:obj.findingsImages[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.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,*/ + ), + ) + ]), + ), + ), + ) + + ], + ); + }),), + 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 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 GestureDetector( + onTap: (){ + 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: Row( + children: [ + Icon( + Icons.add, + color: Colors.green, + size: 40, + ), + Text('Add Findings',style: textButtonStyle(),) + ], + ), + ); + } + + + + } + + Widget reports(var obj){ + if(obj.reportImages.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.reportImages.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:'Findings',imageDetails:obj.reportImages[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.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,*/ + ), + ) + ]), + ), + ), + ) + + ], + ); + }),), + 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 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 GestureDetector( + onTap: (){ + + 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: Row( + children: [ + Icon( + Icons.add, + color: Colors.green, + size: 40, + ), + Text('Add Reports',style: textButtonStyle(),) + ], + ), + ); + } + + + + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Records'), + body: Padding( + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: MediaQuery.of(context).size.height * .15, + width: double.infinity, + child: Padding( + padding: EdgeInsets.all(0), + 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()), + ], + ), + ], + ), + ), + ), + Text('Findings',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),), + findings(widget.recordDetails), + Text('Reports',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),), + reports(widget.recordDetails), + Text('Prescriptions',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),), + prescriptions(widget.recordDetails) + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 906f81d..3a0be6f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -447,6 +447,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + flutter_share: + dependency: "direct main" + description: + name: flutter_share + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" flutter_slidable: dependency: "direct main" description: @@ -1045,6 +1052,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.5" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + qr_flutter: + dependency: "direct main" + description: + name: qr_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" recase: dependency: transitive description: @@ -1066,6 +1087,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + share: + dependency: "direct main" + description: + name: share + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 66c1b62..3834fd9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,9 @@ dependencies: assets_audio_player: ^3.0.3+3 path: ^1.8.0 visibility_detector: ^0.4.0+2 + flutter_share: ^2.0.0 + share: ^2.0.4 + qr_flutter: ^4.0.0 dev_dependencies: flutter_test: