多语言后端数据

This commit is contained in:
czz
2025-08-01 22:25:47 +08:00
parent 12a53ac36c
commit a199606f80
52 changed files with 1736 additions and 1142 deletions

View File

@@ -32,7 +32,7 @@ class SleepCalendarWidget extends StatefulWidget {
class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
CalendarController calendarController = Get.find();
RxMap sleepDate = <String, dynamic>{}.obs;
RxMap sleepDate = <dynamic, dynamic>{}.obs;
RxList showLabel = <dynamic>[
{"level": 5, "name": "无报告", "color": "#9E9E9E"}
].obs;
@@ -206,7 +206,8 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
return Container(
constraints: BoxConstraints(minHeight: 90.rpx),
child: Row(
children: ["".tr, "".tr, "".tr, "".tr, "".tr, "".tr, "".tr].map((day) {
children:
["".tr, "".tr, "".tr, "".tr, "".tr, "".tr, "".tr].map((day) {
return Expanded(
child: Center(
child: Text(
@@ -223,6 +224,96 @@ 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,
DateTime? selectedDate, Map sleepDate) {
final isMonthSelected = widget.type == 3;
@@ -250,7 +341,7 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
return Expanded(
child: SleepdateWidget(
highlightColor: widget.highlightColor, // ✅ 传入高亮颜色
highlightColor: widget.highlightColor,
sleepDate: sleepDate,
date: date,
isSelected: isSelected,
@@ -271,8 +362,8 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
borderRadius:
BorderRadius.circular(AppConstants().button_container_radius),
),
padding: EdgeInsets.symmetric(vertical: 6.rpx),
margin: EdgeInsets.symmetric(vertical: 6.rpx),
// 把padding改成margin避免Row宽度变化导致跳动
margin: EdgeInsets.symmetric(vertical: 6.rpx, horizontal: 12.rpx),
child: row,
);
} else {
@@ -281,7 +372,7 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
}).toList(),
);
// 如果是月份模式,包一层黑色背景容器
// 月视图高亮逻辑不变
if (isMonthSelected && selectedDate != null) {
final displayedMonth = calendarController.displayedMonth.value;
@@ -289,19 +380,12 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
displayedMonth.month == selectedDate.month;
if (isSameMonth) {
// ✅ 当前显示的月 == 当前选中的月 → 加高亮外框
return Container(
decoration: BoxDecoration(
color: widget.highlightColor, // 背景淡色
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 {