import 'package:diplomaticquarterapp/core/model/labs/lab_result.dart'; import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/newUI/labWidgets.dart'; import 'package:flutter/material.dart'; import 'package:readmore/readmore.dart'; import '../FlowChartPage.dart'; class LabItem extends StatefulWidget { final LabResultList item; PatientLabOrders? patientLabOrders; LabItem({super.key, required this.item, this.patientLabOrders}); @override State createState() => _LabItemState(); } class _LabItemState extends State { bool _isShowMoreGeneral = false; bool showBottomSheet = false; @override void initState() { super.initState(); if (showBottomSheet) { print('the bottom sheet is showing'); openFlowChart(context, ''); } } @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: () { setState(() { _isShowMoreGeneral = !_isShowMoreGeneral; }); }, behavior: HitTestBehavior.opaque, child: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Text( widget.item.filterName ?? '', style: TextStyle( fontSize: 21, fontWeight: FontWeight.bold, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), ), ), Icon( _isShowMoreGeneral ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, color: Color(0xff2B353E), size: 26, ) ], ), ), SizedBox( height: 12, ), ReadMoreText( widget.item.description ?? '', trimMode: TrimMode.Line, trimLines: 3, style: const TextStyle(color: Color(0xff575757), fontSize: 11), colorClickableText: CustomColors.accentColor, trimCollapsedText: '${TranslationBase.of(context).readMore}', trimExpandedText: ' show less', ), SizedBox( height: 8, ), if (_isShowMoreGeneral) ...List.generate(widget.item.patientLabResultList?.length ?? 0, (index) { var data = widget.item.patientLabResultList?[index]; return Column( children: [ ItemResultCardWidgetWithParams( title: data?.description ?? '', subTitle: data?.resultValue ?? '', referenceRange: data?.referanceRange ?? '', percentage: data?.percentage ?? 0.0, note: data?.testShortDescription ?? '', source: "", buttonText: "", type: data?.calculatedResultFlag?.getType() ?? ResultTypes.unknown, onButtonPressed: () { openFlowChart(context, data?.description ?? ''); }, ), SizedBox( height: 13, ), ], ); }) // Expanded( // child: ListView.builder( // itemCount: widget.item.patientLabResultList?.length ?? 0, // itemBuilder: (context, index) { // var data = widget.item.patientLabResultList?[index]; // Column( // children: [ // EllipsisTextWithMore( // text: data?.packageShortDescription ?? '', // ), // SizedBox( // height: 8, // ), // ItemResultCardWidgetWithParams( // title: data?.description ?? '', // subTitle: data?.resultValue ?? '', // referenceRange: data?.referanceRange ?? '', // percentage: 20, // note: data?.testShortDescription ?? '', // source: "", // buttonText: "", // type: data?.calculatedResultFlag?.getType() ?? // ResultTypes.unknown), // ], // ); // })) ], ); } openFlowChart(BuildContext context, String procedure) { print('openFlowChart: the bottom sheet is showing'); showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true, context: context, scrollControlDisabledMaxHeightRatio: .75, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20))), builder: (context) { print('builder: the bottom sheet is showing'); return FlowChartPage( filterName: procedure, patientLabOrder: widget.patientLabOrders, ); }).then((value) { setState(() { showBottomSheet = false; }); }); } }