import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_svg/svg.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/ClickableContainer.dart'; class BluetoothPage extends StatefulWidget { BluetoothPage({super.key}); @override State createState() => _BluetoothState(); } BoxConstraints? bodysize; class _BluetoothState extends State { @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, cc) { bodysize = cc; return GestureDetector( onTap: () => FocusScope.of(context).unfocus(), child: Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/new_background.png'), // 本地图片 fit: BoxFit.fill, // 填满整个 Container ), ), child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( backgroundColor: Colors.transparent, iconTheme: const IconThemeData(color: Colors.white), automaticallyImplyLeading: false, titleSpacing: 0, title: SizedBox( width: double.infinity, height: 180.rpx, child: Stack( alignment: Alignment.center, children: [ // 中间居中的标题 Text( '设置', textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 30.rpx, ), ), // 左侧图标 Positioned( left: 20.rpx, child: returnIconButtomNew, ), ], ), ), centerTitle: false, ), body: SafeArea( top: true, child: Padding( padding: EdgeInsets.fromLTRB(0.rpx, 115.rpx, 0.rpx, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('TomFayer', style: TextStyle( color: Colors.white, fontSize: 40.rpx, )), SizedBox(width: 27.rpx), ClickableContainer( backgroundColor: Colors.transparent, highlightColor: const Color(0xFF055466), padding: EdgeInsets.only(left: 0), onTap: () { Get.toNamed("/editBedPage"); }, child: Container( width: 42.rpx, height: 42.rpx, child: SvgPicture.asset( "assets/img/icon/bluetooth_edit.svg", color: Colors.white, ))) ], ), const SizedBox(height: 4), Text('MAC:4645146546', style: TextStyle( color: Colors.white70, fontSize: 26.rpx)), const SizedBox(height: 16), // 蓝牙连接状态 Column( children: [ Image.asset( 'assets/images/active_bluetooth.png', width: 42.rpx, height: 42.rpx, ), SizedBox(height: 4), Text('已连接', style: TextStyle( color: Colors.green, fontSize: 26.rpx)), ], ), ], ), const SizedBox(height: 24), // 按钮列表 Expanded( child: ListView( padding: EdgeInsets.symmetric(horizontal: 30.rpx), children: [ _buildMenuButton( context, '详情', "/devicePeopleInfo"), _buildMenuButton( context, '人员资料', "/peopleInfoPage"), _buildMenuButton( context, '房间选择', "/roomPickerPage"), _buildMenuButton( context, '设备校准', "/devicePeopleInfo"), _buildMenuButton( context, '体征传感器', "/devicePeopleInfo"), _buildMenuButton( context, 'WIFI配置', "/devicePeopleInfo"), _buildMenuButton( context, '睡眠习惯', "/sleepHabitPage"), _buildMenuButton( context, '分享设备', "/devicePeopleInfo"), _buildMenuButton( context, '解绑', "/devicePeopleInfo"), ], ), ), ], ), )), ))); }); } Widget _buildMenuButton(BuildContext context, String title, String? path) { return Padding( padding: EdgeInsets.only(bottom: 19.rpx), // 将 margin 外移 child: ClickableContainer( backgroundColor: Colors.transparent, highlightColor: Color(0XFF055466), padding: EdgeInsets.only(left: 0), onTap: () { if (path?.isNotEmpty == true) { Get.toNamed(path!); } }, child: Container( height: MediaQuery.sizeOf(context).height * 0.0566, decoration: BoxDecoration( color: const Color(0xFF003058), borderRadius: BorderRadius.circular(16.rpx), ), child: Center( child: Text( title, style: const TextStyle(color: Colors.white, fontSize: 16), ), ), ), ), ); } }