更新未登录时的报告和控制显示

This commit is contained in:
wyf
2025-07-25 14:54:11 +08:00
parent 1f4b8bde39
commit 4a3ddd0006
6 changed files with 359 additions and 386 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

View File

@@ -1,8 +1,11 @@
import 'dart:ui';
import 'package:ef/ef.dart'; import 'package:ef/ef.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:flutter_switch/flutter_switch.dart'; import 'package:flutter_switch/flutter_switch.dart';
import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart'; import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
class MattressControlPage extends StatefulWidget { class MattressControlPage extends StatefulWidget {
@@ -14,105 +17,53 @@ class MattressControlPage extends StatefulWidget {
class _MattressControlPageState extends State<MattressControlPage> { class _MattressControlPageState extends State<MattressControlPage> {
final controller = Get.put(ControlCardController()); final controller = Get.put(ControlCardController());
UserInfoController userInfoController = Get.find();
int selectedIndex = 1; // 当前选中的tab索引 int selectedIndex = 1; // 当前选中的tab索引
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isLoggedIn = userInfoController.model.login == 1;
final backgroundImage = isLoggedIn
? 'assets/images/new_background.png'
: 'assets/images/noLoginControl.png';
return LayoutBuilder( return LayoutBuilder(
builder: (context, bodySize) => GestureDetector( builder: (context, bodySize) => GestureDetector(
// // onTap: () => FocusScope.of(context).unfocus(),, child: Stack(
child: Container( children: [
decoration: const BoxDecoration( // Background Image
Container(
decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: image: AssetImage(backgroundImage),
AssetImage('assets/images/new_background.png'), // 本地图片 fit: BoxFit.fill,
fit: BoxFit.fill, // 填满整个 Container ),
), ),
), ),
child: Scaffold(
backgroundColor: Colors.transparent,
// 顶部返回 + 设备选择 + 蓝牙图标 + 设置按钮
// appBar: AppBar(
// backgroundColor: Colors.transparent,
// automaticallyImplyLeading: false,
// titleSpacing: 0,
// elevation: 0,
// title: SizedBox(
// width: double.infinity,
// height: 180.rpx,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// SizedBox(width: 20.rpx),
// returnIconButtomNew,
// SizedBox(width: 26.rpx),
// Container(
// decoration: BoxDecoration(
// color: Color(0xFF003058),
// borderRadius: BorderRadius.circular(30.rpx),
// ),
// constraints: BoxConstraints(
// minHeight: 60.rpx,
// maxHeight: 60.rpx,
// maxWidth: 260.rpx,
// minWidth: 260.rpx),
// padding: EdgeInsets.symmetric(
// horizontal: 20.rpx), // 加左右边距
// child: DropdownButton<String>(
// value: 'Eason Chan',
// underline: const SizedBox(),
// dropdownColor: Colors.blueGrey,
// iconEnabledColor: Colors.white,
// style: const TextStyle(color: Colors.white),
// isExpanded: true,
// items: const [
// DropdownMenuItem(
// value: 'Eason Chan',
// child: Text('Eason Chan'),
// ),
// DropdownMenuItem(
// value: 'Anna',
// child: Text('Anna'),
// ),
// ],
// onChanged: (_) {},
// ),
// ),
// ],
// )),
// actions: [
// ClickableContainer(
// backgroundColor: Colors.transparent,
// highlightColor: Colors.transparent,
// padding: EdgeInsets.only(right: 69.rpx),
// onTap: () {},
// child: Icon(
// Icons.bluetooth,
// color: Colors.white,
// size: 42.rpx,
// ),
// ),
// ClickableContainer(
// backgroundColor: Colors.transparent,
// highlightColor: Colors.transparent,
// padding: EdgeInsets.only(right: 38.rpx),
// onTap: () {
// Get.toNamed('/bluetoothPage', arguments: data);
// },
// child: Icon(Icons.tune,
// color: Colors.white, size: 42.rpx))
// ],
// centerTitle: false,
// ),
// Blur overlay when not logged in
if (!isLoggedIn)
Positioned.fill(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
child: Container(
color: Colors.black.withOpacity(0.5),
),
),
),
// Main Content
Scaffold(
backgroundColor: Colors.transparent,
body: SafeArea( body: SafeArea(
child: WebviewTestView( child: WebviewTestView(),
// oncreate: (widget) {
// return WebviewTestController();
// },
), ),
), ),
)))); ],
),
),
);
} }
// 床体图示 // 床体图示
@@ -121,16 +72,16 @@ class _MattressControlPageState extends State<MattressControlPage> {
padding: EdgeInsets.fromLTRB(0, 38.rpx, 0, 63.rpx), padding: EdgeInsets.fromLTRB(0, 38.rpx, 0, 63.rpx),
child: Image.asset( child: Image.asset(
'assets/images/bed_control.png', 'assets/images/bed_control.png',
width: MediaQuery.of(context).size.width * 0.7, // 你需要准备这个图像资源 width: MediaQuery.of(context).size.width * 0.7,
height: 193.rpx, height: 193.rpx,
), ),
); );
} }
Widget _buildModeSelector(BuildContext context) { Widget _buildModeSelector(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width - 60.rpx; // 左右各30 final screenWidth = MediaQuery.of(context).size.width - 60.rpx;
final spacing = 20.0.rpx; final spacing = 20.0.rpx;
final thirdWidth = 215.rpx; // 三个卡片两个间距 final thirdWidth = 215.rpx;
final tabCount = 3; final tabCount = 3;
final tabWidth = screenWidth / tabCount; final tabWidth = screenWidth / tabCount;
final sideMargin = (tabWidth - thirdWidth) / 2; final sideMargin = (tabWidth - thirdWidth) / 2;
@@ -146,7 +97,9 @@ class _MattressControlPageState extends State<MattressControlPage> {
return Expanded( return Expanded(
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
setState(() {
selectedIndex = index; selectedIndex = index;
});
}, },
child: _selectorTab( child: _selectorTab(
labels[index], labels[index],
@@ -157,7 +110,6 @@ class _MattressControlPageState extends State<MattressControlPage> {
); );
}), }),
), ),
// 白线指示器
Positioned( Positioned(
bottom: 0, bottom: 0,
left: selectedIndex * tabWidth + sideMargin, left: selectedIndex * tabWidth + sideMargin,
@@ -192,7 +144,7 @@ class _MattressControlPageState extends State<MattressControlPage> {
), ),
), ),
), ),
if (isSelected) SizedBox(height: 15.rpx), // 保留间距,避免文字和线重叠 if (isSelected) SizedBox(height: 15.rpx),
], ],
), ),
); );
@@ -216,7 +168,6 @@ class _MattressControlPageState extends State<MattressControlPage> {
final firstRow = allCards.sublist(0, 3); final firstRow = allCards.sublist(0, 3);
final restCards = allCards.sublist(3); final restCards = allCards.sublist(3);
// 后续每行两个
List<List<Map<String, dynamic>>> chunkedRows = []; List<List<Map<String, dynamic>>> chunkedRows = [];
for (int i = 0; i < restCards.length; i += 2) { for (int i = 0; i < restCards.length; i += 2) {
int end = (i + 2 < restCards.length) ? i + 2 : restCards.length; int end = (i + 2 < restCards.length) ? i + 2 : restCards.length;
@@ -228,11 +179,10 @@ class _MattressControlPageState extends State<MattressControlPage> {
padding: EdgeInsets.symmetric(horizontal: 30.rpx, vertical: 30.rpx), padding: EdgeInsets.symmetric(horizontal: 30.rpx, vertical: 30.rpx),
child: Column( child: Column(
children: [ children: [
// 第一行:三个卡片
Row( Row(
children: List.generate(firstRow.length * 2 - 1, (index) { children: List.generate(firstRow.length * 2 - 1, (index) {
if (index.isOdd) { if (index.isOdd) {
return SizedBox(width: spacing); // 卡片间距 return SizedBox(width: spacing);
} else { } else {
final item = firstRow[index ~/ 2]; final item = firstRow[index ~/ 2];
return Expanded( return Expanded(
@@ -241,14 +191,12 @@ class _MattressControlPageState extends State<MattressControlPage> {
index ~/ 2, index ~/ 2,
item['title'], item['title'],
item['time'], item['time'],
// null, // 不再使用固定宽度
), ),
); );
} }
}), }),
), ),
SizedBox(height: spacing), SizedBox(height: spacing),
// 其余每行两个卡片
...chunkedRows.map((row) { ...chunkedRows.map((row) {
return Padding( return Padding(
padding: EdgeInsets.only(bottom: spacing), padding: EdgeInsets.only(bottom: spacing),
@@ -264,7 +212,6 @@ class _MattressControlPageState extends State<MattressControlPage> {
index ~/ 2, index ~/ 2,
item['title'], item['title'],
item['time'], item['time'],
// null,
), ),
); );
} }
@@ -282,12 +229,10 @@ class _MattressControlPageState extends State<MattressControlPage> {
int index, int index,
String title, String title,
String time, String time,
// double width,
) { ) {
final controller = Get.find<ControlCardController>(); final controller = Get.find<ControlCardController>();
return Container( return Container(
// width: width,
height: 241.rpx, height: 241.rpx,
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xFF003058), color: const Color(0xFF003058),
@@ -344,6 +289,5 @@ class _MattressControlPageState extends State<MattressControlPage> {
} }
class ControlCardController extends GetxController { class ControlCardController extends GetxController {
// 共9个卡片每个卡片有自己的开关状态
final List<RxBool> switchStates = List.generate(9, (index) => false.obs); final List<RxBool> switchStates = List.generate(9, (index) => false.obs);
} }

View File

@@ -1,3 +1,5 @@
import 'dart:ui';
import 'package:ef/ef.dart'; import 'package:ef/ef.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart';
@@ -5,7 +7,6 @@ import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart'; import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart'; import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart';
@@ -52,15 +53,33 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
}); });
int login = userInfoController.model.login!; int login = userInfoController.model.login!;
return GestureDetector( return GestureDetector(
// // onTap: () => FocusScope.of(context).unfocus(),, child: Stack(
child: Container( children: [
decoration: const BoxDecoration( // Background Container
Container(
decoration: BoxDecoration(
image: DecorationImage( image: DecorationImage(
image: AssetImage('assets/images/new_background.png'), // 本地图片 image: AssetImage((userInfoController.model.login! != null &&
fit: BoxFit.fill, // 填满整个 Container userInfoController.model.login! == 1)
? 'assets/images/new_background.png'
: "assets/images/noLoginSleep.jpg"),
fit: BoxFit.fill,
), ),
), ),
child: Scaffold( ),
// Blur overlay when not logged in
if (userInfoController.model.login == null ||
userInfoController.model.login != 1)
Positioned.fill(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
child: Container(
color: Colors.black.withOpacity(0.5),
),
),
),
// Main content
Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: SafeArea( body: SafeArea(
child: Container( child: Container(
@@ -83,6 +102,13 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
children: [ children: [
TextSpan(
text: "请先",
style: TextStyle(
color: Colors.white,
fontSize: 30.rpx,
),
),
WidgetSpan( WidgetSpan(
child: Stack( child: Stack(
children: [ children: [
@@ -94,11 +120,11 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
), ),
), ),
Positioned( Positioned(
bottom: 0, // 控制下划线与文字的间距 bottom: 0,
left: 0, left: 0,
right: 0, right: 0,
child: Container( child: Container(
height: 1, // 下划线粗细 height: 1,
color: stringToColor("#84F5FF"), color: stringToColor("#84F5FF"),
), ),
), ),
@@ -106,7 +132,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
), ),
), ),
TextSpan( TextSpan(
text: "查看睡眠报告", text: "后,再查看睡眠报告",
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 30.rpx, fontSize: 30.rpx,
@@ -125,29 +151,17 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
if (userInfoController.model.login! != null && if (userInfoController.model.login! != null &&
userInfoController.model.login! == 1) { userInfoController.model.login! == 1) {
final list = deviceController.personnelList.value; final list = deviceController.personnelList.value;
// if (list.isNotEmpty &&
// formFieldController.value == null) {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// formFieldController.value = list[0]["mac"];
// personInfo.value = list[0];
// homeController.selectPerson.value = list[0];
// homeController.selectDevcie.value = list[0]["mac"];
// deviceController
// .getSleeps(formFieldController.value);
// homeController.updateAll();
// });
// }
if (list.isNotEmpty) { if (list.isNotEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
formFieldController.value = list[0]["mac"]; formFieldController.value = list[0]["mac"];
personInfo.value = list[0]; personInfo.value = list[0];
homeController.selectPerson.value = list[0]; homeController.selectPerson.value = list[0];
homeController.selectDevcie.value = list[0]["mac"]; homeController.selectDevcie.value = list[0]["mac"];
deviceController.getSleeps(formFieldController.value); deviceController
.getSleeps(formFieldController.value);
homeController.updateAll(); homeController.updateAll();
}); });
} }
//themeController.currentColor.sc5,
if (homeController.personnelList.value.length != 0) if (homeController.personnelList.value.length != 0)
return Padding( return Padding(
padding: EdgeInsetsDirectional.fromSTEB( padding: EdgeInsetsDirectional.fromSTEB(
@@ -175,7 +189,8 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
'健康报告'.tr, '健康报告'.tr,
style: TextStyle( style: TextStyle(
fontFamily: 'Readex Pro', fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3, color:
themeController.currentColor.sc3,
letterSpacing: 0, letterSpacing: 0,
fontSize: 30.rpx, fontSize: 30.rpx,
), ),
@@ -191,29 +206,37 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
Colors.transparent), Colors.transparent),
), ),
child: ValueListenableBuilder( child: ValueListenableBuilder(
valueListenable: formFieldController, valueListenable:
formFieldController,
builder: (c, a, s) => ClipRRect( builder: (c, a, s) => ClipRRect(
borderRadius: borderRadius:
BorderRadius.circular(36.rpx), BorderRadius.circular(
36.rpx),
child: Theme( child: Theme(
data: Theme.of(context).copyWith( data: Theme.of(context)
splashColor: Colors.transparent, .copyWith(
splashColor:
Colors.transparent,
highlightColor: highlightColor:
Colors.transparent, Colors.transparent,
hoverColor: Colors.transparent, hoverColor:
Colors.transparent,
), ),
child: child: FlutterFlowDropDown<
FlutterFlowDropDown<String>( String>(
controller: formFieldController, controller:
formFieldController,
options: deviceController options: deviceController
.personnelList.value .personnelList.value
.map<String>( .map<String>((d) =>
(d) => "${d["mac"]}") "${d["mac"]}")
.toList(), .toList(),
optionLabels: deviceController optionLabels:
deviceController
.personnelList.value .personnelList.value
.map<String>((d) { .map<String>((d) {
var s = d["name"] ?? d["mac"]; var s =
d["name"] ?? d["mac"];
if (s == null) { if (s == null) {
return ""; return "";
} else { } else {
@@ -221,17 +244,21 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
} }
}).toList(), }).toList(),
onChanged: (val) { onChanged: (val) {
final list = deviceController final list =
.personnelList.value; deviceController
.personnelList
.value;
final selectedPerson = final selectedPerson =
list.firstWhere( list.firstWhere(
(element) => (element) =>
element['mac'] == val, element['mac'] ==
orElse: () => val,
null, // 防止找不到时报错 orElse: () => null,
); );
homeController.selectPerson homeController
.value = selectedPerson; .selectPerson
.value =
selectedPerson;
personInfo.value = personInfo.value =
selectedPerson; selectedPerson;
@@ -240,17 +267,19 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
(6).obs; (6).obs;
print("$val"); print("$val");
if (val == null) { if (val == null) {
homeController homeController.sleepDays
.sleepDays.value = []; .value = [];
} else { } else {
homeController.selectDevcie homeController
.selectDevcie
.value = .value =
formFieldController formFieldController
.value!; .value!;
deviceController.getSleeps( deviceController.getSleeps(
formFieldController formFieldController
.value); .value);
homeController.updateAll(); homeController
.updateAll();
} }
}, },
width: 300.rpx, width: 300.rpx,
@@ -266,19 +295,24 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
icon: Icon( icon: Icon(
Icons Icons
.keyboard_arrow_down_rounded, .keyboard_arrow_down_rounded,
color: color: stringToColor(
stringToColor("#FFFFFF"), "#FFFFFF"),
size: 30.rpx, size: 30.rpx,
), ),
fillColor: fillColor: stringToColor(
stringToColor("#184468"), "#184468"),
elevation: 2, elevation: 2,
borderColor: Colors.transparent, borderColor:
Colors.transparent,
borderWidth: 2, borderWidth: 2,
borderRadius: 100.rpx, borderRadius: 100.rpx,
margin: EdgeInsetsDirectional margin:
.fromSTEB(32.rpx, 8.rpx, EdgeInsetsDirectional
32.rpx, 8.rpx), .fromSTEB(
32.rpx,
8.rpx,
32.rpx,
8.rpx),
hidesUnderline: true, hidesUnderline: true,
isOverButton: false, isOverButton: false,
isSearchable: false, isSearchable: false,
@@ -310,34 +344,23 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
'date': DateTime.now().millisecondsSinceEpoch, 'date': DateTime.now().millisecondsSinceEpoch,
'mac': homeController.selectDevcie.value, 'mac': homeController.selectDevcie.value,
'person': homeController.selectPerson.value, 'person': homeController.selectPerson.value,
'backgroundImg': 'assets/images/new_background.png', 'backgroundImg':
'assets/images/new_background.png',
'arrow': false, 'arrow': false,
'noBackImg': true, 'noBackImg': true,
'person_show': false, 'person_show': false,
}, },
), ),
); );
// }
return Container(); return Container();
}), }),
// Expanded(
// child: NewSleepReportPage(
// data: {
// "tag": "123",
// 'date': DateTime.now().millisecondsSinceEpoch,
// 'mac': homeController.selectDevcie.value,
// 'person': homeController.selectPerson.value,
// 'backgroundImg': 'assets/images/new_background.png',
// },
// ),
// ),
// }
], ],
), ),
), ),
), ),
), ),
)); ],
),
);
} }
} }

View File

@@ -746,7 +746,7 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
fillColor: Colors fillColor: Colors
.transparent, .transparent,
filled: true, filled: true,
hintText: "请输入联系", hintText: "请输入联系方式",
hintStyle: TextStyle( hintStyle: TextStyle(
color: color:
Colors.white), Colors.white),

View File

@@ -37,8 +37,8 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
web = WebviewHelper( web = WebviewHelper(
isheadless: false, isheadless: false,
jsbridge: buildsdk( jsbridge: buildsdk(
father: this, // father: this,
clientId: '494641114', // clientId: '494641114',
// dbgserverUrl: 'ws://192.168.1.2:9001', // dbgserverUrl: 'ws://192.168.1.2:9001',
), ),
settings: buildsettings(), settings: buildsettings(),
@@ -350,7 +350,6 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
.updateDeviceList(deviceController.deviceList.values); .updateDeviceList(deviceController.deviceList.values);
} }
}); });
return Scaffold( return Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Column( body: Column(
@@ -371,6 +370,13 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
children: [ children: [
TextSpan(
text: "请先",
style: TextStyle(
color: Colors.white,
fontSize: 30.rpx,
),
),
WidgetSpan( WidgetSpan(
child: Stack( child: Stack(
children: [ children: [
@@ -394,7 +400,7 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
), ),
), ),
TextSpan( TextSpan(
text: "进行设备控制", text: "后,再进行设备控制",
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 30.rpx, fontSize: 30.rpx,