Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 643 B After Width: | Height: | Size: 633 B |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 935 KiB |
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 662 KiB |
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 650 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 237 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 738 B After Width: | Height: | Size: 722 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 160 KiB |
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 816 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.3 KiB |
@ -0,0 +1,13 @@
|
||||
|
||||
/* get pharmacies data */
|
||||
/*Expanded(
|
||||
child: Container(
|
||||
child: isPharmacyDataLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: primaryColor,
|
||||
strokeWidth: 5.0,
|
||||
),
|
||||
)
|
||||
: _pharamciesData(),
|
||||
))*/
|
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class EditMedicineTimings extends StatefulWidget {
|
||||
const EditMedicineTimings({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<EditMedicineTimings> createState() => _EditMedicineTimingsState();
|
||||
}
|
||||
|
||||
class _EditMedicineTimingsState extends State<EditMedicineTimings> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:healthcare_user/report_my_self.dart';
|
||||
|
||||
|
||||
class HowAreYouFellingToday extends StatefulWidget {
|
||||
const HowAreYouFellingToday({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<HowAreYouFellingToday> createState() => _HowAreYouFellingTodayState();
|
||||
}
|
||||
|
||||
class _HowAreYouFellingTodayState extends State<HowAreYouFellingToday> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('How are you feeling today?'),
|
||||
body: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: TextButton(
|
||||
child: const Text(
|
||||
'Report a problem!',
|
||||
style: TextStyle(fontSize: 15,
|
||||
decoration: TextDecoration.underline,color: greyColor),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ReportMySelf()),
|
||||
);
|
||||
//signup screen
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
|
||||
class PrescriptionsModel {
|
||||
String prescription_name = '';
|
||||
String patient_name='';
|
||||
String prescription_url='';
|
||||
String age='';
|
||||
String gender='';
|
||||
String patient_type='';
|
||||
|
||||
PrescriptionsModel();
|
||||
|
||||
factory PrescriptionsModel.fromJson(Map<String, dynamic> json){
|
||||
PrescriptionsModel rtvm = new PrescriptionsModel();
|
||||
|
||||
rtvm.prescription_name = json['name'] ?? '';
|
||||
rtvm.patient_type = json['patientType'] ?? '';
|
||||
rtvm.prescription_url = json['pictureUrl'][0] ?? '';
|
||||
|
||||
return rtvm;
|
||||
}
|
||||
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:healthcare_user/models/pharmacies.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class Prescriptions extends StatefulWidget {
|
||||
const Prescriptions({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Prescriptions> createState() => _PrescriptionsState();
|
||||
}
|
||||
|
||||
class _PrescriptionsState extends State<Prescriptions> {
|
||||
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
String Url='';
|
||||
List<PharmaciesModel> pharmaciesList = [];
|
||||
List<PharmaciesModel> FilteredList = [];
|
||||
bool isSupplierDataLoading=false;
|
||||
bool isSereverIssue = false;
|
||||
double lat=0;
|
||||
double lng=0;
|
||||
String userAddress='';
|
||||
String dropdownArea = '2';
|
||||
//String dropdownType = 'Tank';
|
||||
var AreaItems = [
|
||||
'2',
|
||||
'5',
|
||||
'10',
|
||||
'25',
|
||||
'50',
|
||||
'100'
|
||||
];
|
||||
|
||||
|
||||
Future<void> getAllPharmaciesData(var distance) async {
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
//FilteredList=suppliersList.where((product) => product.address.toString().toUpperCase()=='SUMP').toList();
|
||||
|
||||
|
||||
isSupplierDataLoading = false;
|
||||
});
|
||||
|
||||
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isSupplierDataLoading = false;
|
||||
isSereverIssue = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
lat=AppSettings.userLatitude;
|
||||
lng=AppSettings.userLongitude;
|
||||
userAddress=AppSettings.userAddress;
|
||||
getAllPharmaciesData(dropdownArea);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
Future pickImageFromGallery() async {
|
||||
try {
|
||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
|
||||
|
||||
var res=await AppSettings.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['picture'];
|
||||
});
|
||||
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future takeImageFromCamera() async {
|
||||
try {
|
||||
final image = await _picker.pickImage(source: ImageSource.camera);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
|
||||
var res=await AppSettings.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['picture'];
|
||||
});
|
||||
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Prescriptions'),
|
||||
body: Container(
|
||||
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async{
|
||||
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeImageFromCamera();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context)
|
||||
.size
|
||||
.width *
|
||||
.20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickImageFromGallery();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text('Select image'),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * .18,
|
||||
height:
|
||||
MediaQuery.of(context).size.height * .10,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(Url) as ImageProvider, // picked file
|
||||
fit: BoxFit.contain)),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,408 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:pinch_zoom/pinch_zoom.dart';
|
||||
|
||||
class AddPrescription extends StatefulWidget {
|
||||
const AddPrescription({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
@override
|
||||
State<AddPrescription> createState() => _AddPrescriptionState();
|
||||
}
|
||||
|
||||
class _AddPrescriptionState extends State<AddPrescription> {
|
||||
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
String Url = '';
|
||||
final _transformationController = TransformationController();
|
||||
TapDownDetails _doubleTapDetails=TapDownDetails();
|
||||
TextEditingController prescriptionNameController = TextEditingController();
|
||||
TextEditingController patientNameController = TextEditingController();
|
||||
TextEditingController patientAgeController = TextEditingController();
|
||||
String? prescriptionFor;
|
||||
String? gender;
|
||||
|
||||
Future pickImageFromGallery() async {
|
||||
try {
|
||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
|
||||
AppSettings.preLoaderDialog(context);
|
||||
var res = await AppSettings.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['pictures'][0];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future takeImageFromCamera() 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.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['pictures'][0];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Widget zoomPhoto(var imageUrl){
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width * .18,
|
||||
height: MediaQuery.of(context).size.height * .10,
|
||||
child: PhotoView(
|
||||
imageProvider: NetworkImage(imageUrl) as ImageProvider,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _handleDoubleTap() {
|
||||
if (_transformationController.value != Matrix4.identity()) {
|
||||
_transformationController.value = Matrix4.identity();
|
||||
} else {
|
||||
final position = _doubleTapDetails.localPosition;
|
||||
// For a 3x zoom
|
||||
_transformationController.value = Matrix4.identity()
|
||||
..translate(-position.dx * 2, -position.dy * 2)
|
||||
..scale(3.0);
|
||||
// Fox a 2x zoom
|
||||
// ..translate(-position.dx, -position.dy)
|
||||
// ..scale(2.0);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Add Prescription'),
|
||||
body:SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeImageFromCamera();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * .20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickImageFromGallery();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text('Select image'),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Visibility(
|
||||
visible: Url != '',
|
||||
child: GestureDetector(
|
||||
child:
|
||||
/*,*/
|
||||
/*Container(
|
||||
width: MediaQuery.of(context).size.width * .18,
|
||||
height: MediaQuery.of(context).size.height * .10,
|
||||
child: PhotoView(
|
||||
imageProvider: NetworkImage(Url) as ImageProvider,
|
||||
maxScale: PhotoViewComputedScale.contained * 4.0,
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
basePosition: Alignment.center,
|
||||
|
||||
)
|
||||
),*/
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * .18,
|
||||
height: MediaQuery.of(context).size.height * .10,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(Url) as ImageProvider, // picked file
|
||||
fit: BoxFit.fill)),
|
||||
),
|
||||
onTap: (){
|
||||
showPicDialog(Url);
|
||||
|
||||
},
|
||||
)
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: prescriptionNameController,
|
||||
decoration: textFormFieldDecoration(Icons.edit,'Enter Prescription name'),
|
||||
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("For Yourself"),
|
||||
value: "self",
|
||||
groupValue: prescriptionFor,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
prescriptionFor = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("For Family"),
|
||||
value: "others",
|
||||
groupValue: prescriptionFor,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
prescriptionFor = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: patientNameController,
|
||||
decoration: textFormFieldDecoration(Icons.person,'Enter patient name'),
|
||||
|
||||
),
|
||||
),),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
keyboardType: TextInputType.number,
|
||||
controller: patientAgeController,
|
||||
decoration: textFormFieldDecoration(Icons.person,'Enter patient age'),
|
||||
|
||||
),
|
||||
),),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Male",style: TextStyle(fontSize: 10)),
|
||||
value: "male",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Female",style: TextStyle(fontSize: 10),),
|
||||
value: "female",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Others",style: TextStyle(fontSize: 10)),
|
||||
value: "other",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
],
|
||||
),),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
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(Url!=''&& prescriptionNameController.text!=''&&prescriptionFor!=''){
|
||||
|
||||
String _name='';
|
||||
String _age='';
|
||||
String? _gender='';
|
||||
|
||||
if(prescriptionFor.toString().toLowerCase()=='others'){
|
||||
if(patientNameController!=''&& patientAgeController.text!=''&&gender!=''){
|
||||
_name=patientNameController.text;
|
||||
_age=patientAgeController.text;
|
||||
_gender=gender;
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please enter details');
|
||||
}
|
||||
}
|
||||
else{
|
||||
_name=AppSettings.userName;
|
||||
_age=AppSettings.age;
|
||||
_gender=AppSettings.gender;
|
||||
}
|
||||
AppSettings.preLoaderDialog(context);
|
||||
bool isOnline = await AppSettings.internetConnectivity();
|
||||
if(isOnline){
|
||||
var payload = new Map<String, dynamic>();
|
||||
payload["name"] = prescriptionNameController.text.toString();
|
||||
payload["pictureUrl"] = Url.toString();
|
||||
payload["patientType"] = prescriptionFor.toString();
|
||||
payload["others"] ={
|
||||
"name": _name,
|
||||
"age": int.parse(_age),
|
||||
"gender": _gender.toString().toLowerCase()
|
||||
};
|
||||
bool uploadStatus = await AppSettings.addPrescription(payload);
|
||||
|
||||
try{
|
||||
if(uploadStatus){
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longSuccessToast('Prescription added successfully');
|
||||
}
|
||||
else{
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longFailedToast('Fail to add prescription details');
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
print(e);
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longFailedToast('Fail to add prescription details');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please check internet');
|
||||
}
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please upload image');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
child: const Text('Upload'),
|
||||
)),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
)) ,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,693 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
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:image_picker/image_picker.dart';
|
||||
|
||||
import 'package:healthcare_user/models/prescriptions_model.dart';
|
||||
|
||||
class Prescriptions extends StatefulWidget {
|
||||
const Prescriptions({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Prescriptions> createState() => _PrescriptionsState();
|
||||
}
|
||||
|
||||
class _PrescriptionsState extends State<Prescriptions> {
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
String Url = '';
|
||||
List<PharmaciesModel> pharmaciesList = [];
|
||||
List<PrescriptionsModel> prescriptionsList = [];
|
||||
List<PharmaciesModel> FilteredList = [];
|
||||
bool isPharmacyDataLoading = false;
|
||||
bool isPrescriptionsData = false;
|
||||
bool isSereverIssue = false;
|
||||
double lat = 0;
|
||||
double lng = 0;
|
||||
String userAddress = '';
|
||||
String dropdownArea = '2';
|
||||
//String dropdownType = 'Tank';
|
||||
var AreaItems = ['2', '5', '10', '25', '50', '100'];
|
||||
List pharmaciesCheckboxes = [];
|
||||
|
||||
Future<void> getAllPharmaciesData(var distance) async {
|
||||
isPharmacyDataLoading=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);
|
||||
}
|
||||
});
|
||||
|
||||
isPharmacyDataLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isPharmacyDataLoading = false;
|
||||
isSereverIssue = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getAllPrescriptions() async {
|
||||
isPrescriptionsData=true;
|
||||
try {
|
||||
var response = await AppSettings.getAllPrescriptions();
|
||||
|
||||
setState(() {
|
||||
prescriptionsList = ((jsonDecode(response)) as List)
|
||||
.map((dynamic model) {
|
||||
return PrescriptionsModel.fromJson(model);
|
||||
}).toList();
|
||||
|
||||
isPrescriptionsData = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isPrescriptionsData = false;
|
||||
isSereverIssue = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
lat = AppSettings.userLatitude;
|
||||
lng = AppSettings.userLongitude;
|
||||
userAddress = AppSettings.userAddress;
|
||||
getAllPrescriptions();
|
||||
//getAllPharmaciesData(dropdownArea);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future pickImageFromGallery() async {
|
||||
try {
|
||||
final image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
|
||||
AppSettings.preLoaderDialog(context);
|
||||
var res = await AppSettings.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['pictures'][0];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future takeImageFromCamera() 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.uploadImageHTTPForPrescriptions(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
Url = jsonDecode(res)['pictures'][0];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Widget _pharamciesData() {
|
||||
if (FilteredList.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,
|
||||
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()),
|
||||
/*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,
|
||||
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<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='';
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
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(),
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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 pharmacies',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
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()),
|
||||
/*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,
|
||||
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<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='';
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
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(),
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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 pharmacies',
|
||||
style: TextStyle(
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
}}
|
||||
|
||||
/**/
|
||||
|
||||
@override
|
||||
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(),
|
||||
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class ReportMySelf extends StatefulWidget {
|
||||
const ReportMySelf({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ReportMySelf> createState() => _ReportMySelfState();
|
||||
}
|
||||
|
||||
class _ReportMySelfState extends State<ReportMySelf> {
|
||||
|
||||
TextEditingController problemNameController = TextEditingController();
|
||||
TextEditingController descriptionController = TextEditingController();
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
String videoUrl='';
|
||||
|
||||
Future takeVideoFromCamera() async {
|
||||
try {
|
||||
final image = await _picker.pickVideo(source: ImageSource.camera);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
AppSettings.preLoaderDialog(context);
|
||||
var res = await AppSettings.uploadVideoInReportMySelf(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
videoUrl = jsonDecode(res)['picture'];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick video: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future pickVideoFromGallery() async {
|
||||
try {
|
||||
final image = await _picker.pickVideo(source: ImageSource.gallery);
|
||||
if (image == null) return;
|
||||
final imageTemp = File(image.path);
|
||||
|
||||
AppSettings.preLoaderDialog(context);
|
||||
var res = await AppSettings.uploadVideoInReportMySelf(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
videoUrl = jsonDecode(res)['picture'];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick video: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Report MySelf'),
|
||||
body: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: problemNameController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(
|
||||
Icons.phone,
|
||||
color: greyColor,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor)),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color:primaryColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor),
|
||||
),
|
||||
labelText: 'Enter problem name',
|
||||
labelStyle: TextStyle(
|
||||
color: greyColor, //<-- SEE HERE
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: descriptionController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(
|
||||
Icons.description,
|
||||
color: greyColor,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor)),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color:primaryColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor),
|
||||
),
|
||||
labelText: 'Description',
|
||||
labelStyle: TextStyle(
|
||||
color: greyColor, //<-- SEE HERE
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.audio_file,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
),
|
||||
SizedBox(width: 10,),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.video_camera_back_rounded,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeVideoFromCamera();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * .20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: greyColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickVideoFromGallery();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
SizedBox(width: 10,),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.image,
|
||||
color: primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: videoUrl != '',
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(10,0,0,0),
|
||||
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(videoUrl) as ImageProvider, // picked file
|
||||
fit: BoxFit.contain)),
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 805 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 643 B |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 237 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 738 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 3.1 KiB |