diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index 2fee0a41..7f9faccb 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -97,7 +97,7 @@ class LabsViewModel extends BaseViewModel { } } - getPatientLabResult({required PatientLabOrders patientLabOrder, required bool isVidaPlus}) async { + getPatientLabResult({required PatientLabOrders patientLabOrder, required bool isVidaPlus, bool isTablet = false}) async { setState(ViewState.Busy); await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder, isVidaPlus: isVidaPlus); if (_labsService.hasError) { @@ -107,7 +107,7 @@ class LabsViewModel extends BaseViewModel { _labsService.labResultList.forEach((element) { List patientLabOrdersClinic = labResultLists.where((elementClinic) => elementClinic.filterName == element.testCode).toList(); element.percentage = - getPercentage(element.calculatedResultFlag ?? ResultFlag.N); + getPercentage(element.calculatedResultFlag?? ResultFlag.N, isTablet); if (patientLabOrdersClinic.length != 0) { labResultLists[labResultLists.indexOf(patientLabOrdersClinic[0])].patientLabResultList!.add(element); } else { @@ -121,29 +121,39 @@ class LabsViewModel extends BaseViewModel { } } - double getPercentage(ResultFlag flag) { + recalculatePercentage(isTablet){ + for(int i = 0;i { children: [ Utils.tableColumnValue(DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(labOrderResultList![i].verifiedOnDateTime!)), isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel), Utils.tableColumnValue(labOrderResultList[i].resultValue!, isLast: i == (labOrderResultList.length - 1), mProjectViewModel: projectViewModel), - changeResult(labOrderResultList[i].changeResult ?? '8%') + changeResult(labOrderResultList[i].changeResult ?? '', labOrderResultList[i].calculatedResultFlag??'IRR') ], ), ); return tableRow; } - Widget changeResult(String changeValue) => Padding( + + Color getColorForResultType(String type) { + switch (type) { + case "LCL": + case "HCH": + case "CH": + case "CL": + return Color(0xFFDE7676); + case "L": + case "H": + return Color(0xFFEAB157); + case "N": + return Color(0xFF09AA28); + default: + return Color(0xFF09AA28); + } + } + Widget changeResult(String changeValue, String type) => Padding( padding: const EdgeInsets.all(4.0), child: Material( - color: (changeValue.contains("-")) ? Colors.black : Color(0xffcecbcb), + color: getColorForResultType(type), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), child: Padding( @@ -71,9 +88,8 @@ class _VitalSignDetailsWidgetState extends State { child: Text( changeValue, style: TextStyle( - color: (changeValue.contains("-")) - ? Colors.white - : Colors.black, + color: Colors.white + , fontSize: 11, letterSpacing: -.64, fontWeight: FontWeight.w400), diff --git a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart index bc661fab..d4f7a6ee 100644 --- a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart @@ -31,19 +31,46 @@ class _LaboratoryResultWidgetState extends State { bool _isShowMore = true; late ProjectViewModel projectViewModel; late String? labSpecialResult; + bool isTabletScreen = false; + LabsViewModel? model; @override void initState() { super.initState(); + labSpecialResult = widget.details ?? TranslationBase.of(context).noDataAvailable; } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + print("did change dependency is called"); + + var oldStateTablateScreenState = isTabletScreen; + isTabletScreen = isTablet(context); + if(isTabletScreen != oldStateTablateScreenState); + { + print("the screen width is changed"); + model?.recalculatePercentage(isTabletScreen); + } + + } + + bool isTablet(BuildContext context) { + final size = MediaQuery.of(context).size; + final shortestSide = size.shortestSide; + return shortestSide >= 550; + } @override Widget build(BuildContext context) { + isTabletScreen = isTablet(context); projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => - model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!), + onModelReady: (model) { + this.model = model; + model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, int.parse(widget.patientLabOrder!.projectID!)), patientLabOrder: widget.patientLabOrder!, isTablet: isTabletScreen); + }, builder: (_, model, w) => NetworkBaseView( baseViewModel: model, child: Column( diff --git a/lib/widgets/data_display/medical/LabResult/newUI/LabItem.dart b/lib/widgets/data_display/medical/LabResult/newUI/LabItem.dart index 3146b10e..55cd84e8 100644 --- a/lib/widgets/data_display/medical/LabResult/newUI/LabItem.dart +++ b/lib/widgets/data_display/medical/LabResult/newUI/LabItem.dart @@ -19,7 +19,7 @@ class LabItem extends StatefulWidget { } class _LabItemState extends State { - bool _isShowMoreGeneral = false; + bool _isShowMoreGeneral = true; bool showBottomSheet = false; @override diff --git a/lib/widgets/data_display/medical/LabResult/newUI/labWidgets.dart b/lib/widgets/data_display/medical/LabResult/newUI/labWidgets.dart index 2d3f67ed..4fbce744 100644 --- a/lib/widgets/data_display/medical/LabResult/newUI/labWidgets.dart +++ b/lib/widgets/data_display/medical/LabResult/newUI/labWidgets.dart @@ -59,7 +59,13 @@ class CustomResultProgressBar extends StatelessWidget { return LayoutBuilder(builder: (context, constraints) { final double totalWidth = constraints.maxWidth; final double spacing = 2; - final double tooltipPosition = (totalWidth * (percentage / 100)).clamp(0, totalWidth - 50); + final int spacingCount = 4; // between 5 bars + final double flexWidth = totalWidth - 50; + + + final double tooltipPosition = + (flexWidth * (percentage / 100)).clamp(0, flexWidth); + return Stack( children: [ Row( @@ -117,7 +123,7 @@ class CustomResultProgressBar extends StatelessWidget { TextCloud( text: "${value}", color: getColorForResultType(type), - width: 100, + width: 75, height: 20, padding: EdgeInsets.zero, axisDirection: AxisDirection.up,