Health calculator fixes

merge-update-with-lab-changes
haroon amjad 4 years ago
parent ea745f1b9f
commit d2834bb3dd

@ -99,23 +99,9 @@ class _BMICalculatorState extends State<BMICalculator> {
return AppScaffold(
isShowAppBar: true,
isShowDecPage: false,
showHomeAppBarIcon: false,
showHomeAppBarIcon: true,
showNewAppBar: true,
showNewAppBarTitle: true,
appBarIcons: [
IconButton(
icon: Icon(Icons.info_outline),
color: Colors.black,
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HealthDescPage("${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", TranslationBase.of(context).bmiCalcDesc,
"assets/images/AlHabibMedicalService/health_calculator/bmi.png")),
);
},
)
],
appBarTitle: "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}",
body: Column(
children: [

@ -1,49 +1,58 @@
import 'dart:collection';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bariatrics-screen.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:percent_indicator/percent_indicator.dart';
class ResultPage extends StatelessWidget {
class ResultPage extends StatefulWidget {
final double finalResult;
final String textResult;
final String msg;
ResultPage({this.finalResult, this.textResult, this.msg});
@override
_ResultPageState createState() => _ResultPageState();
}
class _ResultPageState extends State<ResultPage> {
Color inductorColor;
double percent;
Color colorInductor() {
if (finalResult >= 30) {
if (widget.finalResult >= 30) {
inductorColor = Color(0xffC70D00);
} else if (finalResult < 30 && finalResult >= 25) {
} else if (widget.finalResult < 30 && widget.finalResult >= 25) {
inductorColor = Color(0xffC25400);
} else if (finalResult < 25 && finalResult >= 18.5) {
} else if (widget.finalResult < 25 && widget.finalResult >= 18.5) {
inductorColor = Color(0xff36D600);
} else if (finalResult < 18.5) {
} else if (widget.finalResult < 18.5) {
inductorColor = Color(0xff1BE0EE);
}
return inductorColor;
}
double percentInductor() {
if (finalResult >= 30) {
if (widget.finalResult >= 30) {
percent = 1.0;
} else if (finalResult < 30 && finalResult >= 25) {
} else if (widget.finalResult < 30 && widget.finalResult >= 25) {
percent = 0.73;
} else if (finalResult < 25 && finalResult >= 18.5) {
} else if (widget.finalResult < 25 && widget.finalResult >= 18.5) {
percent = 0.5;
} else if (finalResult < 18.5) {
} else if (widget.finalResult < 18.5) {
percent = 0.25;
}
return percent;
@ -69,7 +78,7 @@ class ResultPage extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
TranslationBase.of(context).bodyMassIndex + finalResult.toString(),
TranslationBase.of(context).bodyMassIndex + widget.finalResult.toString(),
style: TextStyle(
fontSize: 16,
letterSpacing: -0.64,
@ -81,21 +90,21 @@ class ResultPage extends StatelessWidget {
height: MediaQuery.of(context).size.width / 2.8,
child: Row(
children: [
showMass(context, TranslationBase.of(context).underWeight, "< 18.5", finalResult <= 18.5 ? Colors.red : Colors.black, 8),
showMass(context, TranslationBase.of(context).underWeight, "< 18.5", widget.finalResult <= 18.5 ? Colors.red : Colors.black, 8),
mWidth(12),
showMass(context, TranslationBase.of(context).healthy, "18.5 - 24.9", (finalResult > 18.5 && finalResult < 25) ? Colors.red : Colors.black, 6),
showMass(context, TranslationBase.of(context).healthy, "18.5 - 24.9", (widget.finalResult > 18.5 && widget.finalResult < 25) ? Colors.red : Colors.black, 6),
mWidth(12),
showMass(context, TranslationBase.of(context).overWeight, "25 - 29.9", (finalResult >= 25 && finalResult < 30) ? Colors.red : Colors.black, 4),
showMass(context, TranslationBase.of(context).overWeight, "25 - 29.9", (widget.finalResult >= 25 && widget.finalResult < 30) ? Colors.red : Colors.black, 4),
mWidth(12),
showMass(context, TranslationBase.of(context).obese, "30 - 34.9", (finalResult >= 30 && finalResult < 35) ? Colors.red : Colors.black, 2),
showMass(context, TranslationBase.of(context).obese, "30 - 34.9", (widget.finalResult >= 30 && widget.finalResult < 35) ? Colors.red : Colors.black, 2),
mWidth(12),
showMass(context, TranslationBase.of(context).extremeObese, "> 35", (finalResult >= 35) ? Colors.red : Colors.black, 0),
showMass(context, TranslationBase.of(context).extremeObese, "> 35", (widget.finalResult >= 35) ? Colors.red : Colors.black, 0),
],
),
),
mHeight(20),
Text(
textResult,
widget.textResult,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
@ -104,7 +113,7 @@ class ResultPage extends StatelessWidget {
),
mHeight(4),
Text(
msg,
widget.msg,
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor),
),
],
@ -115,14 +124,10 @@ class ResultPage extends StatelessWidget {
Container(
color: Colors.white,
padding: EdgeInsets.all(16),
child: SecondaryButton(
label: TranslationBase.of(context).seeListOfDoctor,
color: CustomColors.accentColor,
onTap: () {
Navigator.push(
context,
FadePage(page: BariatricsPage(1, 1, finalResult)),
);
child: DefaultButton(
TranslationBase.of(context).seeListOfDoctor,
() {
callDoctorsSearchAPI();
},
),
),
@ -131,6 +136,65 @@ class ResultPage extends StatelessWidget {
);
}
callDoctorsSearchAPI() {
GifLoaderDialogUtils.showMyDialog(context);
List<DoctorList> doctorsList = [];
List<String> arr = [];
List<String> arrDistance = [];
List<String> result;
int numAll;
List<PatientDoctorAppointmentList> _patientDoctorAppointmentListHospital = List();
DoctorsListService service = new DoctorsListService();
service.getDoctorsList(108, 0, false, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
setState(() {
if (res['DoctorList'].length != 0) {
doctorsList.clear();
res['DoctorList'].forEach((v) {
doctorsList.add(new DoctorList.fromJson(v));
});
doctorsList.forEach((element) {
List<PatientDoctorAppointmentList> doctorByHospital = _patientDoctorAppointmentListHospital
.where(
(elementClinic) => elementClinic.filterName == element.projectName,
)
.toList();
if (doctorByHospital.length != 0) {
_patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element);
} else {
_patientDoctorAppointmentListHospital
.add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: element.projectDistanceInKiloMeters.toString(), patientDoctorAppointment: element));
}
});
} else {}
});
result = LinkedHashSet<String>.from(arr).toList();
numAll = result.length;
navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital);
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err);
});
}
Future navigateToSearchResults(context, List<DoctorList> docList, List<PatientDoctorAppointmentList> patientDoctorAppointmentListHospital) async {
Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital)))
.then((value) {
setState(() {
// dropdownValue = null;
});
// getProjectsList();
});
}
Widget showMass(BuildContext context, String title, String weight, Color color, int f) {
return Expanded(
flex: 1,

@ -2,8 +2,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -148,16 +147,7 @@ class _BmrCalculatorState extends State<BmrCalculator> {
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).bmr,
showHomeAppBarIcon: false,
appBarIcons: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0),
child: Icon(
Icons.info_outline,
color: Colors.white,
),
)
],
showHomeAppBarIcon: true,
body: Container(
height: double.infinity,
width: double.infinity,
@ -406,22 +396,20 @@ class _BmrCalculatorState extends State<BmrCalculator> {
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: CustomColors.accentColor,
onTap: () {
child: DefaultButton(
TranslationBase.of(context).calculate,
() {
setState(() {
calculateBmr();
calculateCalories();
{
Navigator.push(
context,
FadePage(
page: BmrResultPage(
bmrResult: bmrResult,
calories: calories,
)),
bmrResult: bmrResult,
calories: calories,
)),
);
}
});
@ -661,5 +649,3 @@ class CommonDropDownView extends StatelessWidget {
);
}
}

@ -5,9 +5,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -26,6 +24,7 @@ class BmrResultPage extends StatelessWidget {
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
showHomeAppBarIcon: true,
appBarTitle: TranslationBase.of(context).bmr,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -80,31 +79,23 @@ class BmrResultPage extends StatelessWidget {
),
mHeight(20),
Text(
'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.',
style: TextStyle(
fontSize: 14,
letterSpacing: -0.56,
fontWeight: FontWeight.w600,
color: CustomColors.textColor
),
'This means the body will burn (${bmrResult.toStringAsFixed(1)}) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is (${calories.toStringAsFixed(1)}) calories, to maintain the current weight.',
style: TextStyle(fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600, color: CustomColors.textColor),
),
],
).withBorderedContainer,
),
mFlex(1),
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).viewDocList,
color: CustomColors.accentColor,
onTap: () {
child: DefaultButton(
TranslationBase.of(context).viewDocList,
() {
getDoctorsList(context);
},
),
),
],
),
);
@ -163,18 +154,19 @@ class BmrResultPage extends StatelessWidget {
});
}
}
extension BorderedContainer on Widget {
Widget get withBorderedContainer => Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
border: Border.all(
color: Color(0xffefefef),
width: 1,
),
),
child: this,
);
}
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.white,
border: Border.all(
color: Color(0xffefefef),
width: 1,
),
),
child: this,
);
}

@ -227,16 +227,8 @@ class _BodyFatState extends State<BodyFat> {
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
showHomeAppBarIcon: true,
appBarTitle: TranslationBase.of(context).bodyFatTitle,
appBarIcons: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0),
child: Icon(
Icons.info_outline,
color: Colors.white,
),
)
],
body: Column(
children: [
Expanded(

@ -2,8 +2,8 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -85,16 +85,8 @@ class _CalorieCalculatorState extends State<CalorieCalculator> {
isShowDecPage: false,
showNewAppBar: true,
showNewAppBarTitle: true,
showHomeAppBarIcon: true,
appBarTitle: "${TranslationBase.of(context).calories} ${TranslationBase.of(context).calcHealth}",
appBarIcons: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0),
child: Icon(
Icons.info_outline,
color: Colors.black,
),
)
],
body: Column(
children: [
Expanded(
@ -261,7 +253,6 @@ class _CalorieCalculatorState extends State<CalorieCalculator> {
SizedBox(
height: 12.0,
),
InkWell(
onTap: () {
// dropdownKey.currentState;
@ -337,10 +328,9 @@ class _CalorieCalculatorState extends State<CalorieCalculator> {
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: CustomColors.accentColor,
onTap: () {
child: DefaultButton(
TranslationBase.of(context).calculate,
() {
setState(() {
calculateCalories();
print(calories);

@ -5,9 +5,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
@ -75,18 +73,13 @@ class CalorieResultPage extends StatelessWidget {
],
),
progressColor: CustomColors.accentColor,
backgroundColor: Colors.white,
backgroundColor: CustomColors.darkGreyColor,
),
),
mHeight(20),
Text(
'Daily intake is ${calorie.toStringAsFixed(1)} calories',
style: TextStyle(
fontSize: 14,
letterSpacing: -0.56,
fontWeight: FontWeight.w600,
color: CustomColors.textColor
),
style: TextStyle(fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600, color: CustomColors.textColor),
),
],
).withBorderedContainer,
@ -95,15 +88,13 @@ class CalorieResultPage extends StatelessWidget {
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).viewDocList,
color: CustomColors.accentColor,
onTap: () {
child: DefaultButton(
TranslationBase.of(context).viewDocList,
() {
getDoctorsList(context);
},
),
),
],
),
);

@ -84,16 +84,7 @@ class _IdealBodyState extends State<IdealBody> {
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).idealBody,
showHomeAppBarIcon: false,
appBarIcons: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0),
child: Icon(
Icons.info_outline,
color: Colors.white,
),
)
],
showHomeAppBarIcon: true,
body: Column(
children: [
Expanded(

Loading…
Cancel
Save