@ -15,35 +15,38 @@ import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_list
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/graph/custom_graph.dart ' ;
import ' package:provider/provider.dart ' show Consumer , Provider ;
import ' package:provider/provider.dart ' show Consumer , Provider , ReadContext ;
import ' ../../../widgets/common_bottom_sheet.dart '
show showCommonBottomSheetWithoutHeight ;
class LabResultDetails extends StatelessWidget {
final LabResult recentLabResult ;
final String ? testDescription ;
/ / final List < DataPoint > graphPoint ;
late LabViewModel model ;
String ? testDescription ;
LabResultDetails ( { super . key , required this . recentLabResult , required this . testDescription } ) ;
const LabResultDetails (
{ super . key ,
required this . recentLabResult ,
required this . testDescription } ) ;
@ override
Widget build ( BuildContext context ) {
model = Provider . of < LabViewModel > ( context , listen: false ) ;
return CollapsingListView (
title: ' Lab Result Details ' . needTranslation ,
child: SingleChildScrollView (
child: Column (
spacing: 16. h ,
children: [ LabNameAndStatus , LabGraph ( context ) ] ,
children: [
LabNameAndStatus ( context ) ,
getLabDescription ( context ) ,
LabGraph ( context )
] ,
) . paddingAll ( 24. h ) ,
) ,
) ;
}
Widget get LabNameAndStatus = > Container (
Widget LabNameAndStatus ( BuildContext context ) = > Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. h ,
@ -80,11 +83,12 @@ class LabResultDetails extends StatelessWidget {
/ / todo change the text color according to the provided test values
Row (
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Expanded (
child: Row (
spacing: 4. h ,
mainAxisSize: MainAxisSize . max ,
children: [
Flexible (
child: Text (
@ -93,7 +97,7 @@ class LabResultDetails extends StatelessWidget {
fontSize: 24. fSize ,
fontWeight: FontWeight . w600 ,
fontFamily: ' Poppins ' ,
color: model . getColor (
color: context. read < LabViewModel > ( ) . getColor (
recentLabResult . calculatedResultFlag ? ? " " ,
) ,
letterSpacing: - 2 ,
@ -103,7 +107,10 @@ class LabResultDetails extends StatelessWidget {
softWrap: false ,
) ,
) ,
Visibility (
SizedBox ( width: 4. h , ) ,
Expanded (
flex: 2 ,
child: Visibility (
visible: recentLabResult . referanceRange ! = null ,
child: Text (
" (Reference range ${ recentLabResult . referanceRange } ) " . needTranslation ,
@ -113,37 +120,44 @@ class LabResultDetails extends StatelessWidget {
fontFamily: ' Poppins ' ,
color: AppColors . greyTextColor ,
) ,
overflow: TextOverflow . ellipsis ,
maxLines: 1 ,
softWrap: false ,
/ / overflow: TextOverflow . ellipsis ,
/ / maxLines: 2 ,
softWrap: true ,
) ,
) ,
) ,
] ,
) ,
) ,
Utils . buildSvgWithAssets (
SizedBox (
width: 21 ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . lab_result_indicator ,
width: 21 ,
height: 23 ,
iconColor: model . getColor (
iconColor: context . read < LabViewModel > ( ) . getColor (
recentLabResult . calculatedResultFlag ? ? " " ,
) ,
) ,
) ,
] ,
)
] ,
) ) ;
Widget LabGraph ( BuildContext context ) = > Consumer < DateRangeSelectorRangeViewModel > (
builder: ( _ , model , ___ ) = > Consumer < LabViewModel > (
Widget LabGraph ( BuildContext context ) = > Consumer < LabViewModel > (
builder: ( _ , labmodel , ___ ) = > Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. h ,
hasShadow: true ,
) ,
height: model . isGraphVisible ? 260. h: ( labmodel . filteredGraphValues . length < 3 ) ? ( labmodel . filteredGraphValues . length * 64 ) + 80. h: 260. h ,
height: labmodel . isGraphVisible
? 260. h
: ( labmodel . filteredGraphValues . length < 3 )
? ( labmodel . filteredGraphValues . length * 64 ) + 80. h
: 260. h ,
padding: EdgeInsets . all ( 16. h ) ,
child: Column (
mainAxisAlignment: MainAxisAlignment . spaceAround ,
@ -153,11 +167,12 @@ class LabResultDetails extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
Text (
model . isGraphVisible ? LocaleKeys . historyFlowchart . tr ( ) : LocaleKeys . history . tr ( ) ,
labmodel . isGraphVisible
? LocaleKeys . historyFlowchart . tr ( )
: LocaleKeys . history . tr ( ) ,
style: TextStyle (
fontSize: 16 ,
fontFamily: ' Poppins ' ,
fontWeight: FontWeight . w600 ,
color: AppColors . textColor ,
) ,
@ -167,11 +182,15 @@ class LabResultDetails extends StatelessWidget {
children: [
/ / todo handle when the graph icon is being displayed
Utils . buildSvgWithAssets (
icon: model . isGraphVisible ? AppAssets . ic_list: AppAssets . ic_graph ,
icon: labmodel . isGraphVisible
? AppAssets . ic_list
: AppAssets . ic_graph ,
width: 24. h ,
height: 24. h )
. onPress ( ( ) {
model . alterGraphVisibility ( ) ;
if ( labmodel . shouldShowGraph ) {
labmodel . alterGraphVisibility ( ) ;
}
} ) ,
Utils . buildSvgWithAssets (
icon: AppAssets . ic_date_filter ,
@ -183,7 +202,6 @@ class LabResultDetails extends StatelessWidget {
context ,
child: DateRangeSelector (
onRangeSelected: ( start , end ) {
/ / if ( start ! = null ) {
labmodel . getSelectedDateRange ( start , end ) ;
/ / }
@ -197,11 +215,11 @@ class LabResultDetails extends StatelessWidget {
] ,
)
] ,
) . paddingOnly ( bottom: model. isGraphVisible ? 16. h : 24. h ) ,
historyBody ( model , labmodel )
) . paddingOnly ( bottom: lab model. isGraphVisible ? 16. h : 24. h ) ,
historyBody ( labmodel )
] ,
) ) ,
) ) ;
) ;
Widget leftLabels ( String value ) {
return Text (
@ -229,17 +247,15 @@ class LabResultDetails extends StatelessWidget {
) ;
}
Widget historyBody ( DateRangeSelectorRangeViewModel model , LabViewModel labmodel ) {
if ( model. isGraphVisible ) {
Widget historyBody ( LabViewModel labmodel ) {
if ( lab model. isGraphVisible & & labmodel . shouldShowGraph ) {
var graphColor = labmodel . getColor ( recentLabResult . calculatedResultFlag ? ? " N " ) ;
return CustomGraph (
dataPoints: labmodel . filteredGraphValues ,
/ / maxY: 100 ,
makeGraphBasedOnActualValue: true ,
leftLabelReservedSize: 40 ,
leftLabelInterval: getInterval ( labmodel ) ,
maxY: ( labmodel . maxY ) + ( getInterval ( labmodel ) ? ? 0 ) / 5 ,
maxY: ( labmodel . maxY ) + ( getInterval ( labmodel ) ? ? 0 ) / 2 ,
maxX: labmodel . filteredGraphValues . length . toDouble ( ) - . 75 ,
leftLabelFormatter: ( value ) {
return leftLabels ( value . toStringAsFixed ( 2 ) . tr ( ) ) ;
@ -279,11 +295,11 @@ class LabResultDetails extends StatelessWidget {
scrollDirection: Axis . horizontal ,
height: 180. h ) ;
} else {
return labHistoryList ( model, labmodel) ;
return labHistoryList ( labmodel) ;
}
}
Widget labHistoryList ( DateRangeSelectorRangeViewModel model , LabViewModel labmodel ) {
Widget labHistoryList ( LabViewModel labmodel ) {
return SizedBox (
height: labmodel . filteredGraphValues . length < 3 ? labmodel . filteredGraphValues . length * 64 : 180. h ,
child: ListView . separated (
@ -315,4 +331,27 @@ class LabResultDetails extends StatelessWidget {
if ( maxX > 100 & & maxX < 200 ) return 30 ;
return 50 ;
}
Widget getLabDescription ( BuildContext context ) {
return Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. h ,
hasShadow: true ,
) ,
height: 98. h ,
padding: EdgeInsets . all ( 16. h ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
spacing: 8. h ,
children: [
" What is this result? "
. needTranslation
. toText16 ( weight: FontWeight . w600 , color: AppColors . textColor ) ,
testDescription ? . toText12 (
fontWeight: FontWeight . w500 , color: AppColors . textColorLight ) ? ?
SizedBox . shrink ( )
] ,
) ) ;
}
}