146 lines
5.1 KiB
Dart
146 lines
5.1 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:vbvs_app/common/color/appConstants.dart';
|
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
|
import 'package:vbvs_app/common/util/MyUtils.dart';
|
|
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
|
import 'package:vbvs_app/enum/APPPackageType.dart';
|
|
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
|
|
|
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:vbvs_app/pages/sleep_report/chart/weekDataShowWidget.dart';
|
|
|
|
class IndicatorCompareCard extends StatelessWidget {
|
|
final String title;
|
|
final String? tooltip;
|
|
final List<String> headers; // 表头 ["名称", "测量值", "参考范围", "趋势"]
|
|
final List<List<Widget>> rows; // 每一行的 4 个 widget
|
|
final double spacing;
|
|
|
|
const IndicatorCompareCard({
|
|
super.key,
|
|
required this.title,
|
|
this.tooltip,
|
|
required this.headers,
|
|
required this.rows,
|
|
this.spacing = 31,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
/// 标题行
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
title.tr,
|
|
style: TextStyle(
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
if (tooltip != null)
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: Colors.white,
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
14.rpx, 10.rpx, 14.rpx, 10.rpx),
|
|
borderRadius: 0.rpx,
|
|
onTap: () {
|
|
if (AppConstants().ent_type == APPPackageType.MHT.code) {
|
|
showTipDialog(
|
|
context,
|
|
Text(
|
|
tooltip!.tr,
|
|
style: TextStyle(
|
|
fontSize: 26.rpx,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
backgroundColor: Color(0xFFFFFFFF),
|
|
colors: [
|
|
Color(0XFF1592AA),
|
|
Color(0xFF0C83A7),
|
|
Color(0xFF006FA3)
|
|
],
|
|
);
|
|
} else {
|
|
showTipDialog(
|
|
context,
|
|
Text(
|
|
tooltip!.tr,
|
|
style: TextStyle(
|
|
fontSize: 26.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
),
|
|
backgroundColor: themeController.currentColor.sc17,
|
|
colors: AppConstants().thNormalButton,
|
|
);
|
|
}
|
|
},
|
|
child: Container(
|
|
width: 30.rpx,
|
|
height: 30.rpx,
|
|
child: SvgPicture.asset(
|
|
'assets/img/icon/explain.svg',
|
|
color: Color(0xFFD3D3D3),
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
SizedBox(height: spacing.rpx),
|
|
|
|
/// 表头
|
|
Weekdatashowwidget(
|
|
alignment: MainAxisAlignment.center,
|
|
widget1: _buildHeader(headers, 0),
|
|
widget2: _buildHeader(headers, 1),
|
|
widget3: _buildHeader(headers, 2),
|
|
widget4: _buildHeader(headers, 3),
|
|
),
|
|
|
|
/// 数据行
|
|
Column(
|
|
children: rows.map((row) {
|
|
return Weekdatashowwidget(
|
|
alignment: MainAxisAlignment.center,
|
|
widget1: row[0],
|
|
widget2: row[1],
|
|
widget3: row[2],
|
|
widget4: row[3],
|
|
).paddingOnly(bottom: 0.rpx);
|
|
}).toList(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildHeader(List<String> headers, int index) {
|
|
return Text(
|
|
headers.length > index ? headers[index].tr : "",
|
|
style: TextStyle(
|
|
color: themeController.currentColor.sc4,
|
|
fontSize: AppConstants().normal_text_fontSize,
|
|
),
|
|
);
|
|
}
|
|
}
|