From 0e054429ef65ae682360353363015db65615f8bd Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 13 Jul 2023 16:26:35 +0300 Subject: [PATCH] Meal Plan implementation completed --- lib/config/config.dart | 5 +- lib/config/localized_values.dart | 2 + lib/core/service/client/base_app_client.dart | 4 +- ...et_meal_items_schedule_response_model.dart | 5 + .../InPatientServices/birth_notification.dart | 34 +- lib/pages/InPatientServices/meal_plan.dart | 697 +++++++++++------- .../clinic_services/get_clinic_service.dart | 45 +- lib/uitl/translations_delegate_base.dart | 2 + lib/uitl/utils_new.dart | 102 +-- 9 files changed, 519 insertions(+), 377 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index cb4bb903..f5c991ab 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -20,8 +20,8 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:3334/'; -// var BASE_URL = 'https://uat.hmgwebservices.com/'; -var BASE_URL = 'https://hmgwebservices.com/'; + var BASE_URL = 'https://uat.hmgwebservices.com/'; +// var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -611,6 +611,7 @@ var GET_ADMITTED_PATIENTS = 'Services/MOP.svc/REST/GetAdmittedPatients'; var GET_CURRENT_WEEKID_WEEKDAY = 'Services/MOP.svc/REST/GetCurrentWeekAndDayHMGMP'; var GET_MEALS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetMealsOfScheduleID_Mobile'; var GET_MEAL_ITEMS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetDefaultItemsOfScheduleID'; +var PLACE_MEAL_PLAN_ORDER = 'Services/MOP.svc/REST/UpdateOrMakeNewOrder'; class AppGlobal { static var context; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 65b2f90b..510dd4a4 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1925,4 +1925,6 @@ const Map localizedValues = { }, "birthNotificationNotes2": {"en": "Non Saudis: Provide copy of iqama or copy of the passport.", "ar": "لغير السعوديين : إرفاق صورة الإقامة آأو جواز السفر"}, "birthNotificationNotes3": {"en": "For Residents without identification card: Provide marriage contract.", "ar": "للمواطنين الغير حاملين لبطاقة الأحوال : إرفاق صورة من عقد الزواج برقم الحاسب"}, + "placeOrder": {"en": "Place Order", "ar": "مكان الامر"}, + "isFasting": {"en": "Are you fasting?", "ar": "هل أنت صائم؟"}, }; \ No newline at end of file diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 08cb2b36..7b8874d3 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -152,8 +152,8 @@ class BaseAppClient { // body['PatientID'] = 2480363; //3844083 // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 3649238; //3844083 - // body['AdmissionNo'] = 2023000038; //3844083 + // body['PatientID'] = 3649689; //3844083 + // body['AdmissionNo'] = 2023000040; //3844083 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart b/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart index 57ba4cb8..c55d716d 100644 --- a/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart +++ b/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart @@ -1,3 +1,5 @@ +import 'package:flutter/material.dart'; + class GetMealItemsScheduleResponseModel { int itemID; String description; @@ -63,6 +65,9 @@ class GetMealItemsScheduleResponseModelList { String filterName = ""; List getMealItemsScheduleResponseModelList = []; + // int selectedItemID = 0; + final ValueNotifier selectedItemID = ValueNotifier(0); + GetMealItemsScheduleResponseModelList({this.filterName, GetMealItemsScheduleResponseModel getMealItemsScheduleResponseModel}) { getMealItemsScheduleResponseModelList.add(getMealItemsScheduleResponseModel); } diff --git a/lib/pages/InPatientServices/birth_notification.dart b/lib/pages/InPatientServices/birth_notification.dart index 3c4d43f9..c5f78af9 100644 --- a/lib/pages/InPatientServices/birth_notification.dart +++ b/lib/pages/InPatientServices/birth_notification.dart @@ -168,20 +168,25 @@ class _BirthNotificationState extends State { // color: CustomColors.accentColor, // disabledColor: CustomColors.grey2, // ), - DefaultButton( - TranslationBase.of(context).submit, - (fatherNameAR.text.isEmpty || fatherName.text.isEmpty || babyNameAR.text.isEmpty || babyName.text.isEmpty || images.isEmpty) - ? null - : () { - submitBirthNotification(); - }, - color: CustomColors.accentColor, - disabledColor: CustomColors.grey2, - ), ], ), ), ), + bottomSheet: Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(20), + child: DefaultButton( + TranslationBase.of(context).submit, + (fatherNameAR.text.isEmpty || fatherName.text.isEmpty || babyNameAR.text.isEmpty || babyName.text.isEmpty || images.isEmpty) + ? null + : () { + submitBirthNotification(); + }, + color: CustomColors.accentColor, + disabledColor: CustomColors.grey2, + ), + ), ); } @@ -210,15 +215,6 @@ class _BirthNotificationState extends State { images.clear(); images.add(image); setState(() {}); - // GifLoaderDialogUtils.showMyDialog(context); - // await model.uploadInsuranceCard(context, patientIdentificationID: patientIdentificationID, patientID: patientID, image: image); - // GifLoaderDialogUtils.hideDialog(context); - // if (model.state == ViewState.ErrorLocal || model.state == ViewState.Error) { - // AppToast.showErrorToast(message: model.error); - // } else { - // AppToast.showSuccessToast(message: TranslationBase.of(context).requestSent); - // } - // Navigator.pop(context); }, isBirthNotification: true, ), diff --git a/lib/pages/InPatientServices/meal_plan.dart b/lib/pages/InPatientServices/meal_plan.dart index 2af39b61..d69e1149 100644 --- a/lib/pages/InPatientServices/meal_plan.dart +++ b/lib/pages/InPatientServices/meal_plan.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -39,6 +40,11 @@ class _MealPlanPageState extends State { int currentDay = 0; int currentWeek = 0; + int selectedMealScheduleID = 0; + + final ValueNotifier isFasting = ValueNotifier(false); + bool isFastingVal = false; + @override void initState() { super.initState(); @@ -59,298 +65,405 @@ class _MealPlanPageState extends State { body: SingleChildScrollView( child: Padding( padding: EdgeInsets.all(21.0), - child: Column( - children: [ - Container( - decoration: containerRadius(getMealsScheduleResponseModelList[0].isShow ? Colors.white : Colors.grey[300], 12), - child: AppExpandableNotifier( - title: "Breakfast TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[0].tATTime), - isTitleSingleLine: false, - widgetColor: Colors.transparent, - isDisabled: !getMealsScheduleResponseModelList[0].isShow, - bodyWidget: Column( - children: [ - getDivider(), - ListView.separated( - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - return Container( - padding: EdgeInsets.all(21.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(_getMealItemsScheduleResponseModelBreakfast[index].filterName, - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), - SizedBox( - height: 12.0, - ), - ListView.separated( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index2) { - return Container( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LargeAvatar( - name: _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].description, - url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", - width: 60, - height: 60, - radius: 5, - disableProfileView: true, - ), - SizedBox(width: 11), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: getMealsScheduleResponseModelList.length != 0 + ? Column( + children: [ + Container( + decoration: containerRadius((getMealsScheduleResponseModelList[0].isShow) ? Colors.white : Colors.grey[300], 12), + child: AppExpandableNotifier( + title: "Breakfast TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[0].tATTime), + isTitleSingleLine: false, + widgetColor: Colors.transparent, + isExpand: getMealsScheduleResponseModelList[0].isShow, + isDisabled: !getMealsScheduleResponseModelList[0].isShow, + bodyWidget: Column( + children: [ + getDivider(), + ListView.separated( + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return Container( + padding: EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_getMealItemsScheduleResponseModelBreakfast[index].filterName, + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), + SizedBox( + height: 12.0, + ), + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index2) { + return Container( + child: Row( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - MyRichText( - "", - projectViewModel.isArabic - ? _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].descriptionN - : _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].description, - projectViewModel.isArabic), + ValueListenableBuilder( + valueListenable: _getMealItemsScheduleResponseModelBreakfast[index].selectedItemID, + builder: (context, val, child) { + return Radio( + value: _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].itemID, + groupValue: _getMealItemsScheduleResponseModelBreakfast[index].selectedItemID.value, + activeColor: Colors.red[800], + onChanged: (value) { + _getMealItemsScheduleResponseModelBreakfast[index].selectedItemID.value = value; + }, + ); + }), + LargeAvatar( + name: _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].description, + url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", + width: 60, + height: 60, + radius: 5, + disableProfileView: true, + ), + SizedBox(width: 11), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + MyRichText( + "", + projectViewModel.isArabic + ? _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].descriptionN + : _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList[index2].description, + projectViewModel.isArabic), + ], + ), + ), ], ), - ), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.all(16.0), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList.length), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelBreakfast.length), - ], - ), - ), - ), - mHeight(21), - Container( - decoration: containerRadius(getMealsScheduleResponseModelList[1].isShow ? Colors.white : Colors.grey[300], 12), - child: AppExpandableNotifier( - title: "Lunch TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[1].tATTime), - isTitleSingleLine: false, - widgetColor: Colors.transparent, - isDisabled: !getMealsScheduleResponseModelList[1].isShow, - bodyWidget: Column( - children: [ - getDivider(), - ListView.separated( - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - return Container( - padding: EdgeInsets.all(21.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(_getMealItemsScheduleResponseModelLunch[index].filterName, - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), - SizedBox( - height: 12.0, - ), - ListView.separated( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index2) { - return Container( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LargeAvatar( - name: _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].description, - url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", - width: 60, - height: 60, - radius: 5, - disableProfileView: true, - ), - SizedBox(width: 11), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.all(16.0), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelBreakfast[index].getMealItemsScheduleResponseModelList.length), + ], + ), + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelBreakfast.length), + ], + ), + ), + ), + mHeight(21), + Container( + decoration: containerRadius(getMealsScheduleResponseModelList[1].isShow ? Colors.white : Colors.grey[300], 12), + child: AppExpandableNotifier( + title: "Lunch TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[1].tATTime), + isTitleSingleLine: false, + widgetColor: Colors.transparent, + isExpand: getMealsScheduleResponseModelList[1].isShow, + isDisabled: !getMealsScheduleResponseModelList[1].isShow, + bodyWidget: Column( + children: [ + getDivider(), + ListView.separated( + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return Container( + padding: EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_getMealItemsScheduleResponseModelLunch[index].filterName, + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), + SizedBox( + height: 12.0, + ), + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index2) { + return Container( + child: Row( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - MyRichText( - "", - projectViewModel.isArabic - ? _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].descriptionN - : _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].description, - projectViewModel.isArabic), + ValueListenableBuilder( + valueListenable: _getMealItemsScheduleResponseModelLunch[index].selectedItemID, + builder: (context, val, child) { + return Radio( + value: _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].itemID, + groupValue: _getMealItemsScheduleResponseModelLunch[index].selectedItemID.value, + activeColor: Colors.red[800], + onChanged: (value) { + _getMealItemsScheduleResponseModelLunch[index].selectedItemID.value = value; + }, + ); + }), + LargeAvatar( + name: _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].description, + url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", + width: 60, + height: 60, + radius: 5, + disableProfileView: true, + ), + SizedBox(width: 11), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + MyRichText( + "", + projectViewModel.isArabic + ? _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].descriptionN + : _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList[index2].description, + projectViewModel.isArabic), + ], + ), + ), ], ), - ), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.all(16.0), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList.length), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelLunch.length), - ], - ), - ), - ), - mHeight(21), - Container( - decoration: containerRadius(getMealsScheduleResponseModelList[2].isShow ? Colors.white : Colors.grey[300], 12), - child: AppExpandableNotifier( - title: "Dinner TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[2].tATTime), - isTitleSingleLine: false, - widgetColor: Colors.transparent, - isDisabled: !getMealsScheduleResponseModelList[2].isShow, - bodyWidget: Column( - children: [ - getDivider(), - ListView.separated( - physics: BouncingScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - return Container( - padding: EdgeInsets.all(21.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(_getMealItemsScheduleResponseModelDinner[index].filterName, - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), - SizedBox( - height: 12.0, - ), - ListView.separated( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index2) { - return Container( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Radio( - value: index, - groupValue: _getMealItemsScheduleResponseModelDinner[index].filterName, - activeColor: Colors.red[800], - onChanged: (value) { - // setState(() { - // selected = value; - // parameterCode = model.askDoctorReqTypes[index].parameterCode; - // }); - }, - ), - LargeAvatar( - name: _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].description, - url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", - width: 60, - height: 60, - radius: 5, - disableProfileView: true, - ), - SizedBox(width: 11), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.all(16.0), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelLunch[index].getMealItemsScheduleResponseModelList.length), + ], + ), + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelLunch.length), + ], + ), + ), + ), + mHeight(21), + Container( + decoration: containerRadius(getMealsScheduleResponseModelList[2].isShow ? Colors.white : Colors.grey[300], 12), + child: AppExpandableNotifier( + title: "Dinner TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[2].tATTime), + isTitleSingleLine: false, + widgetColor: Colors.transparent, + isExpand: getMealsScheduleResponseModelList[2].isShow, + isDisabled: !getMealsScheduleResponseModelList[2].isShow, + bodyWidget: Column( + children: [ + getDivider(), + ListView.separated( + physics: BouncingScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return Container( + padding: EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(_getMealItemsScheduleResponseModelDinner[index].filterName, + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18.0, letterSpacing: -0.64, color: CustomColors.darkGrey)), + SizedBox( + height: 12.0, + ), + ListView.separated( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index2) { + return Container( + child: Row( mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - MyRichText( - "", - projectViewModel.isArabic - ? _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].descriptionN - : _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].description, - projectViewModel.isArabic), + ValueListenableBuilder( + valueListenable: _getMealItemsScheduleResponseModelDinner[index].selectedItemID, + builder: (context, val, child) { + return Radio( + value: _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].itemID, + groupValue: _getMealItemsScheduleResponseModelDinner[index].selectedItemID.value, + activeColor: Colors.red[800], + onChanged: (value) { + _getMealItemsScheduleResponseModelDinner[index].selectedItemID.value = value; + }, + ); + }), + LargeAvatar( + name: _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].description, + url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg", + width: 60, + height: 60, + radius: 5, + disableProfileView: true, + ), + SizedBox(width: 11), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + MyRichText( + "", + projectViewModel.isArabic + ? _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].descriptionN + : _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList[index2].description, + projectViewModel.isArabic), + ], + ), + ), ], ), - ), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.all(16.0), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList.length), - ], - ), - ); - }, - separatorBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Divider( - height: 1.5, - thickness: 1.0, - color: Colors.grey.shade200, - ), - ); - }, - itemCount: _getMealItemsScheduleResponseModelDinner.length), - ], + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.all(16.0), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelDinner[index].getMealItemsScheduleResponseModelList.length), + ], + ), + ); + }, + separatorBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Divider( + height: 1.5, + thickness: 1.0, + color: Colors.grey.shade200, + ), + ); + }, + itemCount: _getMealItemsScheduleResponseModelDinner.length), + ], + ), + ), + ), + ], + ) + : Container(), + ), + ), + bottomSheet: Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + ValueListenableBuilder( + valueListenable: isFasting, + builder: (context, val, child) { + return Checkbox( + onChanged: (bool value) { + isFasting.value = value; + isFastingVal = value; + }, + value: isFastingVal, + activeColor: Color(0xFFc5272d), + ); + }), + Text( + TranslationBase.of(context).isFasting, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.48, ), ), - ), - ], - ), + ], + ), + mHeight(12), + DefaultButton( + TranslationBase.of(context).placeOrder, + () { + placeOrder(); + }, + color: Color(0xff359846), + disabledColor: Colors.grey, + ), + ], ), ), ); } + void placeOrder() { + List selectedItemIDs = []; + + if (_getMealItemsScheduleResponseModelBreakfast.isNotEmpty) { + _getMealItemsScheduleResponseModelBreakfast.forEach((element) { + selectedItemIDs.add(element.selectedItemID.value.toString()); + }); + } + + if (_getMealItemsScheduleResponseModelLunch.isNotEmpty) { + _getMealItemsScheduleResponseModelLunch.forEach((element) { + selectedItemIDs.add(element.selectedItemID.value.toString()); + }); + } + + if (_getMealItemsScheduleResponseModelDinner.isNotEmpty) { + _getMealItemsScheduleResponseModelDinner.forEach((element) { + selectedItemIDs.add(element.selectedItemID.value.toString()); + }); + } + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .placeMealPlanOrder(getAdmittedPatientsResponseModel.projectID, selectedMealScheduleID, selectedItemIDs.join(","), projectViewModel.user.patientID, + getAdmittedPatientsResponseModel.admissionNo, getAdmittedPatientsResponseModel.isHasCompanion, isFastingVal, context) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showSuccessToast(message: "Your meal order has been received successfully"); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + Widget getDivider() { return Padding( padding: EdgeInsets.only(left: 15, right: 15), @@ -405,9 +518,18 @@ class _MealPlanPageState extends State { res['List_MOP_MealsOfScheduleID_Mobile'].forEach((scheduleItem) { getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(scheduleItem)); }); - if (getMealsScheduleResponseModelList[0].isShow) getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[0].scheduleID, 1); - if (getMealsScheduleResponseModelList[1].isShow) getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[1].scheduleID, 2); - if (getMealsScheduleResponseModelList[2].isShow) getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[2].scheduleID, 3); + if (getMealsScheduleResponseModelList[0].isShow) { + selectedMealScheduleID = getMealsScheduleResponseModelList[0].scheduleID; + getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[0].scheduleID, 1); + } + if (getMealsScheduleResponseModelList[1].isShow) { + selectedMealScheduleID = getMealsScheduleResponseModelList[1].scheduleID; + getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[1].scheduleID, 2); + } + if (getMealsScheduleResponseModelList[2].isShow) { + selectedMealScheduleID = getMealsScheduleResponseModelList[2].scheduleID; + getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[2].scheduleID, 3); + } } else { AppToast.showErrorToast(message: "No meal schedule found for admitted patient"); } @@ -463,6 +585,14 @@ class _MealPlanPageState extends State { .add(GetMealItemsScheduleResponseModelList(filterName: projectViewModel.isArabic ? element.categoryDescriptionN : element.categoryDescription, getMealItemsScheduleResponseModel: element)); } }); + + _getMealItemsScheduleResponseModelBreakfast.forEach((element) { + element.getMealItemsScheduleResponseModelList.forEach((elementInner) { + if (elementInner.isDefault) { + element.selectedItemID.value = elementInner.itemID; + } + }); + }); } void sortMealsByCategoryLunch() { @@ -477,6 +607,14 @@ class _MealPlanPageState extends State { .add(GetMealItemsScheduleResponseModelList(filterName: projectViewModel.isArabic ? element.categoryDescriptionN : element.categoryDescription, getMealItemsScheduleResponseModel: element)); } }); + + _getMealItemsScheduleResponseModelLunch.forEach((element) { + element.getMealItemsScheduleResponseModelList.forEach((elementInner) { + if (elementInner.isDefault) { + element.selectedItemID.value = elementInner.itemID; + } + }); + }); } void sortMealsByCategoryDinner() { @@ -491,5 +629,12 @@ class _MealPlanPageState extends State { .add(GetMealItemsScheduleResponseModelList(filterName: projectViewModel.isArabic ? element.categoryDescriptionN : element.categoryDescription, getMealItemsScheduleResponseModel: element)); } }); + _getMealItemsScheduleResponseModelDinner.forEach((element) { + element.getMealItemsScheduleResponseModelList.forEach((elementInner) { + if (elementInner.isDefault) { + element.selectedItemID.value = elementInner.itemID; + } + }); + }); } } diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 5339662a..69e99e53 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_info import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:flutter/material.dart'; class ClinicListService extends BaseService { @@ -277,14 +278,7 @@ class ClinicListService extends BaseService { Future getAdmittedPatientDetails(int patientID, int projectID, int admissionNo, int buildingID, int floorID, int nursingStationID, context) async { Map request; - request = { - "ProjectID": projectID, - "PatientID" : patientID, - "AdmissionNo": admissionNo, - "BuildingID" : buildingID, - "FloorID" : floorID, - "NursingStationID": nursingStationID - }; + request = {"ProjectID": projectID, "PatientID": patientID, "AdmissionNo": admissionNo, "BuildingID": buildingID, "FloorID": floorID, "NursingStationID": nursingStationID}; dynamic localRes; @@ -311,8 +305,8 @@ class ClinicListService extends BaseService { request = { "ProjectID": projectID, "AdmissionNo": admissionNo, - "BuildingID" : 0, - "FloorID" : 0, + "BuildingID": 0, + "FloorID": 0, "NursingStationID": 0, "DietType": dietType, "WeekID": weekID, @@ -346,4 +340,35 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future placeMealPlanOrder(int projectID, int scheduleID, String itemIDList, int patientID, int admissionNo, bool isCompanion, bool isFasting, context) async { + Map request; + request = { + "ProjectID": projectID, + "ItemIDList": itemIDList, + "IsActive": true, + "OrderDate": DateUtil.getISODateFormat(DateTime.now()).replaceAll("T", " "), + "PatientID": patientID, + "AdmissionNo": admissionNo, + "IsCompanion": isCompanion, + "IsFasting": isFasting, + "CreatedBy": patientID, + "EditedBy": patientID, + "MealScheduleID": scheduleID, + "MealStatus": 1, + "ItemStatus": 0, + "ConfirmedBy": patientID, + "Remarks": "", + "IsVIP": false, + "IsFixedRemarks": false + }; + + dynamic localRes; + + await baseAppClient.post(PLACE_MEAL_PLAN_ORDER, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 4264bbf2..3d665c84 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2918,6 +2918,8 @@ class TranslationBase { String get birthNotificationNotes1 => localizedValues["birthNotificationNotes1"][locale.languageCode]; String get birthNotificationNotes2 => localizedValues["birthNotificationNotes2"][locale.languageCode]; String get birthNotificationNotes3 => localizedValues["birthNotificationNotes3"][locale.languageCode]; + String get placeOrder => localizedValues["placeOrder"][locale.languageCode]; + String get isFasting => localizedValues["isFasting"][locale.languageCode]; } diff --git a/lib/uitl/utils_new.dart b/lib/uitl/utils_new.dart index 822137cd..b8a488c8 100644 --- a/lib/uitl/utils_new.dart +++ b/lib/uitl/utils_new.dart @@ -31,16 +31,11 @@ Widget getPaymentMethods() { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Image.asset("assets/images/new/payment/Mada.png", - width: 40, height: 40), - Image.asset("assets/images/new/payment/tamara_en.png", - width: 40, height: 40), - Image.asset("assets/images/new/payment/visa.png", - width: 40, height: 40), - Image.asset("assets/images/new/payment/Mastercard.png", - width: 50, height: 40), - Image.asset("assets/images/new/payment/Apple_Pay.png", - width: 40, height: 40), + Image.asset("assets/images/new/payment/Mada.png", width: 40, height: 40), + Image.asset("assets/images/new/payment/tamara_en.png", width: 40, height: 40), + Image.asset("assets/images/new/payment/visa.png", width: 40, height: 40), + Image.asset("assets/images/new/payment/Mastercard.png", width: 50, height: 40), + Image.asset("assets/images/new/payment/Apple_Pay.png", width: 40, height: 40), ], ), ); @@ -52,15 +47,8 @@ Widget getNoDataWidget(BuildContext context) { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - SvgPicture.asset('assets/images/new/not_found.svg', - width: 110.0, height: 110.0), - Container( - margin: EdgeInsets.only(top: 15.0), - child: Text(TranslationBase.of(context).noResultFound, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Color(0xFFBABABA)))), + SvgPicture.asset('assets/images/new/not_found.svg', width: 110.0, height: 110.0), + Container(margin: EdgeInsets.only(top: 15.0), child: Text(TranslationBase.of(context).noResultFound, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFFBABABA)))), ], ), ), @@ -88,8 +76,7 @@ spacer() { } Future navigateTo(context, page) async { - return await Navigator.push( - context, MaterialPageRoute(builder: (context) => page)); + return await Navigator.push(context, MaterialPageRoute(builder: (context) => page)); } // Future navigateToReplace(context, page) async { @@ -147,11 +134,7 @@ Widget circularAviator( child: Container( width: s, height: s, - decoration: containerColorRadiusBorderWidth( - bcColor == null ? Colors.grey[200] : bcColor, - 2000, - brColor == null ? Colors.blueGrey[800] : brColor, - borderWidth == null ? 2 : borderWidth), + decoration: containerColorRadiusBorderWidth(bcColor == null ? Colors.grey[200] : bcColor, 2000, brColor == null ? Colors.blueGrey[800] : brColor, borderWidth == null ? 2 : borderWidth), child: Icon( icon == null ? Icons.person : icon, size: s / 1.7, @@ -233,8 +216,7 @@ RoundedRectangleBorder buttonShape() { ); } -Decoration containerRadiusWithGradient(double radius, - {Color color1, Color color2}) { +Decoration containerRadiusWithGradient(double radius, {Color color1, Color color2}) { return BoxDecoration( borderRadius: BorderRadius.circular(radius), gradient: LinearGradient( @@ -248,8 +230,7 @@ Decoration containerRadiusWithGradient(double radius, ); } -Decoration containerBottomRightRadiusWithGradient(double radius, - {Color darkColor, Color lightColor}) { +Decoration containerBottomRightRadiusWithGradient(double radius, {Color darkColor, Color lightColor}) { return BoxDecoration( borderRadius: BorderRadius.only(bottomRight: Radius.circular(radius)), gradient: LinearGradient( @@ -263,8 +244,7 @@ Decoration containerBottomRightRadiusWithGradient(double radius, ); } -Decoration containerBottomRightRadiusWithGradientForAr(double radius, - {Color darkColor, Color lightColor}) { +Decoration containerBottomRightRadiusWithGradientForAr(double radius, {Color darkColor, Color lightColor}) { return BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius)), gradient: LinearGradient( @@ -307,11 +287,7 @@ Decoration containerRadiusWithGradientServices( ); } -Decoration containerBottomRightRadiusWithGradientBorder(double radius, - {Color darkColor, - Color lightColor, - Color borderColor = Colors.transparent, - double w = 0}) { +Decoration containerBottomRightRadiusWithGradientBorder(double radius, {Color darkColor, Color lightColor, Color borderColor = Colors.transparent, double w = 0}) { return BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(radius)), border: Border.all( @@ -332,6 +308,13 @@ Decoration containerBottomRightRadiusWithGradientBorder(double radius, Decoration containerRadius(Color background, double radius) { return BoxDecoration( color: background, + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + blurRadius: 27, + offset: Offset(0, -3), + ), + ], border: Border.all( width: 1, // color: background // <--- border width here @@ -340,8 +323,7 @@ Decoration containerRadius(Color background, double radius) { ); } -Decoration containerColorRadiusBorder( - Color background, double radius, Color color) { +Decoration containerColorRadiusBorder(Color background, double radius, Color color) { return BoxDecoration( color: background, border: Border.all( @@ -352,8 +334,7 @@ Decoration containerColorRadiusBorder( ); } -Decoration containerColorRadiusBorderWidth( - Color background, double radius, Color color, double w) { +Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) { return BoxDecoration( color: background, border: Border.all( @@ -364,8 +345,7 @@ Decoration containerColorRadiusBorderWidth( ); } -Decoration containerColorRadiusBorderWidthCircular( - Color background, double radius, Color color, double w) { +Decoration containerColorRadiusBorderWidthCircular(Color background, double radius, Color color, double w) { return BoxDecoration( color: background, border: Border.all( @@ -380,36 +360,29 @@ Decoration containerColorRadiusBorderWidthCircular( Decoration containerColorRadiusRight(Color background, double radius) { return BoxDecoration( color: background, - borderRadius: BorderRadius.only( - topRight: Radius.circular(radius), - bottomRight: Radius.circular(radius)), + borderRadius: BorderRadius.only(topRight: Radius.circular(radius), bottomRight: Radius.circular(radius)), ); } Decoration containerColorRadiusLeft(Color background, double radius) { return BoxDecoration( color: background, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(radius), bottomLeft: Radius.circular(radius)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), bottomLeft: Radius.circular(radius)), ); } -Decoration containerColorRadiusRightBorder( - Color background, double radius, double w) { +Decoration containerColorRadiusRightBorder(Color background, double radius, double w) { return BoxDecoration( color: background, border: Border.all( width: w, // color: Colors.white // <--- border width here ), - borderRadius: BorderRadius.only( - topRight: Radius.circular(radius), - bottomRight: Radius.circular(radius)), + borderRadius: BorderRadius.only(topRight: Radius.circular(radius), bottomRight: Radius.circular(radius)), ); } -Decoration containerColorRadiusRightBorderc( - Color background, double radius, double w, Color borderColor) { +Decoration containerColorRadiusRightBorderc(Color background, double radius, double w, Color borderColor) { return BoxDecoration( color: background, border: Border.all( @@ -440,16 +413,14 @@ Decoration containerColorRadiusBottom(Color color, double radius) { ); } -Decoration containerColorRadiusLeftBorder( - Color background, double radius, double w) { +Decoration containerColorRadiusLeftBorder(Color background, double radius, double w) { return BoxDecoration( color: background, border: Border.all( width: w, // color: Colors.white // <--- border width here ), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(radius), bottomLeft: Radius.circular(radius)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), bottomLeft: Radius.circular(radius)), ); } @@ -481,23 +452,19 @@ ShapeBorder cardRadiusNew(double radius) { ShapeBorder cardRadiusTop(double radius) { return RoundedRectangleBorder( side: BorderSide(color: Colors.transparent, width: 0), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(radius), topRight: Radius.circular(radius)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)), ); } ShapeBorder cardRadiusTop2(double radius) { return RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(radius), topRight: Radius.circular(radius)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)), ); } ShapeBorder cardRadiusBottom(double radius) { return RoundedRectangleBorder( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(radius), - bottomRight: Radius.circular(radius)), + borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)), ); } @@ -620,8 +587,7 @@ FontStyle getFontStyle(String fontStyle) { bool timeCalculator(int startHour, int startMint, int endHour, int endMint) { DateTime now = DateTime.now(); - DateTime startDate = - DateTime(now.year, now.month, now.day, startHour, startHour); + DateTime startDate = DateTime(now.year, now.month, now.day, startHour, startHour); DateTime endDate = DateTime(now.year, now.month, now.day, endHour, endMint); if (startDate.isBefore(now) && endDate.isAfter(now)) return true;