ORDERMEDICINES PAGE ADDED

dev
Sneha 1 year ago
parent 57c9b3618f
commit c67e54ab41

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 805 B

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -549,13 +549,13 @@ class _DashboardState extends State<Dashboard> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppSettings.appBar('Health Care'), appBar: AppSettings.appBar('Health Care'),
drawer: Drawer( drawer: Drawer(
backgroundColor: secondaryColor, backgroundColor: primaryColor,
child: ListView( child: ListView(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
children: [ children: [
DrawerHeader( DrawerHeader(
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: primaryColor, color: buttonColors,
), ),
child: Row( child: Row(
children: [ children: [
@ -597,7 +597,7 @@ class _DashboardState extends State<Dashboard> {
child: Icon( child: Icon(
Icons.camera_alt_outlined, Icons.camera_alt_outlined,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await takeImageFromCamera(); await takeImageFromCamera();
@ -614,7 +614,7 @@ class _DashboardState extends State<Dashboard> {
child: Icon( child: Icon(
Icons.photo, Icons.photo,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGallery();
@ -631,17 +631,17 @@ class _DashboardState extends State<Dashboard> {
), ),
Text( Text(
AppSettings.userName, AppSettings.userName,
style: drawerHeaderTextStyle(), style: drawerHeaderTextStyleNew(),
), ),
Text( Text(
AppSettings.phoneNumber, AppSettings.phoneNumber,
style: drawerHeaderTextStyle(), style: drawerHeaderTextStyleNew(),
), ),
Visibility( Visibility(
visible: AppSettings.email != '', visible: AppSettings.email != '',
child: Text( child: Text(
AppSettings.email, AppSettings.email,
style: drawerHeaderTextStyle(), style: drawerHeaderTextStyleNew(),
), ),
), ),
Row( Row(
@ -650,14 +650,14 @@ class _DashboardState extends State<Dashboard> {
visible: AppSettings.age != '', visible: AppSettings.age != '',
child: Text( child: Text(
AppSettings.age + ' Yrs, ', AppSettings.age + ' Yrs, ',
style: drawerHeaderTextStyle(), style: drawerHeaderTextStyleNew(),
), ),
), ),
Visibility( Visibility(
visible: AppSettings.gender != '', visible: AppSettings.gender != '',
child: Text( child: Text(
AppSettings.gender, AppSettings.gender,
style: drawerHeaderTextStyle(), style: drawerHeaderTextStyleNew(),
), ),
), ),
], ],

@ -112,6 +112,9 @@ TextStyle drawerHeaderTextStyle(){
return TextStyle(color: Colors.white, fontSize: 15); 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 getMedicineTimingsUrl = host + 'getmedicineztiming';
static String prescriptionUploadPicUrl = host + 'uploads-precription'; static String prescriptionUploadPicUrl = host + 'uploads-precription';
static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist'; static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist';
static String uploadPrescriptionUrl = host + 'submitPicture'; static String getQuotationUrl = host + 'submitPicture';
static String addPrescriptionUrl = host + 'add-prescription-details'; static String addPrescriptionUrl = host + 'add-prescription-details';
static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo'; static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo';
static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription'; static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription';
@ -761,8 +764,8 @@ class AppSettings {
} }
} }
static Future<bool> uploadPrescription(payload) async { static Future<bool> getQuotation(payload) async {
var uri = Uri.parse(uploadPrescriptionUrl + '/' + customerId); var uri = Uri.parse(getQuotationUrl + '/' + customerId);
var response = await http.post( var response = await http.post(
uri, uri,
body: json.encode(payload), body: json.encode(payload),

@ -135,7 +135,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
child: Icon( child: Icon(
Icons.camera_alt_outlined, Icons.camera_alt_outlined,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await takeImageFromCamera(); await takeImageFromCamera();
@ -150,7 +150,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
child: Icon( child: Icon(
Icons.photo, Icons.photo,
size: 100, size: 100,
color: greyColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGallery();

@ -18,6 +18,22 @@ class PrescriptionsModel {
rtvm.patient_type = json['patientType'] ?? ''; rtvm.patient_type = json['patientType'] ?? '';
rtvm.prescription_url = json['pictureUrl'][0] ?? ''; 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; return rtvm;
} }

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/prescriptions/prescriptions.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view.dart';
import 'package:pinch_zoom/pinch_zoom.dart'; import 'package:pinch_zoom/pinch_zoom.dart';
@ -218,7 +219,6 @@ class _AddPrescriptionState extends State<AddPrescription> {
), ),
onTap: (){ onTap: (){
showPicDialog(Url); showPicDialog(Url);
}, },
) )
), ),
@ -371,6 +371,12 @@ class _AddPrescriptionState extends State<AddPrescription> {
if(uploadStatus){ if(uploadStatus){
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();
AppSettings.longSuccessToast('Prescription added successfully'); AppSettings.longSuccessToast('Prescription added successfully');
Navigator.pop(context);
/* await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Prescriptions()),
);*/
} }
else{ else{
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context,rootNavigator: true).pop();

@ -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<OrderMedicines> createState() => _OrderMedicinesState();
}
class _OrderMedicinesState extends State<OrderMedicines> {
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<PharmaciesModel> pharmaciesList = [];
List<PharmaciesModel> 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<void> 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: <Widget>[
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<String, dynamic>();
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(),
)
],
));
}
}

@ -6,8 +6,9 @@ import 'package:geolocator/geolocator.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/pharmacies_model.dart'; import 'package:healthcare_user/models/pharmacies_model.dart';
import 'package:healthcare_user/prescriptions/add_prescriptions.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:image_picker/image_picker.dart';
import 'package:photo_view/photo_view.dart';
import 'package:healthcare_user/models/prescriptions_model.dart'; import 'package:healthcare_user/models/prescriptions_model.dart';
class Prescriptions extends StatefulWidget { class Prescriptions extends StatefulWidget {
@ -22,9 +23,10 @@ class _PrescriptionsState extends State<Prescriptions> {
String Url = ''; String Url = '';
List<PharmaciesModel> pharmaciesList = []; List<PharmaciesModel> pharmaciesList = [];
List<PrescriptionsModel> prescriptionsList = []; List<PrescriptionsModel> prescriptionsList = [];
List<PrescriptionsModel> prescriptionsListOriginal = [];
List<PharmaciesModel> FilteredList = []; List<PharmaciesModel> FilteredList = [];
bool isPharmacyDataLoading = false; bool isPharmacyDataLoading = false;
bool isPrescriptionsData = false; bool isPrescriptionsDataLoading = false;
bool isSereverIssue = false; bool isSereverIssue = false;
double lat = 0; double lat = 0;
double lng = 0; double lng = 0;
@ -33,6 +35,7 @@ class _PrescriptionsState extends State<Prescriptions> {
//String dropdownType = 'Tank'; //String dropdownType = 'Tank';
var AreaItems = ['2', '5', '10', '25', '50', '100']; var AreaItems = ['2', '5', '10', '25', '50', '100'];
List pharmaciesCheckboxes = []; List pharmaciesCheckboxes = [];
bool isLoading=false;
Future<void> getAllPharmaciesData(var distance) async { Future<void> getAllPharmaciesData(var distance) async {
isPharmacyDataLoading=true; isPharmacyDataLoading=true;
@ -78,21 +81,21 @@ class _PrescriptionsState extends State<Prescriptions> {
} }
Future<void> getAllPrescriptions() async { Future<void> getAllPrescriptions() async {
isPrescriptionsData=true; isPrescriptionsDataLoading=true;
try { try {
var response = await AppSettings.getAllPrescriptions(); var response = await AppSettings.getAllPrescriptions();
setState(() { setState(() {
prescriptionsList = ((jsonDecode(response)) as List) prescriptionsListOriginal = ((jsonDecode(response)) as List)
.map((dynamic model) { .map((dynamic model) {
return PrescriptionsModel.fromJson(model); return PrescriptionsModel.fromJson(model);
}).toList(); }).toList();
prescriptionsList=prescriptionsListOriginal.reversed.toList();
isPrescriptionsData = false; isPrescriptionsDataLoading = false;
}); });
} catch (e) { } catch (e) {
setState(() { setState(() {
isPrescriptionsData = false; isPrescriptionsDataLoading = false;
isSereverIssue = true; isSereverIssue = true;
}); });
} }
@ -299,7 +302,7 @@ class _PrescriptionsState extends State<Prescriptions> {
payload["picture"] = Url.toString(); payload["picture"] = Url.toString();
payload["pharmacies"] = pharmaciesCheckboxes; payload["pharmacies"] = pharmaciesCheckboxes;
bool status = await AppSettings.uploadPrescription(payload); bool status = await AppSettings.getQuotation(payload);
try { try {
if (status) { if (status) {
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
@ -399,262 +402,264 @@ class _PrescriptionsState extends State<Prescriptions> {
)); ));
} }
} }
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: <Widget>[
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: <Widget>[
TextButton(
child: Text('Close', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
});
},
);
}
Widget _allPrescriptions(){ Widget _allPrescriptions(){
if (prescriptionsList.length != 0) { if (prescriptionsList.length != 0) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
GridView.builder( Expanded(child:ListView.builder(
shrinkWrap: true, padding: EdgeInsets.all(0),
physics: NeverScrollableScrollPhysics(), itemCount: prescriptionsList.length,
itemCount: FilteredList.length, itemBuilder: (BuildContext context, int index) {
itemBuilder: (context, index) {
return Card( return Card(
elevation: 2.0,
child: CheckboxListTile( //color: prescriptionsList[index].cardColor,
title: Padding( child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 0, 0), padding:EdgeInsets.all(8) ,
child: Row( child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
child: Container(
width: MediaQuery.of(context).size.width * .18, width: MediaQuery.of(context).size.width * .18,
height: height:
MediaQuery.of(context).size.height * .10, MediaQuery.of(context).size.height * .10,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: DecorationImage( image: DecorationImage(
image: FilteredList[index].picture == '' image: NetworkImage(prescriptionsList[index].prescription_url) as ImageProvider, // picked file
? AssetImage("images/logo.png")
: NetworkImage(
FilteredList[index].picture)
as ImageProvider, // picked file
fit: BoxFit.contain)), fit: BoxFit.contain)),
), ),
SizedBox( onTap: (){
width: 5, showPicDialog(prescriptionsList[index].prescription_url);
},
), ),
Expanded( SizedBox(width:MediaQuery.of(context).size.width * .02,),
child: Container(
width: Container(
MediaQuery.of(context).size.width * .70, width: MediaQuery.of(context).size.width * .55,
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
Text( Text(prescriptionsList[index].prescription_name.toString().toUpperCase(),style: valuesTextStyle()),
FilteredList[index] Text(prescriptionsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()),
.pharmacy_name Text(prescriptionsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()),
.toUpperCase(), Text(prescriptionsList[index].age.toString().toUpperCase(),style: valuesTextStyle()),
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()),
),
SizedBox(
height: 10,
),
/*Text(
FilteredList[index]
.starting_price
.toUpperCase(),
style: wrapTextStyleBlack()),
SizedBox(height: 10,),*/
], ],
)),
), ),
],
)
), ),
checkColor: Colors.white,
activeColor: primaryColor,
value: FilteredList[index].isChecked, Expanded(child:IconButton(
onChanged: (val) { icon: const Icon(Icons.edit,color: primaryColor,),
setState( onPressed: () {
() {
FilteredList[index].isChecked = val!;
}, },
); ),),
if (FilteredList[index].isChecked) { Expanded(child:IconButton(
pharmaciesCheckboxes.add({ icon: const Icon(Icons.delete,color: primaryColor,),
'pharmacyId': onPressed: () async{
FilteredList[index] /* showDialog(
.pharmacy_id, //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<String, dynamic>();
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 { else{
pharmaciesCheckboxes.removeWhere((e) => AppSettings.longFailedToast('tank deletion failed');
e['pharmacyId'] Navigator.of(context).pop(true);
.toString()
.toUpperCase() ==
FilteredList[index]
.pharmacy_id
.toString()
.toUpperCase());
} }
}, },
child: const Text('Yes',
style: TextStyle(
color: primaryColor,
fontSize: 20,
)),
), ),
); TextButton(
onPressed: () {
Navigator.of(context).pop(true);
}, },
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( child: const Text('No',
crossAxisCount: 1,//.size.width * .33, style: TextStyle(
childAspectRatio: MediaQuery.of(context).size.width / color: primaryColor,
(MediaQuery.of(context).size.height /7)), fontSize: 20,
)),
), ),
ElevatedButton( ],
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
), ),
onPressed: () async { );*/
if(Url!=''&&pharmaciesCheckboxes.isNotEmpty){
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["picture"] = Url.toString(); },
payload["pharmacies"] = pharmaciesCheckboxes; ),)
bool status = await AppSettings.uploadPrescription(payload);
try { ],
if (status) {
Navigator.of(context, rootNavigator: true).pop(); ),
Url=''; TextButton(
pharmaciesCheckboxes = []; child: const Text(
AppSettings.longSuccessToast( 'Order Medicines',
"Prescription uploaded Successfully"); style: TextStyle(color: primaryColor),
// Navigator.pop(context); ),
getAllPharmaciesData(dropdownArea); onPressed: () {
/*
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( new MaterialPageRoute(
builder: (context) => ConnectionsView()), builder: (__) => new OrderMedicines(prescriptionDetails:prescriptionsList[index])));
);*/ //signup screen
} else {
Navigator.of(context, rootNavigator: true).pop();
AppSettings.longFailedToast(
"Failed to upload prescription");
}
} catch (exception) {
AppSettings.longFailedToast("Failed to upload prescription");
print(exception);
}
}
else{
AppSettings.longFailedToast('Please select image and pharmacies' );
}
}, },
child: const Text('Upload'),
) )
], ],
);
} 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(), Padding(
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
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),
: userAddress == '' child: Text(
? Column( 'Add Tanks ',
mainAxisAlignment: MainAxisAlignment.center, style: TextStyle(color: Colors.white),
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 pharmacies',
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold,
), ),
), ),
], ]);
) }
: Column( else{
mainAxisAlignment: MainAxisAlignment.center, return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Image( SizedBox(height: MediaQuery.of(context).size.height * .25,),
image: AssetImage('images/no_data.png'), Text('Click below icon to add new prescription'),
// height: MediaQuery.of(context).size.height * .10,
),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
Text( CircleAvatar(
'No Pharmacies', backgroundColor: primaryColor,
style: serverIssueTextStyle(), 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();
});
},
),
)
], ],
), ),
)); )
}} );
}
}
/**/ /**/
@ -662,32 +667,12 @@ class _PrescriptionsState extends State<Prescriptions> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppSettings.appBar('Prescriptions'), appBar: AppSettings.appBar('Prescriptions'),
body: Container( body: isPrescriptionsDataLoading?Center(
child: Column( child: CircularProgressIndicator(
crossAxisAlignment: CrossAxisAlignment.start, color: primaryColor,
mainAxisAlignment: MainAxisAlignment.start, strokeWidth: 5.0,
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(), ): _allPrescriptions(),
],
)),
); );
} }
} }

Loading…
Cancel
Save