diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 19111f7..e824ca2 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -126,7 +126,7 @@ "gregorianDate": "التاريخ الميلادي", "verifyLoginWith": "يرجى اختيار واحدة من الخيارات التالية للتحقق", "registerUser": "تسجيل", - "verifyWithFingerprint": "بصمة الإصبع", + "verifyWithFingerprint":"البيومترية", "verifyWithFaceid": "معرف الوجه", "verifyWithSms": "رسالة قصيرة", "verifyWithWhatsapp": "واتساب", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index b559b3b..86a4c25 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -126,7 +126,7 @@ "gregorianDate": "Gregorian Date", "verifyLoginWith": "Please choose one of the following options to verify", "registerUser": "Register", - "verifyWithFingerprint": "Fingerprint", + "verifyWithFingerprint": "Biometric", "verifyWithFaceid": "Face ID", "verifyWithSms": "SMS", "verifyWithWhatsapp": "Whatsapp", diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index fa02b2e..5886dfa 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -727,7 +727,7 @@ const FAMILY_FILES= 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatu class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/features/lab/lab_view_model.dart b/lib/features/lab/lab_view_model.dart index 2e481f4..29b90f8 100644 --- a/lib/features/lab/lab_view_model.dart +++ b/lib/features/lab/lab_view_model.dart @@ -17,6 +17,8 @@ class LabViewModel extends ChangeNotifier { List get labSuggestions => _labSuggestionsList; + Set uniqueTests = {}; + LabViewModel({required this.labRepo, required this.errorHandlerService}); initLabProvider() { @@ -32,8 +34,8 @@ class LabViewModel extends ChangeNotifier { final result = await labRepo.getPatientLabOrders(); result.fold( - (failure) async => await errorHandlerService.handleError(failure: failure), - (apiResponse) { + (failure) async => await errorHandlerService.handleError(failure: failure), + (apiResponse) { if (apiResponse.messageStatus == 2) { // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); } else if (apiResponse.messageStatus == 1) { @@ -43,6 +45,7 @@ class LabViewModel extends ChangeNotifier { isLabOrdersLoading = false; isLabResultsLoading = false; filterSuggestions(); + getUniqueTestDescription(); notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); @@ -75,4 +78,15 @@ class LabViewModel extends ChangeNotifier { } notifyListeners(); } + + getUniqueTestDescription() { + + uniqueTests = { + for (var item in patientLabOrders) + if (item.testDetails != null) + ...?item.testDetails?.map((test) => + TestDetails(description: test.description.toString(), testCode: test.testCode.toString(), testID: test.testID, createdOn: item.createdOn)) + }; + uniqueTests.forEach(print); + } } diff --git a/lib/features/lab/models/resp_models/patient_lab_orders_response_model.dart b/lib/features/lab/models/resp_models/patient_lab_orders_response_model.dart index 11bf573..265a19e 100644 --- a/lib/features/lab/models/resp_models/patient_lab_orders_response_model.dart +++ b/lib/features/lab/models/resp_models/patient_lab_orders_response_model.dart @@ -226,13 +226,14 @@ class TestDetails { String? description; String? testCode; String? testID; - - TestDetails({this.description, this.testCode, this.testID}); + String? createdOn; + TestDetails({this.description, this.testCode, this.testID, this.createdOn}); TestDetails.fromJson(Map json) { description = json['Description']; testCode = json['TestCode']; testID = json['TestID']; + createdOn = json['CreatedOn']; } Map toJson() { @@ -240,6 +241,7 @@ class TestDetails { data['Description'] = this.description; data['TestCode'] = this.testCode; data['TestID'] = this.testID; + data['CreatedOn'] = this.createdOn; return data; } } diff --git a/lib/presentation/lab/lab_order_by_test.dart b/lib/presentation/lab/lab_order_by_test.dart new file mode 100644 index 0000000..40e92c4 --- /dev/null +++ b/lib/presentation/lab/lab_order_by_test.dart @@ -0,0 +1,84 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/core/app_assets.dart'; +import 'package:hmg_patient_app_new/core/app_export.dart'; +import 'package:hmg_patient_app_new/core/enums.dart'; +import 'package:hmg_patient_app_new/core/utils/date_util.dart'; +import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; +import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; +import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart'; +import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/theme/colors.dart'; +import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; +import 'package:hmg_patient_app_new/widgets/chip/custom_chip_widget.dart'; + +class LabOrderByTest extends StatelessWidget { + final VoidCallback onTap; + final int index; + final TestDetails? tests; + final bool isLoading; + final bool isExpanded; + + const LabOrderByTest({super.key, required this.onTap, this.tests, required this.index, this.isLoading = false, this.isExpanded = false}); + + @override + build(BuildContext context) { + return AnimatedContainer( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + margin: EdgeInsets.symmetric(vertical: 8.h), + decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true), + child: InkWell( + onTap: () { + if (!isLoading) { + onTap(); + } + }, + child: Container( + key: ValueKey(index), + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 8.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // ...labOrder!.testDetails!.map((detail) { + Padding( + padding: EdgeInsets.only(bottom: 8.h), + child: '${tests!.description}'.toText14(weight: FontWeight.w500), + ), + + SizedBox(height: 12.h), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppCustomChipWidget( + richText: '${"Last Lasted:".needTranslation} ${ DateUtil.formatDateToDate(DateUtil.convertStringToDate(tests!.createdOn), false)}'.toText12(isBold: true), + // chipType: ChipTypeEnum.lightBg, + backgroundColor: AppColors.greyLightColor, + textColor: AppColors.textColor, + // borderRadius: 5, + + ), + CustomButton( + icon: AppAssets.view_report_icon, + iconColor: AppColors.primaryRedColor, + iconSize: 16.h, + text: LocaleKeys.viewReport.tr(context: context), + onPressed: () {}, + backgroundColor: AppColors.secondaryLightRedColor, + borderColor: AppColors.secondaryLightRedColor, + textColor: AppColors.primaryRedColor, + fontSize: 14, + fontWeight: FontWeight.bold, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 40.h, + ), + ], + ), + ], + ), + ))); + } +} diff --git a/lib/presentation/lab/lab_orders_page.dart b/lib/presentation/lab/lab_orders_page.dart index 0e14565..3d7edb9 100644 --- a/lib/presentation/lab/lab_orders_page.dart +++ b/lib/presentation/lab/lab_orders_page.dart @@ -11,6 +11,7 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart'; +import 'package:hmg_patient_app_new/presentation/lab/lab_order_by_test.dart'; import 'package:hmg_patient_app_new/presentation/lab/lab_result_item_view.dart'; import 'package:hmg_patient_app_new/presentation/lab/search_lab_report.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; @@ -32,7 +33,7 @@ class _LabOrdersPageState extends State { List?> labSuggestions = []; int? expandedIndex; String? selectedFilterText = ''; - + int activeIndex = 0; @override void initState() { scheduleMicrotask(() { @@ -78,7 +79,10 @@ class _LabOrdersPageState extends State { // CustomTabBarModel(null, "Completed".needTranslation), ], onTabChange: (index) { - // myAppointmentsViewModel.onTabChange(index); + activeIndex = index; + setState(() { + + }); }, ), SizedBox(height: 16.h), @@ -89,39 +93,73 @@ class _LabOrdersPageState extends State { isSelected: true, ) : SizedBox(), - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - itemCount: model.isLabOrdersLoading ? 5 : model.patientLabOrders.length, - itemBuilder: (context, index) { - final isExpanded = expandedIndex == index; - return model.isLabOrdersLoading - ? LabResultItemView( + activeIndex == 0 + ? ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemCount: model.isLabOrdersLoading ? 5 : model.patientLabOrders.length, + itemBuilder: (context, index) { + final isExpanded = expandedIndex == index; + return model.isLabOrdersLoading + ? LabResultItemView( + onTap: () {}, + labOrder: null, + index: index, + isLoading: true, + ) + : AnimationConfiguration.staggeredList( + position: index, + duration: const Duration(milliseconds: 500), + child: SlideAnimation( + verticalOffset: 100.0, + child: FadeInAnimation( + child: LabResultItemView( + onTap: () { + setState(() { + expandedIndex = isExpanded ? null : index; + }); + }, + labOrder: model.patientLabOrders[index], + index: index, + isExpanded: isExpanded)), + ), + ); + }, + ) + : ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemCount: model.isLabOrdersLoading ? 5 :model.uniqueTests.toList().length, + itemBuilder: (context, index) { + final isExpanded = expandedIndex == index; + return model.isLabOrdersLoading + ? LabResultItemView( onTap: () {}, labOrder: null, index: index, isLoading: true, - ) - : AnimationConfiguration.staggeredList( - position: index, - duration: const Duration(milliseconds: 500), - child: SlideAnimation( - verticalOffset: 100.0, - child: FadeInAnimation( - child: LabResultItemView( - onTap: () { - setState(() { - expandedIndex = isExpanded ? null : index; - }); - }, - labOrder: model.patientLabOrders[index], - index: index, - isExpanded: isExpanded)), - ), - ); - }, - ), + ) : AnimationConfiguration.staggeredList( + position: index, + duration: const Duration(milliseconds: 500), + child: SlideAnimation( + verticalOffset: 100.0, + child: FadeInAnimation( + child: LabOrderByTest( + onTap: () { + setState(() { + expandedIndex = isExpanded ? null : index; + }); + }, + tests: model.uniqueTests.toList()[index], + index: index, + isExpanded: isExpanded)), + ), + ); + + }, + ) ], ); },