更新日历样式

This commit is contained in:
czz
2025-07-11 16:48:25 +08:00
parent 092267ae3a
commit de5bacb553
11 changed files with 271 additions and 89 deletions

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="30" height="30.00006103515625" viewBox="0 0 30 30.00006103515625"><g><g><g transform="matrix(0,1,-1,0,30,-30)"></g></g><g><g><g><path d="M11.342529296875,14.99966720703125C11.342529296875,14.87161720703125,11.391479496875,14.74465720703125,11.489502296875,14.646637207031251C11.489502296875,14.646637207031251,17.804439296875,8.33059720703125,17.804439296875,8.33059720703125C17.999509296875,8.13565060703125,18.316529296875,8.13565060703125,18.511479296875,8.33059720703125C18.706419296874998,8.52664220703125,18.706419296874998,8.84256020703125,18.511479296875,9.03762820703125C18.511479296875,9.03762820703125,12.549439296875,14.99966720703125,12.549439296875,14.99966720703125C12.549439296875,14.99966720703125,18.511479296875,20.96158720703125,18.511479296875,20.96158720703125C18.706419296874998,21.15758720703125,18.706419296874998,21.47368720703125,18.511479296875,21.66858720703125C18.316529296875,21.864687207031253,17.999509296875,21.864687207031253,17.804439296875,21.66858720703125C17.804439296875,21.66858720703125,11.489502296875,15.35366720703125,11.489502296875,15.35366720703125C11.391479496875,15.255647207031249,11.342529296875,15.12759720703125,11.342529296875,14.99966720703125C11.342529296875,14.99966720703125,11.342529296875,14.99966720703125,11.342529296875,14.99966720703125Z" fill="#FFFFFF" fill-opacity="1"/></g></g></g></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="30" height="30" viewBox="0 0 30 30"><g><g><g transform="matrix(0,1,-1,0,30,-30)"></g></g><g><g><g><path d="M11.342529296875,14.99966720703125C11.342529296875,14.87161720703125,11.391479496875,14.74465720703125,11.489502296875,14.646637207031251C11.489502296875,14.646637207031251,17.804439296875,8.33059720703125,17.804439296875,8.33059720703125C17.999509296875,8.13565060703125,18.316529296875,8.13565060703125,18.511479296875,8.33059720703125C18.706419296874998,8.52664220703125,18.706419296874998,8.84256020703125,18.511479296875,9.03762820703125C18.511479296875,9.03762820703125,12.549439296875,14.99966720703125,12.549439296875,14.99966720703125C12.549439296875,14.99966720703125,18.511479296875,20.96158720703125,18.511479296875,20.96158720703125C18.706419296874998,21.15758720703125,18.706419296874998,21.47368720703125,18.511479296875,21.66858720703125C18.316529296875,21.864687207031253,17.999509296875,21.864687207031253,17.804439296875,21.66858720703125C17.804439296875,21.66858720703125,11.489502296875,15.35366720703125,11.489502296875,15.35366720703125C11.391479496875,15.255647207031249,11.342529296875,15.12759720703125,11.342529296875,14.99966720703125C11.342529296875,14.99966720703125,11.342529296875,14.99966720703125,11.342529296875,14.99966720703125Z" fill="#FFFFFF" fill-opacity="1"/></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -95,6 +95,8 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
// 调用获取天气方法 // 调用获取天气方法
_getCurrentWeather(); _getCurrentWeather();
} catch (e) { } catch (e) {
print(e); print(e);
EasyDartModule.logger.error("获取位置失败: $e"); EasyDartModule.logger.error("获取位置失败: $e");
} }

View File

@@ -271,6 +271,153 @@ Future showDateSelectionDialog(BuildContext context,
); );
} }
Future showMonthSelectionDialog(
BuildContext context, {
required DateTime checkDate,
Function(DateTime)? checkChange,
String title = "选择月份",
}) {
ThemeController themeController = Get.find();
final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
..sort();
final List<int> months = List.generate(12, (i) => i + 1);
final RxInt yearIndex = years.indexOf(checkDate.year).obs;
final RxInt monthIndex = months.indexOf(checkDate.month).obs;
return showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Stack(
children: [
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Material(
color: Colors.transparent,
child: Dialog(
backgroundColor: const Color(0xFF003058),
insetPadding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(30.rpx, 10.rpx, 30.rpx, 90.rpx),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 100.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("取消",
style: TextStyle(
fontSize: 30.rpx, color: Colors.white)),
),
),
Text(
title,
style: TextStyle(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () {
final selectedDate = DateTime(
years[yearIndex.value],
months[monthIndex.value],
);
Navigator.of(context).pop();
checkChange?.call(selectedDate);
},
child: Container(
width: 100.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("确定",
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"))),
),
),
],
),
SizedBox(height: 20.rpx),
Stack(
children: [
Positioned.fill(
child: IgnorePointer(
child: Center(
child: Container(
height: 90.rpx,
margin:
EdgeInsets.symmetric(horizontal: 95.rpx),
decoration: BoxDecoration(
color: const Color(0xFF84F5FF),
borderRadius: BorderRadius.circular(16.rpx),
),
),
),
),
),
SizedBox(
height: 240.rpx,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 95.rpx),
child: Row(
children: [
Expanded(
child: getOnePickers(
context,
years,
yearIndex,
unit: "",
),
),
Expanded(
child: getOnePickers(
context,
months,
monthIndex,
unit: "",
),
),
],
),
),
),
],
),
],
),
),
),
),
),
],
);
},
);
}
Future<void> showWeightPickerDialog( Future<void> showWeightPickerDialog(
BuildContext context, { BuildContext context, {
required String initialWeight, // 初始体重单位kg required String initialWeight, // 初始体重单位kg

View File

@@ -46,11 +46,12 @@ class LineView extends StatelessWidget {
bottom: bottomPadding.rpx, bottom: bottomPadding.rpx,
), ),
child: EasyChartView( child: EasyChartView(
key: Key(DateTime.now().toString()),
size: Size(b.maxWidth, 220.rpx), size: Size(b.maxWidth, 220.rpx),
drawer: ChartDrawer( drawer: ChartDrawer(
xAxis: ChartAxis( xAxis: ChartAxis(
intent: 44, intent: 28,
entintent: 15, entintent: 9,
labels: xLabels, labels: xLabels,
count: xCount, count: xCount,
), ),
@@ -177,7 +178,7 @@ class LineView extends StatelessWidget {
remainHeight, remainHeight,
Paint() Paint()
..color = ..color =
stringToColor(remainColor).withOpacity(0.8), stringToColor(remainColor).withOpacity(0.5),
); );
} }
// 若已满,不绘制灰色段、也不显示文字(不做任何处理) // 若已满,不绘制灰色段、也不显示文字(不做任何处理)

View File

@@ -66,9 +66,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
String queryUrl = String queryUrl =
"${serviceAddress}${serviceName}${serviceApi}?bindNum=1"; "${serviceAddress}${serviceName}${serviceApi}?bindNum=1";
String? language = ""; String? language = "";
if (languageController.selectLanguage != null) { language = languageController.selectLanguage.value!.language_code;
language = languageController.selectLanguage.value!.language_code;
}
if (language != null && language.isNotEmpty) { if (language != null && language.isNotEmpty) {
if (queryUrl.contains("?")) { if (queryUrl.contains("?")) {
queryUrl += "&lang=$language"; queryUrl += "&lang=$language";
@@ -77,19 +75,14 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
} }
} }
var response = await EasyDartModule.dio.get(queryUrl); var response = await EasyDartModule.dio.get(queryUrl);
if (response != null) { var responseData =
var responseData = response.data is String ? jsonDecode(response.data) : response.data;
response.data is String ? jsonDecode(response.data) : response.data; ApiResponse res = ApiResponse.fromJson(responseData, (object) => object);
ApiResponse res = MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr);
ApiResponse.fromJson(responseData, (object) => object); if (res.code == HttpStatusCodes.ok) {
MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr); bindDeviceNum.value = res.total!;
if (res.code == HttpStatusCodes.ok) { updateAll();
bindDeviceNum.value = res.total!; return res;
updateAll();
return res;
}
} else {
return ApiResponse(code: -1, msg: "服务器.失败".tr);
} }
return apiResponse; return apiResponse;
} catch (e) { } catch (e) {
@@ -126,9 +119,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
} }
String? language = ""; String? language = "";
if (languageController.selectLanguage != null) { language = languageController.selectLanguage.value!.language_code;
language = languageController.selectLanguage.value!.language_code;
}
if (language != null && language.isNotEmpty) { if (language != null && language.isNotEmpty) {
queryParams['lang'] = language; queryParams['lang'] = language;
} }
@@ -139,19 +130,14 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
} }
var response = await EasyDartModule.dio.get(queryUrl); var response = await EasyDartModule.dio.get(queryUrl);
if (response != null) { var responseData =
var responseData = response.data is String ? jsonDecode(response.data) : response.data;
response.data is String ? jsonDecode(response.data) : response.data; ApiResponse res = ApiResponse.fromJson(responseData, (object) => object);
ApiResponse res = MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr);
ApiResponse.fromJson(responseData, (object) => object); if (res.code == HttpStatusCodes.ok) {
MyUtils.formatResponse(res, "设备.设备列表请求成功".tr, "设备.设备列表请求失败".tr); deviceList.value = res.data!;
if (res.code == HttpStatusCodes.ok) { updateAll();
deviceList.value = res.data!; return res;
updateAll();
return res;
}
} else {
return ApiResponse(code: -1, msg: "服务器.失败".tr);
} }
return apiResponse; return apiResponse;
} catch (e) { } catch (e) {
@@ -365,7 +351,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
String serviceAddress = ServiceConstant.service_address; String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service; String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.device_show; String serviceApi = ServiceConstant.device_show;
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; String queryUrl = "$serviceAddress$serviceName$serviceApi";
String? language = ""; String? language = "";
if (languageController.selectLanguage != null) { if (languageController.selectLanguage != null) {
language = languageController.selectLanguage.value!.language_code; language = languageController.selectLanguage.value!.language_code;
@@ -568,7 +554,7 @@ class MHTHomeController extends GetControllerEx<MHTHomeModel> {
String serviceName = ServiceConstant.server_service; String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.user_setting; String serviceApi = ServiceConstant.user_setting;
String type = "control_${tmp['mac']}"; String type = "control_${tmp['mac']}";
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}"; String queryUrl = "$serviceAddress$serviceName$serviceApi";
var data = { var data = {
"type": type, "type": type,
"duration": tmp['duration'], "duration": tmp['duration'],

View File

@@ -53,11 +53,12 @@ class _DataShowWidgetState extends State<DataShowWidget> {
width: MediaQuery.sizeOf(context).width * 0.35, // 固定宽度 width: MediaQuery.sizeOf(context).width * 0.35, // 固定宽度
decoration: BoxDecoration(), decoration: BoxDecoration(),
child: Align( child: Align(
alignment: widget.alignment == MainAxisAlignment.start alignment: Alignment.centerLeft,
? Alignment.centerLeft // widget.alignment == MainAxisAlignment.start
: widget.alignment == MainAxisAlignment.center // ? Alignment.centerLeft
? Alignment.center // : widget.alignment == MainAxisAlignment.center
: Alignment.centerRight, // 根据传入的 alignment 设置对齐 // ? Alignment.center
// : Alignment.centerRight, // 根据传入的 alignment 设置对齐
child: widget.widget1, // 显示传入的 widget1 child: widget.widget1, // 显示传入的 widget1
), ),
), ),

View File

@@ -89,7 +89,7 @@ class SegmentedCircleWithCenterWidget extends StatelessWidget {
centerWidget, // 放置自定义的中心 Widget centerWidget, // 放置自定义的中心 Widget
Positioned( Positioned(
bottom: 140.rpx, bottom: 140.rpx,
right: 60.rpx, // 放置在右侧 right: 50.rpx, // 放置在右侧
child: SvgPicture.asset( child: SvgPicture.asset(
_getTrendIcon(trend), _getTrendIcon(trend),
width: trend != 0 ? 14.rpx : 18.rpx, width: trend != 0 ? 14.rpx : 18.rpx,

View File

@@ -123,7 +123,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
// SegmentData(color: Colors.orange, value: 10), // SegmentData(color: Colors.orange, value: 10),
// ], // ],
segments: segments, segments: segments,
strokeWidth: 6.rpx, strokeWidth: 12.rpx,
gapAngle: 8, gapAngle: 8,
centerWidget: Container( centerWidget: Container(
child: Column( child: Column(

View File

@@ -96,7 +96,7 @@ Widget WeekDataWidget(
buildWeekDatesAndPoints(sleepReport['scoreList'])['colors'], buildWeekDatesAndPoints(sleepReport['scoreList'])['colors'],
tips: buildValueTexts(sleepReport['scoreList']['data'], '', 1), tips: buildValueTexts(sleepReport['scoreList']['data'], '', 1),
xUnit: sleepReport['scoreList']['yUnit'], xUnit: sleepReport['scoreList']['yUnit'],
barWidth: 0.1, barWidth: 0.2,
), ),
showLabel: sleepReport['scoreList']['type'], showLabel: sleepReport['scoreList']['type'],
), ),
@@ -193,7 +193,7 @@ Widget WeekDataWidget(
offset, offset,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Color(0xFFFFFFFF).withOpacity(0.06), color: Color(0xFFFFFFFF).withOpacity(0.6),
fontSize: 18.rpx), fontSize: 18.rpx),
); );
}, },
@@ -206,7 +206,7 @@ Widget WeekDataWidget(
displayMode: ChartDisplayMode.dualBar, displayMode: ChartDisplayMode.dualBar,
xUnit: sleepReport['csd']['yUnit'], xUnit: sleepReport['csd']['yUnit'],
tips: buildSleepValueTexts(sleepReport['csd']['data'], '小时', 1), tips: buildSleepValueTexts(sleepReport['csd']['data'], '小时', 1),
barWidth: 0.1, barWidth: 0.2,
), ),
showLabel: sleepReport['csd']['type'], showLabel: sleepReport['csd']['type'],
), ),

View File

@@ -103,7 +103,7 @@ class AvgSleepScoreWidget extends StatelessWidget {
height: 256.rpx, height: 256.rpx,
child: SegmentedCircleWithCenterWidget( child: SegmentedCircleWithCenterWidget(
segments: segments, segments: segments,
strokeWidth: 6.rpx, strokeWidth: 12.rpx,
gapAngle: 0, gapAngle: 0,
centerWidget: Column( centerWidget: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -136,7 +136,7 @@ class AvgSleepScoreWidget extends StatelessWidget {
runSpacing: 20.rpx, runSpacing: 20.rpx,
children: showLabel.map<Widget>((item) { children: showLabel.map<Widget>((item) {
return Container( return Container(
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5.rpx),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [

View File

@@ -1032,7 +1032,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
), ),
), ),
Padding( Padding(
padding: EdgeInsets.symmetric(horizontal: 26.rpx), padding: EdgeInsets.symmetric(horizontal: 20.rpx),
child: Text( child: Text(
displayText, displayText,
style: TextStyle( style: TextStyle(
@@ -1079,46 +1079,91 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
borderRadius: 8, borderRadius: 8,
onTap: () { onTap: () {
showSleepCalendarBottomSheet( sleepReportController.model.type == 3
type: sleepReportController.model.type, ? showMonthSelectionDialog(context, checkDate: selectedDate,
timestamp: selectedDate.millisecondsSinceEpoch, checkChange: (DateTime d) {
context: context, sleepReportController.selectedDate.value = d;
mac: widget.data['mac'], calendarController.selectedDate.value = d;
onDateSelected: (newDate) {
sleepReportController.selectedDate.value = newDate; String data = MyUtils.formatDate(
calendarController.selectedDate.value = newDate; calendarController.selectedDate.value!);
String data = MyUtils.formatDate( requestWithLog(
calendarController.selectedDate.value!); logTitle: "查询睡眠报告",
requestWithLog( method: MyHttpMethod.get,
logTitle: "查询睡眠报告", queryUrl:
method: MyHttpMethod.get, "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
queryUrl: onSuccess: (res) {
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}", print(res);
onSuccess: (res) { sleepReportController.sleepReport.value = res.data;
print(res); sleepReportController.updateAll();
sleepReportController.sleepReport.value = res.data; },
onFailure: (res) {
if (MainPageBBottomChange.getCurrentIndex() !=
null) {
if (MainPageBBottomChange.getCurrentIndex() ==
1) {
TopSlideNotification.show(context,
text: res.msg!,
textColor:
themeController.currentColor.sc9);
}
} else {
TopSlideNotification.show(context,
text: res.msg!,
textColor: themeController.currentColor.sc9);
}
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
})
: showSleepCalendarBottomSheet(
type: sleepReportController.model.type,
timestamp: selectedDate.millisecondsSinceEpoch,
context: context,
mac: widget.data['mac'],
onDateSelected: (newDate) {
sleepReportController.selectedDate.value = newDate;
calendarController.selectedDate.value = newDate;
String data = MyUtils.formatDate(
calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value =
res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
if (MainPageBBottomChange.getCurrentIndex() !=
null) {
if (MainPageBBottomChange.getCurrentIndex() ==
1) {
TopSlideNotification.show(context,
text: res.msg!,
textColor:
themeController.currentColor.sc9);
}
} else {
TopSlideNotification.show(context,
text: res.msg!,
textColor:
themeController.currentColor.sc9);
}
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll(); sleepReportController.updateAll();
calendarController.updateAll();
}, },
onFailure: (res) { );
if (MainPageBBottomChange.getCurrentIndex() != null) {
if (MainPageBBottomChange.getCurrentIndex() == 1) {
TopSlideNotification.show(context,
text: res.msg!,
textColor: themeController.currentColor.sc9);
}
} else {
TopSlideNotification.show(context,
text: res.msg!,
textColor: themeController.currentColor.sc9);
}
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
},
);
}, },
child: Padding( child: Padding(
padding: EdgeInsets.all(10.rpx), padding: EdgeInsets.all(10.rpx),