|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/extensions/route_extensions.dart';
|
|
|
|
import 'package:hmg_patient_app_new/extensions/route_extensions.dart';
|
|
|
|
@ -19,9 +20,11 @@ import 'package:hmg_patient_app_new/widgets/date_range_selector/date_range_calen
|
|
|
|
import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_list_item.dart';
|
|
|
|
import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_list_item.dart';
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors;
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors;
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/date_range_selector/viewmodel/date_range_view_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/graph/custom_graph.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/graph/custom_graph.dart';
|
|
|
|
import 'package:provider/provider.dart' show Consumer, Provider, ReadContext, Selector;
|
|
|
|
import 'package:provider/provider.dart' show Consumer, Provider, ReadContext, Selector;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../core/common_models/data_points.dart';
|
|
|
|
import '../../../widgets/common_bottom_sheet.dart' show showCommonBottomSheetWithoutHeight;
|
|
|
|
import '../../../widgets/common_bottom_sheet.dart' show showCommonBottomSheetWithoutHeight;
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
import 'dart:ui' as ui;
|
|
|
|
|
|
|
|
|
|
|
|
@ -63,29 +66,44 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
LabNameAndStatus(context),
|
|
|
|
LabNameAndStatus(context),
|
|
|
|
getLabDescription(context),
|
|
|
|
getLabDescription(context),
|
|
|
|
LabGraph(context),
|
|
|
|
Selector<LabViewModel, List<LabResult>?>(
|
|
|
|
Container(
|
|
|
|
selector: (_, model) => model.mainLabResults,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 24.h, vertical: 16.h),
|
|
|
|
builder: (_, data, __) => Visibility(
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
visible: data?.isNotEmpty == true,
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
child: Column(
|
|
|
|
borderRadius: 24.h,
|
|
|
|
spacing: 16.h,
|
|
|
|
hasShadow: true,
|
|
|
|
children: [
|
|
|
|
),
|
|
|
|
LabGraph(context),
|
|
|
|
child: Column(
|
|
|
|
Container(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 24.h, vertical: 16.h),
|
|
|
|
children: [
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
Row(
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
borderRadius: 24.h,
|
|
|
|
children: [
|
|
|
|
hasShadow: true,
|
|
|
|
LocaleKeys.history.tr(context: context).toText16(isBold: true, color: AppColors.textColor),
|
|
|
|
),
|
|
|
|
(labVM.isLabResultsHistoryShowMore ? "Show Less" : "Show More").toText14(weight: FontWeight.w500, color: AppColors.primaryRedColor, isUnderLine: true).onPress(() {
|
|
|
|
child: Column(
|
|
|
|
labVM.setIsLabResultsHistoryShowMore();
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
}),
|
|
|
|
children: [
|
|
|
|
],
|
|
|
|
Row(
|
|
|
|
),
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
SizedBox(height: 24.h,),
|
|
|
|
children: [
|
|
|
|
labHistoryList(labVM),
|
|
|
|
LocaleKeys.history.tr(context: context).toText16(isBold: true, color: AppColors.textColor),
|
|
|
|
],
|
|
|
|
(labVM.isLabResultsHistoryShowMore ? "Show Less" : "Show More")
|
|
|
|
|
|
|
|
.toText14(weight: FontWeight.w500, color: AppColors.primaryRedColor, isUnderLine: true)
|
|
|
|
|
|
|
|
.onPress(() {
|
|
|
|
|
|
|
|
labVM.setIsLabResultsHistoryShowMore();
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
|
|
height: 24.h,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
labHistoryList(labVM),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Selector<LabViewModel, LabOrderResponseByAi?>(
|
|
|
|
Selector<LabViewModel, LabOrderResponseByAi?>(
|
|
|
|
@ -324,7 +342,7 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget historyBody(LabViewModel labmodel) {
|
|
|
|
Widget historyBody(LabViewModel labmodel) {
|
|
|
|
if (labmodel.isGraphVisible && labmodel.shouldShowGraph) {
|
|
|
|
if (labmodel.shouldShowGraph) {
|
|
|
|
var graphColor = labmodel.getColor(recentLabResult.calculatedResultFlag ?? "N");
|
|
|
|
var graphColor = labmodel.getColor(recentLabResult.calculatedResultFlag ?? "N");
|
|
|
|
return CustomGraph(
|
|
|
|
return CustomGraph(
|
|
|
|
dataPoints: labmodel.filteredGraphValues,
|
|
|
|
dataPoints: labmodel.filteredGraphValues,
|
|
|
|
@ -336,10 +354,11 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
maxY: (labmodel.maxY),
|
|
|
|
maxY: (labmodel.maxY),
|
|
|
|
minY: labmodel.minY,
|
|
|
|
minY: labmodel.minY,
|
|
|
|
maxX: labmodel.filteredGraphValues.length.toDouble() - .75,
|
|
|
|
maxX: labmodel.filteredGraphValues.length.toDouble() - .75,
|
|
|
|
horizontalInterval: .1,
|
|
|
|
horizontalInterval: .01,
|
|
|
|
isRTL: getIt.get<AppState>().isArabic(),
|
|
|
|
isRTL: getIt.get<AppState>().isArabic(),
|
|
|
|
getDrawingHorizontalLine: (value) {
|
|
|
|
getDrawingHorizontalLine: (value) {
|
|
|
|
value = double.parse(value.toStringAsFixed(1));
|
|
|
|
value = double.parse(value.toStringAsFixed(2));
|
|
|
|
|
|
|
|
// print("the value is $value");
|
|
|
|
if (value == labmodel.highRefrenceValue || value == labmodel.lowRefenceValue) {
|
|
|
|
if (value == labmodel.highRefrenceValue || value == labmodel.lowRefenceValue) {
|
|
|
|
return FlLine(
|
|
|
|
return FlLine(
|
|
|
|
color: AppColors.bgGreenColor.withOpacity(0.6),
|
|
|
|
color: AppColors.bgGreenColor.withOpacity(0.6),
|
|
|
|
@ -354,7 +373,7 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
;
|
|
|
|
;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
leftLabelFormatter: (value) {
|
|
|
|
leftLabelFormatter: (value) {
|
|
|
|
value = double.parse(value.toStringAsFixed(1));
|
|
|
|
value = double.parse(value.toStringAsFixed(2));
|
|
|
|
return leftLabels(value.toStringAsFixed(2));
|
|
|
|
return leftLabels(value.toStringAsFixed(2));
|
|
|
|
// if (value == labmodel.highRefrenceValue) {
|
|
|
|
// if (value == labmodel.highRefrenceValue) {
|
|
|
|
// return leftLabels(LocaleKeys.high.tr());
|
|
|
|
// return leftLabels(LocaleKeys.high.tr());
|
|
|
|
@ -387,9 +406,8 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
minX: (labmodel.filteredGraphValues.length == 1) ? null : -.2,
|
|
|
|
minX: (labmodel.filteredGraphValues.length == 1) ? null : -.2,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
height: 180.h);
|
|
|
|
height: 180.h);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return labHistoryList(labmodel);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SizedBox.shrink();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<HorizontalRangeAnnotation> _buildRangeShades(
|
|
|
|
List<HorizontalRangeAnnotation> _buildRangeShades(
|
|
|
|
@ -419,18 +437,18 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
|
|
Widget labHistoryList(LabViewModel labmodel) {
|
|
|
|
Widget labHistoryList(LabViewModel labmodel) {
|
|
|
|
return SizedBox(
|
|
|
|
return SizedBox(
|
|
|
|
height: labmodel.filteredGraphValues.length < 3 ? labmodel.filteredGraphValues.length * 64 : (!labmodel.isLabResultsHistoryShowMore ? 180.h : 220.h),
|
|
|
|
height: labmodel.mainLabResults.length < 3 ? labmodel.mainLabResults.length * 64 : (!labmodel.isLabResultsHistoryShowMore ? 180.h : 220.h),
|
|
|
|
child: ListView.separated(
|
|
|
|
child: ListView.separated(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
// itemCount: labmodel.isLabResultsHistoryShowMore ? (labmodel.filteredGraphValues.length < 3 ? labmodel.filteredGraphValues : 3) : labmodel.filteredGraphValues.length,
|
|
|
|
// itemCount: labmodel.isLabResultsHistoryShowMore ? (labmodel.filteredGraphValues.length < 3 ? labmodel.filteredGraphValues : 3) : labmodel.filteredGraphValues.length,
|
|
|
|
itemCount: !labmodel.isLabResultsHistoryShowMore ? (labmodel.filteredGraphValues.length < 3 ? labmodel.filteredGraphValues.length : 3) : labmodel.filteredGraphValues.length,
|
|
|
|
itemCount: !labmodel.isLabResultsHistoryShowMore ? (labmodel.mainLabResults.length < 3 ? labmodel.mainLabResults.length : 3) : labmodel.mainLabResults.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
var data = labmodel.filteredGraphValues.reversed.toList()[index];
|
|
|
|
var data = labmodel.mainLabResults.reversed.toList()[index];
|
|
|
|
return LabHistoryItem(
|
|
|
|
return LabHistoryItem(
|
|
|
|
dayNameAndDate: labmodel.getFormattedDate(data.time),
|
|
|
|
dayNameAndDate: labmodel.getFormattedDate(DateUtil.convertStringToDate(data.verifiedOnDateTime)),
|
|
|
|
result: data.actualValue,
|
|
|
|
result: data.resultValue??"",
|
|
|
|
assetUrl: labmodel.getAssetUrlWRTResult(data.referenceValue),
|
|
|
|
assetUrl: labmodel.getAssetUrlWRTResult(data.calculatedResultFlag??""),
|
|
|
|
shouldRotateIcon: labmodel.getRotationWRTResult(data.referenceValue),
|
|
|
|
shouldRotateIcon: labmodel.getRotationWRTResult(data.calculatedResultFlag??""),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separatorBuilder: (_, __) => Divider(
|
|
|
|
separatorBuilder: (_, __) => Divider(
|
|
|
|
@ -457,6 +475,7 @@ class LabResultDetails extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
|
|
Widget getLabDescription(BuildContext context) {
|
|
|
|
Widget getLabDescription(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
width: MediaQuery.sizeOf(context).width,
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
borderRadius: 24.h,
|
|
|
|
borderRadius: 24.h,
|
|
|
|
|