From db840906942255053e52135387f76e41a3e409d3 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 20 Jun 2021 15:12:57 +0300 Subject: [PATCH 1/7] PAP-872 & PAP-593 fixed, Water addition was not visible. --- lib/widgets/others/app_scaffold_widget.dart | 84 +++++++-------------- 1 file changed, 27 insertions(+), 57 deletions(-) diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index ca72e267..1412adf6 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -58,8 +58,7 @@ class AppScaffold extends StatelessWidget { final List appBarIcons; final List imagesInfo; final bool isHelp; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); AppBarWidget appBar; AppScaffold( @@ -96,8 +95,7 @@ class AppScaffold extends StatelessWidget { Widget build(BuildContext context) { AppGlobal.context = context; return Scaffold( - backgroundColor: - backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, + backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, appBar: isShowAppBar ? appBar = AppBarWidget( appBarTitle: appBarTitle, @@ -114,22 +112,21 @@ class AppScaffold extends StatelessWidget { body: SafeArea( top: true, bottom: true, - child: - (!Provider.of(context, listen: false).isLogin && - isShowDecPage) - ? NotAutPage( - title: title ?? appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, + child: (!Provider.of(context, listen: false).isLogin && isShowDecPage) + ? NotAutPage( + title: title ?? appBarTitle, + description: description, + infoList: infoList, + imagesInfo: imagesInfo, + ) + : baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(context), + baseViewModel: baseViewModel, ) - : baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(context), - baseViewModel: baseViewModel, - ) - : buildBodyWidget(context), + : buildBodyWidget(context), ), + floatingActionButton: floatingActionButton, ); } @@ -138,14 +135,12 @@ class AppScaffold extends StatelessWidget { } buildBodyWidget(context) { - return Stack( - children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); } } class AppBarWidget extends StatefulWidget with PreferredSizeWidget { - final AuthenticatedUserObject authenticatedUserObject = - locator(); + final AuthenticatedUserObject authenticatedUserObject = locator(); final String appBarTitle; final bool showHomeAppBarIcon; @@ -193,22 +188,12 @@ class AppBarWidgetState extends State { ProjectViewModel projectViewModel = Provider.of(context); return AppBar( elevation: 0, - backgroundColor: widget.isPharmacy - ? Colors.green - : Theme.of(context).appBarTheme.color, + backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, textTheme: TextTheme( - headline6: TextStyle( - color: Theme.of(context).textTheme.headline1.color, - fontWeight: FontWeight.bold), + headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), ), - title: Text( - widget.authenticatedUserObject.isLogin || !widget.isShowDecPage - ? widget.appBarTitle.toUpperCase() - : TranslationBase.of(context).serviceInformationTitle, - style: TextStyle( - fontWeight: FontWeight.bold, - color: Theme.of(context).textTheme.headline1.color, - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), + title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, + style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { return ArrowBack(); @@ -218,9 +203,7 @@ class AppBarWidgetState extends State { actions: [ (widget.isPharmacy && widget.showPharmacyCart) ? IconButton( - icon: Badge( - badgeContent: Text(badgeText), - child: Icon(Icons.shopping_cart)), + icon: Badge(badgeContent: Text(badgeText), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { Navigator.of(context).popUntil(ModalRoute.withName('/')); @@ -232,10 +215,7 @@ class AppBarWidgetState extends State { position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( badgeText, - style: TextStyle( - fontSize: 9, - color: Colors.white, - fontWeight: FontWeight.normal), + style: TextStyle(fontSize: 9, color: Colors.white, fontWeight: FontWeight.normal), ), child: Icon(Icons.shopping_cart)), color: Colors.white, @@ -249,10 +229,7 @@ class AppBarWidgetState extends State { icon: Icon(FontAwesomeIcons.home), color: Colors.white, onPressed: () { - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute(builder: (context) => LandingPage()), - (Route r) => false); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); // Cart Click Event if (_onCartClick != null) _onCartClick(); @@ -316,18 +293,11 @@ class _RobotIcon extends State { ], ), child: TyperAnimatedTextKit( - text: Provider.of(context, - listen: false) - .isArabic == - true + text: Provider.of(context, listen: false).isArabic == true ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file.", - textLength: Provider.of(context, - listen: false) - .isArabic == - true - ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." - .length + textLength: Provider.of(context, listen: false).isArabic == true + ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.".length : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file." .length)) : Container(), From 7771b8f3201bff66befc2362c5b99ab275b23402 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 20 Jun 2021 15:58:32 +0300 Subject: [PATCH 2/7] PAP-886 fixed, Insurance image button added. --- .../insurance/insurance_card_screen.dart | 173 +++++++----------- lib/widgets/others/app_scaffold_widget.dart | 80 +++++--- 2 files changed, 117 insertions(+), 136 deletions(-) diff --git a/lib/pages/insurance/insurance_card_screen.dart b/lib/pages/insurance/insurance_card_screen.dart index da66c572..cf58e815 100644 --- a/lib/pages/insurance/insurance_card_screen.dart +++ b/lib/pages/insurance/insurance_card_screen.dart @@ -6,7 +6,7 @@ import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_details.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.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'; @@ -33,26 +33,41 @@ class _InsuranceCardState extends State { @override Widget build(BuildContext context) { imagesInfo.add(ImagesInfo( - imageEn: - 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/en/0.png', - imageAr: - 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/ar/0.png')); + imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/insurance-card/ar/0.png')); return BaseView( onModelReady: (model) => model.getInsurance(), - builder: (BuildContext context, InsuranceViewModel model, Widget child) => - AppScaffold( + builder: (BuildContext context, InsuranceViewModel model, Widget child) => AppScaffold( isShowAppBar: true, baseViewModel: model, + showHomeAppBarIcon: false, appBarTitle: TranslationBase.of(context).insuranceCards, description: TranslationBase.of(context).infoInsuranceCards, infoList: TranslationBase.of(context).infoInsuranceCardsPoints, imagesInfo: imagesInfo, + appBarIcons: [ + IconButton( + padding: EdgeInsets.zero, + icon: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + margin: EdgeInsets.only(right: 8), + padding: EdgeInsets.only(right: 4, left: 4), + child: Image.asset( + 'assets/images/medical/insurance_update_icon_.png', + height: SizeConfig.heightMultiplier * 5, + width: SizeConfig.heightMultiplier * 5, + ), + ), + onPressed: () { + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }, + ), + ], body: Container( - margin: EdgeInsets.only( - left: SizeConfig.screenWidth * 0.004, - right: SizeConfig.screenWidth * 0.004, - top: SizeConfig.screenWidth * 0.04), + margin: EdgeInsets.only(left: SizeConfig.screenWidth * 0.004, right: SizeConfig.screenWidth * 0.004, top: SizeConfig.screenWidth * 0.04), child: ListView.builder( itemCount: model.insurance == null ? 0 : model.insurance.length, itemBuilder: (BuildContext context, int index) { @@ -82,23 +97,16 @@ class _InsuranceCardState extends State { Container( padding: EdgeInsets.all(14), width: double.infinity, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - border: Border.all( - color: Colors.grey, width: 0.2), - borderRadius: - BorderRadius.all(Radius.circular(2)), - boxShadow: [ - BoxShadow( - color: Colors.white70, - ), - ]), + decoration: BoxDecoration(shape: BoxShape.rectangle, border: Border.all(color: Colors.grey, width: 0.2), borderRadius: BorderRadius.all(Radius.circular(2)), boxShadow: [ + BoxShadow( + color: Colors.white70, + ), + ]), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - TranslationBase.of(context).companyName + - model.insurance[index].companyName, + TranslationBase.of(context).companyName + model.insurance[index].companyName, fontSize: 20.0, fontWeight: FontWeight.w700, ), @@ -108,93 +116,46 @@ class _InsuranceCardState extends State { thickness: 0.5, ), Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context) - .category, - fontSize: 18.5), - Texts( - model.insurance[index] - .subCategoryDesc, - fontSize: 18.5) - ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [Texts(TranslationBase.of(context).category, fontSize: 18.5), Texts(model.insurance[index].subCategoryDesc, fontSize: 18.5)], ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts( - TranslationBase.of(context) - .expirationDate, - fontSize: 18.5), + Texts(TranslationBase.of(context).expirationDate, fontSize: 18.5), Texts( convertDateFormat( - model.insurance[index] - .cardValidTo, + model.insurance[index].cardValidTo, ), fontSize: 18.5), ], ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts( - TranslationBase.of(context) - .status + - ": ", - fontSize: 18.5), - model.insurance[index].isActive == - true - ? Texts( - TranslationBase.of(context) - .activeInsurence, - color: Colors.green, - fontWeight: FontWeight.w900, - fontSize: 17.9) - : Texts( - TranslationBase.of(context) - .notActive, - color: Colors.red, - fontWeight: FontWeight.w900, - fontSize: 17.9) + Texts(TranslationBase.of(context).status + ": ", fontSize: 18.5), + model.insurance[index].isActive == true + ? Texts(TranslationBase.of(context).activeInsurence, color: Colors.green, fontWeight: FontWeight.w900, fontSize: 17.9) + : Texts(TranslationBase.of(context).notActive, color: Colors.red, fontWeight: FontWeight.w900, fontSize: 17.9) ], ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context) - .patientCard, - fontSize: 18.5), - Texts( - model.insurance[index] - .patientCardID, - fontSize: 18.5) - ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [Texts(TranslationBase.of(context).patientCard, fontSize: 18.5), Texts(model.insurance[index].patientCardID, fontSize: 18.5)], ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context) - .policyNumber, - fontSize: 18.5, - ), - Texts( - model.insurance[index] - .insurancePolicyNumber, - fontSize: 18.5, - ) - ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Texts( + TranslationBase.of(context).policyNumber, + fontSize: 18.5, + ), + Texts( + model.insurance[index].insurancePolicyNumber, + fontSize: 18.5, + ) + ]), ], ), SizedBox( @@ -204,11 +165,8 @@ class _InsuranceCardState extends State { Container( color: Colors.transparent, child: SecondaryButton( - onTap: () => { - getDetails(model.insurance[index]) - }, - label: TranslationBase.of(context) - .seeDetails, + onTap: () => {getDetails(model.insurance[index])}, + label: TranslationBase.of(context).seeDetails, textColor: Colors.white, ), width: double.infinity, @@ -235,23 +193,16 @@ class _InsuranceCardState extends State { final startIndex = exDate.indexOf(start); final endIndex = exDate.indexOf(end, startIndex + start.length); - var date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(exDate.substring(startIndex + start.length, endIndex))); - String newDate = date.year.toString() + - "-" + - date.month.toString().padLeft(2, '0') + - "-" + - date.day.toString().padLeft(2, '0'); + var date = new DateTime.fromMillisecondsSinceEpoch(int.parse(exDate.substring(startIndex + start.length, endIndex))); + String newDate = date.year.toString() + "-" + date.month.toString().padLeft(2, '0') + "-" + date.day.toString().padLeft(2, '0'); return newDate.toString(); } getDetails(data) { GifLoaderDialogUtils.showMyDialog(context); - _insuranceCardService.getInsuranceDetails(data).then((value) => { - GifLoaderDialogUtils.hideDialog(context), - Navigator.push(context, - FadePage(page: InsuranceCardDetails(data: value[0]['CheckList']))) - }); + _insuranceCardService + .getInsuranceDetails(data) + .then((value) => {GifLoaderDialogUtils.hideDialog(context), Navigator.push(context, FadePage(page: InsuranceCardDetails(data: value[0]['CheckList'])))}); } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 1412adf6..64dd8c27 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -95,7 +95,8 @@ class AppScaffold extends StatelessWidget { Widget build(BuildContext context) { AppGlobal.context = context; return Scaffold( - backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, + backgroundColor: + backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, appBar: isShowAppBar ? appBar = AppBarWidget( appBarTitle: appBarTitle, @@ -112,19 +113,21 @@ class AppScaffold extends StatelessWidget { body: SafeArea( top: true, bottom: true, - child: (!Provider.of(context, listen: false).isLogin && isShowDecPage) - ? NotAutPage( - title: title ?? appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, - ) - : baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(context), - baseViewModel: baseViewModel, + child: + (!Provider.of(context, listen: false).isLogin && + isShowDecPage) + ? NotAutPage( + title: title ?? appBarTitle, + description: description, + infoList: infoList, + imagesInfo: imagesInfo, ) - : buildBodyWidget(context), + : baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(context), + baseViewModel: baseViewModel, + ) + : buildBodyWidget(context), ), floatingActionButton: floatingActionButton, ); @@ -135,12 +138,14 @@ class AppScaffold extends StatelessWidget { } buildBodyWidget(context) { - return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack( + children: [body, isHelp == true ? RobotIcon() : Container()]); } } class AppBarWidget extends StatefulWidget with PreferredSizeWidget { - final AuthenticatedUserObject authenticatedUserObject = locator(); + final AuthenticatedUserObject authenticatedUserObject = + locator(); final String appBarTitle; final bool showHomeAppBarIcon; @@ -188,12 +193,22 @@ class AppBarWidgetState extends State { ProjectViewModel projectViewModel = Provider.of(context); return AppBar( elevation: 0, - backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, + backgroundColor: widget.isPharmacy + ? Colors.green + : Theme.of(context).appBarTheme.color, textTheme: TextTheme( - headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), + headline6: TextStyle( + color: Theme.of(context).textTheme.headline1.color, + fontWeight: FontWeight.bold), ), - title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, - style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), + title: Text( + widget.authenticatedUserObject.isLogin || !widget.isShowDecPage + ? widget.appBarTitle.toUpperCase() + : TranslationBase.of(context).serviceInformationTitle, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context).textTheme.headline1.color, + fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { return ArrowBack(); @@ -203,7 +218,9 @@ class AppBarWidgetState extends State { actions: [ (widget.isPharmacy && widget.showPharmacyCart) ? IconButton( - icon: Badge(badgeContent: Text(badgeText), child: Icon(Icons.shopping_cart)), + icon: Badge( + badgeContent: Text(badgeText), + child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { Navigator.of(context).popUntil(ModalRoute.withName('/')); @@ -215,7 +232,10 @@ class AppBarWidgetState extends State { position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( badgeText, - style: TextStyle(fontSize: 9, color: Colors.white, fontWeight: FontWeight.normal), + style: TextStyle( + fontSize: 9, + color: Colors.white, + fontWeight: FontWeight.normal), ), child: Icon(Icons.shopping_cart)), color: Colors.white, @@ -229,7 +249,10 @@ class AppBarWidgetState extends State { icon: Icon(FontAwesomeIcons.home), color: Colors.white, onPressed: () { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (context) => LandingPage()), + (Route r) => false); // Cart Click Event if (_onCartClick != null) _onCartClick(); @@ -293,11 +316,18 @@ class _RobotIcon extends State { ], ), child: TyperAnimatedTextKit( - text: Provider.of(context, listen: false).isArabic == true + text: Provider.of(context, + listen: false) + .isArabic == + true ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file.", - textLength: Provider.of(context, listen: false).isArabic == true - ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي.".length + textLength: Provider.of(context, + listen: false) + .isArabic == + true + ? "هذه الخدمة تم تصميمها لتتمكن من ربط الملفات الطبية للعائلة بملفك الطبي حتى تتمكن من إدارة سجلاتهم عن طريق تسجيل الدخول إلى ملفك الطبي." + .length : "Through this service, you will be able to link your family medical files to your medical file so that you can manage their records by login to your medical file." .length)) : Container(), From e41040b1b96734bbb32778520dbbd39c14ceac84 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 21 Jun 2021 15:27:58 +0300 Subject: [PATCH 3/7] PAP-675 fixed, H2O Week chart vales from -1 to 1. --- lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart index a89ec799..972891a9 100644 --- a/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart @@ -96,6 +96,8 @@ class H2OViewModel extends BaseViewModel { id: 'Global Revenue', domainFn: (ChartSeries sales, _) => sales.y, measureFn: (ChartSeries sales, _) => sales.x, + measureLowerBoundFn: (ChartSeries sales, _) => sales.x - 1, + measureUpperBoundFn: (ChartSeries sales, _) => sales.x + 1, data: globalData, ), ]; From 1f01f40ad81caa0fcbbbdb9d6e0364a6bbf9fc1e Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 22 Jun 2021 10:07:55 +0300 Subject: [PATCH 4/7] PAP-681 fixed, H2O Unit changing & reflection. --- lib/config/localized_values.dart | 2 +- lib/config/shared_pref_kay.dart | 1 + .../h2o/h20_setting.dart | 30 ++--- .../AlHabibMedicalService/h2o/today_page.dart | 122 +++++++++++------- 4 files changed, 91 insertions(+), 64 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index e5f21342..815cbd3f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1808,7 +1808,7 @@ const Map localizedValues = { "drinking": {"en": "Drinkning", "ar": "الشرب"}, "remaining": {"en": "Remaining", "ar": "المتبقي"}, "taken": {"en": "Taken", "ar": " مأخوذ"}, - "ml": {"en": "ml", "ar": "مل"}, + "ml": {"en": "ML", "ar": "مل"}, "l": {"en": "L", "ar": "لتر"}, "custom-label": {"en": "Enter amount", "ar": "أدخل كمية الماء"}, "custom-label-in-litres": { diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index caada21f..6e761991 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -29,3 +29,4 @@ const BLOOD_TYPE = 'blood-type'; const NOTIFICATION_COUNT = 'notification-count'; const PHARMACY_SELECTED_ADDRESS = 'selected-address'; const PHARMACY_AUTORZIE_TOKEN = 'PHARMACY_AUTORZIE_TOKEN'; +const H2O_UNIT = 'H2O_UNIT'; diff --git a/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart b/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart index 4295558a..4acc7eaf 100644 --- a/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart +++ b/lib/pages/AlHabibMedicalService/h2o/h20_setting.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/H2O/user_detail_model.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/H2O_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; @@ -13,6 +14,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'Dialog/setting_page_radio_button_list_dialog.dart'; @@ -31,7 +33,7 @@ class _H2oSettingState extends State { TextEditingController _nameController = TextEditingController(); TextEditingController _heightController = TextEditingController(); TextEditingController _weightController = TextEditingController(); - bool _isUnitML = false; + bool _isUnitML = true; bool _isGenderMale = false; bool _isHeightCM = false; bool _isWeightKG = false; @@ -61,6 +63,14 @@ class _H2oSettingState extends State { _isGenderMale = _userDetailModel.gender == "M" ? true : false; _dobDate = DateUtil.convertStringToDate(_userDetailModel.dOB); _selectedActiveLevel = _userDetailModel.activityID ?? 1; + readPrefs(); + } + + SharedPreferences prefs; + void readPrefs() async { + prefs = await SharedPreferences.getInstance(); + _isUnitML = (prefs.getString(H2O_UNIT) ?? "ml") == "ml" ? true : false; + setState(() {}); } @override @@ -68,19 +78,9 @@ class _H2oSettingState extends State { // TODO: implement didChangeDependencies super.didChangeDependencies(); - _activityLevelListEng = [ - TranslationBase.of(context).notActive, - TranslationBase.of(context).lightActive, - TranslationBase.of(context).modActive, - TranslationBase.of(context).active - ]; + _activityLevelListEng = [TranslationBase.of(context).notActive, TranslationBase.of(context).lightActive, TranslationBase.of(context).modActive, TranslationBase.of(context).active]; - _remindedTimeListEng = [ - "1 ${TranslationBase.of(context).time}", - "2 ${TranslationBase.of(context).times}", - "3 ${TranslationBase.of(context).times}", - "4 ${TranslationBase.of(context).times}" - ]; + _remindedTimeListEng = ["1 ${TranslationBase.of(context).time}", "2 ${TranslationBase.of(context).times}", "3 ${TranslationBase.of(context).times}", "4 ${TranslationBase.of(context).times}"]; } @override @@ -339,8 +339,7 @@ class _H2oSettingState extends State { ]); } - Widget _commonSlidersRow( - _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange) { + Widget _commonSlidersRow(_controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange) { return Container( margin: EdgeInsets.only(top: 6), padding: EdgeInsets.all(6), @@ -451,6 +450,7 @@ class _H2oSettingState extends State { _userDetailModel.dOB = tempDate; _userDetailModel.activityID = _selectedActiveLevel; GifLoaderDialogUtils.showMyDialog(context); + await prefs.setString(H2O_UNIT, _isUnitML ? "ml" : "l"); await widget.viewModel.updateUserDetail(_userDetailModel, (tag) { if (tag) { AppToast.showSuccessToast(message: TranslationBase.of(context).success); diff --git a/lib/pages/AlHabibMedicalService/h2o/today_page.dart b/lib/pages/AlHabibMedicalService/h2o/today_page.dart index 33383287..e52d2732 100644 --- a/lib/pages/AlHabibMedicalService/h2o/today_page.dart +++ b/lib/pages/AlHabibMedicalService/h2o/today_page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/widgets/h20_floating_action_button.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; @@ -7,8 +8,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:percent_indicator/circular_percent_indicator.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class TodayPage extends StatelessWidget { + Future readPrefs() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + return (prefs.getString(H2O_UNIT) ?? "ml") == "ml" ? true : false; + } + @override Widget build(BuildContext context) { return BaseView( @@ -34,55 +41,74 @@ class TodayPage extends StatelessWidget { : (model.userProgressData.percentageConsumed / 100) >= 1 ? 1 : (model.userProgressData.percentageConsumed / 100), - //, center: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // SizedBox( - // height: 40, - // ), - Text( - TranslationBase.of(context).consumed, - style: TextStyle(fontSize: 16.0), - ), - SizedBox( - height: 4, - ), - Text( - model.userProgressData == null - ? "0.0" - : model.userProgressData.quantityConsumed.toString() + TranslationBase.of(context).ml, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.0, color: HexColor("#60BCF9")), - ), - SizedBox( - height: 4, - ), - SizedBox( - height: 5, - width: 50, - child: Container(), - ), - SizedBox( - height: 4, - ), - Text( - TranslationBase.of(context).remaining, - style: TextStyle(fontSize: 16.0), - ), - SizedBox( - height: 4, - ), - Text( - model.userProgressData == null - ? "0.0" - : (model.userProgressData.quantityLimit - model.userProgressData.quantityConsumed) < 0 - ? "0 ${TranslationBase.of(context).ml}" - : (model.userProgressData.quantityLimit - model.userProgressData.quantityConsumed).toString() + - ' ${TranslationBase.of(context).ml}', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.0), - ), - ], + child: FutureBuilder( + future: readPrefs(), + builder: (context, data) { + var isUnitML = true; + var unit; + if (data.connectionState == ConnectionState.done) { + isUnitML = data.data; + } + if (isUnitML) { + unit = TranslationBase.of(context).ml; + } else { + unit = TranslationBase.of(context).l; + } + var totalH2O = model?.userProgressData?.quantityLimit ?? 0.0; + var consumedH2O = model?.userProgressData?.quantityConsumed ?? 0.0; + if (!isUnitML) { + totalH2O = totalH2O / 1000; + consumedH2O = consumedH2O / 1000; + } + var remainingH2O = totalH2O - consumedH2O; + + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + // SizedBox( + // height: 40, + // ), + Text( + TranslationBase.of(context).consumed, + style: TextStyle(fontSize: 16.0), + ), + SizedBox( + height: 4, + ), + Text( + model.userProgressData == null ? "0.0" : "$consumedH2O $unit", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.0, color: HexColor("#60BCF9")), + ), + SizedBox( + height: 4, + ), + SizedBox( + height: 5, + width: 50, + child: Container(), + ), + SizedBox( + height: 4, + ), + Text( + TranslationBase.of(context).remaining, + style: TextStyle(fontSize: 16.0), + ), + SizedBox( + height: 4, + ), + Text( + model.userProgressData == null + ? "0.0" + : (remainingH2O) < 0 + ? "0 $unit" + : '$remainingH2O $unit', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.0), + ), + ], + ); + }, ), ), circularStrokeCap: CircularStrokeCap.butt, From d6566d4abfe239a654bfeaf8f8a7d1501410167c Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 22 Jun 2021 11:46:03 +0300 Subject: [PATCH 5/7] PAP-678 fixed, month & days in axis are aligned now. --- lib/pages/AlHabibMedicalService/h2o/month_page.dart | 7 +++++-- lib/pages/AlHabibMedicalService/h2o/week_page.dart | 5 ++++- lib/widgets/charts/app_bar_chart.dart | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/h2o/month_page.dart b/lib/pages/AlHabibMedicalService/h2o/month_page.dart index e0118495..8867fb77 100644 --- a/lib/pages/AlHabibMedicalService/h2o/month_page.dart +++ b/lib/pages/AlHabibMedicalService/h2o/month_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_bar_chart.dart'; @@ -8,15 +9,17 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class MonthPage extends StatelessWidget { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getUserProgressForMonthData(), builder: (_, model, widget) => AppScaffold( isShowAppBar: false, - appBarTitle: TranslationBase.of(context).h2o, + appBarTitle: TranslationBase.of(context).h2o, baseViewModel: model, body: Padding( padding: EdgeInsets.all(8.0), @@ -46,7 +49,7 @@ class MonthPage extends StatelessWidget { ], ), // SizedBox(height: 8), - AppBarChart(seriesList: model.userProgressForMonthDataSeries), + AppBarChart(seriesList: model.userProgressForMonthDataSeries, isArabic: projectViewModel.isArabic), ], ), ), diff --git a/lib/pages/AlHabibMedicalService/h2o/week_page.dart b/lib/pages/AlHabibMedicalService/h2o/week_page.dart index 34e365e6..6f4423b2 100644 --- a/lib/pages/AlHabibMedicalService/h2o/week_page.dart +++ b/lib/pages/AlHabibMedicalService/h2o/week_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_bar_chart.dart'; @@ -8,10 +9,12 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class WeekPage extends StatelessWidget { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getUserProgressForWeekData(), builder: (_, model, widget) => AppScaffold( @@ -46,7 +49,7 @@ class WeekPage extends StatelessWidget { ], ), // SizedBox(height: 8), - AppBarChart(seriesList: model.userProgressForWeekDataSeries), + AppBarChart(seriesList: model.userProgressForWeekDataSeries,isArabic: projectViewModel.isArabic), ], ), ), diff --git a/lib/widgets/charts/app_bar_chart.dart b/lib/widgets/charts/app_bar_chart.dart index 439d5ae9..818de33f 100644 --- a/lib/widgets/charts/app_bar_chart.dart +++ b/lib/widgets/charts/app_bar_chart.dart @@ -4,10 +4,12 @@ import 'package:charts_flutter/flutter.dart' as charts; class AppBarChart extends StatelessWidget { const AppBarChart({ Key key, + @required this.isArabic, @required this.seriesList, }) : super(key: key); final List seriesList; + final bool isArabic; @override Widget build(BuildContext context) { @@ -19,7 +21,7 @@ class AppBarChart extends StatelessWidget { // animate: animate, domainAxis: charts.OrdinalAxisSpec( renderSpec: charts.GridlineRendererSpec( - labelAnchor: charts.TickLabelAnchor.after, + labelAnchor: isArabic ? charts.TickLabelAnchor.before : charts.TickLabelAnchor.after, labelRotation: -30, labelOffsetFromAxisPx: 30, labelOffsetFromTickPx: 15, From b7fbee32521c614a294a58a08c3cf47ea1174dcc Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 23 Jun 2021 10:06:43 +0300 Subject: [PATCH 6/7] improvements --- .../AlHabibMedicalService/H2O_view_model.dart | 13 +++++++++++-- lib/pages/AlHabibMedicalService/h2o/today_page.dart | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart index 972891a9..9d163a27 100644 --- a/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/H2O_view_model.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:charts_flutter/flutter.dart' as charts; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import '../../../locator.dart'; +import 'dart:math' as math; class H2OViewModel extends BaseViewModel { H2OService _h2OService = locator(); @@ -91,13 +92,21 @@ class H2OViewModel extends BaseViewModel { _h2OService.userProgressForWeekDataList.forEach((UserProgressForWeekDataModel data) { globalData.add(new ChartSeries(data.dayName, data.percentageConsumed)); }); + Iterable minMaxList = globalData.map((e) => e.x).toList(); + int maxValue = minMaxList.isEmpty ? 0 : minMaxList.reduce(math.max); + int minValue = minMaxList.isEmpty ? 0 : minMaxList.reduce(math.min); + + if (maxValue == 0 && minValue == 0) { + maxValue = 1; + minValue = -1; + } return [ new charts.Series( id: 'Global Revenue', domainFn: (ChartSeries sales, _) => sales.y, measureFn: (ChartSeries sales, _) => sales.x, - measureLowerBoundFn: (ChartSeries sales, _) => sales.x - 1, - measureUpperBoundFn: (ChartSeries sales, _) => sales.x + 1, + measureLowerBoundFn: (ChartSeries sales, _) => minValue, + measureUpperBoundFn: (ChartSeries sales, _) => maxValue, data: globalData, ), ]; diff --git a/lib/pages/AlHabibMedicalService/h2o/today_page.dart b/lib/pages/AlHabibMedicalService/h2o/today_page.dart index e52d2732..03d11f50 100644 --- a/lib/pages/AlHabibMedicalService/h2o/today_page.dart +++ b/lib/pages/AlHabibMedicalService/h2o/today_page.dart @@ -46,7 +46,7 @@ class TodayPage extends StatelessWidget { future: readPrefs(), builder: (context, data) { var isUnitML = true; - var unit; + String unit; if (data.connectionState == ConnectionState.done) { isUnitML = data.data; } @@ -55,6 +55,7 @@ class TodayPage extends StatelessWidget { } else { unit = TranslationBase.of(context).l; } + unit = unit.toLowerCase(); var totalH2O = model?.userProgressData?.quantityLimit ?? 0.0; var consumedH2O = model?.userProgressData?.quantityConsumed ?? 0.0; if (!isUnitML) { From 3128810fb0ebf446d84b3451051ab5ad99c5682b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 23 Jun 2021 15:10:09 +0300 Subject: [PATCH 7/7] improvements. --- lib/core/service/client/base_app_client.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index f12ef3da..03f12df1 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -68,7 +68,7 @@ class BaseAppClient { body['VersionID'] = VERSION_ID; body['Channel'] = CHANNEL; - body['LanguageID'] = languageID == 'ar' ? 1 : 2; + body['LanguageID'] = (languageID == 'ar' ? 1 : 2); body['IPAdress'] = IP_ADDRESS; body['generalid'] = GENERAL_ID;