From 864f849425246413b39b3d90ba704e4ed6b30310 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 17 Aug 2021 12:10:10 +0300 Subject: [PATCH 1/2] Baby age in ovulation period --- .../ovulation_period/ovulation_period.dart | 62 ++++++++++--------- .../ovulation_result_page.dart | 2 +- .../AlHabibMedicalService/parking_page.dart | 44 ++++++------- 3 files changed, 57 insertions(+), 51 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart index b05637bc..a6708855 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart @@ -19,6 +19,7 @@ class OvulationPeriod extends StatefulWidget { class _OvulationPeriodState extends State { DateTime bloodSugarDate = DateTime.now(); DateTime timeSugarDate = DateTime.now(); + DateTime selectedDateTime = DateTime.now(); int cycleLength = 0; int lutealPhaseLength = 0; String selectedDate; @@ -37,13 +38,30 @@ class _OvulationPeriodState extends State { } String getDate() { - return "${DateUtil.getMonth(bloodSugarDate.month)} ${bloodSugarDate.day}, ${bloodSugarDate.year}"; + return "${DateUtil.getMonth(selectedDateTime.month)} ${selectedDateTime.day}, ${selectedDateTime.year}"; } // void calculate() {} // // void calculateFertility(DateTime selectedDate) {const diff = Date.} + calculateBabyInformation() { + setState(() { + bloodSugarDate = selectedDateTime; + dateFrom = selectedDateTime.add(Duration(days: 10)); + updatedDt = DateFormat.yMMMEd().format(dateFrom); + dateTo = selectedDateTime.add(Duration(days: 20)); + conceivedDate = selectedDateTime.add(Duration(days: 14)); + deliveryDue = selectedDateTime.add(Duration(days: 280)); + + // babyAge = Jiffy([DateTime.now()]).diff(Jiffy([date]), Units.WEEK); + babyAgeWeeks = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day]) + .diff(Jiffy([selectedDateTime.year, selectedDateTime.month, dateTo.day]), Units.WEEK); + babyAgeDays = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day]) + .diff(Jiffy([selectedDateTime.year, selectedDateTime.month, dateTo.day]), Units.DAY); + }); + } + @override Widget build(BuildContext context) { return AppScaffold( @@ -78,18 +96,7 @@ class _OvulationPeriodState extends State { onConfirm: (date) { print('confirm $date'); setState(() { - bloodSugarDate = date; - dateFrom = date.add(Duration(days: 10)); - updatedDt = DateFormat.yMMMEd().format(dateFrom); - dateTo = date.add(Duration(days: 20)); - conceivedDate = date.add(Duration(days: 14)); - deliveryDue = date.add(Duration(days: 280)); - - // babyAge = Jiffy([DateTime.now()]).diff(Jiffy([date]), Units.WEEK); - babyAgeWeeks = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day]) - .diff(Jiffy([date.year, date.month, dateTo.day]), Units.WEEK); - babyAgeDays = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day]) - .diff(Jiffy([date.year, date.month, dateTo.day]), Units.DAY); + selectedDateTime = date; }); }, currentTime: DateTime.now(), @@ -321,22 +328,19 @@ class _OvulationPeriodState extends State { child: SecondaryButton( label: 'CALCULATE', onTap: () { - setState(() { - { - Navigator.push( - context, - FadePage( - page: OvulationResult( - conceivedDate: conceivedDate, - dateFrom: dateFrom, - dateTo: dateTo, - deliveryDue: deliveryDue, - babyAge: babyAgeWeeks, - babyAgeDays: babyAgeDays, - )), - ); - } - }); + calculateBabyInformation(); + Navigator.push( + context, + FadePage( + page: OvulationResult( + conceivedDate: conceivedDate, + dateFrom: dateFrom, + dateTo: dateTo, + deliveryDue: deliveryDue, + babyAge: babyAgeWeeks, + babyAgeDays: babyAgeDays, + )), + ); }, ), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart index 855e5af7..53ccb664 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart @@ -78,7 +78,7 @@ class OvulationResult extends StatelessWidget { fontWeight: FontWeight.w400, ), Texts( - babyAge.toString() + " Weeks," + "2", + babyAge <= 0 ? "baby age is not available" : babyAge.toString() + " Weeks," + "3", fontWeight: FontWeight.w800, fontSize: 21.0, ), diff --git a/lib/pages/AlHabibMedicalService/parking_page.dart b/lib/pages/AlHabibMedicalService/parking_page.dart index 19f06a56..f3620917 100644 --- a/lib/pages/AlHabibMedicalService/parking_page.dart +++ b/lib/pages/AlHabibMedicalService/parking_page.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/qr_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -9,11 +10,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:maps_launcher/maps_launcher.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; +import 'package:provider/provider.dart'; import '../../d_q_icons_icons.dart'; class ParkingPage extends StatelessWidget { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getIsSaveParking(), builder: (_, model, widget) => AppScaffold( @@ -21,10 +24,7 @@ class ParkingPage extends StatelessWidget { appBarTitle: TranslationBase.of(context).parking, description: TranslationBase.of(context).parkingDescription, imagesInfo: [ - ImagesInfo( - imageAr: 'assets/images/bc_parking.png', - imageEn: 'assets/images/bc_parking.png', - isAsset: true) + ImagesInfo(imageAr: 'assets/images/bc_parking.png', imageEn: 'assets/images/bc_parking.png', isAsset: true) ], body: SingleChildScrollView( padding: EdgeInsets.all(12), @@ -50,7 +50,9 @@ class ParkingPage extends StatelessWidget { Row( children: [ Expanded( - child: Container(child: Icon(/*Icons.landscape*/DQIcons.parking_icon,size: 130),), + child: Container( + child: Icon(/*Icons.landscape*/ DQIcons.parking_icon, size: 130), + ), ), SizedBox( width: 15, @@ -85,15 +87,15 @@ class ParkingPage extends StatelessWidget { padding: EdgeInsets.all(8), width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - shape: BoxShape.rectangle), + borderRadius: BorderRadius.circular(10), color: Colors.white, shape: BoxShape.rectangle), height: 70, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts(TranslationBase.of(context).showMyPark), - Texts(model.qrParkingModel.floorDescriptionN), + Texts(projectViewModel.isArabic + ? model.qrParkingModel.floorDescriptionN + : model.qrParkingModel.floorDescription), ], ), ), @@ -102,9 +104,7 @@ class ParkingPage extends StatelessWidget { ), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - shape: BoxShape.rectangle), + borderRadius: BorderRadius.circular(10), color: Colors.white, shape: BoxShape.rectangle), padding: EdgeInsets.all(8), width: double.infinity, height: 70, @@ -112,7 +112,9 @@ class ParkingPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts(TranslationBase.of(context).gate), - Texts(model.qrParkingModel.gateDescriptionN), + Texts(projectViewModel.isArabic + ? model.qrParkingModel.gateDescriptionN + : model.qrParkingModel.gateDescription), ], ), ), @@ -121,9 +123,7 @@ class ParkingPage extends StatelessWidget { ), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - shape: BoxShape.rectangle), + borderRadius: BorderRadius.circular(10), color: Colors.white, shape: BoxShape.rectangle), padding: EdgeInsets.all(8), width: double.infinity, height: 70, @@ -131,7 +131,9 @@ class ParkingPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts(TranslationBase.of(context).building), - Texts(model.qrParkingModel.buildingDescriptionN), + Texts(projectViewModel.isArabic + ? model.qrParkingModel.buildingDescriptionN + : model.qrParkingModel.buildingDescription), ], ), ), @@ -141,16 +143,16 @@ class ParkingPage extends StatelessWidget { Container( padding: EdgeInsets.all(8), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.white, - shape: BoxShape.rectangle), + borderRadius: BorderRadius.circular(10), color: Colors.white, shape: BoxShape.rectangle), width: double.infinity, height: 70, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts(TranslationBase.of(context).branch), - Texts(model.qrParkingModel.branchDescriptionN), + Texts(projectViewModel.isArabic + ? model.qrParkingModel.branchDescriptionN + : model.qrParkingModel.branchDescription), ], ), ), From fe83b91602dae19d5d98d192ef4e1aaab18a6077 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 17 Aug 2021 14:58:10 +0300 Subject: [PATCH 2/2] body fat texfield fix --- .../health_calculator/body_fat/body_fat.dart | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 7f0d0c5c..44a3dc9e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -50,6 +50,15 @@ class _BodyFatState extends State { TextEditingController waistController = TextEditingController(); TextEditingController hipController = TextEditingController(); + @override + void initState() { + neckController.text = neck.toString(); + hipController.text = hip.toString(); + waistController.text = waist.toString(); + heightController.text = heightCm.toString(); + super.initState(); + } + void updateColorHeight(int type) { //MG/DLT card if (type == 1) { @@ -319,11 +328,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: heightController, - decoration: InputDecoration( - labelText: heightCm.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -350,6 +354,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (heightCm < 250) heightCm++; + heightController.text = heightCm.toString(); }); }, ), @@ -362,6 +367,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (heightCm > 0) heightCm--; + heightController.text = heightCm.toString(); }); }, ), @@ -381,6 +387,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { heightCm = newValue.round(); + heightController.text = heightCm.toString(); }); }, activeColor: Color(0xffC5272D), @@ -492,15 +499,10 @@ class _BodyFatState extends State { Expanded( child: Center( child: Padding( - padding: const EdgeInsets.only(left: 10.0), + padding: const EdgeInsets.only(left: 15.0, bottom: 0), child: TextFormField( keyboardType: TextInputType.number, controller: neckController, - decoration: InputDecoration( - labelText: neck.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -527,6 +529,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (neck < 60) neck++; + neckController.text = neck.toString(); }); }, ), @@ -539,6 +542,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (neck > 5) neck--; + neckController.text = neck.toString(); }); }, ), @@ -558,6 +562,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { neck = newValue.round(); + neckController.text = neck.toString(); }); }, activeColor: Color(0xffC5272D), @@ -673,11 +678,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: waistController, - decoration: InputDecoration( - labelText: waist.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -704,6 +704,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (waist < 200) waist++; + waistController.text = waist.toString(); }); }, ), @@ -716,6 +717,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (waist > 5) waist--; + waistController.text = waist.toString(); }); }, ), @@ -735,6 +737,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { waist = newValue.round(); + waistController.text = waist.toString(); }); }, activeColor: Color(0xffC5272D), @@ -850,11 +853,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: hipController, - decoration: InputDecoration( - labelText: hip.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -881,6 +879,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (hip < 140) hip++; + hipController.text = hip.toString(); }); }, ), @@ -893,6 +892,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (hip > 5) hip--; + hipController.text = hip.toString(); }); }, ), @@ -912,6 +912,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { hip = newValue.round(); + hipController.text = hip.toString(); }); }, activeColor: Color(0xffC5272D),