更新分享
This commit is contained in:
@@ -6,10 +6,28 @@ 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/controller/device/body_device_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
|
||||
class SleepDateWidget extends StatefulWidget {
|
||||
const SleepDateWidget({super.key});
|
||||
final String? mac;
|
||||
final String? time; // 必传:日期,例如 "07/15"
|
||||
final DateTime date; // 必传:日期,例如 "07/15"
|
||||
final String? score; // 可选:分数,默认为 "--"
|
||||
final String? comment; // 可选:评价,默认为 "暂无".tr
|
||||
final Color? textColor; // 可选:文字颜色,默认为灰色
|
||||
final bool? isSelected; // 是否选中
|
||||
|
||||
const SleepDateWidget({
|
||||
super.key,
|
||||
this.mac,
|
||||
this.time,
|
||||
required this.date,
|
||||
this.score = '--',
|
||||
this.comment = '暂无',
|
||||
this.textColor,
|
||||
this.isSelected = false, // 新增参数,默认不选中
|
||||
});
|
||||
|
||||
@override
|
||||
State<SleepDateWidget> createState() => _SleepDateWidgetState();
|
||||
@@ -19,14 +37,35 @@ class _SleepDateWidgetState extends State<SleepDateWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ThemeController themeController = Get.find();
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
String week = MyUtils.formatDateTimeWeek(widget.date);
|
||||
String day = MyUtils.formatDateTimeDay(widget.date);
|
||||
|
||||
// 选中时背景色为黑色,否则为透明
|
||||
Color backgroundColor =
|
||||
widget.isSelected == true ? Colors.black : Colors.transparent;
|
||||
|
||||
return ClickableContainer(
|
||||
backgroundColor: Colors.transparent, // 原 BoxDecoration 为空
|
||||
highlightColor:
|
||||
themeController.currentColor.sc3.withOpacity(0.1), // 自定义点击波纹颜色
|
||||
borderRadius: AppConstants().normal_container_radius, // 原来没设置圆角
|
||||
backgroundColor: backgroundColor,
|
||||
// highlightColor: themeController.currentColor.sc3.withOpacity(0.1),
|
||||
highlightColor: Colors.transparent,
|
||||
borderRadius: AppConstants().normal_container_radius,
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
print("今日评分卡片点击");
|
||||
final mac = widget.mac;
|
||||
final time = widget.time;
|
||||
|
||||
if (bodyDeviceController.sleepReportData.value.containsKey(mac)) {
|
||||
final list = bodyDeviceController.sleepReportData.value[mac];
|
||||
|
||||
for (var item in list!) {
|
||||
item['selected'] = (item['time'] == time);
|
||||
}
|
||||
bodyDeviceController.sleepReportData.value = {
|
||||
...bodyDeviceController.sleepReportData.value,
|
||||
};
|
||||
bodyDeviceController.updateAll();
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.19,
|
||||
@@ -36,54 +75,55 @@ class _SleepDateWidgetState extends State<SleepDateWidget> {
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(10.rpx, 25.rpx, 10.rpx, 22.rpx),
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 14.rpx),
|
||||
child: Text(
|
||||
'今日',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants().title_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 33.rpx),
|
||||
child: Text(
|
||||
'07/15',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 20.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 16.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'70',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 48.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: stringToColor("#00C1AA")),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 14.rpx),
|
||||
child: Text(
|
||||
'${week}',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants().title_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 33.rpx),
|
||||
child: Text(
|
||||
'${day}',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 20.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 16.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
(widget.score?.isEmpty ?? true) ? '--' : widget.score!,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 48.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: widget.textColor ??
|
||||
themeController.currentColor.sc4),
|
||||
),
|
||||
if ((widget.score?.trim().isNotEmpty ?? false))
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 16.rpx, 0, 0.rpx),
|
||||
child: Text(
|
||||
'分',
|
||||
'分'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
@@ -94,40 +134,40 @@ class _SleepDateWidgetState extends State<SleepDateWidget> {
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 0.2.rpx,
|
||||
height: 2.4.rpx,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 123.rpx,
|
||||
minHeight: 47.rpx,
|
||||
),
|
||||
child: FFButtonWidget(
|
||||
onPressed: () {
|
||||
print('合格按钮点击');
|
||||
},
|
||||
text: (widget.comment?.trim().isEmpty ?? true)
|
||||
? '暂无'.tr
|
||||
: widget.comment!,
|
||||
options: FFButtonOptions(
|
||||
height: 40.rpx,
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(16.rpx, 0, 16.rpx, 0),
|
||||
iconPadding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
|
||||
color: widget.textColor ?? themeController.currentColor.sc4,
|
||||
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
||||
fontFamily: 'Inter Tight',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
elevation: 0,
|
||||
borderRadius: BorderRadius.circular(50.rpx),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 0.2.rpx,
|
||||
height: 2.4.rpx,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 123.rpx,
|
||||
minHeight: 47.rpx,
|
||||
),
|
||||
child: FFButtonWidget(
|
||||
onPressed: () {
|
||||
print('合格按钮点击');
|
||||
},
|
||||
text: '合格',
|
||||
options: FFButtonOptions(
|
||||
height: 40.rpx,
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(16.rpx, 0, 16.rpx, 0),
|
||||
iconPadding: EdgeInsetsDirectional.fromSTEB(0, 0, 0, 0),
|
||||
color: stringToColor("#00C1AA"),
|
||||
textStyle:
|
||||
FlutterFlowTheme.of(context).titleSmall.override(
|
||||
fontFamily: 'Inter Tight',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
elevation: 0,
|
||||
borderRadius: BorderRadius.circular(50.rpx),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user