|
|
|
|
@ -4,9 +4,12 @@ import 'package:diplomaticquarterapp/models/InPatientServices/get_meal_items_sch
|
|
|
|
|
import 'package:diplomaticquarterapp/models/InPatientServices/get_meals_schedule_response_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.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';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@ -28,6 +31,10 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelLunch = [];
|
|
|
|
|
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelDinner = [];
|
|
|
|
|
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelBreakfast = [];
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelLunch = [];
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelDinner = [];
|
|
|
|
|
|
|
|
|
|
int currentDay = 0;
|
|
|
|
|
int currentWeek = 0;
|
|
|
|
|
|
|
|
|
|
@ -56,15 +63,64 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
Container(
|
|
|
|
|
decoration: containerRadius(Colors.white, 12),
|
|
|
|
|
child: AppExpandableNotifier(
|
|
|
|
|
title: "Breakfast TAT: 10:00 AM",
|
|
|
|
|
title: "Breakfast TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[0].tATTime),
|
|
|
|
|
isTitleSingleLine: false,
|
|
|
|
|
widgetColor: Colors.transparent,
|
|
|
|
|
bodyWidget: Column(
|
|
|
|
|
children: [
|
|
|
|
|
getDivider(),
|
|
|
|
|
Container(
|
|
|
|
|
height: 200.0,
|
|
|
|
|
),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
|
padding: EdgeInsets.only(top: 12),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.all(21.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
LargeAvatar(
|
|
|
|
|
name: getMealItemsScheduleResponseModelBreakfast[index].description,
|
|
|
|
|
url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg",
|
|
|
|
|
width: 60,
|
|
|
|
|
height: 60,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 11),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
MyRichText(
|
|
|
|
|
"",
|
|
|
|
|
projectViewModel.isArabic ? _getMealItemsScheduleResponseModelBreakfast[index].filterName : _getMealItemsScheduleResponseModelBreakfast[index].filterName,
|
|
|
|
|
projectViewModel.isArabic),
|
|
|
|
|
// MyRichText(
|
|
|
|
|
// "",
|
|
|
|
|
// projectViewModel.isArabic
|
|
|
|
|
// ? getMealItemsScheduleResponseModelBreakfast[index].categoryDescriptionN
|
|
|
|
|
// : getMealItemsScheduleResponseModelBreakfast[index].categoryDescription ?? "",
|
|
|
|
|
// projectViewModel.isArabic),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
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),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -73,7 +129,7 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
Container(
|
|
|
|
|
decoration: containerRadius(Colors.white, 12),
|
|
|
|
|
child: AppExpandableNotifier(
|
|
|
|
|
title: "Lunch TAT: 04:00 PM",
|
|
|
|
|
title: "Lunch TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[1].tATTime),
|
|
|
|
|
isTitleSingleLine: false,
|
|
|
|
|
widgetColor: Colors.transparent,
|
|
|
|
|
bodyWidget: Column(
|
|
|
|
|
@ -90,7 +146,7 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
Container(
|
|
|
|
|
decoration: containerRadius(Colors.white, 12),
|
|
|
|
|
child: AppExpandableNotifier(
|
|
|
|
|
title: "Dinner TAT: 12:00 AM",
|
|
|
|
|
title: "Dinner TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[2].tATTime),
|
|
|
|
|
isTitleSingleLine: false,
|
|
|
|
|
widgetColor: Colors.transparent,
|
|
|
|
|
bodyWidget: Column(
|
|
|
|
|
@ -133,7 +189,6 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
getCurrentWeekIDAndDay(getAdmittedPatientsResponseModel.dietType);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: "No data found for admitted patient");
|
|
|
|
|
|
|
|
|
|
getCurrentWeekIDAndDay(1);
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
@ -161,8 +216,8 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
service.getMealsOfScheduleID(projectViewModel.inPatientProjectID, projectViewModel.getAdmissionInfoResponseModel.admissionNo, dietType, currentWeek, currentDay, context).then((res) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (res["List_MOP_MealsOfScheduleID"] != null && res["List_MOP_MealsOfScheduleID"].length != 0) {
|
|
|
|
|
res['List_MOP_MealsOfScheduleID'].forEach((scheduleItem) {
|
|
|
|
|
if (res["List_MOP_MealsOfScheduleID_Mobile"] != null && res["List_MOP_MealsOfScheduleID_Mobile"].length != 0) {
|
|
|
|
|
res['List_MOP_MealsOfScheduleID_Mobile'].forEach((scheduleItem) {
|
|
|
|
|
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(scheduleItem));
|
|
|
|
|
});
|
|
|
|
|
getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[0].scheduleID, 1);
|
|
|
|
|
@ -187,23 +242,63 @@ class _MealPlanPageState extends State<MealPlanPage> {
|
|
|
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
|
|
|
getMealItemsScheduleResponseModelBreakfast.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
|
|
|
});
|
|
|
|
|
sortMealsByCategoryBreakfast();
|
|
|
|
|
}
|
|
|
|
|
if (mealType == 2) {
|
|
|
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
|
|
|
getMealItemsScheduleResponseModelLunch.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
|
|
|
});
|
|
|
|
|
sortMealsByCategoryLunch();
|
|
|
|
|
}
|
|
|
|
|
if (mealType == 3) {
|
|
|
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
|
|
|
getMealItemsScheduleResponseModelDinner.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
|
|
|
});
|
|
|
|
|
sortMealsByCategoryDinner();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: "No meal items found for admitted patient");
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sortMealsByCategoryBreakfast() {
|
|
|
|
|
getMealItemsScheduleResponseModelBreakfast.forEach((element) {
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
|
|
|
|
|
_getMealItemsScheduleResponseModelBreakfast.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
|
|
|
|
|
if (breakfastMealItems.length != 0) {
|
|
|
|
|
_getMealItemsScheduleResponseModelBreakfast[_getMealItemsScheduleResponseModelBreakfast.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
|
|
|
|
|
} else {
|
|
|
|
|
_getMealItemsScheduleResponseModelBreakfast.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sortMealsByCategoryLunch() {
|
|
|
|
|
getMealItemsScheduleResponseModelLunch.forEach((element) {
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
|
|
|
|
|
_getMealItemsScheduleResponseModelLunch.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
|
|
|
|
|
if (breakfastMealItems.length != 0) {
|
|
|
|
|
_getMealItemsScheduleResponseModelLunch[_getMealItemsScheduleResponseModelLunch.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
|
|
|
|
|
} else {
|
|
|
|
|
_getMealItemsScheduleResponseModelLunch.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sortMealsByCategoryDinner() {
|
|
|
|
|
getMealItemsScheduleResponseModelDinner.forEach((element) {
|
|
|
|
|
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
|
|
|
|
|
_getMealItemsScheduleResponseModelDinner.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
|
|
|
|
|
if (breakfastMealItems.length != 0) {
|
|
|
|
|
_getMealItemsScheduleResponseModelDinner[_getMealItemsScheduleResponseModelDinner.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
|
|
|
|
|
} else {
|
|
|
|
|
_getMealItemsScheduleResponseModelDinner.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|