更新睡眠报告页面和控制页面无设备的显示
This commit is contained in:
@@ -178,7 +178,8 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
ef.log('查询睡眠习惯: $args[0]');
|
||||
try {
|
||||
MHTBlueToothController blueToothController = Get.find();
|
||||
var sleepData = await blueToothController.loadMattressTimeData(args[0]);
|
||||
var sleepData =
|
||||
await blueToothController.loadMattressTimeData(args[0]);
|
||||
return sleepData['data'];
|
||||
} catch (e) {
|
||||
ef.log("[查询睡眠习惯失败]:$e");
|
||||
@@ -373,44 +374,133 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
@override
|
||||
WebviewTestController newinstance() {
|
||||
if (ef.kvRoot.WebviewTestController == null) {
|
||||
|
||||
ef.kvRoot.WebviewTestController = WebviewTestController();
|
||||
if (Get.isRegistered<WebviewTestController>() == false) {
|
||||
Get.put<WebviewTestController>(ef.kvRoot.WebviewTestController);
|
||||
WebviewTestController webviewTestController = Get.find();
|
||||
webviewTestController.global=true;
|
||||
webviewTestController.global = true;
|
||||
return webviewTestController;
|
||||
}
|
||||
}
|
||||
return ef.kvRoot.WebviewTestController;
|
||||
}
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// UserInfoController userInfoController = Get.find();
|
||||
// MHTHomeController deviceController = Get.find();
|
||||
// deviceController.getDeviceList().then((x) {
|
||||
// if (controller.web.jsbridge!.inited) {
|
||||
// //发送测试消息给webview
|
||||
// // controller.web.jsbridge!.dart
|
||||
// // .updateDeviceList(deviceController.deviceList.values);
|
||||
// }
|
||||
// });
|
||||
// return Scaffold(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// body: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: (userInfoController.model.login! != null &&
|
||||
// userInfoController.model.login! == 1)
|
||||
// ? MainAxisAlignment.start
|
||||
// : MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Obx(() {
|
||||
// return Visibility(
|
||||
// visible: userInfoController.model.login! == null ||
|
||||
// userInfoController.model.login! == 0,
|
||||
// child: Center(
|
||||
// child: InkWell(
|
||||
// onTap: () => Get.toNamed("/loginPage"),
|
||||
// child: RichText(
|
||||
// text: TextSpan(
|
||||
// children: [
|
||||
// TextSpan(
|
||||
// text: "请先".tr,
|
||||
// style: TextStyle(
|
||||
// color: Colors.white,
|
||||
// fontSize: 30.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// WidgetSpan(
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// Text(
|
||||
// "登录".tr,
|
||||
// style: TextStyle(
|
||||
// color: stringToColor("#84F5FF"),
|
||||
// fontSize: 30.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// bottom: 0, // 控制下划线与文字的间距
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// child: Container(
|
||||
// height: 1, // 下划线粗细
|
||||
// color: stringToColor("#84F5FF"),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// TextSpan(
|
||||
// text: "后,再进行设备控制".tr,
|
||||
// style: TextStyle(
|
||||
// color: Colors.white,
|
||||
// fontSize: 30.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// Obx(() {
|
||||
// return Visibility(
|
||||
// visible: userInfoController.model.login! != null &&
|
||||
// userInfoController.model.login! == 1,
|
||||
// child: Expanded(
|
||||
// child: Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: Obx(() {
|
||||
// return controller.ready.value
|
||||
// ? controller.web.build()
|
||||
// : Container();
|
||||
// }),
|
||||
// ),
|
||||
// ));
|
||||
// }),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
UserInfoController userInfoController = Get.find();
|
||||
MHTHomeController deviceController = Get.find();
|
||||
deviceController.getDeviceList().then((x) {
|
||||
if (controller.web.jsbridge!.inited) {
|
||||
//发送测试消息给webview
|
||||
// controller.web.jsbridge!.dart
|
||||
// .updateDeviceList(deviceController.deviceList.values);
|
||||
}
|
||||
});
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: (userInfoController.model.login! != null &&
|
||||
userInfoController.model.login! == 1)
|
||||
? MainAxisAlignment.start
|
||||
: MainAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() {
|
||||
return Visibility(
|
||||
visible: userInfoController.model.login! == null ||
|
||||
userInfoController.model.login! == 0,
|
||||
child: Center(
|
||||
return Obx(() {
|
||||
UserInfoController userInfoController = Get.find();
|
||||
MHTHomeController deviceController = Get.find();
|
||||
final isLoggedIn = userInfoController.model.login == 1;
|
||||
final hasDevice = deviceController.deviceList.values.isNotEmpty;
|
||||
|
||||
final showWeb = isLoggedIn && hasDevice;
|
||||
final mainAxisAlignment =
|
||||
showWeb ? MainAxisAlignment.start : MainAxisAlignment.center;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: mainAxisAlignment,
|
||||
children: [
|
||||
// 未登录提示
|
||||
if (!isLoggedIn)
|
||||
Center(
|
||||
child: InkWell(
|
||||
onTap: () => Get.toNamed("/loginPage"),
|
||||
child: RichText(
|
||||
@@ -434,11 +524,11 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0, // 控制下划线与文字的间距
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
height: 1, // 下划线粗细
|
||||
height: 1,
|
||||
color: stringToColor("#84F5FF"),
|
||||
),
|
||||
),
|
||||
@@ -457,25 +547,72 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
Obx(() {
|
||||
return Visibility(
|
||||
visible: userInfoController.model.login! != null &&
|
||||
userInfoController.model.login! == 1,
|
||||
child: Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() {
|
||||
return controller.ready.value
|
||||
? controller.web.build()
|
||||
: Container();
|
||||
}),
|
||||
|
||||
// 已登录但无设备提示
|
||||
if (isLoggedIn && !hasDevice)
|
||||
Center(
|
||||
child: InkWell(
|
||||
onTap: () => Get.toNamed("/mHTDeviceTypePage"),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "请先".tr,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
WidgetSpan(
|
||||
child: Stack(
|
||||
children: [
|
||||
Text(
|
||||
"绑定设备".tr,
|
||||
style: TextStyle(
|
||||
color: stringToColor("#84F5FF"),
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: stringToColor("#84F5FF"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "后,再进行设备控制".tr,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
),
|
||||
),
|
||||
|
||||
// 显示 WebView
|
||||
if (showWeb)
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() {
|
||||
return controller.ready.value
|
||||
? controller.web.build()
|
||||
: Container();
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user