diff --git a/images/bmivalue.png b/images/bmivalue.png new file mode 100644 index 0000000..5b4b6a6 Binary files /dev/null and b/images/bmivalue.png differ diff --git a/images/date.png b/images/date.png index 1a22262..4cd1f64 100644 Binary files a/images/date.png and b/images/date.png differ diff --git a/images/height.png b/images/height.png index 7f152d3..371440d 100644 Binary files a/images/height.png and b/images/height.png differ diff --git a/images/time.png b/images/time.png index 2efce7a..20da481 100644 Binary files a/images/time.png and b/images/time.png differ diff --git a/images/weight.png b/images/weight.png index 04eac04..ad5b01c 100644 Binary files a/images/weight.png and b/images/weight.png differ diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index 7e5fa29..160600e 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -549,13 +549,13 @@ class _DashboardState extends State { resizeToAvoidBottomInset: false, appBar: AppSettings.appBar('Health Care'), drawer: Drawer( - backgroundColor: secondaryColor, + backgroundColor: primaryColor, child: ListView( padding: EdgeInsets.zero, children: [ DrawerHeader( decoration: const BoxDecoration( - color: primaryColor, + color: buttonColors, ), child: Row( children: [ @@ -597,7 +597,7 @@ class _DashboardState extends State { child: Icon( Icons.camera_alt_outlined, size: 100, - color: greyColor, + color: primaryColor, ), onTap: () async { await takeImageFromCamera(); @@ -614,7 +614,7 @@ class _DashboardState extends State { child: Icon( Icons.photo, size: 100, - color: greyColor, + color: primaryColor, ), onTap: () async { await pickImageFromGallery(); @@ -631,17 +631,17 @@ class _DashboardState extends State { ), Text( AppSettings.userName, - style: drawerHeaderTextStyle(), + style: drawerHeaderTextStyleNew(), ), Text( AppSettings.phoneNumber, - style: drawerHeaderTextStyle(), + style: drawerHeaderTextStyleNew(), ), Visibility( visible: AppSettings.email != '', child: Text( AppSettings.email, - style: drawerHeaderTextStyle(), + style: drawerHeaderTextStyleNew(), ), ), Row( @@ -650,14 +650,14 @@ class _DashboardState extends State { visible: AppSettings.age != '', child: Text( AppSettings.age + ' Yrs, ', - style: drawerHeaderTextStyle(), + style: drawerHeaderTextStyleNew(), ), ), Visibility( visible: AppSettings.gender != '', child: Text( AppSettings.gender, - style: drawerHeaderTextStyle(), + style: drawerHeaderTextStyleNew(), ), ), ], diff --git a/lib/common/settings.dart b/lib/common/settings.dart index 215fa9b..2d8b044 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -112,6 +112,9 @@ TextStyle drawerHeaderTextStyle(){ return TextStyle(color: Colors.white, fontSize: 15); } +TextStyle drawerHeaderTextStyleNew(){ + return TextStyle(color: Colors.black, fontSize: 15); +} @@ -194,7 +197,7 @@ class AppSettings { static String getMedicineTimingsUrl = host + 'getmedicineztiming'; static String prescriptionUploadPicUrl = host + 'uploads-precription'; static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist'; - static String uploadPrescriptionUrl = host + 'submitPicture'; + static String getQuotationUrl = host + 'submitPicture'; static String addPrescriptionUrl = host + 'add-prescription-details'; static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo'; static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription'; @@ -761,8 +764,8 @@ class AppSettings { } } - static Future uploadPrescription(payload) async { - var uri = Uri.parse(uploadPrescriptionUrl + '/' + customerId); + static Future getQuotation(payload) async { + var uri = Uri.parse(getQuotationUrl + '/' + customerId); var response = await http.post( uri, body: json.encode(payload), diff --git a/lib/common/updateprofile.dart b/lib/common/updateprofile.dart index 92624bc..8d4e890 100644 --- a/lib/common/updateprofile.dart +++ b/lib/common/updateprofile.dart @@ -135,7 +135,7 @@ class _UpdateprofileState extends State { child: Icon( Icons.camera_alt_outlined, size: 100, - color: greyColor, + color: primaryColor, ), onTap: () async { await takeImageFromCamera(); @@ -150,7 +150,7 @@ class _UpdateprofileState extends State { child: Icon( Icons.photo, size: 100, - color: greyColor, + color: primaryColor, ), onTap: () async { await pickImageFromGallery(); diff --git a/lib/models/prescriptions_model.dart b/lib/models/prescriptions_model.dart index 6a7176e..63a9a5d 100644 --- a/lib/models/prescriptions_model.dart +++ b/lib/models/prescriptions_model.dart @@ -18,6 +18,22 @@ class PrescriptionsModel { rtvm.patient_type = json['patientType'] ?? ''; rtvm.prescription_url = json['pictureUrl'][0] ?? ''; + if(rtvm.patient_type.toString().toLowerCase()=='self'){ + rtvm.age=AppSettings.age; + rtvm.gender=AppSettings.gender; + rtvm.patient_name=AppSettings.userName; + } + /* "others": { + "name": "jhanu", + "age": 23, + "gender": "female" + },*/ + else{ + rtvm.age=json['others']['age'].toString(); + rtvm.gender=json['others']['gender']; + rtvm.patient_name=json['others']['name']; + } + return rtvm; } diff --git a/lib/prescriptions/add_prescriptions.dart b/lib/prescriptions/add_prescriptions.dart index a68fbad..313033e 100644 --- a/lib/prescriptions/add_prescriptions.dart +++ b/lib/prescriptions/add_prescriptions.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/prescriptions/prescriptions.dart'; import 'package:image_picker/image_picker.dart'; import 'package:photo_view/photo_view.dart'; import 'package:pinch_zoom/pinch_zoom.dart'; @@ -218,7 +219,6 @@ class _AddPrescriptionState extends State { ), onTap: (){ showPicDialog(Url); - }, ) ), @@ -371,6 +371,12 @@ class _AddPrescriptionState extends State { if(uploadStatus){ Navigator.of(context,rootNavigator: true).pop(); AppSettings.longSuccessToast('Prescription added successfully'); + Navigator.pop(context); + /* await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Prescriptions()), + );*/ } else{ Navigator.of(context,rootNavigator: true).pop(); diff --git a/lib/prescriptions/oreder_medicines.dart b/lib/prescriptions/oreder_medicines.dart new file mode 100644 index 0000000..dc44d21 --- /dev/null +++ b/lib/prescriptions/oreder_medicines.dart @@ -0,0 +1,717 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/google_maps_place_picker_mb/src/models/pick_result.dart'; +import 'package:healthcare_user/google_maps_place_picker_mb/src/place_picker.dart'; +import 'package:healthcare_user/keys.dart'; +import 'package:healthcare_user/models/pharmacies_model.dart'; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'package:location/location.dart' as locationmap; + + +class OrderMedicines extends StatefulWidget { + var prescriptionDetails; + OrderMedicines({this.prescriptionDetails}); + + @override + State createState() => _OrderMedicinesState(); +} + +class _OrderMedicinesState extends State { + double lat = 0; + double lng = 0; + String userAddress = ''; + String dropdownArea = '2'; + //String dropdownType = 'Tank'; + var AreaItems = ['2', '5', '10', '25', '50', '100']; + List pharmaciesCheckboxes = []; + List selectedPharmacies = []; + bool isLoading = false; + bool isSereverIssue = false; + List pharmaciesList = []; + List FilteredList = []; + + PickResult? selectedPlace; + + bool _mapsInitialized = false; + final String _mapsRenderer = "latest"; + + var kInitialPosition = const LatLng(15.462477, 78.717401); + + locationmap.Location location = locationmap.Location(); + + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + + void initRenderer() { + if (_mapsInitialized) return; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + switch (_mapsRenderer) { + case "legacy": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.legacy); + break; + case "latest": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.latest); + break; + } + } + setState(() { + _mapsInitialized = true; + }); + } + + Future getAllPharmaciesData(var distance) async { + isLoading = true; + try { + var pharmacyResponse = await AppSettings.getAllpharmacies(); + + setState(() { + pharmaciesList = ((jsonDecode(pharmacyResponse)['data']) as List) + .map((dynamic model) { + return PharmaciesModel.fromJson(model); + }).toList(); + FilteredList = []; + pharmaciesList.forEach((element) async { + var distanceInM; + if (distance == '2') { + distanceInM = 2000; + } else if (distance == '5') { + distanceInM = 5000; + } else if (distance == '10') { + distanceInM = 10000; + } else if (distance == '25') { + distanceInM = 25000; + } else if (distance == '50') { + distanceInM = 50000; + } else if (distance == '100') { + distanceInM = 100000; + } + double distanceInMeters = await Geolocator.distanceBetween( + element.lat, element.lng, lat, lng); + if (distanceInMeters <= distanceInM) { + FilteredList.add(element); + } + }); + + isLoading = false; + }); + } catch (e) { + setState(() { + isLoading = false; + isSereverIssue = true; + }); + } + } + + + showListOfSelectedPharmacies() async { + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + + return Container( + height: 300.0, // Change as per your requirement + width: 300.0, // Change as per your requirement + child: ListView.builder( + shrinkWrap: true, + itemCount: 5, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Text('Gujarat, India'), + ); + }, + ), + ); + /* return AlertDialog( + title: const Text('Selected pharmacies'), + content: SingleChildScrollView( + child: Expanded( + child: ListView.builder( + itemCount: selectedPharmacies.length, + itemBuilder: (context, index) { + return Card( + child: Column( + children: [ + Text(selectedPharmacies[index].pharmacy_name) + ], + ), + );}, + ), + ) + ), + actions: [ + TextButton( + child: Text('Cancel', style: textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text('Get quote', style: textButtonStyle()), + onPressed: () async { + Navigator.of(context).pop(); + }, + ), + ], + );*/ + }); + }, + ); + } + + Widget setupAlertDialoadContainer() { + return Container( + height: 300.0, // Change as per your requirement + width: 300.0, // Change as per your requirement + child: ListView.builder( + shrinkWrap: true, + itemCount: 5, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Text('Gujarat, India'), + ); + }, + ), + ); + } + + Widget _pharamciesData() { + if (FilteredList.length != 0) { + return + Container( + color: secondaryColor, + child: Column(crossAxisAlignment: CrossAxisAlignment.end, children: [ + Expanded( + child: GridView.builder( + itemCount: FilteredList.length, + itemBuilder: (context, index) { + return Card( + elevation: 2.0, + child: CheckboxListTile( + title: Padding( + padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: FilteredList[index].picture == '' + ? AssetImage("images/logo.png") + : NetworkImage( + FilteredList[index].picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: 5, + ), + Expanded( + child: Container( + width: MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + FilteredList[index] + .pharmacy_name + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .contact_number + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .pharmacy_address + .toUpperCase(), + style: wrapTextStyleBlack()), + Visibility( + visible: + FilteredList[index].description != '', + child: SizedBox( + height: 10, + ), + ), + Visibility( + visible: + FilteredList[index].description != '', + child: Text( + FilteredList[index] + .description + .toUpperCase(), + style: wrapTextStyleBlack()), + ), + SizedBox( + height: 10, + ), + ], + )), + ), + ], + )), + checkColor: Colors.white, + activeColor: primaryColor, + value: FilteredList[index].isChecked, + onChanged: (val) { + setState( + () { + FilteredList[index].isChecked = val!; + }, + ); + if (FilteredList[index].isChecked) { + pharmaciesCheckboxes.add({ + 'pharmacyId': FilteredList[index].pharmacy_id, + }); + selectedPharmacies.add(FilteredList[index]); + } else { + pharmaciesCheckboxes.removeWhere((e) => + e['pharmacyId'].toString().toUpperCase() == + FilteredList[index] + .pharmacy_id + .toString() + .toUpperCase()); + selectedPharmacies.remove(FilteredList[index]); + } + }, + ), + ); + }, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 1, //.size.width * .33, + childAspectRatio: MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 7)), + ), + ), + Padding( + padding: EdgeInsets.all(0), + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + + + if(pharmaciesCheckboxes.length==3){ + + var payload = new Map(); + + payload["picture"] = widget.prescriptionDetails.prescription_url.toString(); + payload["pharmacies"] = pharmaciesCheckboxes; + payload["familyDetails"] = { + "patient_name": widget.prescriptionDetails.patient_name.toString(), + "patient_age": int.parse(widget.prescriptionDetails.age.toString()), + "patient_gender": widget.prescriptionDetails.gender, + "patient_address": userAddress + }; + bool status = await AppSettings.getQuotation(payload); + + if(status){ + AppSettings.longSuccessToast('Quotation request sent successfully'); + } + else{ + AppSettings.longFailedToast('Get quotation failed try after some time'); + } + + } + else if(pharmaciesCheckboxes.length>3){ + + showListOfSelectedPharmacies(); + + } + else{ + AppSettings.longFailedToast('Please select at least three pharmacies to get quotation'); + } + + + }, + child: Text('Get quote'), + )), + ), + ]), + ); + } + else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: isSereverIssue + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('images/serverissue.png'), + // height: MediaQuery.of(context).size.height * .10, + ), + SizedBox( + height: 20, + ), + Text( + 'There is an issue at server please try after some time',style:serverIssueTextStyle() ,), + ], + ) + : userAddress==''?Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( + image: AssetImage('images/resourceblue.pngs'), + // height: MediaQuery.of(context).size.height * .10, + ),*/ + Icon(Icons.location_on_outlined,color: primaryColor,size: 40,), + SizedBox( + height: 20, + ), + Text( + 'Please select location to see near by tankers',style:TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ),), + ], + ): + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( + image: AssetImage('images/resourceblue.pngs'), + // height: MediaQuery.of(context).size.height * .10, + ),*/ + Icon( + Icons.info, + color: primaryColor, + size: 40, + ), + SizedBox( + height: 20, + ), + Text( + 'No pharmacies near to your selected locaton', + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ], + ) + )); + } + } + + @override + void initState() { + lat = AppSettings.userLatitude; + lng = AppSettings.userLongitude; + userAddress = AppSettings.userAddress; + getAllPharmaciesData(dropdownArea); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Order Medicines'), + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage(widget.prescriptionDetails.prescription_url) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: MediaQuery.of(context).size.width * .02, + ), + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.prescriptionDetails.prescription_name + .toString() + .toUpperCase(), + style: valuesTextStyle()), + Text( + widget.prescriptionDetails.patient_name + .toString() + .toUpperCase(), + style: valuesTextStyle()), + Text( + widget.prescriptionDetails.gender + .toString() + .toUpperCase(), + style: valuesTextStyle()), + Text( + widget.prescriptionDetails.age + .toString() + .toUpperCase(), + style: valuesTextStyle()), + ], + ), + ), + ], + )), + Padding( + padding: EdgeInsets.all(10), + child: TextButton( + onPressed: () {}, + child: const Text( + 'Want to order non prescribed items?', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + )), + ), + Padding( + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Your address', + style: labelTextStyle(), + ), + Text( + userAddress, + style: valuesTextStyle(), + ), + Row( + children: [ + TextButton( + child: const Text( + 'Change', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + ), + onPressed: () { + location.serviceEnabled().then((value) { + if (value) { + initRenderer(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return PlacePicker( + resizeToAvoidBottomInset: false, + hintText: "Find a place ...", + searchingText: "Please wait ...", + selectText: "Select place", + outsideOfPickAreaText: + "Place not in area", + initialPosition: kInitialPosition, + useCurrentLocation: true, + selectInitialPosition: true, + usePinPointingSearch: true, + usePlaceDetailSearch: true, + zoomGesturesEnabled: true, + zoomControlsEnabled: true, + onMapCreated: (GoogleMapController + controller) {}, + onPlacePicked: (PickResult result) { + setState(() { + selectedPlace = result; + lat = selectedPlace! + .geometry!.location.lat; + lng = selectedPlace! + .geometry!.location.lng; + if (selectedPlace! + .types!.length == + 1) { + userAddress = selectedPlace! + .formattedAddress!; + } else { + userAddress = selectedPlace! + .name! + + ', ' + + selectedPlace! + .formattedAddress!; + } + Navigator.of(context).pop(); + getAllPharmaciesData( + dropdownArea); + }); + }, + onMapTypeChanged: + (MapType mapType) {}, + apiKey: Platform.isAndroid + ? APIKeys.androidApiKey + : APIKeys.iosApiKey, + forceAndroidLocationManager: true, + ); + }, + ), + ); + } else { + showGeneralDialog( + context: context, + pageBuilder: (context, x, y) { + return Scaffold( + backgroundColor: + Colors.grey.withOpacity(.5), + body: Center( + child: Container( + width: double.infinity, + height: 150, + padding: + const EdgeInsets.symmetric( + horizontal: 20), + child: Card( + child: Padding( + padding: const EdgeInsets.all( + 10.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + const Text( + "Please enable the location", + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.w500, + ), + ), + const SizedBox( + height: 20, + ), + ElevatedButton( + onPressed: () { + Navigator.pop( + context); + }, + child: const Text( + "Cancel"), + ), + ], + ), + ), + ), + ), + ), + ); + }, + ); + } + }); + }, + ), + Icon( + Icons.location_on_outlined, + color: primaryColor, + size: 20, + ), + ], + ) + ], + ), + ), + Expanded( + child: Container( + height: MediaQuery.of(context).size.height * .09, + padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), + child: DropdownButtonFormField( + value: dropdownArea, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.area_chart, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'distance', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + hint: Text('Select Area'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: AreaItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownArea = newValue!; + }); + getAllPharmaciesData(dropdownArea); + }, + ), + ), + ) + ], + ), + ), + Expanded( + child: isLoading + ? Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ) + : _pharamciesData(), + ) + ], + )); + } +} diff --git a/lib/prescriptions/prescriptions.dart b/lib/prescriptions/prescriptions.dart index a85cc23..4ccc2b3 100644 --- a/lib/prescriptions/prescriptions.dart +++ b/lib/prescriptions/prescriptions.dart @@ -6,8 +6,9 @@ import 'package:geolocator/geolocator.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/models/pharmacies_model.dart'; import 'package:healthcare_user/prescriptions/add_prescriptions.dart'; +import 'package:healthcare_user/prescriptions/oreder_medicines.dart'; import 'package:image_picker/image_picker.dart'; - +import 'package:photo_view/photo_view.dart'; import 'package:healthcare_user/models/prescriptions_model.dart'; class Prescriptions extends StatefulWidget { @@ -22,9 +23,10 @@ class _PrescriptionsState extends State { String Url = ''; List pharmaciesList = []; List prescriptionsList = []; + List prescriptionsListOriginal = []; List FilteredList = []; bool isPharmacyDataLoading = false; - bool isPrescriptionsData = false; + bool isPrescriptionsDataLoading = false; bool isSereverIssue = false; double lat = 0; double lng = 0; @@ -33,6 +35,7 @@ class _PrescriptionsState extends State { //String dropdownType = 'Tank'; var AreaItems = ['2', '5', '10', '25', '50', '100']; List pharmaciesCheckboxes = []; + bool isLoading=false; Future getAllPharmaciesData(var distance) async { isPharmacyDataLoading=true; @@ -78,21 +81,21 @@ class _PrescriptionsState extends State { } Future getAllPrescriptions() async { - isPrescriptionsData=true; + isPrescriptionsDataLoading=true; try { var response = await AppSettings.getAllPrescriptions(); setState(() { - prescriptionsList = ((jsonDecode(response)) as List) + prescriptionsListOriginal = ((jsonDecode(response)) as List) .map((dynamic model) { return PrescriptionsModel.fromJson(model); }).toList(); - - isPrescriptionsData = false; + prescriptionsList=prescriptionsListOriginal.reversed.toList(); + isPrescriptionsDataLoading = false; }); } catch (e) { setState(() { - isPrescriptionsData = false; + isPrescriptionsDataLoading = false; isSereverIssue = true; }); } @@ -299,7 +302,7 @@ class _PrescriptionsState extends State { payload["picture"] = Url.toString(); payload["pharmacies"] = pharmaciesCheckboxes; - bool status = await AppSettings.uploadPrescription(payload); + bool status = await AppSettings.getQuotation(payload); try { if (status) { Navigator.of(context, rootNavigator: true).pop(); @@ -399,262 +402,264 @@ class _PrescriptionsState extends State { )); } } + showPicDialog(var imageUrl){ + return showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return AlertDialog( + title: const Text(''), + content: SingleChildScrollView( + child: ListBody( + children: [ + Container( + width: MediaQuery.of(context).size.width * .10, + height: MediaQuery.of(context).size.height * .50, + child: PhotoView( + imageProvider: NetworkImage(imageUrl) as ImageProvider, + maxScale: PhotoViewComputedScale.contained * 4.0, + minScale: PhotoViewComputedScale.contained, + initialScale: PhotoViewComputedScale.contained, + basePosition: Alignment.center, + + ) + ) + ], + ), + ), + actions: [ + TextButton( + child: Text('Close', style: textButtonStyle()), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); + }, + ); + } Widget _allPrescriptions(){ if (prescriptionsList.length != 0) { - return Column( - children: [ - GridView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: FilteredList.length, - itemBuilder: (context, index) { - return Card( - elevation: 2.0, - child: CheckboxListTile( - title: Padding( - padding: EdgeInsets.fromLTRB(10, 10, 0, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, + return Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded(child:ListView.builder( + padding: EdgeInsets.all(0), + itemCount: prescriptionsList.length, + itemBuilder: (BuildContext context, int index) { + return Card( + + //color: prescriptionsList[index].cardColor, + child: Padding( + padding:EdgeInsets.all(8) , + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: MediaQuery.of(context).size.width * .18, - height: - MediaQuery.of(context).size.height * .10, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: FilteredList[index].picture == '' - ? AssetImage("images/logo.png") - : NetworkImage( - FilteredList[index].picture) - as ImageProvider, // picked file - fit: BoxFit.contain)), - ), - SizedBox( - width: 5, - ), - Expanded( - child: Container( - width: - MediaQuery.of(context).size.width * .70, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + child: Container( + width: MediaQuery.of(context).size.width * .18, + height: + MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage(prescriptionsList[index].prescription_url) as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + onTap: (){ + showPicDialog(prescriptionsList[index].prescription_url); + + }, + ), + SizedBox(width:MediaQuery.of(context).size.width * .02,), + + Container( + width: MediaQuery.of(context).size.width * .55, child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - FilteredList[index] - .pharmacy_name - .toUpperCase(), - style: wrapTextStyleBlack()), - SizedBox( - height: 10, - ), - Text( - FilteredList[index] - .contact_number - .toUpperCase(), - style: wrapTextStyleBlack()), - /*Visibility( - visible: FilteredList[index].supplier_alternate_phone_number!='', - child: Text( - FilteredList[index] - .supplier_alternate_phone_number - .toUpperCase(), - style: wrapTextStyleBlack()),),*/ - SizedBox( - height: 10, - ), - Text( - FilteredList[index] - .pharmacy_address - .toUpperCase(), - style: wrapTextStyleBlack()), - Visibility( - visible: - FilteredList[index].description != - '', - child: SizedBox( - height: 10, - ), - ), - Visibility( - visible: - FilteredList[index].description != - '', - child: Text( - FilteredList[index] - .description - .toUpperCase(), - style: wrapTextStyleBlack()), + Text(prescriptionsList[index].prescription_name.toString().toUpperCase(),style: valuesTextStyle()), + Text(prescriptionsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()), + Text(prescriptionsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()), + Text(prescriptionsList[index].age.toString().toUpperCase(),style: valuesTextStyle()), + ], + ), + + + ), + + + Expanded(child:IconButton( + icon: const Icon(Icons.edit,color: primaryColor,), + onPressed: () { + + + }, + ),), + Expanded(child:IconButton( + icon: const Icon(Icons.delete,color: primaryColor,), + + onPressed: () async{ + /* showDialog( + //if set to true allow to close popup by tapping out of the popup + //barrierDismissible: false, + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Do you want to delete tank?', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), + actionsAlignment: MainAxisAlignment.spaceBetween, + actions: [ + TextButton( + onPressed: ()async { + var payload = new Map(); + payload["tankLocation"] = modelTanksViewList[index].tank_location.toString().toLowerCase(); + bool deleteTankStatus = await AppSettings.deleteTank(modelTanksViewList[index].tank_name,payload); + + + if(deleteTankStatus){ + readJson(); + AppSettings.longSuccessToast('tank deleted successfully'); + Navigator.of(context).pop(true); + + } + else{ + AppSettings.longFailedToast('tank deletion failed'); + Navigator.of(context).pop(true); + } + }, + child: const Text('Yes', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), ), - SizedBox( - height: 10, + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text('No', + style: TextStyle( + color: primaryColor, + fontSize: 20, + )), ), - /*Text( - FilteredList[index] - .starting_price - .toUpperCase(), - style: wrapTextStyleBlack()), - SizedBox(height: 10,),*/ ], - )), - ), - ], - ) - ), - checkColor: Colors.white, - activeColor: primaryColor, - value: FilteredList[index].isChecked, - onChanged: (val) { - setState( - () { - FilteredList[index].isChecked = val!; - }, - ); - if (FilteredList[index].isChecked) { - pharmaciesCheckboxes.add({ + ), + );*/ - 'pharmacyId': - FilteredList[index] - .pharmacy_id, - }); - } else { - pharmaciesCheckboxes.removeWhere((e) => - e['pharmacyId'] - .toString() - .toUpperCase() == - FilteredList[index] - .pharmacy_id - .toString() - .toUpperCase()); - } - }, - ), - ); - }, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 1,//.size.width * .33, - childAspectRatio: MediaQuery.of(context).size.width / - (MediaQuery.of(context).size.height /7)), - ), - ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async { - if(Url!=''&&pharmaciesCheckboxes.isNotEmpty){ - AppSettings.preLoaderDialog(context); + }, + ),) - var payload = new Map(); + ], - payload["picture"] = Url.toString(); - payload["pharmacies"] = pharmaciesCheckboxes; - bool status = await AppSettings.uploadPrescription(payload); - try { - if (status) { - Navigator.of(context, rootNavigator: true).pop(); - Url=''; - pharmaciesCheckboxes = []; - AppSettings.longSuccessToast( - "Prescription uploaded Successfully"); - // Navigator.pop(context); - getAllPharmaciesData(dropdownArea); - /* - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ConnectionsView()), - );*/ - } else { - Navigator.of(context, rootNavigator: true).pop(); - AppSettings.longFailedToast( - "Failed to upload prescription"); - } - } catch (exception) { - AppSettings.longFailedToast("Failed to upload prescription"); - print(exception); - } + ), + TextButton( + child: const Text( + 'Order Medicines', + style: TextStyle(color: primaryColor), + ), + onPressed: () { - } - else{ - AppSettings.longFailedToast('Please select image and pharmacies' ); - } - }, - child: const Text('Upload'), - ) - ], - ); - } else { - return Center( + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicines(prescriptionDetails:prescriptionsList[index]))); + //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{ + /*await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AddPrescription()), + );*/ + Navigator.push(context, MaterialPageRoute(builder: (context) => AddPrescription())).then((value) { + getAllPrescriptions(); + }); + //showBoreAddingDialog(); + }, + ), + /* Padding( + padding: EdgeInsets.fromLTRB(5, 0, 5, 5), + child: Text( + 'Add Tanks ', + style: TextStyle(color: Colors.white), + ), + )*/ + ], + ), + ), + ), + ]); + } + else{ + return Center( child: Padding( padding: EdgeInsets.fromLTRB(0, 40, 0, 0), - child: isSereverIssue - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image( - image: AssetImage('images/serverissue.png'), - // height: MediaQuery.of(context).size.height * .10, - ), - SizedBox( - height: 20, - ), - Text( - 'There is an issue at server please try after some time', - style: serverIssueTextStyle(), - ), - ], - ) - : userAddress == '' - ? Column( - mainAxisAlignment: MainAxisAlignment.center, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ - /*Image( - image: AssetImage('images/resourceblue.pngs'), - // height: MediaQuery.of(context).size.height * .10, - ),*/ - Icon( - Icons.location_on_outlined, - color: primaryColor, - size: 40, - ), + SizedBox(height: MediaQuery.of(context).size.height * .25,), + Text('Click below icon to add new prescription'), SizedBox( height: 20, ), - Text( - 'Please select location to see near by pharmacies', - style: TextStyle( - color: primaryColor, - fontWeight: FontWeight.bold, + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + Navigator.push(context, MaterialPageRoute(builder: (context) => AddPrescription())).then((value) { + getAllPrescriptions(); + }); + }, ), - ), - ], - ) - : Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image( - image: AssetImage('images/no_data.png'), - // height: MediaQuery.of(context).size.height * .10, - ), - SizedBox( - height: 20, - ), - Text( - 'No Pharmacies', - style: serverIssueTextStyle(), - ), + ) ], ), - )); - }} + ) + ); + } + } /**/ @@ -662,32 +667,12 @@ class _PrescriptionsState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppSettings.appBar('Prescriptions'), - body: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.all(10), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, // background - onPrimary: Colors.white, // foreground - ), - onPressed: () async { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const AddPrescription()), - ); - }, - child: const Text('Add'), - ), - ), - _allPrescriptions(), - - ], - )), + body: isPrescriptionsDataLoading?Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ): _allPrescriptions(), ); } }