added medicine timings functionality

dev
Sneha 1 year ago
parent 903f044073
commit a35d50972f

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -0,0 +1,324 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/BMI/bmi_history.dart';
import 'package:healthcare_user/common/settings.dart';
class BMICalculator extends StatefulWidget {
const BMICalculator({Key? key}) : super(key: key);
@override
State<BMICalculator> createState() => _BMICalculatorState();
}
class _BMICalculatorState extends State<BMICalculator> {
TextEditingController heightController = TextEditingController();
TextEditingController weightController = TextEditingController();
TextEditingController ageController = TextEditingController();
String bmiValue = '';
String bmiText = '';
var heightUnitItems = [
'feet',
'cm',
'inches',
];
var heightUnits = 'feet';
var weightUnitItems = [
'kg',
'gr',
];
var weightUnits = 'kg';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Calculate BMI'),
body: SingleChildScrollView(
child: Container(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
TextFormField(
cursorColor: greyColor,
controller: ageController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Age',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
SizedBox(height: 10),
Container(
//height: 60,
child: Row(
children: [
Expanded(
child: TextFormField(
cursorColor: greyColor,
controller: heightController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.height,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Height',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
SizedBox(width: 5),
Expanded(
child: DropdownButtonFormField(
// Initial Value
value: heightUnits,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.ac_unit_outlined,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: heightUnitItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
heightUnits = newValue!;
});
},
),
)
],
),
),
SizedBox(height: 10),
Container(
//height: 40,
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Row(
children: [
Expanded(
child: TextFormField(
cursorColor: greyColor,
controller: weightController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.line_weight_outlined,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Weight',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
SizedBox(width: 5),
Expanded(
child: DropdownButtonFormField(
// Initial Value
value: weightUnits,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.ac_unit_outlined,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: weightUnitItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
weightUnits = newValue!;
});
},
),
)
],
),
),
SizedBox(height: 10),
TextButton(
child: Text('Calculate BMI', style: textButtonStyle()),
onPressed: () async {
if (ageController.text != '' &&
heightController.text != '' &&
weightController.text != '') {
var payload = new Map<String, dynamic>();
payload["age"] =
int.parse(ageController.text.toString());
payload["height"] = heightController.text.toString();
payload["weight"] = weightController.text.toString();
payload["heightUnit"] = heightUnits.toString();
payload["weightUnit"] = weightUnits.toString();
var value = await AppSettings.calculateBmi(payload);
var valueResponse = jsonDecode(value);
print(valueResponse);
setState(() {
bmiValue = valueResponse['userDetails']['bmivalue'].toString();
if(double.parse(bmiValue)<18.5){
bmiText='Underweight';
}
else if(double.parse(bmiValue)>=18.5&&double.parse(bmiValue)<=24.9){
bmiText='Normal weight';
}
else if(double.parse(bmiValue)>=25&&double.parse(bmiValue)<=29.9){
bmiText='Overweight';
}
else if(double.parse(bmiValue)>=30){
bmiText='Obesity';
}
});
}
},
),
SizedBox(height: 10),
Container(
child: Row(
children: [
Text('Your Bmi value: $bmiValue'),
SizedBox(width: 10,),
Text(bmiText,style: TextStyle(color: Colors.red)),
],
)
),
SizedBox(height: 30),
Container(
child: Text('Underweight = <18.5',style: bmiTextStyle(),),
),
SizedBox(height: 10),
Container(
child: Text('Normal weight = 18.524.9',style: bmiTextStyle()),
),
SizedBox(height: 10),
Container(
child: Text('Overweight = 2529.9',style: bmiTextStyle()),
),
SizedBox(height: 10),
Container(
child: Text('Obesity = BMI of 30 or greater',style: bmiTextStyle()),
),
SizedBox(height: 20),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BMIHistory()),
);
},
icon: Icon(
Icons.history,
color: primaryColor,
size: 40,
),
),
SizedBox(height: 10),
Padding(padding: EdgeInsets.fromLTRB(10,0,0,0),
child: Container(
child: Text('History',style:TextStyle(color:Colors.black,fontSize: 12,fontWeight: FontWeight.bold,)),
),)
],
),
)
),
)
);
}
}

@ -0,0 +1,267 @@
import 'dart:convert';
import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
import 'package:healthcare_user/models/bmi_history_model.dart';
import 'package:healthcare_user/common/settings.dart';
class BMIHistory extends StatefulWidget {
const BMIHistory({Key? key}) : super(key: key);
@override
State<BMIHistory> createState() => _BMIHistoryState();
}
class _BMIHistoryState extends State<BMIHistory> {
bool isLoading=false;
List<BmiHistoryModel> bmiHistoryList = [];
List<BmiHistoryModel> FilteredList = [];
var dateItems = [
'last 7 days',
'last one month',
'last one year',
];
var dateItemsVariable = 'last 7 days';
Future<void> getBmiHistoryDetails(var selectedRange) async {
isLoading=true;
var response1= await AppSettings.getBmiHistory();
print(response1);
setState(() {
bmiHistoryList =
((jsonDecode(response1)) as List).map((dynamic model) {
return BmiHistoryModel.fromJson(model);
}).toList();
var now = new DateTime.now();
var now_1w = now.subtract(Duration(days: 7));
var now_1m = new DateTime(now.year, now.month-1, now.day);
var now_1y = new DateTime(now.year-1, now.month, now.day);
if(selectedRange.toString().toUpperCase()=='LAST 7 DAYS'){
FilteredList=bmiHistoryList.where((product) {
final date = product.dateForFilter;
return now_1w.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE MONTH'){
FilteredList=bmiHistoryList.where((product) {
final date = product.dateForFilter;
return now_1m.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE YEAR'){
FilteredList=bmiHistoryList.where((product) {
final date = product.dateForFilter;
return now_1y.isBefore(date);
}).toList();
}
else{
FilteredList=bmiHistoryList;
}
isLoading=false;
});
}
@override
void initState() {
getBmiHistoryDetails(dateItemsVariable);
super.initState();
}
Widget renderzUi(){
if(bmiHistoryList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: DropdownButtonFormField(
// Initial Value
value: dateItemsVariable,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.calendar_month,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: dateItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
dateItemsVariable = newValue!;
});
getBmiHistoryDetails(dateItemsVariable);
},
),),
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: FilteredList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Colors.white,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width * .55,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].height.toString().toUpperCase()+' ft',style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/weight.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].weight.toString().toUpperCase()+' Kgs',style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/date.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].displayDate.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/weight.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].bmiValue.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
],
),
),
],
),
),
);
}) ),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('No Data'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.info,
color: Colors.white,
),
onPressed: () async {
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Body Mass Index'),
body: isLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzUi(),
);
}
}

@ -0,0 +1,164 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/BMI/bmi_history.dart';
import 'package:healthcare_user/BP/bp_history.dart';
import 'package:healthcare_user/common/settings.dart';
class BPCalculator extends StatefulWidget {
const BPCalculator({Key? key}) : super(key: key);
@override
State<BPCalculator> createState() => _BPCalculatorState();
}
class _BPCalculatorState extends State<BPCalculator> {
TextEditingController systoloicController = TextEditingController();
TextEditingController diastolicController = TextEditingController();
String bpValue = '';
String bpText = '';
var heightUnitItems = [
'feet',
'cm',
'inches',
];
var heightUnits = 'feet';
var weightUnitItems = [
'kg',
'gr',
];
var weightUnits = 'kg';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Blood Pressure'),
body: SingleChildScrollView(
child: Container(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
TextFormField(
cursorColor: greyColor,
controller: systoloicController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Enter systolic value',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
SizedBox(height: 10),
TextFormField(
cursorColor: greyColor,
controller: diastolicController,
textCapitalization: TextCapitalization.characters,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Enter diastolic value',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
SizedBox(height: 10),
TextButton(
child: Text('Check BP', style: textButtonStyle()),
onPressed: () async {
if (systoloicController.text != '' &&
diastolicController.text != '') {
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["Systolic"] = double.parse(systoloicController.text.toString());
payload["Diastolic"] = double.parse(diastolicController.text.toString());
var value = await AppSettings.calculateBP(payload);
var valueResponse = jsonDecode(value);
print(valueResponse);
setState(() {
bpValue = valueResponse['userDetails']['bpCategory'].toString();
/*bpValue = valueResponse['userDetails']['bmivalue'].toString();
if(double.parse(bpValue)<18.5){
bpText='Underweight';
}
else if(double.parse(bpValue)>=18.5&&double.parse(bpValue)<=24.9){
bpText='Normal weight';
}
else if(double.parse(bpValue)>=25&&double.parse(bpValue)<=29.9){
bpText='Overweight';
}
else if(double.parse(bpValue)>=30){
bpText='Obesity';
}*/
});
systoloicController.clear();
diastolicController.clear();
Navigator.of(context,rootNavigator: true).pop();
}
},
),
SizedBox(height: 10),
Container(
child: Row(
children: [
Text(bpValue,style: TextStyle(color: Colors.red),),
],
)
),
SizedBox(height: 20),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BPHistory()),
);
},
icon: Icon(
Icons.history,
color: primaryColor,
size: 40,
),
),
SizedBox(height: 10),
Padding(padding: EdgeInsets.fromLTRB(10,0,0,0),
child: Container(
child: Text('History',style:TextStyle(color:Colors.black,fontSize: 12,fontWeight: FontWeight.bold,)),
),)
],
),
)
),
)
);
}
}

@ -0,0 +1,256 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/models/bmi_history_model.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/bp_history_model.dart';
class BPHistory extends StatefulWidget {
const BPHistory({Key? key}) : super(key: key);
@override
State<BPHistory> createState() => _BPHistoryState();
}
class _BPHistoryState extends State<BPHistory> {
bool isLoading=false;
List<BPHistoryModel> BpHistoryList = [];
List<BPHistoryModel> FilteredList = [];
var dateItems = [
'last 7 days',
'last one month',
'last one year',
];
var dateItemsVariable = 'last 7 days';
Future<void> getBmiHistoryDetails(var selectedRange) async {
isLoading=true;
var response1= await AppSettings.getBPHistory();
print(response1);
setState(() {
BpHistoryList =
((jsonDecode(response1)) as List).map((dynamic model) {
return BPHistoryModel.fromJson(model);
}).toList();
var now = new DateTime.now();
var now_1w = now.subtract(Duration(days: 7));
var now_1m = new DateTime(now.year, now.month-1, now.day);
var now_1y = new DateTime(now.year-1, now.month, now.day);
if(selectedRange.toString().toUpperCase()=='LAST 7 DAYS'){
FilteredList=BpHistoryList.where((product) {
final date = product.dateForFilter;
return now_1w.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE MONTH'){
FilteredList=BpHistoryList.where((product) {
final date = product.dateForFilter;
return now_1m.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE YEAR'){
FilteredList=BpHistoryList.where((product) {
final date = product.dateForFilter;
return now_1y.isBefore(date);
}).toList();
}
else{
FilteredList=BpHistoryList;
}
isLoading=false;
});
}
@override
void initState() {
getBmiHistoryDetails(dateItemsVariable);
super.initState();
}
Widget renderzUi(){
if(BpHistoryList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: DropdownButtonFormField(
// Initial Value
value: dateItemsVariable,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.calendar_month,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: dateItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
dateItemsVariable = newValue!;
});
getBmiHistoryDetails(dateItemsVariable);
},
),),
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: FilteredList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Colors.white,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Container(
width: MediaQuery.of(context).size.width * .55,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/* Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),*/
Text('Systolic',style: TextStyle(color: primaryColor),),
SizedBox(width: 5,),
Padding(padding: EdgeInsets.all(1),
child: Text(FilteredList[index].systolic.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Diastolic',style: TextStyle(color: primaryColor),),
Padding(padding: EdgeInsets.all(1),
child: Text(FilteredList[index].diastolic.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].bpText.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/date.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].displayDate.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
],
),
),
),
);
}) ),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('No data'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.info,
color: Colors.white,
),
onPressed: () async {
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Blood Pressure'),
body: isLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzUi(),
);
}
}

@ -0,0 +1,143 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/BMI/bmi_history.dart';
import 'package:healthcare_user/BP/bp_history.dart';
import 'package:healthcare_user/Sugar/sugar_history.dart';
import 'package:healthcare_user/common/settings.dart';
class SugarCalculator extends StatefulWidget {
const SugarCalculator({Key? key}) : super(key: key);
@override
State<SugarCalculator> createState() => _SugarCalculatorState();
}
class _SugarCalculatorState extends State<SugarCalculator> {
TextEditingController fastingValueController = TextEditingController();
TextEditingController postParandialValueController = TextEditingController();
String sugarValue = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Diabetes'),
body: SingleChildScrollView(
child: Container(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
TextFormField(
cursorColor: greyColor,
controller: fastingValueController,
textCapitalization: TextCapitalization.characters,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Enter fasting sugar value',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
SizedBox(height: 10),
TextFormField(
cursorColor: greyColor,
controller: postParandialValueController,
textCapitalization: TextCapitalization.characters,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Enter PostPrandial value',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
SizedBox(height: 10),
TextButton(
child: Text('Check Sugar', style: textButtonStyle()),
onPressed: () async {
if (fastingValueController.text != '' &&
postParandialValueController.text != '') {
AppSettings.preLoaderDialog(context);
var payload = new Map<String, dynamic>();
payload["fasting"] = double.parse(fastingValueController.text.toString());
payload["postPrandial"] = double.parse(postParandialValueController.text.toString());
var value = await AppSettings.calculateSugar(payload);
var valueResponse = jsonDecode(value);
print(valueResponse);
setState(() {
sugarValue = valueResponse['userSugarDetails']['sugarCategory'].toString();
});
fastingValueController.clear();
postParandialValueController.clear();
Navigator.of(context,rootNavigator: true).pop();
}
},
),
SizedBox(height: 10),
Container(
child: Row(
children: [
Text(sugarValue,style: TextStyle(color: Colors.red),),
],
)
),
SizedBox(height: 20),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SugarHistory()),
);
},
icon: Icon(
Icons.history,
color: primaryColor,
size: 40,
),
),
SizedBox(height: 10),
Padding(padding: EdgeInsets.fromLTRB(10,0,0,0),
child: Container(
child: Text('History',style:TextStyle(color:Colors.black,fontSize: 12,fontWeight: FontWeight.bold,)),
),)
],
),
)
),
)
);
}
}

@ -0,0 +1,281 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:healthcare_user/models/bmi_history_model.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/bp_history_model.dart';
import 'package:healthcare_user/models/sugar_history_model.dart';
class SugarHistory extends StatefulWidget {
const SugarHistory({Key? key}) : super(key: key);
@override
State<SugarHistory> createState() => _SugarHistoryState();
}
class _SugarHistoryState extends State<SugarHistory> {
bool isLoading=false;
List<SugarHistoryModel> sugarHistoryList = [];
List<SugarHistoryModel> FilteredList = [];
var dateItems = [
'last 7 days',
'last one month',
'last one year',
];
var dateItemsVariable = 'last 7 days';
Future<void> getSugarHistoryDetails(var selectedRange) async {
isLoading=true;
var response1= await AppSettings.getSugarHistory();
print(response1);
setState(() {
sugarHistoryList =
((jsonDecode(response1)) as List).map((dynamic model) {
return SugarHistoryModel.fromJson(model);
}).toList();
var now = new DateTime.now();
var now_1w = now.subtract(Duration(days: 7));
var now_1m = new DateTime(now.year, now.month-1, now.day);
var now_1y = new DateTime(now.year-1, now.month, now.day);
if(selectedRange.toString().toUpperCase()=='LAST 7 DAYS'){
FilteredList=sugarHistoryList.where((product) {
final date = product.dateForFilter;
return now_1w.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE MONTH'){
FilteredList=sugarHistoryList.where((product) {
final date = product.dateForFilter;
return now_1m.isBefore(date);
}).toList();
}
else if(selectedRange.toString().toUpperCase()=='LAST ONE YEAR'){
FilteredList=sugarHistoryList.where((product) {
final date = product.dateForFilter;
return now_1y.isBefore(date);
}).toList();
}
else{
FilteredList=sugarHistoryList;
}
isLoading=false;
});
}
@override
void initState() {
getSugarHistoryDetails(dateItemsVariable);
super.initState();
}
Widget renderzUi(){
if(sugarHistoryList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: DropdownButtonFormField(
// Initial Value
value: dateItemsVariable,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.calendar_month,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: dateItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
dateItemsVariable = newValue!;
});
getSugarHistoryDetails(dateItemsVariable);
},
),),
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0),
itemCount: FilteredList.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Colors.white,
child: Padding(
padding:EdgeInsets.all(8) ,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width * .55,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].fasting.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].postPrandial.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].sugarValue.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/height.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].sugartText.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image(
image: const AssetImage('images/date.png'),
height: 25,
width: 25,
fit: BoxFit.fill),
Padding(padding: EdgeInsets.all(5),
child: Text(FilteredList[index].displayDate.toString().toUpperCase(),style: valuesTextStyle()),)
],
),
],
),
),
],
),
),
);
}) ),
]);
}
else{
return Center(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('No data'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: primaryColor,
radius: 40,
child: IconButton(
iconSize: 40,
icon: const Icon(
Icons.info,
color: Colors.white,
),
onPressed: () async {
},
),
)
],
),
)
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Diabetes'),
body: isLoading?Center(
child: CircularProgressIndicator(
color: primaryColor,
strokeWidth: 5.0,
),
):renderzUi(),
);
}
}

@ -1,23 +0,0 @@
import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart';
class BMIHistory extends StatefulWidget {
const BMIHistory({Key? key}) : super(key: key);
@override
State<BMIHistory> createState() => _BMIHistoryState();
}
class _BMIHistoryState extends State<BMIHistory> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('Body Mass Index'),
body: Container(
),
);
}
}

@ -1,15 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:healthcare_user/common/updateprofile.dart';
import 'package:healthcare_user/emergency.dart'; import 'package:healthcare_user/emergency.dart';
import 'package:healthcare_user/invitations.dart'; import 'package:healthcare_user/invitations.dart';
import 'package:healthcare_user/medicines.dart'; import 'package:healthcare_user/medicines.dart';
import 'package:healthcare_user/my_health.dart'; import 'package:healthcare_user/my_health.dart';
import 'package:healthcare_user/my_medicine_timings.dart';
import 'package:healthcare_user/prescriptions.dart'; import 'package:healthcare_user/prescriptions.dart';
import 'package:healthcare_user/reports.dart'; import 'package:healthcare_user/reports.dart';
import 'package:healthcare_user/seekopinion.dart'; import 'package:healthcare_user/seekopinion.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/updateprofile.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'dart:ui' as ui; import 'dart:ui' as ui;
@ -179,13 +180,13 @@ class _DashboardState extends State<Dashboard> {
devicedetection(); devicedetection();
} }
Future<void> uploadProfileApi(image) async { /*Future<void> uploadProfileApi(image) async {
var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["formData"] = image.toString(); payload["formData"] = image.toString();
var response1 = await AppSettings.updateProfilePicture(payload); var response1 = await AppSettings.updateProfilePicture(payload);
print(response1); print(response1);
} }*/
Future pickImageFromGallery() async { Future pickImageFromGallery() async {
try { try {
@ -195,7 +196,8 @@ class _DashboardState extends State<Dashboard> {
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.updatedImage = imageTemp;
}); });
uploadProfileApi(image.path); //uploadProfileApi(image.path);
AppSettings.uploadImageHTTP(image);
AppSettings.saveProfile(image.path); AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
@ -211,7 +213,8 @@ class _DashboardState extends State<Dashboard> {
AppSettings.updatedImage = imageTemp; AppSettings.updatedImage = imageTemp;
}); });
uploadProfileApi(image.path); //uploadProfileApi(image.path);
AppSettings.uploadImageHTTP(image);
AppSettings.saveProfile(image.path); AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
@ -380,10 +383,18 @@ class _DashboardState extends State<Dashboard> {
AppSettings.phoneNumber, AppSettings.phoneNumber,
style: TextStyle(color: Colors.white, fontSize: 15), style: TextStyle(color: Colors.white, fontSize: 15),
), ),
Text( Visibility(
visible:AppSettings.email!='',
child: Text(
AppSettings.email, AppSettings.email,
style: TextStyle(color: Colors.white, fontSize: 15), style: TextStyle(color: Colors.white, fontSize: 15),
), ),),
Visibility(
visible: AppSettings.age!='',
child: Text(
AppSettings.age+' Yrs',
style: TextStyle(color: Colors.white, fontSize: 15),
),),
], ],
), ),
Container() Container()
@ -506,7 +517,13 @@ class _DashboardState extends State<Dashboard> {
Text('My Medicine Timings', style: TextStyle(color: primaryColor)), Text('My Medicine Timings', style: TextStyle(color: primaryColor)),
], ],
), ),
onTap: () {}, onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MyMedicineTimings()),
);
},
), ),
Divider( Divider(
color: Colors.grey, color: Colors.grey,

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/dashboard.dart'; import 'package:healthcare_user/common/dashboard.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/signup.dart'; import 'package:healthcare_user/common/signup.dart';
import 'package:path/path.dart' as Path; import 'package:path/path.dart' as Path;
class Login extends StatefulWidget { class Login extends StatefulWidget {

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/dashboard.dart'; import 'package:healthcare_user/common/login.dart';
import 'package:healthcare_user/login.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/settings.dart';
class OtpScreen extends StatefulWidget { class OtpScreen extends StatefulWidget {
var myObject; var myObject;
OtpScreen({this.myObject}); OtpScreen({this.myObject});

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class Dialogs { class Dialogs {
static Future<void> showLoadingDialog(BuildContext context, GlobalKey key) async { static Future<void> showLoadingDialog(BuildContext context, GlobalKey key) async {

@ -3,8 +3,9 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/preloader.dart'; import 'package:healthcare_user/common/preloader.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart';
@ -19,10 +20,11 @@ const Color screenBackgroundColor = Color(0XFFEAF6FF);
const Color screenBackgroundColord = Colors.black12; const Color screenBackgroundColord = Colors.black12;
const Color dashboardbackground = Color(0XFFF5F5F5); const Color dashboardbackground = Color(0XFFF5F5F5);
Color AppBarGradient_1 = Color(0XFF1258F6); //Color AppBarGradient_1 = Color(0XFF1258F6);
Color AppBarGradient_1 = Color(0XFF1786A3);
TextStyle PreloaderText() { TextStyle PreloaderText() {
return TextStyle(color: Colors.blueAccent); return TextStyle(color: Color(0XFF1786A3));
} }
TextStyle labelTextStyle() { TextStyle labelTextStyle() {
@ -92,6 +94,9 @@ TextStyle wrapTextStyleBlack() {
TextStyle withoutWrapTextStyle() { TextStyle withoutWrapTextStyle() {
return TextStyle(color:primaryColor,fontSize: 12,fontWeight: FontWeight.bold,); return TextStyle(color:primaryColor,fontSize: 12,fontWeight: FontWeight.bold,);
} }
TextStyle bmiTextStyle() {
return TextStyle(color:primaryColor,fontSize: 16,fontWeight: FontWeight.bold,);
}
final GlobalKey<State> preloaderWindowKey = new GlobalKey<State>(); final GlobalKey<State> preloaderWindowKey = new GlobalKey<State>();
Future<void> preloaderWindow(BuildContext context) async { Future<void> preloaderWindow(BuildContext context) async {
@ -106,6 +111,7 @@ class AppSettings {
static String userName = ''; static String userName = '';
static String userAddress = ''; static String userAddress = '';
static String email = ''; static String email = '';
static String age = '';
static String phoneNumber = ''; static String phoneNumber = '';
static String accessToken = ''; static String accessToken = '';
static String customerId = ''; static String customerId = '';
@ -136,7 +142,21 @@ class AppSettings {
static String verifyPhnUrl = host + 'phone'; static String verifyPhnUrl = host + 'phone';
static String resetTokenUrl = host + 'reset_token'; static String resetTokenUrl = host + 'reset_token';
static String bmiCaluculateUrl = host + 'insertBMI'; static String bmiCaluculateUrl = host + 'insertBMI';
static String bpCaluculateUrl = host + 'insertBP';
static String sugarCaluculateUrl = host + 'insertSugar';
static String profilePicUrl = host + 'users/profile-picture'; static String profilePicUrl = host + 'users/profile-picture';
static String updateProfileUrl = host + 'update/currentUser';
static String uploadPicUrl = host + 'uploads';
static String getBmiHistoryUrl = host + 'usersbmi';
static String getBpHistoryUrl = host + 'usersbp';
static String getSugarHistoryUrl = host + 'userssugar';
static String addMedicineTimingsUrl = host + 'medicine-timing';
static String getMedicineTimingsUrl = host + 'getmedicineztiming';
static String prescriptionUploadPicUrl = host + 'uploads-precription';
static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist';
@ -343,6 +363,56 @@ class AppSettings {
} }
} }
static Future<String> calculateBP(payload) async {
var uri = Uri.parse(bpCaluculateUrl+ '/'+customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<String> calculateSugar(payload) async {
var uri = Uri.parse(sugarCaluculateUrl+ '/'+customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<bool> resetToken() async { static Future<bool> resetToken() async {
var uri = Uri.parse(resetTokenUrl + '/' + customerId); var uri = Uri.parse(resetTokenUrl + '/' + customerId);
@ -425,6 +495,205 @@ class AppSettings {
} }
} }
static Future<bool> updateProfile(payload) async {
var uri = Uri.parse(updateProfileUrl + '/' + customerId);
try {
var response = await http.put(
uri,
body: json.encode(payload),
headers: await buildRequestHeaders());
if (response.statusCode == 200) {
var _response = json.decode(response.body);
userName = _response['username'];
phoneNumber = _response['phone'];
email = _response['emails'][0]['email'];
age = _response['age'].toString();
await saveData('phone', _response['phone'], 'STRING');
await saveData('email', _response['emails'][0]['email'], 'STRING');
await saveData('username', _response['username'], 'STRING');
await saveData('age', _response['age'].toString(), 'STRING');
await loadDataFromMemory();
return true;
} else {
return false;
}
} catch (e) {
print(e);
return false;
}
}
static Future<String> getBmiHistory() async {
var uri = Uri.parse(getBmiHistoryUrl+'/'+customerId);
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<String> getBPHistory() async {
var uri = Uri.parse(getBpHistoryUrl+'/'+customerId);
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<String> getSugarHistory() async {
var uri = Uri.parse(getSugarHistoryUrl+'/'+customerId);
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
/* static Future upload() async{
final uri = Uri.parse('https://myendpoint.com');
var request = new http.MultipartRequest('POST', uri);
final httpImage = http.MultipartFile.fromBytes('files.myimage', bytes,
contentType: MediaType.parse(mimeType), filename: 'myImage.png');
request.files.add(httpImage);
final response = await request.send();
}*/
static Future<http.StreamedResponse> uploadImageHTTP(file) async {
var request = http.MultipartRequest('POST', Uri.parse(uploadPicUrl + '/' + customerId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
return res;
}
static Future<String> uploadImageHTTPForPrescriptions(file) async {
var request = http.MultipartRequest('POST', Uri.parse(prescriptionUploadPicUrl + '/' + customerId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
var response = await http.Response.fromStream(res);
return response.body;
}
static Future<String> getAllpharmacies() async {
var uri = Uri.parse(getAllpharmaciesDataUrl);
//uri = uri.replace(query: 'customerId=$customerId');
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<String> addMedicineTimings(payload) async {
var uri = Uri.parse(addMedicineTimingsUrl+ '/'+customerId);
var response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.post(uri,
body: json.encode(payload), headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
static Future<String> getMedicineTimings() async {
var uri = Uri.parse(getMedicineTimingsUrl+'/'+customerId);
var response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else if (response.statusCode == 401) {
bool status = await AppSettings.resetToken();
if (status) {
response = await http.get(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
/*Apis ends here*/ /*Apis ends here*/
@ -443,6 +712,7 @@ class AppSettings {
await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE'); await saveData('latitude', input['simplydata']['latitude'], 'DOUBLE');
await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE'); await saveData('longitude', input['simplydata']['longitude'], 'DOUBLE');
await saveData('fcmId', input['simplydata']['fcmId'], 'STRING'); await saveData('fcmId', input['simplydata']['fcmId'], 'STRING');
//await saveData('age', input['simplydata']['age'], 'STRING');
//latitude,longitude //latitude,longitude
await loadDataFromMemory(); await loadDataFromMemory();
} }
@ -467,6 +737,31 @@ class AppSettings {
userLatitude = await getData('latitude', 'DOUBLE'); userLatitude = await getData('latitude', 'DOUBLE');
userLongitude =await getData('longitude', 'DOUBLE'); userLongitude =await getData('longitude', 'DOUBLE');
fcmId =await getData('fcmId', 'STRING'); fcmId =await getData('fcmId', 'STRING');
age=await getData('age', 'STRING');
getProfile();
}
static Future<void> getProfile() async {
final image1 = await getData('profile', 'STRING');
//Io.File.fromUri(imageFile.uri)
var x = image1;
if (image1 == null) return;
if (image1 == '') {
updatedImage = null;
}
else if (image1 == 'null') {
updatedImage = null;
}
else {
final imageTemp = File(image1);
updatedImage = imageTemp;
}
print(updatedImage);
} }
static void longFailedStyledToast(String message, context) { static void longFailedStyledToast(String message, context) {
@ -494,6 +789,17 @@ class AppSettings {
textColor: Colors.white, textColor: Colors.white,
fontSize: 16.0); fontSize: 16.0);
} }
static void longSuccessToast1(String message) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 16.0
);
}
static void longFailedToast(String message) { static void longFailedToast(String message) {
Fluttertoast.showToast( Fluttertoast.showToast(

@ -1,19 +1,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:healthcare_user/common/login.dart';
import 'package:healthcare_user/google_maps_place_picker_mb/google_maps_place_picker.dart'; import 'package:healthcare_user/google_maps_place_picker_mb/google_maps_place_picker.dart';
import 'package:healthcare_user/keys.dart'; import 'package:healthcare_user/keys.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'login.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:geocoding/geocoding.dart';
import 'package:image_picker/image_picker.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'dart:io' show File, Platform; import 'dart:io' show File, Platform;
import 'package:google_maps_flutter_android/google_maps_flutter_android.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:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:location/location.dart' as locationmap; import 'package:location/location.dart' as locationmap;
import 'google_maps_place_picker_mb/src/models/pick_result.dart'; import '../google_maps_place_picker_mb/src/models/pick_result.dart';
import 'google_maps_place_picker_mb/src/place_picker.dart'; import '../google_maps_place_picker_mb/src/place_picker.dart';
import 'otpscreen.dart'; import 'otpscreen.dart';
@ -38,6 +36,12 @@ class _SignUpState extends State<SignUp> {
TextEditingController userAddressCapturingController = TextEditingController(); TextEditingController userAddressCapturingController = TextEditingController();
TextEditingController passwordController = TextEditingController(); TextEditingController passwordController = TextEditingController();
TextEditingController confirmPasswordController = TextEditingController(); TextEditingController confirmPasswordController = TextEditingController();
var genderUnitItems = [
'Male',
'Female',
'Other',
];
var genderUnit = 'Male';
String _currentAddress =''; String _currentAddress ='';
@ -197,6 +201,59 @@ class _SignUpState extends State<SignUp> {
), ),
), ),
), //name ), //name
const SizedBox(
height: 5,
),
Container(
padding: const EdgeInsets.all(10),
child: DropdownButtonFormField(
// Initial Value
value: genderUnit,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.female,
color: primaryColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
labelText: 'Units',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Units'),
// Down Arrow Icon
//icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: genderUnitItems.map((String items) {
return DropdownMenuItem(
value: items,
child: Text(
items,
style: TextStyle(
fontSize: 16,
),
textAlign: TextAlign.center,
));
}).toList(),
// After selecting the desired option,it will
// change button value to selected value
onChanged: (String? newValue) {
setState(() {
genderUnit = newValue!;
});
},
),),
const SizedBox( const SizedBox(
height: 5, height: 5,
@ -500,15 +557,17 @@ class _SignUpState extends State<SignUp> {
]; ];
payload["lastName"] = ''; payload["lastName"] = '';
payload["address1"] = userAddressCapturingController.text; payload["address1"] = userAddressCapturingController.text;
payload["address2"] = address2; payload["address2"] = '';
payload["city"] = city; payload["city"] = '';
payload["state"] = state; payload["state"] = '';
payload["zip"] = zip; payload["zip"] = '';
payload["country"] = country; payload["country"] = '';
payload["notes"] = ''; payload["notes"] = '';
payload["latitude"] = lat; payload["latitude"] = lat;
payload["longitude"] = lng; payload["longitude"] = lng;
payload["fcmId"] = AppSettings.fcmId; payload["fcmId"] = AppSettings.fcmId;
payload["age"] = 0;
payload["gender"] = genderUnit.toString();
bool signUpStatus = await AppSettings.signUp(payload); bool signUpStatus = await AppSettings.signUp(payload);

@ -1,11 +1,8 @@
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/settings.dart'; import 'package:healthcare_user/common/dashboard.dart';
import 'package:healthcare_user/signup.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/common/signup.dart';
import 'dashboard.dart';
void main() async{ void main() async{
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

@ -2,7 +2,8 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/dashboard.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'dart:io'; import 'dart:io';
@ -20,6 +21,8 @@ class _UpdateprofileState extends State<UpdateProfile> {
TextEditingController nameController = TextEditingController(); TextEditingController nameController = TextEditingController();
TextEditingController mobileNumberController = TextEditingController(); TextEditingController mobileNumberController = TextEditingController();
TextEditingController emailController = TextEditingController(); TextEditingController emailController = TextEditingController();
TextEditingController ageController = TextEditingController();
@ -30,6 +33,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
nameController.text=AppSettings.userName; nameController.text=AppSettings.userName;
mobileNumberController.text=AppSettings.phoneNumber; mobileNumberController.text=AppSettings.phoneNumber;
emailController.text=AppSettings.email; emailController.text=AppSettings.email;
ageController.text=AppSettings.age;
super.initState(); super.initState();
@ -46,10 +50,9 @@ class _UpdateprofileState extends State<UpdateProfile> {
setState(() { setState(() {
AppSettings.updatedImage = imageTemp; AppSettings.updatedImage = imageTemp;
}); });
//uploadProfileApi(AppSettings.updatedImage); //uploadProfileApi(image.path);
AppSettings.uploadImageHTTP(image);
AppSettings.saveProfile(image.path); AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
@ -64,14 +67,30 @@ class _UpdateprofileState extends State<UpdateProfile> {
AppSettings.updatedImage = imageTemp; AppSettings.updatedImage = imageTemp;
}); });
// uploadProfileApi(AppSettings.updatedImage); //uploadProfileApi(image.path);
AppSettings.uploadImageHTTP(image);
AppSettings.saveProfile(image.path); AppSettings.saveProfile(image.path);
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
} }
Future<void> uploadProfileApi(image) async {
var formData = new Map<String, dynamic>();
/* formData = FormData.fromMap({
"username" : "John",
"password" : "123456",
"device-type" : "Android"
});*/
var payload = new Map<String, dynamic>();
payload["formData"] = image.toString();
var response1 = await AppSettings.updateProfilePicture(payload);
print(response1);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -246,10 +265,32 @@ class _UpdateprofileState extends State<UpdateProfile> {
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Container( Container(
width: 400, padding: const EdgeInsets.all(10),
height: 55, child: TextFormField(
cursorColor: greyColor,
controller: ageController,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.person,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Enter age',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
@ -258,9 +299,18 @@ class _UpdateprofileState extends State<UpdateProfile> {
), ),
onPressed: () async{ onPressed: () async{
/* var payload = new Map<String, dynamic>(); int age=0;
if(ageController.text.toString()!=''){
age=int.parse(ageController.text.toString());
}
else{
age=0;
}
var payload = new Map<String, dynamic>();
payload["username"] = nameController.text.toString(); payload["username"] = nameController.text.toString();
payload["phone"] = mobileNumberController.text.toString(); payload["phone"] = mobileNumberController.text.toString();
payload["age"] = age;
payload["emails"] = [{"email":emailController.text.toString()}]; payload["emails"] = [{"email":emailController.text.toString()}];
bool signUpStatus = await AppSettings.updateProfile(payload); bool signUpStatus = await AppSettings.updateProfile(payload);
try{ try{
@ -279,7 +329,7 @@ class _UpdateprofileState extends State<UpdateProfile> {
catch(exception){ catch(exception){
print(exception); print(exception);
AppSettings.longFailedToast("Please enter valid details"); AppSettings.longFailedToast("Please enter valid details");
}*/ }
}, },
child: Text('Update'), child: Text('Update'),

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class Emergency extends StatefulWidget { class Emergency extends StatefulWidget {
const Emergency({Key? key}) : super(key: key); const Emergency({Key? key}) : super(key: key);

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class Invitations extends StatefulWidget { class Invitations extends StatefulWidget {
const Invitations({Key? key}) : super(key: key); const Invitations({Key? key}) : super(key: key);

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/dashboard.dart'; import 'package:healthcare_user/common/splash_screen.dart';
import 'package:healthcare_user/splash_screen.dart';
import 'package:sizer/sizer.dart'; import 'package:sizer/sizer.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class Medicines extends StatefulWidget { class Medicines extends StatefulWidget {
const Medicines({Key? key}) : super(key: key); const Medicines({Key? key}) : super(key: key);

@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class BmiHistoryModel {
String bmiValue = '';
String height= '';
String weight= '';
String date= '';
String displayDate='';
DateTime dateForFilter=new DateTime.now();
BmiHistoryModel();
factory BmiHistoryModel.fromJson(Map<String, dynamic> json){
BmiHistoryModel rtvm = new BmiHistoryModel();
/*"heightUnit": "feet",
"weightUnit": "kg",
"_id": "6493fe48eca67b71b8444e24",
"bmiinfoid": "BMI1687420488845468",
"customerId": "AHSUSNE2",
"height": "164.592",
"weight": "50",
"age": 27,
"bmivalue": 18.46,
"createdAt": "2023-06-22T07:54:48.847Z",
"updatedAt": "2023-06-22T07:54:48.847Z",*/
rtvm.bmiValue = json['bmivalue'].toString() ?? '';
rtvm.height = json['height'].toString() ?? '';
rtvm.weight = json['weight'].toString() ?? '';
rtvm.date = json['createdAt'].toString() ?? '';
//DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date);
DateTime parseDate = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(rtvm.date);
var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
rtvm.dateForFilter=parseDate;
var outputDate = outputFormat.format(parseDate);
rtvm.displayDate=outputDate;
return rtvm;
}
}

@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class BPHistoryModel {
String bpText = '';
String systolic= '';
String diastolic= '';
String date= '';
String displayDate='';
DateTime dateForFilter=new DateTime.now();
BPHistoryModel();
factory BPHistoryModel.fromJson(Map<String, dynamic> json){
BPHistoryModel rtvm = new BPHistoryModel();
/*"heightUnit": "feet",
"weightUnit": "kg",
"_id": "6493fe48eca67b71b8444e24",
"bmiinfoid": "BMI1687420488845468",
"customerId": "AHSUSNE2",
"height": "164.592",
"weight": "50",
"age": 27,
"bmivalue": 18.46,
"createdAt": "2023-06-22T07:54:48.847Z",
"updatedAt": "2023-06-22T07:54:48.847Z",*/
rtvm.bpText = json['bpCategory'].toString() ?? '';
rtvm.systolic = json['Systolic'].toString() ?? '';
rtvm.diastolic = json['Diastolic'].toString() ?? '';
rtvm.date = json['createdAt'].toString() ?? '';
//DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date);
DateTime parseDate = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(rtvm.date);
var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
rtvm.dateForFilter=parseDate;
var outputDate = outputFormat.format(parseDate);
rtvm.displayDate=outputDate;
return rtvm;
}
}

@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart';
class PharmaciesModel {
String pharmacy_name = '';
String status='';
String picture='';
Color text_color=Colors.black;
double lat=0;
double lng=0;
PharmaciesModel();
factory PharmaciesModel.fromJson(Map<String, dynamic> json){
PharmaciesModel rtvm = new PharmaciesModel();
rtvm.pharmacy_name = json['pharmacyname'] ?? '';
rtvm.picture = json['pharmacyname'] ?? '';
rtvm.status = json['status'] ?? '';
rtvm.lat = json['latitude'] ?? 0;
rtvm.lng = json['longitude'] ??0;
return rtvm;
}
}

@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class SugarHistoryModel {
String sugartText = '';
String sugarValue = '';
String fasting= '';
String postPrandial= '';
String date= '';
String displayDate='';
DateTime dateForFilter=new DateTime.now();
SugarHistoryModel();
factory SugarHistoryModel.fromJson(Map<String, dynamic> json){
SugarHistoryModel rtvm = new SugarHistoryModel();
/*"heightUnit": "feet",
"weightUnit": "kg",
"_id": "6493fe48eca67b71b8444e24",
"bmiinfoid": "BMI1687420488845468",
"customerId": "AHSUSNE2",
"height": "164.592",
"weight": "50",
"age": 27,
"bmivalue": 18.46,
"createdAt": "2023-06-22T07:54:48.847Z",
"updatedAt": "2023-06-22T07:54:48.847Z",*/
rtvm.sugartText = json['sugarCategory'].toString() ?? '';
rtvm.sugarValue = json['sugarValue'].toString() ?? '';
rtvm.fasting = json['fasting'].toString() ?? '';
rtvm.postPrandial = json['postPrandial'].toString() ?? '';
rtvm.date = json['createdAt'].toString() ?? '';
//DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date);
DateTime parseDate = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(rtvm.date);
var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
rtvm.dateForFilter=parseDate;
var outputDate = outputFormat.format(parseDate);
rtvm.displayDate=outputDate;
return rtvm;
}
}

@ -1,9 +1,14 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/BMI/bmi_history.dart';
import 'package:healthcare_user/BP/bp_calculator.dart';
import 'package:healthcare_user/BP/bp_history.dart';
import 'package:healthcare_user/Sugar/sugar_calculator.dart';
import 'package:healthcare_user/Sugar/sugar_history.dart';
import 'package:healthcare_user/common/settings.dart';
import 'bmi_history.dart'; import 'BMI/bmi_caluculator.dart';
class MyHealth extends StatefulWidget { class MyHealth extends StatefulWidget {
const MyHealth({Key? key}) : super(key: key); const MyHealth({Key? key}) : super(key: key);
@ -317,12 +322,12 @@ class _MyHealthState extends State<MyHealth> {
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
/* Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => BMICalculator()), builder: (context) => BMICalculator()),
);*/ );
showBMIAdddialog(); // showBMIAdddialog();
}, },
icon: Icon( icon: Icon(
Icons.add, Icons.add,
@ -340,7 +345,27 @@ class _MyHealthState extends State<MyHealth> {
children: [ children: [
Text('Blood Pressure'), Text('Blood Pressure'),
IconButton( IconButton(
onPressed: () {}, onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BPHistory()),
);
},
icon: Icon(
Icons.history,
color: greyColor,
),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BPCalculator()),
);
// showBMIAdddialog();
},
icon: Icon( icon: Icon(
Icons.add, Icons.add,
color: greyColor, color: greyColor,
@ -357,7 +382,27 @@ class _MyHealthState extends State<MyHealth> {
children: [ children: [
Text('Diabetes'), Text('Diabetes'),
IconButton( IconButton(
onPressed: () {}, onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SugarHistory()),
);
},
icon: Icon(
Icons.history,
color: greyColor,
),
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SugarCalculator()),
);
// showBMIAdddialog();
},
icon: Icon( icon: Icon(
Icons.add, Icons.add,
color: greyColor, color: greyColor,

@ -0,0 +1,876 @@
import 'dart:convert';
import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:day_night_time_picker/day_night_time_picker.dart';
class MyMedicineTimings extends StatefulWidget {
const MyMedicineTimings({Key? key}) : super(key: key);
@override
State<MyMedicineTimings> createState() => _MyMedicineTimingsState();
}
class _MyMedicineTimingsState extends State<MyMedicineTimings> {
bool isLoading=false;
TimeOfDay selectedTime = TimeOfDay.now();
Time _time = Time(hour: 0, minute: 0, second: 0);
Time _wakeupTime = Time(hour: 0, minute: 0, second: 0);
Time _beforeBreakfastTime = Time(hour: 0, minute: 0, second: 0);
Time _afterBreakfastTime = Time(hour: 0, minute: 0, second: 0);
Time _beforeLunchTime = Time(hour: 0, minute: 0, second: 0);
Time _afterLunchTime = Time(hour: 0, minute: 0, second: 0);
Time _eveningTeaTime = Time(hour: 0, minute: 0, second: 0);
Time _beforeDinnerTime = Time(hour: 0, minute: 0, second: 0);
Time _afterDinnerTime = Time(hour: 0, minute: 0, second: 0);
Time _sleepTime = Time(hour: 0, minute: 0, second: 0);
String wakeUpfForApi='';
String _beforeBreakfastTimeForApi='';
String _afterBreakfastTimeForApi='';
String _beforeLunchTimeForApi='';
String _afterLunchTimeForApi='';
String _eveningTeaTimeForApi='';
String _beforeDinnerTimeForApi='';
String _afterDinnerTimeForApi='';
String _sleepTimeForApi='';
DateTime wakeUp = DateTime.now();
bool iosStyle = true;
List timings = [
{'name': 'Wakeup'},
{'name': 'Before breakfast'},
{'name': 'After- breakfast'},
{'name': 'Before lunch'},
{'name': 'After lunch'},
{'name': 'Evening tea'},
{'name': 'Before dinner'},
{'name': 'After dinner'},
{'name': 'Sleep'}
];
Map<String,dynamic> medicineTimings={};
Future<void> getMedicineTimingsList() async {
isLoading=true;
var response1= await AppSettings.getMedicineTimings();
setState(() {
if(response1!='null'){
medicineTimings=jsonDecode(response1);
wakeUpfForApi=medicineTimings['wakeUp'];
_beforeBreakfastTimeForApi=medicineTimings['beforeBreakfast'];
_afterBreakfastTimeForApi=medicineTimings['afterBreakfast'];
_beforeLunchTimeForApi=medicineTimings['beforeLunch'];
_afterLunchTimeForApi=medicineTimings['afterLunch'];
_eveningTeaTimeForApi=medicineTimings['eveningTea'];
_beforeDinnerTimeForApi=medicineTimings['beforeDinner'];
_afterDinnerTimeForApi=medicineTimings['afterDinner'];
_sleepTimeForApi=medicineTimings['sleep'];
}
isLoading=false;
});
}
@override
void initState() {
getMedicineTimingsList();
super.initState();
}
void onTimeChanged(Time newTime, int index) {
setState(() {
_time=newTime;
});
if (index == 0) {
setState(() {
_wakeupTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _wakeupTime.hour, _wakeupTime.minute);
final format = DateFormat.jm();
setState(() {
wakeUpfForApi=format.format(dt);
});
}
else if (index == 1) {
setState(() {
_beforeBreakfastTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _beforeBreakfastTime.hour, _beforeBreakfastTime.minute);
final format = DateFormat.jm();
setState(() {
_beforeBreakfastTimeForApi=format.format(dt);
});
}
else if (index == 2) {
setState(() {
_afterBreakfastTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _afterBreakfastTime.hour, _afterBreakfastTime.minute);
final format = DateFormat.jm();
setState(() {
_afterBreakfastTimeForApi=format.format(dt);
});
}
else if (index == 3) {
setState(() {
_beforeLunchTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _beforeLunchTime.hour, _beforeLunchTime.minute);
final format = DateFormat.jm();
setState(() {
_beforeLunchTimeForApi=format.format(dt);
});
}
else if (index == 4) {
setState(() {
_afterLunchTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _afterLunchTime.hour, _afterLunchTime.minute);
final format = DateFormat.jm();
setState(() {
_afterLunchTimeForApi=format.format(dt);
});
}
else if (index == 5) {
setState(() {
_eveningTeaTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _eveningTeaTime.hour, _eveningTeaTime.minute);
final format = DateFormat.jm();
setState(() {
_eveningTeaTimeForApi=format.format(dt);
});
}
else if (index == 6) {
setState(() {
_beforeDinnerTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _beforeDinnerTime.hour, _beforeDinnerTime.minute);
final format = DateFormat.jm();
setState(() {
_beforeDinnerTimeForApi=format.format(dt);
});
}
else if (index == 7) {
setState(() {
_afterDinnerTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _afterDinnerTime.hour, _afterDinnerTime.minute);
final format = DateFormat.jm();
setState(() {
_afterDinnerTimeForApi=format.format(dt);
});
}
else if (index == 8) {
setState(() {
_sleepTime = newTime;
});
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, _sleepTime.hour, _sleepTime.minute);
final format = DateFormat.jm();
setState(() {
_sleepTimeForApi=format.format(dt);
});
}
}
void valueOfTiming(int index) {
if (index == 0) {
_time = _wakeupTime;
} else if (index == 1) {
_time = _beforeBreakfastTime;
}
}
String formatTimeOfDay(TimeOfDay tod) {
final now = new DateTime.now();
final dt = DateTime(now.year, now.month, now.day, tod.hour, tod.minute);
final format = DateFormat.jm(); //"6:00 AM"
return format.format(dt);
}
void _selectedDateWithTime(DateTime newTime,int ind){
if (ind == 0) {
setState(() {
wakeUp = newTime;
String formattedDate = DateFormat('yyyy-MM-dd kk:mm').format(wakeUp);
// DateTime parseDate = new DateFormat("dd-MM-yyyy HH:mm:ss").parse(wakeUp);
print(formattedDate);
});
}
/*else if (ind == 1) {
setState(() {
_beforeBreakfastTime = newTime;
});
}
else if (ind == 2) {
setState(() {
_afterBreakfastTime = newTime;
});
}
else if (ind == 3) {
setState(() {
_beforeLunchTime = newTime;
});
}
else if (ind == 4) {
setState(() {
_afterLunchTime = newTime;
});
}
else if (ind == 5) {
setState(() {
_eveningTeaTime = newTime;
});
}
else if (ind == 6) {
setState(() {
_beforeDinnerTime = newTime;
});
}
else if (ind == 7) {
setState(() {
_afterDinnerTime = newTime;
});
}
else if (ind == 8) {
setState(() {
_sleepTime = newTime;
});
}*/
}
Widget textForSelectedTime(int index) {
if (index == 0) {
return
Text(
wakeUpfForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 1) {
return Text(
_beforeBreakfastTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 2) {
return Text(
_afterBreakfastTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 3) {
return Text(
_beforeLunchTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 4) {
return Text(
_afterLunchTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 5) {
return Text(
_eveningTeaTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 6) {
return Text(
_beforeDinnerTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 7) {
return Text(
_afterDinnerTimeForApi,
style: TextStyle(color: Colors.black),
);
} else if (index == 8) {
return Text(
_sleepTimeForApi,
style: TextStyle(color: Colors.black),
);
} else {
return Container();
}
}
Widget renderTimings(){
return Column(
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) => const Divider(
height: 4.0,
color: primaryColor,
),
//padding: EdgeInsets.all(8),
itemCount: timings.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .40,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
GestureDetector(
onTap: () {
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
textForSelectedTime(index)
],
),
],
)),
);
})),
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40),
child: Row(
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async {
editTimingsDialog();
},
child: const Text('Edit'),
),
],
)
)
],
);
}
editTimingsDialog(){
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return AlertDialog(
title: const Text('Edit Timings'),
content: SingleChildScrollView(
child: Container(
width: double.maxFinite,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.4,
),
child: ListView.separated(
separatorBuilder: (context, index) => const Divider(
height: 4.0,
color: primaryColor,
),
//padding: EdgeInsets.all(8),
itemCount: timings.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .25,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
//onChange: onTimeChanged,
onChange: (val) {
onTimeChanged(val, index);
},
is24HrFormat: false,
sunrise: TimeOfDay(
hour: 6, minute: 0), // optional
sunset: TimeOfDay(hour: 18, minute: 0),
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
_selectedDateWithTime(dateTime,index);
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
textForSelectedTime(index)
],
),
],
)),
);
})
),
]),
)),
actions: <Widget>[
TextButton(
child: Text('Cancel', style: textButtonStyle()),
onPressed: () {
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Save', style: textButtonStyle()),
onPressed: () async {
},
),
],
);
});
},
);
}
Widget renderUi() {
return Column(
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) => const Divider(
height: 4.0,
color: primaryColor,
),
//padding: EdgeInsets.all(8),
itemCount: timings.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.fromLTRB(8, 8, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width:
MediaQuery.of(context).size.width * .40,
child: Text(
timings[index]['name'],
style: wrapTextStyle(),
),
),
GestureDetector(
onTap: () {
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
//onChange: onTimeChanged,
onChange: (val) {
onTimeChanged(val, index);
},
is24HrFormat: false,
sunrise: TimeOfDay(
hour: 6, minute: 0), // optional
sunset: TimeOfDay(hour: 18, minute: 0),
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
_selectedDateWithTime(dateTime,index);
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
textForSelectedTime(index)
],
),
],
)),
);
})),
Padding(padding: EdgeInsets.fromLTRB(10, 10, 10, 40),
child: Row(
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async {
AppSettings.preLoaderDialog(context);
bool isOnline = await AppSettings.internetConnectivity();
if(isOnline){
if(_time!=TimeOfDay(hour: 0,minute: 0)){
var payload = new Map<String, dynamic>();
payload["wakeUp"] = wakeUpfForApi;//_wakeupTime.hour.toString()+':'+_wakeupTime.minute.toString();
payload["beforeBreakfast"] = _beforeBreakfastTime.hour.toString()+':'+_beforeBreakfastTime.minute.toString();
payload["afterBreakfast"] = _afterBreakfastTime.hour.toString()+':'+_afterBreakfastTime.minute.toString();
payload["beforeLunch"] = _beforeLunchTime.hour.toString()+':'+_beforeLunchTime.minute.toString();
payload["afterLunch"] = _afterLunchTime.hour.toString()+':'+_afterLunchTime.minute.toString();
payload["eveningTea"] = _eveningTeaTime.hour.toString()+':'+_eveningTeaTime.minute.toString();
payload["beforeDinner"] = _beforeDinnerTime.hour.toString()+':'+_beforeDinnerTime.minute.toString();
payload["afterDinner"] = _afterDinnerTime.hour.toString()+':'+_afterDinnerTime.minute.toString();
payload["sleep"] = _sleepTime.hour.toString()+':'+_sleepTime.minute.toString();
var value = await AppSettings.addMedicineTimings(payload);
var valueResponse = jsonDecode(value);
Navigator.of(context,rootNavigator: true).pop();
getMedicineTimingsList();
}
else{
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Please select timing' );
}
}
},
child: const Text('Save'),
),
SizedBox(width: 20,),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
),
onPressed: () async {},
child: const Text('Cancel'),
),
],
)
)
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppSettings.appBar('My medicine timings'),
body: medicineTimings.length==0?renderUi():renderTimings(),
/*Container(
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 10,),
Text('Wakeup'),
SizedBox(height: 10,),
Text('Before breakfast'),
SizedBox(height: 15,),
Text('After breakfast'),
SizedBox(height: 15,),
Text('Before lunch'),
SizedBox(height: 15,),
Text('After lunch'),
SizedBox(height: 15,),
Text('Evening Tea'),
SizedBox(height: 15,),
Text('Before dinner'),
SizedBox(height: 15,),
Text('After dinner'),
SizedBox(height: 15,),
Text('Sleep'),
],
),
Column(
children: [
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
SizedBox(height: 5,),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
SizedBox(height: 5,),
GestureDetector(
onTap: (){
Navigator.of(context).push(
showPicker(
showSecondSelector: true,
context: context,
value: _time,
onChange: onTimeChanged,
minuteInterval: TimePickerInterval.FIVE,
// Optional onChange to receive value as DateTime
onChangeDateTime: (DateTime dateTime) {
// print(dateTime);
debugPrint("[debug datetime]: $dateTime");
},
),
);
},
child: Image(
image: AssetImage('images/time.png'),
width: 30,
height: 30,
),
),
],
),
],
),
],
),
)
)*/
);
}
}

@ -1,5 +1,12 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.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 { class Prescriptions extends StatefulWidget {
const Prescriptions({Key? key}) : super(key: key); const Prescriptions({Key? key}) : super(key: key);
@ -9,11 +16,207 @@ class Prescriptions extends StatefulWidget {
} }
class _PrescriptionsState extends State<Prescriptions> { 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppSettings.appBar('Prescriptions'), appBar: AppSettings.appBar('Prescriptions'),
body: Container(), 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)),
),
],
)
),
); );
} }
} }

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class Reports extends StatefulWidget { class Reports extends StatefulWidget {
const Reports({Key? key}) : super(key: key); const Reports({Key? key}) : super(key: key);

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:healthcare_user/settings.dart'; import 'package:healthcare_user/common/settings.dart';
class SeekOpinion extends StatefulWidget { class SeekOpinion extends StatefulWidget {
const SeekOpinion({Key? key}) : super(key: key); const SeekOpinion({Key? key}) : super(key: key);

@ -155,6 +155,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
day_night_time_picker:
dependency: "direct dev"
description:
name: day_night_time_picker
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
dbus: dbus:
dependency: transitive dependency: transitive
description: description:

@ -60,8 +60,8 @@ dev_dependencies:
permission_handler: ^10.2.0 permission_handler: ^10.2.0
cloudinary_public: ^0.21.0 cloudinary_public: ^0.21.0
carousel_slider: ^4.2.1 carousel_slider: ^4.2.1
fluttertoast: ^8.1.2 fluttertoast: ^8.2.2
day_night_time_picker: ^1.3.0
flutter_icons: flutter_icons:
image_path_ios: 'images/logo.png' image_path_ios: 'images/logo.png'

@ -7,9 +7,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:healthcare_user/common/splash_screen.dart';
import 'package:healthcare_user/main.dart';
import 'package:healthcare_user/splash_screen.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {

Loading…
Cancel
Save