1.更新睡眠报告无数据时居中显示

2.更新控制按钮变圆圈
3.修复首页设备列表名称太长导致控制图标挤出去
This commit is contained in:
wyf
2025-07-15 14:18:16 +08:00
parent 35cf04b580
commit 6423485e34
5 changed files with 592 additions and 43 deletions

View File

@@ -211,7 +211,7 @@ class DeviceInfoWidget extends GetView {
webviewTestController.web.jsbridge?.dart webviewTestController.web.jsbridge?.dart
.pageActive(false); .pageActive(false);
await Future.delayed(Duration(seconds: 1)); // await Future.delayed(Duration(seconds: 1));
webviewTestController.web.jsbridge?.dart webviewTestController.web.jsbridge?.dart
.appToHtmlDevice(device); .appToHtmlDevice(device);
MainPageBBottomChange.jumpTo(2); MainPageBBottomChange.jumpTo(2);

View File

@@ -33,8 +33,10 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Column( Flexible(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Container(
width: 170.rpx, width: 170.rpx,
@@ -42,7 +44,8 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(8.rpx), borderRadius: BorderRadius.circular(8.rpx),
child: Image.network( child: Image.network(
widget.deviceStatus['device_image'], // 从DeviceStatus获取图片 widget
.deviceStatus['device_image'], // 从DeviceStatus获取图片
width: 200.rpx, width: 200.rpx,
height: 200.rpx, height: 200.rpx,
fit: BoxFit.cover, fit: BoxFit.cover,
@@ -56,9 +59,13 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
fontSize: 26.rpx, fontSize: 26.rpx,
letterSpacing: 0.0.rpx, letterSpacing: 0.0.rpx,
), ),
maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
].divide(SizedBox(height: 26.rpx)), ].divide(SizedBox(height: 26.rpx)),
), ),
),
SizedBox(width: 26.rpx),
Column( Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [

View File

@@ -282,7 +282,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
borderColor: borderColor:
Colors.transparent, Colors.transparent,
borderWidth: 2, borderWidth: 2,
borderRadius: 0.rpx, borderRadius: 100.rpx,
margin: margin:
EdgeInsetsDirectional EdgeInsetsDirectional
.fromSTEB( .fromSTEB(

View File

@@ -540,7 +540,7 @@ class _NewHomePageState extends State<NewHomePage> {
borderColor: borderColor:
Colors.transparent, Colors.transparent,
borderWidth: 2, borderWidth: 2,
borderRadius: 18, borderRadius: 100.rpx,
margin: margin:
EdgeInsetsDirectional EdgeInsetsDirectional
.fromSTEB( .fromSTEB(

View File

@@ -155,15 +155,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
builder: (context, bodySize) => GestureDetector( builder: (context, bodySize) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(), onTap: () => FocusScope.of(context).unfocus(),
child: Container( child: Container(
// decoration: BoxDecoration(
// image: DecorationImage(
// image: (widget.data['backgroundImg'] != null &&
// widget.data['backgroundImg'].toString().isNotEmpty)
// ? AssetImage(widget.data['backgroundImg'])
// : AssetImage('assets/img/bgNoImg.png') as ImageProvider,
// fit: BoxFit.fill,
// ),
// ),
decoration: BoxDecoration( decoration: BoxDecoration(
image: (widget.data['noBackImg'] != null && image: (widget.data['noBackImg'] != null &&
widget.data['noBackImg'] == true) widget.data['noBackImg'] == true)
@@ -176,7 +167,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
fit: BoxFit.fill, fit: BoxFit.fill,
), ),
), ),
child: Scaffold( child: Scaffold(
backgroundColor: Colors.transparent, // 背景透明 backgroundColor: Colors.transparent, // 背景透明
// appBar: AppBar( // appBar: AppBar(
@@ -252,13 +242,12 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
), ),
), ),
), ),
body: SafeArea( body: SafeArea(
top: true, top: true,
child: SingleChildScrollView(
child: Obx(() { child: Obx(() {
var sleepReport = sleepReportController.sleepReport; var sleepReport = sleepReportController.sleepReport;
print(sleepReport); print(sleepReport);
if (sleepReport.isEmpty || sleepReport.isEmpty) {
return Column( return Column(
children: [ children: [
Padding( Padding(
@@ -767,7 +756,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
), ),
(sleepReport.value == null || sleepReport.value.isEmpty) (sleepReport.value == null || sleepReport.value.isEmpty)
? Container( ? Container(
child: NullDataWidget(), child: Expanded(child: NullDataWidget()),
) )
: (sleepReportController.model.type == 1 : (sleepReportController.model.type == 1
? DailyDataWidget(sleepReport, sleepCardKey, ? DailyDataWidget(sleepReport, sleepCardKey,
@@ -782,8 +771,561 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
height: 25.rpx, height: 25.rpx,
)), )),
); );
}), } else {
return SingleChildScrollView(
child: Column(
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
minHeight: 90.rpx,
), ),
decoration: BoxDecoration(
color: widget.data['backgroundColor'] != null
? widget.data['backgroundColor']
: themeController.currentColor.sc5,
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 15.rpx, 30.rpx, 15.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Stack(
alignment: Alignment.bottomLeft,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController
.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController.model.type =
1;
String data = MyUtils.formatDate(
calendarController
.selectedDate.value!);
await 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();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width:
115.rpx, // 固定宽度为 160.rpx
alignment:
Alignment.center, // 文字居中
child: Text(
'日报'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color: sleepReportController
.model.type ==
1
? themeController
.currentColor.sc2
: themeController
.currentColor.sc3,
),
),
),
SizedBox(height: 10.rpx),
],
),
),
Obx(() {
return ClickableContainer(
backgroundColor:
Colors.transparent,
highlightColor: themeController
.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController
.model.type = 2;
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
await 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();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 115
.rpx, // 固定宽度为 160.rpx
alignment: Alignment
.center, // 文字居中
child: Text('周报'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color: sleepReportController
.model
.type ==
2
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
)),
),
SizedBox(height: 10.rpx),
],
),
);
}),
Obx(() {
return ClickableContainer(
backgroundColor:
Colors.transparent,
highlightColor: themeController
.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController
.model.type = 3;
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
await 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();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 115
.rpx, // 固定宽度为 160.rpx
alignment: Alignment
.center, // 文字居中
child: Text(
'月报'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color:
sleepReportController
.model
.type ==
3
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
),
),
),
SizedBox(height: 10.rpx),
],
),
);
}),
],
),
AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0,
left:
sleepReportController.model.type ==
1
? 0
: sleepReportController
.model.type ==
2
? 115.rpx
: 230.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
decoration: BoxDecoration(
color: themeController
.currentColor.sc2,
borderRadius:
BorderRadius.circular(2.rpx),
),
),
),
],
),
],
),
),
),
),
Container(
width: double.infinity,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 32.rpx, 30.rpx, 32.rpx),
child: getTimeWidget(),
),
),
if (widget.data['person_show'] == null ||
widget.data['person_show'] != false)
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 51.rpx),
child: ClickableContainer(
backgroundColor:
widget.data['backgroundColor'] != null
? widget.data['backgroundColor']
: themeController.currentColor.sc5,
highlightColor: themeController
.currentColor.sc5, // 或你希望的点击水波纹颜色
borderRadius: AppConstants()
.normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx
padding: EdgeInsets.zero,
onTap: () {},
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
flex: 2,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'姓名'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc4,
),
),
Text(
'年龄'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc4,
),
),
].divide(
SizedBox(height: 34.rpx)),
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
(widget.data['person']
?['name']
?.toString()
.trim()
.isNotEmpty ??
false)
? widget.data['person']![
'name']
.toString()
: '未知数据'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
Text(
'${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(widget.data['person']?['birthday'])) ?? '未知数据'.tr}',
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
].divide(
SizedBox(height: 34.rpx)),
),
]
.divide(SizedBox(width: 33.rpx))
.addToStart(
SizedBox(width: 37.rpx)),
),
]
.addToStart(SizedBox(height: 36.rpx))
.addToEnd(SizedBox(height: 36.rpx)),
),
),
Flexible(
flex: 3,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
Text(
'设备ID'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc4,
),
),
Text(
'体重'.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc4,
),
),
].divide(
SizedBox(height: 34.rpx)),
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${widget.data['code'] ?? '未知数据'.tr}',
// "D11250300003",
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
maxLines: 1,
overflow:
TextOverflow.ellipsis,
),
Text(
'${widget.data['person']?['weight'] ?? '未知数据'.tr}kg',
style: TextStyle(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
].divide(
SizedBox(height: 34.rpx)),
),
]
.divide(SizedBox(width: 33.rpx))
.addToStart(
SizedBox(width: 37.rpx)),
),
]
.addToStart(SizedBox(height: 36.rpx))
.addToEnd(SizedBox(height: 36.rpx)),
),
),
],
),
),
),
(sleepReport.value == null || sleepReport.value.isEmpty)
? Container(
child: NullDataWidget(),
)
: (sleepReportController.model.type == 1
? DailyDataWidget(
sleepReport,
sleepCardKey,
heartRateCardKey,
breatheCardKey,
widget.data)
: sleepReportController.model.type == 2
? WeekDataWidget(sleepReport, widget.data)
: sleepReportController.model.type == 3
? MonthDataWidget(
sleepReport, widget.data)
: NullDataWidget()),
].divide(SizedBox(
height: 25.rpx,
)),
),
);
}
}),
), ),
), ),
), ),