睡眠报告日期选择器颜色更改
This commit is contained in:
@@ -31,11 +31,14 @@ class SleepCalendarWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
||||||
|
static final level5Item = {
|
||||||
|
"level": 5,
|
||||||
|
"name": "无报告".tr,
|
||||||
|
"color": "#313541",
|
||||||
|
};
|
||||||
CalendarController calendarController = Get.find();
|
CalendarController calendarController = Get.find();
|
||||||
RxMap sleepDate = <dynamic, dynamic>{}.obs;
|
RxMap sleepDate = <dynamic, dynamic>{}.obs;
|
||||||
RxList showLabel = <dynamic>[
|
RxList showLabel = <dynamic>[level5Item].obs;
|
||||||
{"level": 5, "name": "无报告".tr, "color": "#9E9E9E"}
|
|
||||||
].obs;
|
|
||||||
// @override
|
// @override
|
||||||
// void initState() {
|
// void initState() {
|
||||||
// super.initState();
|
// super.initState();
|
||||||
@@ -95,13 +98,13 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
|||||||
onSuccess: (res) {
|
onSuccess: (res) {
|
||||||
showLabel.value = [
|
showLabel.value = [
|
||||||
...res.data,
|
...res.data,
|
||||||
{"level": 5, "name": "无报告".tr, "color": "#9E9E9E"},
|
level5Item,
|
||||||
// ✅ 注意拼写是 scoreList
|
// ✅ 注意拼写是 scoreList
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
onFailure: (res) {
|
onFailure: (res) {
|
||||||
showLabel.value = [
|
showLabel.value = [
|
||||||
{"level": 5, "name": "无报告".tr, "color": "#9E9E9E"},
|
level5Item,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -230,96 +233,6 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget _buildCalendarGrid(List<List<DateTime>> 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<List<DateTime>> calendarRows,
|
Widget _buildCalendarGrid(List<List<DateTime>> calendarRows,
|
||||||
DateTime? selectedDate, Map sleepDate) {
|
DateTime? selectedDate, Map sleepDate) {
|
||||||
final isMonthSelected = widget.type == 3;
|
final isMonthSelected = widget.type == 3;
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ class SleepdateWidget extends StatelessWidget {
|
|||||||
EdgeInsetsDirectional.fromSTEB(10.rpx, 10.rpx, 10.rpx, 10.rpx),
|
EdgeInsetsDirectional.fromSTEB(10.rpx, 10.rpx, 10.rpx, 10.rpx),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: fillColor ?? Color(0xFF757575), // 如果匹配不到就默认灰色
|
// color: fillColor ?? Color(0xFF757575), // 如果匹配不到就默认灰色
|
||||||
|
color: fillColor ?? Color(0xFF313541),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
|||||||
Reference in New Issue
Block a user