更新日历样式
This commit is contained in:
@@ -57,7 +57,7 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
||||
|
||||
// 初始化请求
|
||||
fetchDate(initialDate);
|
||||
|
||||
fetchSleepColor();
|
||||
// 每当月份变化时,重新请求数据
|
||||
ever(calendarController.displayedMonth, (DateTime newMonth) {
|
||||
fetchDate(newMonth);
|
||||
@@ -74,38 +74,26 @@ class _SleepCalendarWidgetState extends State<SleepCalendarWidget> {
|
||||
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.mac}&time=$dateStr&type=3",
|
||||
onSuccess: (res) {
|
||||
sleepDate.value = res.data;
|
||||
showLabel.value = [
|
||||
...res.data['scoreList']['type'],
|
||||
{"level": 5, "name": "无报告", "color": "#9E9E9E"},
|
||||
// ✅ 注意拼写是 scoreList
|
||||
];
|
||||
},
|
||||
onFailure: (res) {
|
||||
sleepDate.value = {};
|
||||
showLabel.value = [
|
||||
{"level": 5, "name": "无报告", "color": "#9E9E9E"},
|
||||
];
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> fetchSleepColor(DateTime timeStamp) async {
|
||||
final dateStr = timeStamp.toString().split(' ')[0];
|
||||
|
||||
Future<void> fetchSleepColor() async {
|
||||
await requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: "https://sleepdata.he-info.com/api/analysis/sleep/score/type",
|
||||
onSuccess: (res) {
|
||||
sleepDate.value = res.data;
|
||||
showLabel.value = [
|
||||
...res.data['scoreList']['type'],
|
||||
...res.data,
|
||||
{"level": 5, "name": "无报告", "color": "#9E9E9E"},
|
||||
// ✅ 注意拼写是 scoreList
|
||||
];
|
||||
},
|
||||
onFailure: (res) {
|
||||
sleepDate.value = {};
|
||||
showLabel.value = [
|
||||
{"level": 5, "name": "无报告", "color": "#9E9E9E"},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user