diff --git a/lib/component/base/SleepCalendarWidget.dart b/lib/component/base/SleepCalendarWidget.dart index ed631f9..ce6943f 100644 --- a/lib/component/base/SleepCalendarWidget.dart +++ b/lib/component/base/SleepCalendarWidget.dart @@ -31,11 +31,14 @@ class SleepCalendarWidget extends StatefulWidget { } class _SleepCalendarWidgetState extends State { + static final level5Item = { + "level": 5, + "name": "无报告".tr, + "color": "#313541", + }; CalendarController calendarController = Get.find(); RxMap sleepDate = {}.obs; - RxList showLabel = [ - {"level": 5, "name": "无报告".tr, "color": "#9E9E9E"} - ].obs; + RxList showLabel = [level5Item].obs; // @override // void initState() { // super.initState(); @@ -95,13 +98,13 @@ class _SleepCalendarWidgetState extends State { onSuccess: (res) { showLabel.value = [ ...res.data, - {"level": 5, "name": "无报告".tr, "color": "#9E9E9E"}, + level5Item, // ✅ 注意拼写是 scoreList ]; }, onFailure: (res) { showLabel.value = [ - {"level": 5, "name": "无报告".tr, "color": "#9E9E9E"}, + level5Item, ]; }, ); @@ -230,96 +233,6 @@ class _SleepCalendarWidgetState extends State { ); } - // Widget _buildCalendarGrid(List> calendarRows, - // DateTime? selectedDate, Map sleepDate) { - // final isMonthSelected = widget.type == 3; - - // Widget content = Column( - // children: calendarRows.map((week) { - // final isWeekSelected = widget.type == 2 && - // selectedDate != null && - // week.any((d) => - // d.year == selectedDate.year && - // d.month == selectedDate.month && - // d.day == selectedDate.day); - - // final row = Row( - // children: week.map((date) { - // if (date.year == 0) { - // return const Expanded(child: SizedBox.shrink()); - // } - - // final isSelected = widget.type == 1 && - // selectedDate != null && - // date.year == selectedDate.year && - // date.month == selectedDate.month && - // date.day == selectedDate.day; - - // return Expanded( - // child: SleepdateWidget( - // highlightColor: widget.highlightColor, // ✅ 传入高亮颜色 - // sleepDate: sleepDate, - // date: date, - // isSelected: isSelected, - // onTap: () { - // calendarController.selectDate(date); - // widget.onDateSelected?.call(date); - // Get.back(); - // }, - // ), - // ); - // }).toList(), - // ); - - // if (isWeekSelected) { - // return Container( - // decoration: BoxDecoration( - // color: widget.highlightColor, - // borderRadius: - // BorderRadius.circular(AppConstants().button_container_radius), - // ), - // padding: EdgeInsets.symmetric( - // vertical: 6.rpx, horizontal: 12.rpx), // 增加左右padding - // margin: EdgeInsets.symmetric(vertical: 6.rpx), - // child: row, - // ); - // } else { - // return row; - // } - // }).toList(), - // ); - - // // 如果是月份模式,包一层黑色背景容器 - // if (isMonthSelected && selectedDate != null) { - // final displayedMonth = calendarController.displayedMonth.value; - - // final isSameMonth = displayedMonth.year == selectedDate.year && - // displayedMonth.month == selectedDate.month; - - // if (isSameMonth) { - // // ✅ 当前显示的月 == 当前选中的月 → 加高亮外框 - // return Container( - // decoration: BoxDecoration( - // color: widget.highlightColor, // 背景淡色 - // borderRadius: - // BorderRadius.circular(AppConstants().normal_container_radius), - // // border: Border.all( - // // color: widget.highlightColor, - // // width: 2.rpx, - // // ), - // ), - // // padding: EdgeInsets.symmetric(vertical: 0.rpx, horizontal: 0.rpx), - // // margin: EdgeInsets.symmetric(vertical: 0.rpx), - // child: content, - // ); - // } else { - // return content; - // } - // } else { - // return content; - // } - // } - Widget _buildCalendarGrid(List> calendarRows, DateTime? selectedDate, Map sleepDate) { final isMonthSelected = widget.type == 3; diff --git a/lib/component/base/SleepdateWidget.dart b/lib/component/base/SleepdateWidget.dart index fc96083..39f97b5 100644 --- a/lib/component/base/SleepdateWidget.dart +++ b/lib/component/base/SleepdateWidget.dart @@ -73,7 +73,8 @@ class SleepdateWidget extends StatelessWidget { EdgeInsetsDirectional.fromSTEB(10.rpx, 10.rpx, 10.rpx, 10.rpx), child: Container( decoration: BoxDecoration( - color: fillColor ?? Color(0xFF757575), // 如果匹配不到就默认灰色 + // color: fillColor ?? Color(0xFF757575), // 如果匹配不到就默认灰色 + color: fillColor ?? Color(0xFF313541), shape: BoxShape.circle, ), alignment: Alignment.center,