You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/vital_signs/components/vital_sign_widget.dart

355 lines
13 KiB
Dart

import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class VitalSignWidget extends StatelessWidget {
final String vitalSignName;
final String vitalSignValue;
final String vectorUrl;
final dynamic condition;
final Map<String, dynamic>? lookupValues;
final Map<String, dynamic>? bloodPressureValues;
final Color? textColor;
const VitalSignWidget({
Key? key,
required this.vitalSignName,
required this.vitalSignValue,
this.textColor,
required this.condition,
required this.vectorUrl,
this.lookupValues,
this.bloodPressureValues,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
color: Colors.white,
elevation: 2,
shadowColor: CustomColors.lightGreyColor,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
SvgPicture.asset(vectorUrl, width: 36.0, height: 36.0),
SizedBox(
width: 16,
),
Text(
vitalSignName,
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: textColor ?? Colors.white,
),
),
],
),
SizedBox(
height: 8,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"$vitalSignValue ${condition.unit}",
style: TextStyle(
fontSize: 14,
color: textColor ?? Colors.white,
fontWeight: FontWeight.w500,
),
),
SizedBox(
width: 8,
),
if (lookupValues != null)
Status(
status:
"${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}",
originalData:
condition.current?.quantitativeInterpretation ?? '',
)
// Text(
// "${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}",
// style: TextStyle(
// fontSize: 14,
// color: textColor ?? Colors.white,
// fontWeight: FontWeight.w500,
// ),
// ),
],
),
SizedBox(
height: 8,
),
// SizedBox(
// height: 30,
// child: Row(mainAxisSize: MainAxisSize.max, children: [
if (lookupValues != null)
Flexible(
flex: 1,
child: ListView.separated(
physics: NeverScrollableScrollPhysics(),
separatorBuilder: (_, __) => SizedBox(
width: 8,
),
shrinkWrap: true,
itemCount: lookupValues?.length ?? 0,
itemBuilder: (_, index) {
var key = lookupValues?.keys.elementAt(index);
return RangeWidget(
title: key ?? '',
values: lookupValues?[key] ?? [],
isSelected: false,
);
}),
),
if (bloodPressureValues != null)
Flexible(
flex: 1,
child: ListView.separated(
separatorBuilder: (_, __) => SizedBox(
width: 8,
),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: bloodPressureValues?.length ?? 0,
itemBuilder: (_, index) {
var key = bloodPressureValues?.keys.elementAt(index);
print(
'the ssize is ${(bloodPressureValues?[key]?.length ?? 1) * 40} ');
// return RangeWidget(
// title: key??'',
// values: lookupValues?[key]??[],isSelected: false,
// );
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
TranslationBase.of(context)
.getValue(key ?? ''),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 16),
),
Status(
status:
"${TranslationBase.of(context).getValue(condition.getValue(key)?.quantitativeInterpretation ?? '')}",
originalData: condition
.getValue(key)
?.quantitativeInterpretation ??
'',
)
],
),
SizedBox(height: 8),
SizedBox(
height: 220,
child: ListView.separated(
separatorBuilder: (_, __) => SizedBox(
width: 8,
),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount:
bloodPressureValues?[key]?.length ?? 0,
itemBuilder: (_, index) {
var title = bloodPressureValues?[key]
?.keys
.elementAt(index);
return RangeWidget(
title: title ?? '',
values: bloodPressureValues?[key]
?[title] ??
[],
isSelected: false,
);
}))
],
);
}),
),
// ]),
// ),
SizedBox(
height: 8,
),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text(
// TranslationBase.of(context).getValue(
// condition.condition?.first.interpretation ?? ''),
// style: TextStyle(
// fontSize: 14,
// color: textColor ?? Colors.white,
// fontWeight: FontWeight.w500,
// ),
// ),
// Text(
// TranslationBase.of(context).getValue(
// condition.condition?.last.interpretation ?? ''),
// style: TextStyle(
// fontSize: 14,
// color: textColor ?? Colors.white,
// fontWeight: FontWeight.w500,
// ),
// ),
// ],
// ),
// SizedBox(
// height: 8,
// ),
]),
),
);
}
}
class RangeWidget extends StatelessWidget {
final String title;
final List<String> values;
final bool isSelected;
const RangeWidget(
{super.key,
required this.title,
required this.isSelected,
required this.values});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
SizedBox(
height: 30,
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.only(
topStart: Radius.circular(8),
bottomStart: Radius.circular(8),
),
),
// color: Color(0xFF359846),
color: CustomColors.lightGreyColor,
child: Padding(
padding: const EdgeInsets.only(
top: 4.0, bottom: 4, right: 8, left: 8),
child: Text(
TranslationBase.of(context).getValue(title),
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black, fontSize: 12),
),
),
),
),
Expanded(
child: Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.only(
topEnd: Radius.circular(8),
bottomEnd: Radius.circular(8),
),
),
// color: Color(0xFF359846),
color: getColor(title),
child: SizedBox(
height: 30,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: List.generate(
values.length,
(index) => Row(
children: [
Text(
values[index],
textAlign: TextAlign.center,
style:
TextStyle(color: Colors.white, fontSize: 12),
),
SizedBox(
width: 8,
)
],
),
),
),
),
)),
)
],
),
);
}
getColor(title) {
switch (title) {
case "excellent":
return Color(0xFF275b45);
case "good":
return Color(0xFF507a3d);
case "poor":
return Color(0xFFa86452);
case "atRisk":
return Color(0xFFa2494b);
}
}
}
class Status extends StatelessWidget {
final String status;
final String originalData;
const Status({super.key, required this.status, required this.originalData});
@override
Widget build(BuildContext context) {
return Material(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
// color: Color(0xFF359846),
color: (originalData.toLowerCase() == 'good' ||
originalData.toLowerCase() == 'excellent' ||
originalData.toLowerCase() == 'normal')
? Color(0xFFD8E8DB)
: (originalData.toLowerCase() == 'poor' ||
originalData.toLowerCase() == 'low')
? Color(0xFFD3D37E)
: Color(0x98d02127),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
child: Text(status,
style: TextStyle(
color: (originalData.toLowerCase() == 'good' ||
originalData.toLowerCase() == 'excellent' ||
originalData.toLowerCase() == 'normal')
? Color(0xFF359846)
: (originalData.toLowerCase() == 'poor' ||
originalData.toLowerCase() == 'low')
? Colors.white
: Colors.white,
fontSize: 8,
fontWeight: FontWeight.w600,
)),
));
}
}