import 'package:diplomaticquarterapp/core/model/labs/lab_result.dart'; import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import '../../text.dart'; import 'FlowChartPage.dart'; class LabResultWidget extends StatelessWidget { final String filterName; final List patientLabResultList; final PatientLabOrders patientLabOrder; LabResultWidget({Key key, this.filterName, this.patientLabResultList, this.patientLabOrder}) : super(key: key); ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return Container( width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 8), Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( filterName, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.56, height: 21 / 14), ),SizedBox(width: 16), InkWell( onTap: () { Navigator.push( context, FadePage( page: FlowChartPage( filterName: filterName, patientLabOrder: patientLabOrder, ), ), ); }, child: Text( TranslationBase.of(context).viewFlowChart, style: TextStyle(decoration: TextDecoration.underline, fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.48, height: 18 / 12), ), ), ], ), Table( columnWidths: { 0: FlexColumnWidth(2), 1: FlexColumnWidth(1.5), 2: FlexColumnWidth(1), }, children: fullData(patientLabResultList, context), ), ], ), ); } List fullData(List labResultList, context) { List tableRow = []; tableRow.add( TableRow( children: [ _tableColumnTitle(TranslationBase.of(context).description), _tableColumnTitle(TranslationBase.of(context).value), _tableColumnTitle(TranslationBase.of(context).range), ], ), ); for (int i = 0; i < labResultList.length; i++) tableRow.add( TableRow( children: [ _tableColumnValue(labResultList[i].description, isLast: i == (labResultList.length - 1)), _tableColumnValue(labResultList[i].resultValue + " " + labResultList[i].uOM, isLast: i == (labResultList.length - 1)), _tableColumnValue(labResultList[i].referanceRange, isLast: i == (labResultList.length - 1)), ], ), ); return tableRow; } Widget _tableColumnTitle(String text) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 6), Text( text, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), ), SizedBox(height: 6), Divider( height: 1, color: Color(0xff2E303A), thickness: 1, ) ], ); } Widget _tableColumnValue(String text, {bool isLast = false}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 12), Text( text.toLowerCase().capitalizeFirstofEach, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), ), SizedBox(height: 12), if (!isLast) Divider( height: 1, color: Color(0xffEFEFEF), thickness: 1, ) ], ); } }