Health Calculator 3.0

merge-update-with-lab-changes
devmirza121 4 years ago
parent d4eab13982
commit 6225f2468d

@ -1630,4 +1630,9 @@ const Map localizedValues = {
"RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"},
"RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"},
"transportation": {"en": "Transportation", "ar": "النقل"}, "transportation": {"en": "Transportation", "ar": "النقل"},
"neck": {"en": "Neck", "ar": "رقبه"},
"waist": {"en": "Waist", "ar": "وسط"},
"hip": {"en": "Hip", "ar": "ورك او نتوء"},
"carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"},
}; };

@ -1,4 +1,4 @@
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'bmr_result_page.dart'; import 'bmr_result_page.dart';
@ -30,9 +31,23 @@ class _BmrCalculatorState extends State<BmrCalculator> {
Color lbCard = inactiveCardColor; Color lbCard = inactiveCardColor;
Color cmCard = activeCardColor; Color cmCard = activeCardColor;
Color ftCard = inactiveCardColor; Color ftCard = inactiveCardColor;
int age = 0;
int height = 0; final GlobalKey clinicDropdownKey = GlobalKey();
int weight = 0; TextEditingController ageController = new TextEditingController();
TextEditingController _heightController = new TextEditingController();
TextEditingController _weightController = TextEditingController();
bool _isHeightCM = true;
bool _isWeightKG = true;
double _heightValue = 150;
double _weightValue = 40;
List<PopupMenuItem> _heightPopupList = List();
List<PopupMenuItem> _weightPopupList = List();
// int age = 0;
// int height = 0;
// int weight = 0;
double bmrResult = 0; double bmrResult = 0;
String dropdownValue = 'Lighty Active (1-3) days per week'; String dropdownValue = 'Lighty Active (1-3) days per week';
double calories = 0; double calories = 0;
@ -99,10 +114,9 @@ class _BmrCalculatorState extends State<BmrCalculator> {
void calculateBmr() { void calculateBmr() {
if (isMale == true) { if (isMale == true) {
bmrResult = 66.5 + (13.75 * weight) + (5.003 * height) - (6.755 * age); bmrResult = 66.5 + (13.75 * int.parse(_weightController.text)) + (5.003 * int.parse(_heightController.text)) - (6.755 * int.parse(ageController.text));
} else if (isMale == false) { } else if (isMale == false) {
bmrResult = bmrResult = 655.0955 + (9.5634 * int.parse(_weightController.text)) + (1.850 * int.parse(_heightController.text)) - (4.676 * int.parse(ageController.text));
655.0955 + (9.5634 * weight) + (1.850 * height) - (4.676 * age);
} }
bmrResult = bmrResult.roundToDouble(); bmrResult = bmrResult.roundToDouble();
@ -124,6 +138,10 @@ class _BmrCalculatorState extends State<BmrCalculator> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
_weightPopupList = <PopupMenuItem>[PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)];
_heightPopupList = <PopupMenuItem>[PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)];
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
isShowDecPage: false, isShowDecPage: false,
@ -140,639 +158,303 @@ class _BmrCalculatorState extends State<BmrCalculator> {
), ),
) )
], ],
body: Padding( body: Container(
padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), height: double.infinity,
child: SingleChildScrollView( width: double.infinity,
child: Container( child: Column(
height: 850, children: [
child: Column( Expanded(
crossAxisAlignment: CrossAxisAlignment.start, child: SingleChildScrollView(
children: [ child: Padding(
Text( padding: const EdgeInsets.all(21.0),
'Calculates the amount of energy that the persons body expends in a day', child: Column(
style: TextStyle( crossAxisAlignment: CrossAxisAlignment.start,
fontSize: 14, children: [
fontWeight: FontWeight.w600, Text(
letterSpacing: -0.56, 'Calculates the amount of energy that the persons body expends in a day',
color: CustomColors.textColor, style: TextStyle(
), fontSize: 14,
), fontWeight: FontWeight.w600,
Divider( letterSpacing: -0.56,
thickness: 2.0, color: CustomColors.textColor,
), ),
SizedBox(
height: 5.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 20,
),
Text(
TranslationBase.of(context).selectGender,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.56,
color: CustomColors.textColor,
), ),
), Column(
SizedBox( crossAxisAlignment: CrossAxisAlignment.start,
height: 8.0,
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Expanded( SizedBox(
child: GestureDetector( height: 20,
onTap: () {
setState(() {
updateColor(1);
isMale = false;
});
},
child: Row(
children: [
Container(
decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1),
width: 24,
height: 24,
padding: EdgeInsets.all(4),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: containerRadius(!isMale?CustomColors.accentColor:Colors.white, 100),
),
),
mWidth(12),
Text(TranslationBase.of(context).female, style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.56,
),),
],
),
),
), ),
Expanded( Text(
child: GestureDetector( TranslationBase.of(context).selectGender,
onTap: () { style: TextStyle(
setState(() { fontSize: 12,
updateColor(2); fontWeight: FontWeight.w600,
isMale = true; letterSpacing: -0.56,
}); color: CustomColors.textColor,
},
child: Row(
children: [
Container(
decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1),
width: 24,
height: 24,
padding: EdgeInsets.all(4),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: containerRadius(isMale?CustomColors.accentColor:Colors.white, 100),
),
),
mWidth(12),
Text(TranslationBase.of(context).male, style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.56,
),),
],
),
), ),
), ),
], SizedBox(
), height: 8.0,
),
SizedBox(
height: 5.0,
),
Texts(
'The Age ( 11 - 120 ) yrs',
),
SizedBox(
height: 10.0,
),
Row(
children: [
Container(
width: 340.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
), ),
child: Row( Container(
children: [ child: Row(
Padding( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
padding: EdgeInsets.symmetric( children: [
vertical: 10.0, horizontal: 8.0), Expanded(
child: Center( child: GestureDetector(
child: Container( onTap: () {
width: 60.0, setState(() {
foregroundDecoration: BoxDecoration( updateColor(1);
borderRadius: BorderRadius.circular(5.0), isMale = false;
border: Border.all( });
color: Colors.blueGrey, },
width: 2.0,
),
),
child: Row( child: Row(
children: <Widget>[ children: [
Expanded( Container(
child: Center( decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1),
child: Text(age.toString()), width: 24,
height: 24,
padding: EdgeInsets.all(4),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: containerRadius(!isMale ? CustomColors.accentColor : Colors.white, 100),
), ),
), ),
Container( mWidth(12),
height: 38.0, Text(
child: Column( TranslationBase.of(context).female,
crossAxisAlignment: style: TextStyle(
CrossAxisAlignment.center, fontSize: 12,
mainAxisAlignment: fontWeight: FontWeight.w600,
MainAxisAlignment.center, letterSpacing: -0.56,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
if (age < 120) age++;
});
},
),
),
InkWell(
child: Icon(
Icons.arrow_drop_down,
size: 18.0,
),
onTap: () {
setState(() {
if (age > 0) age--;
});
},
),
],
), ),
), ),
], ],
), ),
), ),
), ),
), Expanded(
Expanded( child: GestureDetector(
child: Slider( onTap: () {
value: age.toDouble(), setState(() {
min: 0, updateColor(2);
max: 120, isMale = true;
onChanged: (double newValue) { });
setState(() { },
age = newValue.round();
});
},
activeColor: Color(0xffC5272D),
inactiveColor: Color(0xffF3C5C6),
),
),
],
),
),
],
),
Texts(
'Height',
),
Row(
children: [
Container(
width: 340.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
),
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 8.0),
child: Center(
child: Container(
width: 60.0,
foregroundDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
color: Colors.blueGrey,
width: 2.0,
),
),
child: Row( child: Row(
children: <Widget>[ children: [
Expanded( Container(
child: Center( decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1),
child: Text(height.toString()), width: 24,
height: 24,
padding: EdgeInsets.all(4),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: containerRadius(isMale ? CustomColors.accentColor : Colors.white, 100),
), ),
), ),
Container( mWidth(12),
height: 38.0, Text(
child: Column( TranslationBase.of(context).male,
crossAxisAlignment: style: TextStyle(
CrossAxisAlignment.center, fontSize: 12,
mainAxisAlignment: fontWeight: FontWeight.w600,
MainAxisAlignment.center, letterSpacing: -0.56,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
if (height < 250)
height++;
});
},
),
),
InkWell(
child: Icon(
Icons.arrow_drop_down,
size: 18.0,
),
onTap: () {
setState(() {
if (height > 0) height--;
});
},
),
],
), ),
), ),
], ],
), ),
), ),
), ),
),
Expanded(
child: Slider(
value: height.toDouble(),
min: 0,
max: 250,
onChanged: (double newValue) {
setState(() {
height = newValue.round();
});
},
activeColor: Color(0xffC5272D),
inactiveColor: Color(0xffF3C5C6),
),
),
],
),
),
],
),
Texts('Select Unit'),
SizedBox(
height: 5.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
setState(() {
updateColorHeight(1);
isHeightCm = true;
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
], ],
color: cmCard,
borderRadius: BorderRadius.circular(3.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Center(child: Texts('CM')),
), ),
), ),
), SizedBox(
GestureDetector( height: 12.0,
onTap: () {
setState(() {
updateColorHeight(2);
isHeightCm = false;
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
color: ftCard,
borderRadius: BorderRadius.circular(3.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
],
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(child: Texts('Ft')),
),
), ),
), inputWidget(TranslationBase.of(context).age11_120Years, "0", ageController),
], SizedBox(
), height: 12.0,
SizedBox(
height: 5.0,
),
Texts(
'Weight',
),
SizedBox(
height: 5.0,
),
Row(
children: [
Container(
width: 340.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
), ),
child: Row( _commonInputAndUnitRow(
children: [ TranslationBase.of(context).height,
Padding( _heightController,
padding: EdgeInsets.symmetric( 1,
vertical: 10.0, horizontal: 8.0), 270,
child: Center( _heightValue,
child: Container( (text) {
width: 60.0, _heightController.text = text;
foregroundDecoration: BoxDecoration( },
borderRadius: BorderRadius.circular(5.0), (value) {
border: Border.all( _heightValue = value;
color: Colors.blueGrey, },
width: 2.0, _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft,
), (value) {
), if (_isHeightCM != value) {
child: Row( setState(() {
children: <Widget>[ _isHeightCM = value;
Expanded( });
child: Center( }
child: Text(weight.toString()), },
_heightPopupList,
),
SizedBox(
height: 12.0,
),
_commonInputAndUnitRow(
TranslationBase.of(context).weight,
_weightController,
1,
270,
_weightValue,
(text) {
_weightController.text = text;
},
(value) {
_weightValue = value;
},
_isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound,
(value) {
if (_isWeightKG != value) {
setState(() {
_isWeightKG = value;
});
}
},
_weightPopupList,
),
SizedBox(
height: 12.0,
),
InkWell(
onTap: () {
// dropdownKey.currentState;
openDropdown(clinicDropdownKey);
},
child: Container(
// width: double.infinity,
// decoration: containerRadius(Colors.white, 12),
// padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
child: Row(
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).activityLevel,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
fontWeight: FontWeight.w600,
), ),
), ),
Container( Container(
height: 38.0, height: 18,
child: Column( child: DropdownButtonHideUnderline(
crossAxisAlignment: child: DropdownButton<String>(
CrossAxisAlignment.center, value: dropdownValue,
mainAxisAlignment: icon: Icon(Icons.arrow_downward),
MainAxisAlignment.center, iconSize: 0,
children: <Widget>[ elevation: 16,
Container( isExpanded: true,
decoration: BoxDecoration( style: TextStyle(color: Colors.black87),
border: Border( underline: Container(
bottom: BorderSide( height: 2,
width: 0.5, color: Colors.black54,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
if (weight < 250)
weight++;
});
},
),
), ),
InkWell( onChanged: (String newValue) {
child: Icon( setState(() {
Icons.arrow_drop_down, dropdownValue = newValue;
size: 18.0, });
), },
onTap: () { items: <String>[
setState(() { 'Almost Inactive(Little or no exercises)',
if (weight > 0) weight--; 'Lighty Active (1-3) days per week',
}); 'very Active(6-7) days per week',
}, 'Super Active(very hard exercises)'
), ].map<DropdownMenuItem<String>>((String value) {
], return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
), ),
), ),
], ],
), ),
), ),
), Icon(Icons.keyboard_arrow_down),
), ],
Expanded(
child: Slider(
value: weight.toDouble(),
min: 0,
max: 250,
onChanged: (double newValue) {
setState(() {
weight = newValue.round();
});
},
activeColor: Color(0xffC5272D),
inactiveColor: Color(0xffF3C5C6),
),
), ),
], ).withBorderedContainer,
),
),
],
),
Texts('Select Unit'),
SizedBox(
height: 5.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
setState(() {
updateColorWeight(1);
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
],
color: kgCard,
borderRadius: BorderRadius.circular(3.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Center(child: Texts('KG')),
),
), ),
), SizedBox(
GestureDetector( height: 25.0,
onTap: () {
setState(() {
updateColorWeight(2);
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
color: lbCard,
borderRadius: BorderRadius.circular(3.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
],
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(child: Texts('LB')),
),
), ),
), ],
],
),
SizedBox(
height: 45.0,
),
Divider(
thickness: 2.0,
),
SizedBox(
height: 5.0,
),
Texts('Activity level'),
Container(
width: 300,
child: DropdownButton<String>(
value: dropdownValue,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.black87),
underline: Container(
height: 2,
color: Colors.black54,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>[
'Almost Inactive(Little or no exercises)',
'Lighty Active (1-3) days per week',
'very Active(6-7) days per week',
'Super Active(very hard exercises)'
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
),
SizedBox(
height: 30.0,
),
Container(
height: 50.0,
width: 350.0,
child: SecondaryButton(
label: 'CALCULATE',
onTap: () {
setState(() {
calculateBmr();
calculateCalories();
{
Navigator.push(
context,
FadePage(
page: BmrResultPage(
bmrResult: bmrResult,
calories: calories,
)),
);
}
});
},
), ),
), ],
], ),
), ),
], ),
), ),
), Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: CustomColors.accentColor,
onTap: () {
setState(() {
calculateBmr();
calculateCalories();
{
Navigator.push(
context,
FadePage(
page: BmrResultPage(
bmrResult: bmrResult,
calories: calories,
)),
);
}
});
},
),
),
],
), ),
), ),
); );
} }
void openDropdown(GlobalKey key) {
GestureDetector detector;
void searchForGestureDetector(BuildContext element) {
element.visitChildElements((element) {
if (element.widget != null && element.widget is GestureDetector) {
detector = element.widget;
return false;
} else {
searchForGestureDetector(element);
}
return true;
});
}
searchForGestureDetector(key.currentContext);
assert(detector != null);
detector.onTap();
}
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) {
return Container( return Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
@ -830,15 +512,15 @@ class _BmrCalculatorState extends State<BmrCalculator> {
prefixIcon: prefix == null prefixIcon: prefix == null
? null ? null
: Text( : Text(
"+" + prefix, "+" + prefix,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
height: 21 / 14, height: 21 / 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Color(0xff2E303A), color: Color(0xff2E303A),
letterSpacing: -0.56, letterSpacing: -0.56,
), ),
), ),
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,
border: InputBorder.none, border: InputBorder.none,
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
@ -980,18 +662,4 @@ class CommonDropDownView 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,
);
}

@ -1,9 +1,12 @@
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
@ -27,50 +30,81 @@ class BmrResultPage extends StatelessWidget {
body: Column( body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Center( Padding(
child: CircularPercentIndicator( padding: const EdgeInsets.all(20.0),
radius: 220.0, child: Column(
lineWidth: 20.0, mainAxisAlignment: MainAxisAlignment.start,
percent: ((this.bmrResult > 3500) ? 100 : this.bmrResult / 3500), crossAxisAlignment: CrossAxisAlignment.start,
center: Column( children: [
mainAxisAlignment: MainAxisAlignment.center, Text(
children: [ "Calories",
Text( style: TextStyle(
bmrResult.toStringAsFixed(1), fontSize: 19,
style: TextStyle( letterSpacing: -1.34,
fontSize: 18.0, fontWeight: FontWeight.bold,
fontWeight: FontWeight.bold,
),
), ),
SizedBox( ),
height: 5.0, mHeight(20),
Center(
child: CircularPercentIndicator(
radius: 220.0,
lineWidth: 3.0,
percent: ((this.bmrResult > 3500) ? 100 : this.bmrResult / 3500),
center: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
bmrResult.toStringAsFixed(1),
style: TextStyle(
fontSize: 17,
letterSpacing: -1.02,
fontWeight: FontWeight.w600,
),
),
SizedBox(
height: 5.0,
),
Text(
'Calories',
style: TextStyle(
fontSize: 18,
letterSpacing: -1.08,
fontWeight: FontWeight.w600,
),
),
],
),
progressColor: CustomColors.accentColor,
backgroundColor: Colors.white,
), ),
Text( ),
'Calories/Day', mHeight(20),
style: TextStyle( Text(
fontSize: 16.0, '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, fontWeight: FontWeight.w600,
), color: CustomColors.textColor
), ),
], ),
), ],
progressColor: Color(0xff3C3939), ).withBorderedContainer,
),
),
Container(
height: 120,
width: 280.0,
child: Texts(
'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.'),
), ),
mFlex(1),
Container( Container(
width: 350, margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
child: Button( color: Colors.white,
label: TranslationBase.of(context).viewDocList, child: SecondaryButton(
onTap: () { label: TranslationBase.of(context).viewDocList,
getDoctorsList(context); color: CustomColors.accentColor,
}), onTap: () {
getDoctorsList(context);
},
),
), ),
], ],
), ),
); );
@ -129,3 +163,18 @@ 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,
);
}

@ -1,9 +1,12 @@
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
@ -41,49 +44,70 @@ class FatResult extends StatelessWidget {
showNewAppBar: true, showNewAppBar: true,
appBarTitle: TranslationBase.of(context).bodyFatTitle, appBarTitle: TranslationBase.of(context).bodyFatTitle,
body: Column( body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
SizedBox( Padding(
// height: 40.0, padding: const EdgeInsets.all(20.0),
), child: Column(
Center( mainAxisAlignment: MainAxisAlignment.start,
child: CircularPercentIndicator( crossAxisAlignment: CrossAxisAlignment.start,
radius: 220.0, children: [
lineWidth: 20.0, Text(
percent: ((fat > 70) ? 100 : fat / 100), TranslationBase.of(context).bodyFatTitle,
center: Column( style: TextStyle(
mainAxisAlignment: MainAxisAlignment.center, fontSize: 19,
children: [ letterSpacing: -1.34,
Text( fontWeight: FontWeight.bold,
fat.toStringAsFixed(1) + '%', ),
style: TextStyle( ),
fontSize: 18.0, mHeight(20),
fontWeight: FontWeight.bold, Center(
child: CircularPercentIndicator(
radius: 220.0,
lineWidth: 3.0,
percent: ((fat > 70) ? 100 : fat / 100),
center: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
fat.toStringAsFixed(1) + '%',
style: TextStyle(
fontSize: 17,
letterSpacing: -1.02,
fontWeight: FontWeight.w600,
),
),
],
), ),
progressColor: CustomColors.accentColor,
backgroundColor: Colors.white,
), ),
SizedBox( ),
height: 5.0, mHeight(20),
Text(
textResult, style: TextStyle(
fontSize: 14,
letterSpacing: -0.56,
fontWeight: FontWeight.w600,
color: CustomColors.textColor
), ),
], ),
), ],
progressColor: inductorColor, ).withBorderedContainer,
backgroundColor: Colors.white,
),
),
Container(
height: 120,
width: 280.0,
child: Texts(textResult),
), ),
mFlex(1),
Container( Container(
width: 350, margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
child: Button( color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).viewDocList, label: TranslationBase.of(context).viewDocList,
color: CustomColors.accentColor,
onTap: () { onTap: () {
getDoctorsList(context); getDoctorsList(context);
}, },
), ),
), ),
], ],
), ),
); );
@ -142,3 +166,18 @@ class FatResult 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,
);
}

@ -261,6 +261,7 @@ class _CalorieCalculatorState extends State<CalorieCalculator> {
SizedBox( SizedBox(
height: 12.0, height: 12.0,
), ),
InkWell( InkWell(
onTap: () { onTap: () {
// dropdownKey.currentState; // dropdownKey.currentState;

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
@ -17,6 +18,7 @@ class Carbs extends StatefulWidget {
class _CarbsState extends State<Carbs> { class _CarbsState extends State<Carbs> {
TextEditingController textController = new TextEditingController(); TextEditingController textController = new TextEditingController();
final GlobalKey clinicDropdownKey = GlobalKey();
int calories; int calories;
String dropdownValue; String dropdownValue;
bool _visible = false; bool _visible = false;
@ -67,9 +69,9 @@ class _CarbsState extends State<Carbs> {
void calculate() { void calculate() {
pCal = (protein / 100.0) * int.parse(textController.text).ceil(); pCal = (protein / 100.0) * int.parse(textController.text).ceil();
cCal = (carbs / 100.0) * int.parse(textController.text); cCal = (carbs / 100.0) * int.parse(textController.text);
;
fCal = (fat / 100) * int.parse(textController.text); fCal = (fat / 100) * int.parse(textController.text);
;
pCalGram = pCal / 4.0; pCalGram = pCal / 4.0;
cCalGram = cCal / 4.0; cCalGram = cCal / 4.0;
fCalGram = fCal / 9.0; fCalGram = fCal / 9.0;
@ -95,286 +97,274 @@ class _CarbsState extends State<Carbs> {
), ),
) )
], ],
body: Padding( body: Column(
padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), children: [
child: SingleChildScrollView( Expanded(
child: Container( child: SingleChildScrollView(
child: Column( child: Container(
crossAxisAlignment: CrossAxisAlignment.start, padding: EdgeInsets.all(21),
children: [ child: Column(
Texts( crossAxisAlignment: CrossAxisAlignment.start,
'Calculates carbohydrate protein and fat\n ratio in calories and grams according to a\n pre-set ratio',
),
SizedBox(
height: 15.0,
),
Column(
children: [ children: [
Container( Text(
width: 340.0, 'Calculates carbohydrate protein and fat ratio in calories and grams according to a pre-set ratio',
height: 60.0, style: TextStyle(
decoration: BoxDecoration( fontSize: 14,
color: Colors.white, fontWeight: FontWeight.w600,
), letterSpacing: -0.56,
child: Row( color: CustomColors.textColor,
children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 8.0),
child: Center(
child: Container(
width: 300.0,
foregroundDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
color: Colors.blueGrey,
width: 2.0,
),
),
child: Row(
children: <Widget>[
Expanded(
child: Center(
child: TextFormField(
controller: textController,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter
.digitsOnly
],
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: " The Calories per day ",
labelStyle: TextStyle(
color: Colors.black87,
),
),
),
),
),
Container(
height: 38.0,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
int currentValue = int.parse(
textController.text);
currentValue++;
textController.text =
(currentValue).toString();
});
},
),
),
InkWell(
child: Icon(
Icons.arrow_drop_down,
size: 18.0,
),
onTap: () {
setState(() {
int currentValue = int.parse(
textController.text);
currentValue--;
textController.text =
(currentValue).toString();
});
},
),
],
),
),
],
),
),
),
),
],
), ),
), ),
SizedBox( SizedBox(
height: 20.0, height: 15.0,
), ),
Button( Column(
backgroundColor: Color(0xffC5272D), mainAxisAlignment: MainAxisAlignment.end,
label: 'NOT SURE? CLICK HERE', crossAxisAlignment: CrossAxisAlignment.end,
onTap: () { children: [
setState(() { inputWidget("The Calories per day", "0", textController),
{ InkWell(
onTap: () {
Navigator.push( Navigator.push(
context, context,
FadePage(page: CalorieCalculator()), FadePage(page: CalorieCalculator()),
); );
} },
}); child: Padding(
}, padding: const EdgeInsets.all(12.0),
child: Text(
'NOT SURE? CLICK HERE',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.accentColor, decoration: TextDecoration.underline),
),
),
)
],
), ),
], SizedBox(
), height: 12.0,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Texts('Select Diet Type'),
Container(
width: 400,
child: DropdownButton<String>(
value: dropdownValue,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.black87),
underline: Container(
height: 2,
color: Colors.black54,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
calculateDietRatios();
dropdownValue == null
? _visible = false
: _visible = true;
});
},
items: <String>[
'Very Low Carb',
'Low Carb',
'Moderate Carb',
'USDA Gudilines',
'Zone Diet',
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
), ),
Visibility( InkWell(
visible: _visible, onTap: () {
// dropdownKey.currentState;
openDropdown(clinicDropdownKey);
},
child: Container( child: Container(
height: 170.0, // width: double.infinity,
child: Column( // decoration: containerRadius(Colors.white, 12),
crossAxisAlignment: CrossAxisAlignment.start, // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
mainAxisAlignment: MainAxisAlignment.spaceEvenly, child: Row(
children: [ children: [
Texts( Flexible(
'Ratios are divided according to the selected diet'), child: Column(
RichText( crossAxisAlignment: CrossAxisAlignment.start,
text: TextSpan(
style: TextStyle(color: Colors.black),
children: [
TextSpan(text: 'Meals Per Day '),
TextSpan(
text: '$meals',
style: TextStyle(color: Color(0xffC5272D)),
),
],
),
),
RichText(
text: TextSpan(
style: TextStyle(color: Colors.black),
children: [ children: [
TextSpan( Text(
text: 'Protein ', "Select Diet Type",
), style: TextStyle(
TextSpan( fontSize: 11,
text: '$protein%', letterSpacing: -0.44,
style: TextStyle(color: Color(0xffC5272D)), fontWeight: FontWeight.w600,
) ),
],
),
),
RichText(
text: TextSpan(
style: TextStyle(color: Colors.black),
children: [
TextSpan(
text: 'Carbohydrate ',
), ),
TextSpan( Container(
text: '$carbs%', height: 18,
style: TextStyle(color: Color(0xffC5272D)), child: DropdownButtonHideUnderline(
) child: DropdownButton<String>(
], value: dropdownValue,
), icon: Icon(Icons.arrow_downward),
), iconSize: 0,
RichText( elevation: 16,
text: TextSpan( isExpanded: true,
style: TextStyle(color: Colors.black), style: TextStyle(color: Colors.black87),
children: [ underline: Container(
TextSpan( height: 2,
text: 'Fat ', color: Colors.black54,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
calculateDietRatios();
});
},
items: <String>['Very Low Carb', 'Low Carb', 'Moderate Carb', 'USDA Gudilines', 'Zone Diet'].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
),
), ),
TextSpan(
text: '$fat%',
style: TextStyle(color: Color(0xffC5272D)),
)
], ],
), ),
), ),
Icon(Icons.keyboard_arrow_down),
], ],
), ),
), ).withBorderedContainer,
) ),
SizedBox(
height: 25.0,
),
SizedBox(
height: 55.0,
),
], ],
), ),
SizedBox( ),
height: 55.0, ),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: CustomColors.accentColor,
onTap: () {
setState(() {
{
calculate();
Navigator.push(
context,
FadePage(
page: CarbsResult(
cCal: cCal,
pCal: pCal,
fCal: fCal,
pCalGram: pCalGram,
pCalMeal: pCalMeal,
fCalGram: fCalGram,
fCalMeal: fCalMeal,
cCalGram: cCalGram,
cCalMeal: cCalMeal,
)),
);
}
});
},
),
),
],
),
);
}
void openDropdown(GlobalKey key) {
GestureDetector detector;
void searchForGestureDetector(BuildContext element) {
element.visitChildElements((element) {
if (element.widget != null && element.widget is GestureDetector) {
detector = element.widget;
return false;
} else {
searchForGestureDetector(element);
}
return true;
});
}
searchForGestureDetector(key.currentContext);
assert(detector != null);
detector.onTap();
}
}
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) {
return 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: InkWell(
onTap: hasSelection ? () {} : null,
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_labelText,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: Color(0xff2B353E),
letterSpacing: -0.44,
),
), ),
Container( TextField(
height: 50.0, enabled: isEnable,
width: 350.0, scrollPadding: EdgeInsets.zero,
child: SecondaryButton( keyboardType: TextInputType.number,
label: 'CALCULATE', controller: _controller,
onTap: () { onChanged: (value) => {},
setState(() { style: TextStyle(
{ fontSize: 14,
calculate(); height: 21 / 14,
Navigator.push( fontWeight: FontWeight.w400,
context, color: Color(0xff2B353E),
FadePage( letterSpacing: -0.44,
page: CarbsResult( ),
cCal: cCal, decoration: InputDecoration(
pCal: pCal, isDense: true,
fCal: fCal, hintText: _hintText,
pCalGram: pCalGram, hintStyle: TextStyle(
pCalMeal: pCalMeal, fontSize: 14,
fCalGram: fCalGram, height: 21 / 14,
fCalMeal: fCalMeal, fontWeight: FontWeight.w400,
cCalGram: cCalGram, color: Color(0xff575757),
cCalMeal: cCalMeal, letterSpacing: -0.56,
)), ),
); prefixIconConstraints: BoxConstraints(minWidth: 50),
} prefixIcon: prefix == null
}); ? null
}, : Text(
"+" + prefix,
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: Color(0xff2E303A),
letterSpacing: -0.56,
),
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
), ),
), ),
], ],
), ),
), ),
), if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
],
), ),
); ),
} );
}
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,
);
} }

@ -1,15 +1,20 @@
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.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/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:provider/provider.dart';
class CarbsResult extends StatelessWidget { class CarbsResult extends StatelessWidget {
double pCal; double pCal;
@ -22,18 +27,11 @@ class CarbsResult extends StatelessWidget {
double cCalMeal; double cCalMeal;
double fCalMeal; double fCalMeal;
CarbsResult( CarbsResult({this.pCal, this.cCal, this.fCal, this.pCalGram, this.cCalGram, this.fCalGram, this.fCalMeal, this.cCalMeal, this.pCalMeal});
{this.pCal,
this.cCal,
this.fCal,
this.pCalGram,
this.cCalGram,
this.fCalGram,
this.fCalMeal,
this.cCalMeal,
this.pCalMeal});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
isShowDecPage: false, isShowDecPage: false,
@ -43,135 +41,96 @@ class CarbsResult extends StatelessWidget {
body: Column( body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Padding( Container(
padding: EdgeInsets.symmetric(vertical: 30.0, horizontal: 10.0), decoration: containerRadius(Colors.white, 12),
child: Table( padding: EdgeInsets.all(12),
border: TableBorder( margin: EdgeInsets.all(20),
verticalInside: BorderSide(width: 1, color: Colors.black54), child: Column(
bottom: BorderSide(width: 1, color: Colors.black54), crossAxisAlignment: CrossAxisAlignment.start,
left: BorderSide(width: 1, color: Colors.black54),
right: BorderSide(width: 1, color: Colors.black54),
top: BorderSide(width: 1, color: Colors.black54),
),
children: [ children: [
TableRow( Text(
decoration: BoxDecoration( TranslationBase.of(context).carbsProtin,
color: Colors.white, style: TextStyle(
), fontSize: 19,
children: [ fontWeight: FontWeight.bold,
TableCell( letterSpacing: -1.34,
child: Center(
child: Texts('Description'),
),
),
TableCell(
child: Center(
child: Texts('Protein'),
),
),
TableCell(
child: Center(
child: Texts(
'Carbohydrate',
),
),
),
TableCell(
child: Center(
child: Texts('Fat'),
),
),
]),
TableRow(children: [
Padding(
padding: EdgeInsets.all(8.0),
child: TableCell(
child: Center(
child: Texts('Calories\n Per Day'),
),
),
),
TableCell(
child: Center(
child: Texts(pCal.ceil().toString() + ' Cals'),
),
),
TableCell(
child: Center(
child: Texts(cCal.ceil().toString() + ' Cals'),
),
),
TableCell(
child: Center(
child: Texts(fCal.ceil().toString() + ' Cals'),
),
),
]),
TableRow(children: [
Padding(
padding: EdgeInsets.all(8.0),
child: TableCell(
child: Center(
child: Texts('Grams Per\n Day'),
),
),
),
TableCell(
child: Center(
child: Texts(pCalGram.ceil().toString() + ' gr'),
),
),
TableCell(
child: Center(
child: Texts(cCalGram.ceil().toString() + ' gr'),
),
), ),
TableCell( ),
child: Center( mHeight(12),
child: Texts(fCalGram.ceil().toString() + ' gr'), Table(
), columnWidths: {
), 0: FlexColumnWidth(2.4),
]), 1: FlexColumnWidth(1.8),
TableRow(children: [ 2: FlexColumnWidth(2),
Padding( 3: FlexColumnWidth(1),
padding: EdgeInsets.all(8.0), },
child: TableCell( children: fullData(context, projectViewModel),
child: Center( ),
child: Texts('Grams Per\n Meal'),
),
),
),
TableCell(
child: Center(
child: Texts(pCalMeal.ceil().toString() + ' gr'),
),
),
TableCell(
child: Center(
child: Texts(cCalMeal.ceil().toString() + ' gr'),
),
),
TableCell(
child: Center(
child: Texts(fCalMeal.ceil().toString() + ' gr'),
),
),
]),
], ],
), ),
), ),
Container( Container(
width: 350, margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
child: Button( color: Colors.white,
label: TranslationBase.of(context).viewDocList, child: SecondaryButton(
label: TranslationBase.of(context).seeListOfDoctor,
color: CustomColors.accentColor,
onTap: () { onTap: () {
getDoctorsList(context); getDoctorsList(context);
}, },
), ),
), ),
],
),
);
}
List<TableRow> fullData(BuildContext context, ProjectViewModel projectViewModel) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle("Description"),
Utils.tableColumnTitle("Protein"),
Utils.tableColumnTitle("Carbohydrate"),
Utils.tableColumnTitle("Fat"),
],
),
);
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue("Calories Per Day", isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(pCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue("Grams Per Day", isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(pCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(cCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(fCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
], ],
), ),
); );
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue('Grams Per Meal', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(pCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(cCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
Utils.tableColumnValue(fCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
return tableRow;
} }
getDoctorsList(BuildContext context) { getDoctorsList(BuildContext context) {
@ -208,7 +167,7 @@ class CarbsResult extends StatelessWidget {
List<PatientDoctorAppointmentList> doctorByHospital = _patientDoctorAppointmentListHospital List<PatientDoctorAppointmentList> doctorByHospital = _patientDoctorAppointmentListHospital
.where( .where(
(elementClinic) => elementClinic.filterName == element.projectName, (elementClinic) => elementClinic.filterName == element.projectName,
) )
.toList(); .toList();
if (doctorByHospital.length != 0) { if (doctorByHospital.length != 0) {
@ -226,5 +185,4 @@ class CarbsResult extends StatelessWidget {
print(err); print(err);
}); });
} }
} }

@ -1,10 +1,11 @@
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'ideal_body_result_page.dart'; import 'ideal_body_result_page.dart';
@ -24,8 +25,9 @@ class _IdealBodyState extends State<IdealBody> {
Color lbCard = inactiveCardColor; Color lbCard = inactiveCardColor;
Color cmCard = activeCardColor; Color cmCard = activeCardColor;
Color ftCard = inactiveCardColor; Color ftCard = inactiveCardColor;
int age = 0;
int height = 0; // int age = 0;
// int height = 0;
double heightInches; double heightInches;
double minRange; double minRange;
double maxRange; double maxRange;
@ -38,48 +40,22 @@ class _IdealBodyState extends State<IdealBody> {
double maxIdealWeight; double maxIdealWeight;
double heightFeet; double heightFeet;
void updateColorHeight(int type) { final GlobalKey clinicDropdownKey = GlobalKey();
//MG/DLT card bool _isHeightCM = true;
if (type == 1) { bool _isWeightKG = true;
if (cmCard == inactiveCardColor) { double _heightValue = 0;
cmCard = activeCardColor; double _weightValue = 0;
ftCard = inactiveCardColor;
} else { TextEditingController _heightController = new TextEditingController();
cmCard = inactiveCardColor; TextEditingController _weightController = TextEditingController();
}
} List<PopupMenuItem> _heightPopupList = List();
if (type == 2) { List<PopupMenuItem> _weightPopupList = List();
if (ftCard == inactiveCardColor) {
ftCard = activeCardColor;
cmCard = inactiveCardColor;
} else {
ftCard = inactiveCardColor;
}
}
}
void updateColorWeight(int type) {
//MG/DLT card
if (type == 1) {
if (kgCard == inactiveCardColor) {
kgCard = activeCardColor;
lbCard = inactiveCardColor;
} else {
kgCard = inactiveCardColor;
}
}
if (type == 2) {
if (lbCard == inactiveCardColor) {
lbCard = activeCardColor;
kgCard = inactiveCardColor;
} else {
lbCard = inactiveCardColor;
}
}
}
void calculateIdealWeight() { void calculateIdealWeight() {
heightInches = height * .39370078740157477; heightInches = int.parse(_heightController.text) * .39370078740157477;
heightFeet = heightInches / 12; heightFeet = heightInches / 12;
idealWeight = (50 + 2.3 * (heightInches - 60)); idealWeight = (50 + 2.3 * (heightInches - 60));
if (dropdownValue == 'Small(fingers overlap)') { if (dropdownValue == 'Small(fingers overlap)') {
@ -99,6 +75,9 @@ class _IdealBodyState extends State<IdealBody> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_weightPopupList = <PopupMenuItem>[PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)];
_heightPopupList = <PopupMenuItem>[PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)];
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
isShowDecPage: false, isShowDecPage: false,
@ -115,458 +94,418 @@ class _IdealBodyState extends State<IdealBody> {
), ),
) )
], ],
body: Padding( body: Column(
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0), children: [
child: SingleChildScrollView( Expanded(
child: Container( child: SingleChildScrollView(
height: 800.0, child: Container(
child: Column( padding: EdgeInsets.all(21),
children: [ child: Column(
Padding(
padding: EdgeInsets.all(10.0),
child: Texts(
'Calculates the ideal body weight based on height, Weight, and Body Size',
),
),
Divider(
thickness: 2.0,
),
SizedBox(
height: 5.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Text(
'Height', 'Calculates the ideal body weight based on height, Weight, and Body Size',
), style: TextStyle(
Row( fontSize: 14,
children: [ fontWeight: FontWeight.w600,
Expanded( letterSpacing: -0.56,
child: Container( color: CustomColors.textColor,
width: 340.0, ),
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
),
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 8.0),
child: Center(
child: Container(
width: 60.0,
foregroundDecoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5.0),
border: Border.all(
color: Colors.blueGrey,
width: 2.0,
),
),
child: Row(
children: <Widget>[
Expanded(
child: Center(
child: Text(height.toString()),
),
),
Container(
height: 38.0,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
if (height < 250)
height++;
});
},
),
),
InkWell(
child: Icon(
Icons.arrow_drop_down,
size: 18.0,
),
onTap: () {
setState(() {
if (height > 0) height--;
});
},
),
],
),
),
],
),
),
),
),
Expanded(
child: Slider(
value: height.toDouble(),
min: 0,
max: 250,
onChanged: (double newValue) {
setState(() {
height = newValue.round();
});
},
activeColor: Color(0xffC5272D),
inactiveColor: Color(0xffF3C5C6),
),
),
],
),
),
),
],
), ),
Texts('Select Unit'),
SizedBox( SizedBox(
height: 5.0, height: 5.0,
), ),
Row( Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
GestureDetector( SizedBox(
onTap: () { height: 12.0,
setState(() { ),
updateColorHeight(1); _commonInputAndUnitRow(
isHeightCm = true; TranslationBase.of(context).height,
}); _heightController,
1,
270,
_heightValue,
(text) {
_heightController.text = text;
}, },
child: Container( (value) {
height: 55.0, _heightValue = value;
width: 150.0, },
decoration: BoxDecoration( _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft,
boxShadow: [ (value) {
BoxShadow( if (_isHeightCM != value) {
color: Colors.grey.withOpacity(0.5), setState(() {
spreadRadius: 3, _isHeightCM = value;
blurRadius: 7, });
offset: Offset( }
0, 3), // changes position of shadow },
), _heightPopupList,
],
color: cmCard,
borderRadius: BorderRadius.circular(3.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Center(child: Texts('CM')),
),
),
), ),
GestureDetector( SizedBox(
onTap: () { height: 12.0,
setState(() { ),
updateColorHeight(2); _commonInputAndUnitRow(
isHeightCm = false; TranslationBase.of(context).weight,
}); _weightController,
1,
270,
_weightValue,
(text) {
_weightController.text = text;
}, },
child: Container( (value) {
height: 55.0, _weightValue = value;
width: 150.0, },
decoration: BoxDecoration( _isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound,
color: ftCard, (value) {
borderRadius: BorderRadius.circular(3.0), if (_isWeightKG != value) {
boxShadow: [ setState(() {
BoxShadow( _isWeightKG = value;
color: Colors.grey.withOpacity(0.5), });
spreadRadius: 3, }
blurRadius: 7, },
offset: Offset( _weightPopupList,
0, 3), // changes position of shadow
),
],
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(child: Texts('Ft')),
),
),
), ),
], SizedBox(
), height: 12.0,
SizedBox( ),
height: 45.0, InkWell(
), onTap: () {
Divider( // dropdownKey.currentState;
thickness: 2.0, openDropdown(clinicDropdownKey);
), },
Texts(
'Weight',
),
SizedBox(
height: 5.0,
),
Row(
children: [
Expanded(
child: Container( child: Container(
width: 340.0, // width: double.infinity,
height: 60.0, // decoration: containerRadius(Colors.white, 12),
decoration: BoxDecoration( // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
color: Colors.white,
),
child: Row( child: Row(
children: [ children: [
Padding( Flexible(
padding: EdgeInsets.symmetric( child: Column(
vertical: 10.0, horizontal: 8.0), crossAxisAlignment: CrossAxisAlignment.start,
child: Center( children: [
child: Container( Text(
width: 60.0, "Body Frame Size",
foregroundDecoration: BoxDecoration( style: TextStyle(
borderRadius: fontSize: 11,
BorderRadius.circular(5.0), letterSpacing: -0.44,
border: Border.all( fontWeight: FontWeight.w600,
color: Colors.blueGrey,
width: 2.0,
), ),
), ),
child: Row( Container(
children: <Widget>[ height: 18,
Expanded( child: DropdownButtonHideUnderline(
child: Center( child: DropdownButton<String>(
child: Text(weight.toString()), value: dropdownValue,
), icon: Icon(Icons.arrow_downward),
), iconSize: 0,
Container( elevation: 16,
height: 38.0, isExpanded: true,
child: Column( style: TextStyle(color: Colors.black87),
crossAxisAlignment: underline: Container(
CrossAxisAlignment.center, height: 2,
mainAxisAlignment: color: Colors.black54,
MainAxisAlignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
width: 0.5,
),
),
),
child: InkWell(
child: Icon(
Icons.arrow_drop_up,
size: 18.0,
),
onTap: () {
setState(() {
if (weight < 250)
weight++;
});
},
),
),
InkWell(
child: Icon(
Icons.arrow_drop_down,
size: 18.0,
),
onTap: () {
setState(() {
if (weight > 0) weight--;
});
},
),
],
), ),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>[
'Small(fingers overlap)',
'Medium(fingers touch)',
'Large(fingers don\'n touch)',
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
), ),
], ),
), ),
), ],
),
),
Expanded(
child: Slider(
value: weight.toDouble(),
min: 0,
max: 250,
onChanged: (double newValue) {
setState(() {
weight = newValue.round();
});
},
activeColor: Color(0xffC5272D),
inactiveColor: Color(0xffF3C5C6),
), ),
), ),
Icon(Icons.keyboard_arrow_down),
], ],
), ),
), ).withBorderedContainer,
),
],
),
Texts('Select Unit'),
SizedBox(
height: 5.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
setState(() {
updateColorWeight(1);
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
],
color: kgCard,
borderRadius: BorderRadius.circular(3.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Center(child: Texts('KG')),
),
),
),
GestureDetector(
onTap: () {
setState(() {
updateColorWeight(2);
});
},
child: Container(
height: 55.0,
width: 150.0,
decoration: BoxDecoration(
color: lbCard,
borderRadius: BorderRadius.circular(3.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
),
],
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Center(child: Texts('LB')),
),
),
), ),
], ],
), ),
SizedBox( ],
height: 45.0, ),
), ),
Divider( ),
thickness: 2.0, ),
Container(
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: CustomColors.accentColor,
onTap: () {
setState(() {
// calculateBmr();
// calculateCalories();
calculateIdealWeight();
print(idealWeight);
print(minRange);
print(maxRange);
print(overWeightBy);
print(textResult);
//print(overWeightBy);
{
Navigator.push(
context,
FadePage(
page: IdealBodyResult(
idealBodyWeight: idealWeight,
minRange: minRange,
mixRange: maxRange,
overWeightBy: overWeightBy,
textResult: textResult,
)),
);
}
});
},
),
),
],
),
);
}
void openDropdown(GlobalKey key) {
GestureDetector detector;
void searchForGestureDetector(BuildContext element) {
element.visitChildElements((element) {
if (element.widget != null && element.widget is GestureDetector) {
detector = element.widget;
return false;
} else {
searchForGestureDetector(element);
}
return true;
});
}
searchForGestureDetector(key.currentContext);
assert(detector != null);
detector.onTap();
}
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) {
return 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: InkWell(
onTap: hasSelection ? () {} : null,
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_labelText,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: Color(0xff2B353E),
letterSpacing: -0.44,
), ),
SizedBox( ),
height: 5.0, TextField(
enabled: isEnable,
scrollPadding: EdgeInsets.zero,
keyboardType: TextInputType.number,
controller: _controller,
onChanged: (value) => {},
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff2B353E),
letterSpacing: -0.44,
), ),
Texts('Body Frame Size'), decoration: InputDecoration(
Container( isDense: true,
width: 300, hintText: _hintText,
child: DropdownButton<String>( hintStyle: TextStyle(
value: dropdownValue, fontSize: 14,
icon: Icon(Icons.arrow_downward), height: 21 / 14,
iconSize: 24, fontWeight: FontWeight.w400,
elevation: 16, color: Color(0xff575757),
style: TextStyle(color: Colors.black87), letterSpacing: -0.56,
underline: Container(
height: 2,
color: Colors.black54,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>[
'Small(fingers overlap)',
'Medium(fingers touch)',
'Large(fingers don\'n touch)',
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
), ),
prefixIconConstraints: BoxConstraints(minWidth: 50),
prefixIcon: prefix == null
? null
: Text(
"+" + prefix,
style: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: Color(0xff2E303A),
letterSpacing: -0.56,
),
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
), ),
SizedBox( ),
height: 30.0, ],
), ),
Container( ),
height: 50.0, if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
width: 350.0, ],
child: SecondaryButton( ),
label: 'CALCULATE', ),
onTap: () { );
setState(() { }
// calculateBmr();
// calculateCalories();
calculateIdealWeight();
print(idealWeight); Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle,
//print(overWeightBy); Function(bool) onUnitTap, _list) {
{ return Row(
Navigator.push( children: [
context, Expanded(
FadePage( flex: 3,
page: IdealBodyResult( child: Column(
idealBodyWeight: idealWeight, mainAxisSize: MainAxisSize.min,
minRange: minRange, crossAxisAlignment: CrossAxisAlignment.start,
mixRange: maxRange, children: [
overWeightBy: overWeightBy, Text(
textResult: textResult, _title,
)), style: TextStyle(
); fontSize: 12,
} fontWeight: FontWeight.w600,
}); color: Color(0xff2E303A),
}, letterSpacing: -0.44,
),
),
],
), ),
], ),
), TextField(
controller: _controller,
keyboardType: TextInputType.number,
onChanged: (value) {
double _value = double.parse(value);
if (_value > _maxValue) {
onTextValueChange(_maxValue.toStringAsFixed(0));
onValueChange(_maxValue);
return;
} else if (_value < _minValue) {
onTextValueChange(_minValue.toStringAsFixed(0));
onValueChange(_minValue);
return;
} else if (_value >= _minValue && _value <= _maxValue) {
onValueChange(_value);
return;
}
},
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
],
style: TextStyle(
color: Color(0xff575757),
letterSpacing: -0.56,
),
decoration: InputDecoration(
isDense: true,
hintText: "0",
hintStyle: TextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w400,
color: Color(0xff575757),
letterSpacing: -0.56,
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
],
), ),
), ),
Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)),
Expanded(
flex: 1,
child: PopupMenuButton(
child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null),
onSelected: (value) {
onUnitTap(value);
},
itemBuilder: (context) => _list),
)
],
).withBorderedContainer;
}
}
// todo 'sikander' move these to separate file once usability known
class CommonDropDownView extends StatelessWidget {
final String title;
final String value;
final VoidCallback callback;
final IconData iconData;
CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: callback,
child: Row(
children: [
Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(
title,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xff2E303A),
letterSpacing: -0.44,
),
),
Text(
value,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xff575757),
letterSpacing: -0.56,
),
),
]),
),
Icon(
iconData ?? Icons.keyboard_arrow_down_sharp,
color: Color(0xff2E303A),
)
],
), ),
); );
} }
} }

@ -1,9 +1,12 @@
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
@ -28,139 +31,170 @@ class IdealBodyResult extends StatelessWidget {
appBarTitle: TranslationBase.of(context).idealBody, appBarTitle: TranslationBase.of(context).idealBody,
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Texts(
'Ideal weight range is', Padding(
fontSize: 23.0, padding: const EdgeInsets.all(20.0),
), child: Column(
Row( crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
children: [ Text(
Row( 'Ideal weight range is',
children: [ style: TextStyle(
Texts( fontSize: 19,
minRange.toStringAsFixed(1), letterSpacing: -1.34,
fontSize: 30.0, fontWeight: FontWeight.bold,
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 4.0),
child: Text(
'Kg',
style: TextStyle(color: Colors.red),
),
),
],
),
Icon(
Icons.arrow_forward,
color: Colors.red,
size: 55.0,
),
Row(
children: [
Texts(
mixRange.toStringAsFixed(1),
fontSize: 30.0,
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 4.0),
child: Text(
'Kg',
style: TextStyle(color: Colors.red),
),
), ),
], ),
), mHeight(12),
], Row(
), mainAxisAlignment: MainAxisAlignment.spaceEvenly,
overWeightBy >= 0 && overWeightBy <= 10
? Column(
children: [ children: [
Texts( Row(
'Congratulations! The current weight is\n perfect and considered healthy', children: [
fontSize: 20.0, Texts(
minRange.toStringAsFixed(1),
fontSize: 30.0,
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 4.0),
child: Text(
'Kg',
style: TextStyle(color: Colors.red),
),
),
],
), ),
], Icon(
) Icons.arrow_forward,
: overWeightBy > 10 && overWeightBy < 17 color: Colors.red,
? Column( size: 55.0,
),
Row(
children: [ children: [
Texts('This means that the weight is a little bit more than ideal weight by'), Texts(
Texts(overWeightBy.toStringAsFixed(1)), mixRange.toStringAsFixed(1),
Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), fontSize: 30.0,
),
Padding(
padding: EdgeInsets.only(top: 8.0, left: 4.0),
child: Text(
'Kg',
style: TextStyle(color: Colors.red),
),
),
], ],
) ),
: overWeightBy >= 18 ],
? Container( ),
height: 250.0, mHeight(12),
width: 350, overWeightBy >= 0 && overWeightBy <= 10
child: Column( ? Column(
children: [
Texts(
'Congratulations! The current weight is perfect and considered healthy',
fontSize: 20.0,
),
],
)
: overWeightBy > 10 && overWeightBy < 17
? Column(
children: [ children: [
Texts( Texts('This means that the weight is a little bit more than ideal weight by'),
'Means that you suffer from excessive\n obesity by', Texts(overWeightBy.toStringAsFixed(1)),
), Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'),
SizedBox(
height: 55.0,
),
Texts(
overWeightBy.toStringAsFixed(1),
fontSize: 40.0,
),
SizedBox(
height: 25.0,
),
Texts('May wish to consult with the doctor for\n medical help. Click to view our list of\n Doctors'),
], ],
), )
) : overWeightBy >= 18
: overWeightBy < -18 ? Container(
? Column(
crossAxisAlignment: CrossAxisAlignment.center, child: Column(
children: [ children: [
Padding( Texts(
padding: const EdgeInsets.all(8.0), 'Means that you suffer from excessive obesity by',
child: Texts( ),
'Under Weight', SizedBox(
fontSize: 18.0, height: 12.0,
), ),
), Text(
SizedBox( overWeightBy.toStringAsFixed(1),
height: 55.0, style: TextStyle(
), fontSize: 17,
Texts( fontWeight: FontWeight.bold,
overWeightBy.toStringAsFixed(1), letterSpacing: -1.34,
fontSize: 20.0, ),
),
SizedBox(
height: 12.0,
),
Texts('May wish to consult with the doctor for medical help. Click to view our list of\n Doctors'),
],
), ),
], )
) : overWeightBy < -18
: Container( ? Column(
height: 250.0, crossAxisAlignment: CrossAxisAlignment.center,
width: 350.0, children: [
child: Column( Padding(
children: [ padding: const EdgeInsets.all(8.0),
Texts( child: Texts(
'under wheight', 'Under Weight',
fontSize: 20.0, fontSize: 18.0,
), ),
SizedBox( ),
height: 55.0, SizedBox(
), height: 12.0,
Texts( ),
overWeightBy.toStringAsFixed(1), Text(
fontSize: 20.0, overWeightBy.toStringAsFixed(1),
), style: TextStyle(
SizedBox( fontSize: 17,
height: 25.0, fontWeight: FontWeight.bold,
letterSpacing: -1.34,
),
),
],
)
: Container(
child: Column(
children: [
Text(
'under wheight',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
letterSpacing: -1.34,
),
),
SizedBox(
height: 12.0,
),
Text(
overWeightBy.toStringAsFixed(1),
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
letterSpacing: -1.34,
),
),
SizedBox(
height: 12.0,
),
Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'),
],
),
), ),
Texts('May wish to consult with the doctor for\n medical help. Click to view our list of\n Doctors'), ],
], ).withBorderedContainer,
), ),
),
Container( Container(
width: 350, margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
child: Button( color: Colors.white,
child: SecondaryButton(
label: TranslationBase.of(context).viewDocList, label: TranslationBase.of(context).viewDocList,
color: CustomColors.accentColor,
onTap: () { onTap: () {
getDoctorsList(context); getDoctorsList(context);
}, },
@ -224,3 +258,19 @@ class IdealBodyResult 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,
);
}

@ -2618,6 +2618,10 @@ class TranslationBase {
String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode]; String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode];
String get transportation => localizedValues["transportation"][locale.languageCode]; String get transportation => localizedValues["transportation"][locale.languageCode];
String get neck => localizedValues["neck"][locale.languageCode];
String get waist => localizedValues["waist"][locale.languageCode];
String get hip => localizedValues["hip"][locale.languageCode];
String get carbsProtin => localizedValues["carbsProtin"][locale.languageCode];
} }
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> { class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -168,6 +168,7 @@ dependencies:
in_app_review: ^1.0.4 in_app_review: ^1.0.4
badges: ^1.1.4 badges: ^1.1.4
syncfusion_flutter_sliders: ^18.4.49-beta
# Dep by Zohaib # Dep by Zohaib
shimmer: ^1.1.2 shimmer: ^1.1.2

Loading…
Cancel
Save