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

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

View File

@@ -1,8 +1,11 @@
import 'dart:ui';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_switch/flutter_switch.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';
class MattressControlPage extends StatefulWidget {
@@ -14,105 +17,53 @@ class MattressControlPage extends StatefulWidget {
class _MattressControlPageState extends State<MattressControlPage> {
final controller = Get.put(ControlCardController());
UserInfoController userInfoController = Get.find();
int selectedIndex = 1; // 当前选中的tab索引
@override
Widget build(BuildContext context) {
final isLoggedIn = userInfoController.model.login == 1;
final backgroundImage = isLoggedIn
? 'assets/images/new_background.png'
: 'assets/images/noLoginControl.png';
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
// // onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image:
AssetImage('assets/images/new_background.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
builder: (context, bodySize) => GestureDetector(
child: Stack(
children: [
// Background Image
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(backgroundImage),
fit: BoxFit.fill,
),
),
),
// 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),
),
),
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,
// ),
),
body: SafeArea(
child: WebviewTestView(
// oncreate: (widget) {
// return WebviewTestController();
// },
),
),
))));
// Main Content
Scaffold(
backgroundColor: Colors.transparent,
body: SafeArea(
child: WebviewTestView(),
),
),
],
),
),
);
}
// 床体图示
@@ -121,16 +72,16 @@ class _MattressControlPageState extends State<MattressControlPage> {
padding: EdgeInsets.fromLTRB(0, 38.rpx, 0, 63.rpx),
child: Image.asset(
'assets/images/bed_control.png',
width: MediaQuery.of(context).size.width * 0.7, // 你需要准备这个图像资源
width: MediaQuery.of(context).size.width * 0.7,
height: 193.rpx,
),
);
}
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 thirdWidth = 215.rpx; // 三个卡片两个间距
final thirdWidth = 215.rpx;
final tabCount = 3;
final tabWidth = screenWidth / tabCount;
final sideMargin = (tabWidth - thirdWidth) / 2;
@@ -146,7 +97,9 @@ class _MattressControlPageState extends State<MattressControlPage> {
return Expanded(
child: GestureDetector(
onTap: () {
selectedIndex = index;
setState(() {
selectedIndex = index;
});
},
child: _selectorTab(
labels[index],
@@ -157,7 +110,6 @@ class _MattressControlPageState extends State<MattressControlPage> {
);
}),
),
// 白线指示器
Positioned(
bottom: 0,
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 restCards = allCards.sublist(3);
// 后续每行两个
List<List<Map<String, dynamic>>> chunkedRows = [];
for (int i = 0; i < restCards.length; i += 2) {
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),
child: Column(
children: [
// 第一行:三个卡片
Row(
children: List.generate(firstRow.length * 2 - 1, (index) {
if (index.isOdd) {
return SizedBox(width: spacing); // 卡片间距
return SizedBox(width: spacing);
} else {
final item = firstRow[index ~/ 2];
return Expanded(
@@ -241,14 +191,12 @@ class _MattressControlPageState extends State<MattressControlPage> {
index ~/ 2,
item['title'],
item['time'],
// null, // 不再使用固定宽度
),
);
}
}),
),
SizedBox(height: spacing),
// 其余每行两个卡片
...chunkedRows.map((row) {
return Padding(
padding: EdgeInsets.only(bottom: spacing),
@@ -264,7 +212,6 @@ class _MattressControlPageState extends State<MattressControlPage> {
index ~/ 2,
item['title'],
item['time'],
// null,
),
);
}
@@ -282,12 +229,10 @@ class _MattressControlPageState extends State<MattressControlPage> {
int index,
String title,
String time,
// double width,
) {
final controller = Get.find<ControlCardController>();
return Container(
// width: width,
height: 241.rpx,
decoration: BoxDecoration(
color: const Color(0xFF003058),
@@ -344,6 +289,5 @@ class _MattressControlPageState extends State<MattressControlPage> {
}
class ControlCardController extends GetxController {
// 共9个卡片每个卡片有自己的开关状态
final List<RxBool> switchStates = List.generate(9, (index) => false.obs);
}