This commit is contained in:
wyf
2025-05-13 11:59:04 +08:00
parent eae7a2284d
commit fb5c3864a3
101 changed files with 8427 additions and 1953 deletions

View File

@@ -69,7 +69,6 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
}
Future<void> _requestBluetoothPermission() async {
// Android 13+ 使用新的蓝牙权限
Map<Permission, PermissionStatus> statuses = await [
Permission.bluetoothScan,
Permission.bluetoothConnect,
@@ -113,7 +112,9 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
// 开始扫描蓝牙设备
void _startScanning() async {
if (!mounted) return;
if (!mounted || isScanning) return;
_scanSubscription?.cancel();
var bluetoothState = await FlutterBluePlus.isOn;
if (!bluetoothState && !_isDialogShowing) {
_isDialogShowing = true;
@@ -131,6 +132,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
// await FlutterBluePlus.startScan(timeout: Duration(minutes: 30));
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
if (!mounted) return; // 确保页面未销毁
final signalThreshold = blueteethBindController.model.singal!;
final filteredResults = results
.where((r) =>
@@ -334,7 +336,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
mainAxisSize: MainAxisSize.max,
children: [
Text(
'最小信号强度',
'最小信号强度'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@@ -415,7 +417,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
Expanded(
child: Container(
width: 100.rpx,
height: 100.rpx,
height: 80.rpx,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context)
.secondaryBackground,
@@ -519,7 +521,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
),
),
Text(
'搜索',
'搜索'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@@ -547,7 +549,8 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
EdgeInsetsDirectional.fromSTEB(19.rpx, 0, 0, 0),
child: Obx(() {
return Text(
'匹配出的外围设备${blueteethBindController.model.betDevicelist!.length}',
'匹配出的外围设备'.tr +
"${blueteethBindController.model.betDevicelist!.length}",
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(

View File

@@ -0,0 +1,123 @@
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.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';
import 'package:vbvs_app/controller/device/device_share_list_controller.dart';
import 'package:vbvs_app/controller/message/message_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
class DeviceShareInfoWidget extends StatefulWidget {
final data;
const DeviceShareInfoWidget({super.key, required this.data});
@override
State<DeviceShareInfoWidget> createState() => _DeviceShareInfoWidgetState();
}
class _DeviceShareInfoWidgetState extends State<DeviceShareInfoWidget> {
ThemeController themeController = Get.find();
MessageController messageController = Get.find();
DeviceShareListController deviceShareListController = Get.find();
@override
Widget build(BuildContext context) {
bool selected = false;
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: themeController.currentColor.sc3,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 33.rpx, 0.rpx, 33.rpx),
onTap: () {},
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Obx(() {
return Theme(
data: ThemeData(
checkboxTheme: CheckboxThemeData(
visualDensity: VisualDensity.compact,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(64),
),
),
unselectedWidgetColor: Color(0xFFD3D3D3),
),
child: Checkbox(
value: deviceShareListController.selectedShareInfo.value
.contains(widget.data[0]['k']),
onChanged: (newValue) async {
if (newValue != null) {
if (newValue == true) {
deviceShareListController.selectedShareInfo.value
.add(widget.data[0]['k']);
} else {
deviceShareListController.selectedShareInfo.value
.remove(widget.data[0]['k']);
}
}
final selectedCount =
deviceShareListController.selectedShareInfo.length;
final totalCount =
deviceShareListController.shareInfoList.length;
deviceShareListController.model.all =
(selectedCount == totalCount) ? 1 : 0;
deviceShareListController.selectedShareInfo
.refresh(); // ✅ 关键代码
deviceShareListController.updateAll();
},
side: BorderSide(
width: 1.5,
color: FlutterFlowTheme.of(context).secondaryText,
),
activeColor: stringToColor("#16C89F"),
checkColor: FlutterFlowTheme.of(context).info,
),
);
}),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Container(
constraints: BoxConstraints(
minWidth: 30.rpx,
),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(widget.data.length, (index) {
final item = widget.data[index];
return Container(
constraints: BoxConstraints(
minHeight: 62.rpx,
),
child: Align(
alignment: AlignmentDirectional(-1, 0),
child: Text(
"${item['k']}" + ":" + "${item['v']}",
style:
FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
),
),
);
}),
),
),
].divide(SizedBox(width: 50.rpx)),
),
].divide(SizedBox(
width: 10.rpx,
)),
),
);
}
}

View File

@@ -41,6 +41,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
deviceData.rssi = widget.bleDevice.rssi;
deviceData.mac = deviceData.deviceId.replaceAll(':', '');
BleDeviceData device = deviceData;
blueteethBindController.currentDeviceMac = device.mac;
device = blueteethBindController.model.betDevicelist!.firstWhere(
(d) => d.mac == device.mac,
orElse: () => device,
@@ -208,7 +209,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
],
),
Text(
'版本:${device.version ?? '-'}',
"版本".tr + '${device.version ?? '-'}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFF6FAFD),

View File

@@ -708,3 +708,133 @@ void showWifiDialog(
},
);
}
void showTipDialog(
BuildContext context,
Widget widget,
// String title,
) {
ThemeController themeController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
showDialog(
context: context,
barrierDismissible: true,
barrierColor: Colors.black.withOpacity(0.5), // 背景模糊色
builder: (BuildContext context) {
return FrostedDialog(
blurSigma: 3.0,
child: Container(
decoration: BoxDecoration(
color: themeController.currentColor.sc17,
borderRadius: BorderRadius.circular(20.0),
),
padding: EdgeInsetsDirectional.fromSTEB(64.rpx, 0, 64.rpx, 0),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height * 0.656,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 标题
// Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// ClickableContainer(
// backgroundColor: Colors.transparent, // 容器背景色
// highlightColor:
// themeController.currentColor.sc21, // 点击时的背景色
// padding: EdgeInsets.zero, // 这里去掉外部的 padding避免影响点击范围
// onTap: () {
// Get.back();
// },
// child: Padding(
// padding:
// EdgeInsetsDirectional.fromSTEB(0, 33.rpx, 0, 0.rpx),
// child: SvgPicture.asset(
// 'assets/img/icon/close.svg',
// width: 25.rpx,
// height: 25.rpx, // 如果 SVG 中没有固定颜色,使用 color 设置
// color: themeController.currentColor.sc3,
// ),
// ),
// ),
// ],
// ),
// Align(
// alignment: AlignmentDirectional(0, 0),
// child: Padding(
// padding: EdgeInsetsDirectional.fromSTEB(
// 0.rpx, 93.rpx, 0, 74.rpx),
// child: Text(
// title,
// style: FlutterFlowTheme.of(context).bodyMedium.override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController.currentColor.sc3,
// ),
// ),
// ),
// ),
Align(
alignment: AlignmentDirectional(0, 0),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 93.rpx, 0, 74.rpx),
child: widget,
),
),
// widget,
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 19.rpx, 0, 60.rpx),
child: CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back();
},
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'蓝牙绑定.知道了'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize: AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
width: 17.rpx,
)),
),
),
),
),
],
),
),
),
);
},
);
}

View File

@@ -0,0 +1,617 @@
import 'dart:async';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/common/util/requestWithLog.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/device/device_calibration_controller.dart';
import 'package:vbvs_app/pages/common/selectDialog.dart';
class CalibrationPage extends StatefulWidget {
int? type; //1.绑定时 2.绑定后
CalibrationPage({super.key, required this.type});
@override
State<CalibrationPage> createState() => _CalibrationPageState();
}
class _CalibrationPageState extends State<CalibrationPage> {
DeviceCalibrationController deviceCalibrationController = Get.find();
@override
void initState() {
super.initState();
deviceCalibrationController.process.value = 0;
deviceCalibrationController.bed_calibration.value = 0;
deviceCalibrationController.position_calibration.value = 0;
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/img/bgNoImg.png'),
fit: BoxFit.fill,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
titleSpacing: 0,
title: Container(
width: double.infinity,
height: 180.rpx,
child: Stack(
alignment: Alignment.center,
children: [
Text(
'设备校准'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
),
Positioned(
left: 0,
child: returnIconButtom,
),
if (widget.type == 1)
Positioned(
right: 20.rpx,
child: CustomCard(
borderRadius: 20.rpx,
onTap: () async {
Get.toNamed("/personPage");
},
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: 100.rpx,
height: 60.rpx,
alignment: Alignment.center,
padding: EdgeInsetsDirectional.fromSTEB(
16.rpx, 0, 16.rpx, 0),
child: Text(
'跳过'.tr,
style: TextStyle(
fontFamily: 'Inter Tight',
color: themeController.currentColor.sc3,
letterSpacing: 0.0,
),
),
),
),
),
],
),
),
actions: [],
centerTitle: false,
),
body: SafeArea(
top: true,
// child: Container(),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 30.rpx, 0, 0),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(16.rpx),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10.rpx, 20.rpx, 34.rpx, 20.rpx),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc21,
borderRadius: 0, // 可按需设置圆角
padding: EdgeInsets.symmetric(
vertical: 10.rpx), // 可自定义内边距
onTap: () {
deviceCalibrationController.process.value = 0;
deviceCalibrationController.updateAll();
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Obx(() {
return Visibility(
maintainState: true,
maintainAnimation: true,
maintainSize: true,
visible: deviceCalibrationController
.process.value ==
0,
child: SvgPicture.asset(
'assets/img/icon/select_arrow.svg',
width: 17.rpx,
height: 17.rpx,
color: themeController
.currentColor.sc9,
),
);
}),
SizedBox(width: 8.rpx),
Text(
'离床校准'.tr,
style: TextStyle(
fontSize: 30.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
],
),
Obx(() {
return Text(
deviceCalibrationController
.bed_calibration.value ==
0
? '未完成'.tr
: "已完成".tr,
style: TextStyle(
fontSize: 26.rpx,
letterSpacing: 0.0,
color: deviceCalibrationController
.bed_calibration.value ==
0
? themeController.currentColor.sc3
: themeController
.currentColor.sc1,
),
);
}),
],
),
),
SizedBox(height: 41.rpx),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc21,
borderRadius: 0, // 可根据需要设为圆角
padding: EdgeInsets.symmetric(
vertical: 10.rpx), // 可根据需要调整上下内边距
onTap: () {
deviceCalibrationController.process.value = 1;
deviceCalibrationController.updateAll();
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Obx(() {
return Visibility(
maintainState: true,
maintainAnimation: true,
maintainSize: true,
visible: deviceCalibrationController
.process.value ==
1,
child: SvgPicture.asset(
'assets/img/icon/select_arrow.svg',
width: 17.rpx,
height: 17.rpx,
color: themeController
.currentColor.sc9,
),
);
}),
SizedBox(width: 8.rpx),
Text(
'位置校准'.tr,
style: TextStyle(
fontSize: 30.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
],
),
Obx(() {
return Text(
deviceCalibrationController
.position_calibration
.value ==
0
? '未完成'.tr
: "已完成".tr,
style: TextStyle(
fontSize: 26.rpx,
letterSpacing: 0.0,
color: deviceCalibrationController
.position_calibration
.value ==
0
? themeController.currentColor.sc3
: themeController
.currentColor.sc1,
),
);
}),
],
),
),
],
),
),
),
),
Obx(() {
return Expanded(
child: SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
100.rpx, 55.rpx, 100.rpx, 0),
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
width:
MediaQuery.sizeOf(context).width * 0.65,
height:
MediaQuery.sizeOf(context).height * 0.3,
child: Stack(
children: [
// Image.asset(
// deviceCalibrationController
// .bed_type.value ==
// 0
// ? "assets/img/single_pillow.png"
// : "assets/img/double_pillow.png",
// width: double.infinity,
// height: double.infinity,
// fit: BoxFit.contain,
// ),
Image.asset(
deviceCalibrationController
.process.value ==
1 &&
deviceCalibrationController
.position_calibration
.value ==
1
? (deviceCalibrationController
.bed_type.value ==
0
? "assets/img/single_person.png"
: "assets/img/double_person.png")
: (deviceCalibrationController
.bed_type.value ==
0
? "assets/img/single_pillow.png"
: "assets/img/double_pillow.png"),
width: double.infinity,
height: double.infinity,
fit: BoxFit.contain,
),
// 床头文字
Positioned(
top: 23.rpx,
left:
(MediaQuery.sizeOf(context).width *
0.65) /
2 -
26.rpx,
child: Text(
'床头'.tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController
.currentColor.sc4,
),
),
),
],
),
),
Obx(() {
final double centerLeft =
(bodySize.maxWidth * 0.56) / 2;
if (deviceCalibrationController
.bed_type.value ==
0 &&
deviceCalibrationController
.process.value ==
1) {
//单人床位置校准
return Positioned(
top: -40.rpx,
left: centerLeft - 0.rpx,
child: Container(
width: bodySize.maxWidth * 0.087,
height: bodySize.maxHeight * 0.06,
constraints: BoxConstraints(
minWidth: 65.rpx,
minHeight: 76.rpx,
),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/img/tip_arrow.gif'),
fit: BoxFit.cover,
),
),
),
);
}
if (deviceCalibrationController
.bed_type.value ==
1 &&
deviceCalibrationController
.process.value ==
1) {
//双人人床位置校准
return Positioned(
top: -40.rpx,
left: (MediaQuery.sizeOf(context).width *
0.65) *
0.22 -
0.rpx,
child: Container(
width: bodySize.maxWidth * 0.087,
height: bodySize.maxHeight * 0.06,
constraints: BoxConstraints(
minWidth: 65.rpx,
minHeight: 76.rpx,
),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/img/tip_arrow.gif'),
fit: BoxFit.cover,
),
),
),
);
}
return Container();
}),
Positioned(
top: MediaQuery.sizeOf(context).height * 0.3 +
82.rpx,
left: 0,
right: 0,
child: Obx(() {
return Column(
children: [
Text(
(deviceCalibrationController
.process.value ==
0 &&
deviceCalibrationController
.bed_calibration
.value ==
1) ||
(deviceCalibrationController
.process.value ==
1 &&
deviceCalibrationController
.position_calibration
.value ==
1)
? '校准完成'.tr
: deviceCalibrationController
.process.value ==
0
? '离床校准提示'.tr
: '位置校准提示'.tr,
style: TextStyle(
fontSize: 38.rpx,
letterSpacing: 0.0,
color: ((deviceCalibrationController
.process
.value ==
0 &&
deviceCalibrationController
.bed_calibration
.value ==
1) ||
(deviceCalibrationController
.process
.value ==
1 &&
deviceCalibrationController
.position_calibration
.value ==
1))
? themeController
.currentColor.sc1
: themeController
.currentColor.sc9,
),
),
],
);
}),
),
],
),
),
),
);
}),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
100.rpx, 0.rpx, 100.rpx, 60.rpx),
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () async {
BlueteethBindController blueteethBindController =
Get.find();
requestWithLog(
logTitle: "设备校准",
method: MyHttpMethod.post,
queryUrl: ServiceConstant.start_calibration,
data: {
"deviceId":
blueteethBindController.currentDeviceMac
},
onSuccess: (res) {
final ValueNotifier<double> progressNotifier =
ValueNotifier<double>(0.0);
final ValueNotifier<bool> failureNotifier =
ValueNotifier<bool>(false);
Timer? pollingTimer;
// 定义请求函数
void requestCalibrationProgress() {
requestWithLog(
logTitle: "设备校准进度",
method: MyHttpMethod.post,
queryUrl: ServiceConstant.calibration_process,
data: {
"deviceId":
blueteethBindController.currentDeviceMac
},
onSuccess: (res) {
double process =
(res.data['process'] ?? 0).toDouble();
progressNotifier.value = process;
if (process >= 100) {
if (deviceCalibrationController
.process.value ==
0) {
deviceCalibrationController
.bed_calibration.value = 1;
deviceCalibrationController.updateAll();
}
if (deviceCalibrationController
.process.value ==
1) {
deviceCalibrationController
.position_calibration.value = 1;
deviceCalibrationController.updateAll();
}
pollingTimer?.cancel();
}
},
onFailure: (res) {
pollingTimer?.cancel();
failureNotifier.value = true;
TopSlideNotification.show(
context,
text: res.msg ?? "服务器.失败".tr,
textColor:
themeController.currentColor.sc9,
);
},
);
}
// 启动轮询
pollingTimer =
Timer.periodic(Duration(seconds: 2), (timer) {
requestCalibrationProgress();
});
// 初始调用一次
requestCalibrationProgress();
// 显示进度弹窗
showProgressDialog(
context, progressNotifier, failureNotifier);
},
onFailure: (res) {
TopSlideNotification.show(
context,
text: res.msg ?? "服务器.失败".tr,
textColor: themeController.currentColor.sc9,
);
},
);
},
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: bodySize.maxWidth,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'开始校准'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
//todo 颜色
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
width: 17.rpx,
)),
),
),
),
),
],
),
),
),
),
),
),
);
}
}

View File

@@ -0,0 +1,461 @@
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/controller/device/device_share_list_controller.dart';
import 'package:vbvs_app/model/BleDeviceData.dart';
import 'package:vbvs_app/pages/device_bind/componnet/DeviceShareInfoWidget.dart';
class DeviceShareListPage extends StatefulWidget {
String device = "";
DeviceShareListPage({super.key, required this.device});
@override
State<DeviceShareListPage> createState() => _DeviceShareListPageState();
}
class _DeviceShareListPageState extends State<DeviceShareListPage> {
DeviceShareListController deviceShareListController = Get.find();
@override
void initState() {
deviceShareListController.model.key = null;
deviceShareListController.shareInfoList.value = [];
deviceShareListController.selectedShareInfo.value = [];
deviceShareListController.getDeviceShareList(widget.device);
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, boxConstraints) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/img/bgNoImg.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
),
),
child: Scaffold(
backgroundColor: Colors.transparent, // 加上这一行
appBar: AppBar(
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
titleSpacing: 0,
title: Container(
width: double.infinity,
height: 180.rpx,
child: Stack(
alignment: Alignment.center,
children: [
Text(
'已分享'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
),
//todo 返回刷新列表
Positioned(
left: 0,
child: returnIconButtom,
),
],
),
),
actions: [],
centerTitle: false,
),
body: SafeArea(
top: true,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
SizedBox(
height: 40.rpx,
),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: themeController.currentColor.sc3,
borderRadius: BorderRadius.circular(20.rpx),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
35.rpx, 0, 35.rpx, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 25.rpx,
height: 25.rpx,
// width: double.infinity,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/query.svg',
fit: BoxFit.cover,
color: stringToColor("#333333"), //固定
),
),
),
Expanded(
child: Container(
width: 100.rpx,
height: 80.rpx,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context)
.secondaryBackground,
),
child: Align(
alignment: AlignmentDirectional(-1, 0),
child: TextFormField(
onChanged: (value) {
deviceShareListController
.model.key = value;
},
autofocus: false,
obscureText: false,
decoration: InputDecoration(
isDense: true,
labelStyle:
FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
hintText: '输入关键字'.tr,
hintStyle:
FlutterFlowTheme.of(context)
.labelMedium
.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius:
BorderRadius.circular(8.rpx),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1.rpx,
),
borderRadius:
BorderRadius.circular(8.rpx),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color:
FlutterFlowTheme.of(context)
.error,
width: 1.rpx,
),
borderRadius:
BorderRadius.circular(8.rpx),
),
focusedErrorBorder:
OutlineInputBorder(
borderSide: BorderSide(
color:
FlutterFlowTheme.of(context)
.error,
width: 1.rpx,
),
borderRadius:
BorderRadius.circular(8.rpx),
),
filled: false,
fillColor: themeController
.currentColor.sc22,
),
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
),
cursorColor:
FlutterFlowTheme.of(context)
.primaryText,
),
),
),
),
].divide(SizedBox(width: 6.rpx)),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
26.rpx, 0, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
SizedBox(
height: 50.rpx,
child: VerticalDivider(
thickness: 2.rpx,
color: stringToColor("#333333"), //固定
),
),
ClickableContainer(
onTap: () async {
// ApiResponse apiResponse =
// await deviceShareListController
// .getDeviceShareList(
// key: deviceShareListController
// .model.key);
// if (apiResponse.code ==
// HttpStatusCodes.ok) {
// TopSlideNotification.show(
// context,
// text: apiResponse.msg!,
// textColor:
// themeController.currentColor.sc2,
// );
// deviceShareListController.updateAll();
// } else {
// TopSlideNotification.show(
// context,
// text: apiResponse.msg!,
// textColor:
// themeController.currentColor.sc9,
// );
// }
},
padding: EdgeInsets.symmetric(
horizontal: 10.rpx, vertical: 6.rpx),
borderRadius: 12.rpx,
backgroundColor: Colors.transparent,
highlightColor: stringToColor("#333333")
.withOpacity(0.08), // 可选点击反馈色
child: Text(
'搜索'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color:
stringToColor("#333333"), //固定
),
),
),
].divide(SizedBox(width: 26.rpx)),
),
),
],
),
),
),
Container(
constraints: BoxConstraints(
minHeight: 100.rpx,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Theme(
data: ThemeData(
checkboxTheme: CheckboxThemeData(
visualDensity: VisualDensity.compact,
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(64),
),
),
unselectedWidgetColor: Color(0xFFD3D3D3),
),
child: Obx(
() => Checkbox(
value:
deviceShareListController.model.all ==
0
? false
: true,
onChanged: (newValue) async {
if (newValue == true) {
// 设置为全选
deviceShareListController.model.all =
1;
deviceShareListController
.selectedShareInfo.value =
deviceShareListController
.shareInfoList
.map((e) => e['id'] as String)
.toList();
} else {
// 取消全选
deviceShareListController.model.all =
0;
deviceShareListController
.selectedShareInfo
.clear();
}
deviceShareListController
.selectedShareInfo
.refresh();
deviceShareListController.updateAll();
},
side: BorderSide(
width: 1.5,
color: FlutterFlowTheme.of(context)
.secondaryText,
),
activeColor: stringToColor("#16C89F"),
checkColor:
FlutterFlowTheme.of(context).info,
),
)),
Text(
"全选".tr,
style: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
),
),
].divide(SizedBox(
width: 10.rpx,
)),
),
ClickableContainer(
onTap: () async {
//todo 删除分享
// ApiResponse apiResponse =
// await deviceShareListController
// .deleteShareDevice();
// if (apiResponse.code == HttpStatusCodes.ok) {
// TopSlideNotification.show(context,
// text: apiResponse.msg!);
// } else {
// TopSlideNotification.show(context,
// text: apiResponse.msg!,
// textColor:
// themeController.currentColor.sc9);
// }
},
padding: EdgeInsets.symmetric(
horizontal: 20.rpx, vertical: 10.rpx),
borderRadius: 20.rpx,
backgroundColor: Colors.transparent,
highlightColor: themeController.currentColor.sc3
.withOpacity(0.1),
child: Text(
"删除".tr,
style: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
),
),
),
],
),
),
Expanded(
child: deviceShareListController
.shareInfoList.value.isNotEmpty
? SingleChildScrollView(
child: Obx(() {
var selected = deviceShareListController
.selectedShareInfo.value;
return Column(
children: deviceShareListController
.shareInfoList.value
.map((item) =>
DeviceShareInfoWidget(data: item))
.toList()
.divide(SizedBox(height: 30.rpx))
.addToEnd(SizedBox(
height: 30.rpx,
)),
);
}),
)
: NullDataWidget(),
),
].divide(SizedBox(height: 30.rpx)),
),
),
),
),
),
),
);
}
}
BleDeviceData parseBleData(List<int> data) {
if (data.length < 18) {
throw Exception('BLE广播数据长度不足18字节');
}
int type = data[0];
int sn = data[1];
// 设备唯一ID (6字节),格式化为 MAC 地址样式
String deviceId =
List.generate(6, (i) => data[2 + i].toRadixString(16).padLeft(2, '0'))
.join(":")
.toUpperCase();
int bre = data[8];
int ht = data[9];
int active = data[10];
int flag = data[11];
// version 是4字节 uint大端字节序
int version =
(data[12] << 24) | (data[13] << 16) | (data[14] << 8) | data[15];
// qsn 是2字节 ushort大端字节序
int qsn = (data[16] << 8) | data[17];
return BleDeviceData(
type: type,
sn: sn,
deviceId: deviceId,
bre: bre,
ht: ht,
active: active,
flag: flag,
version: version,
qsn: qsn,
);
}

View File

@@ -276,7 +276,7 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
children: [
TextSpan(
text:
'${deviceShareController.code == 1 ? "邀请成功".tr : "邀请失败".tr}',
'${deviceShareController.code.value == 1 ? "邀请成功".tr : "邀请失败".tr}',
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@@ -284,7 +284,7 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
fontSize: 26.rpx,
letterSpacing: 0.0,
color: deviceShareController
.code ==
.code.value ==
1
? themeController
.currentColor.sc2

View File

@@ -35,8 +35,9 @@ class _EPageState extends State<DeviceTypePage> {
super.initState();
deviceTypeController.getDeviceType().then((response) {
if (response.code != HttpStatusCodes.ok) {
// 延迟到 widget 构建后再执行 show
TopSlideNotification.show(
Get.context!,
context, // 用当前页面 context 替代 Get.context!
text: response.msg ?? "服务器.失败".tr,
textColor: themeController.currentColor.sc9,
);
@@ -273,7 +274,7 @@ class _EPageState extends State<DeviceTypePage> {
),
alignment: Alignment.center, // 居中对齐
child: Text(
'绑定引导.跳过'.tr,
'确认'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@@ -332,7 +333,7 @@ class _EPageState extends State<DeviceTypePage> {
children: [
/// 居中标题
Text(
'设备列表',
'设备列表'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
@@ -429,7 +430,7 @@ class _EPageState extends State<DeviceTypePage> {
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFC2CED7),
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
letterSpacing: 0.0,
),

View File

@@ -30,11 +30,13 @@ class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
super.initState();
deviceTypeController.getDeviceType().then((response) {
if (response.code != HttpStatusCodes.ok) {
TopSlideNotification.show(
Get.context!,
text: response.msg ?? "服务器.失败".tr,
textColor: themeController.currentColor.sc9,
);
WidgetsBinding.instance.addPostFrameCallback((_) {
TopSlideNotification.show(
context,
text: response.msg ?? "服务器.失败".tr,
textColor: themeController.currentColor.sc9,
);
});
}
});
}
@@ -68,7 +70,7 @@ class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
children: [
/// 居中标题
Text(
'设备列表',
'设备列表'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
@@ -165,7 +167,7 @@ class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFFC2CED7),
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
letterSpacing: 0.0,
),

View File

@@ -19,7 +19,6 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
class WifiPage extends StatefulWidget {
WifiPage({super.key});
// WifiPage({super.key});
@override
State<WifiPage> createState() => _WifiPageState();
@@ -32,8 +31,6 @@ class _WifiPageState extends State<WifiPage> {
PersonController personController = Get.find();
ThemeController themeController = Get.find();
var lisObj;
// List<String> _logBuffer = [];
// bool _isCollecting = false;
@override
void initState() {
@@ -106,7 +103,8 @@ class _WifiPageState extends State<WifiPage> {
textColor: themeController.currentColor.sc9,
);
}
Get.toNamed("/personPage");
Get.toNamed("/calibrationPage",arguments: 1);
// Get.toNamed("/personPage");
// Get.toNamed("/bindDeviceSuccess");
},
colors: [
@@ -686,7 +684,7 @@ class _WifiPageState extends State<WifiPage> {
),
),
Text(
'刷新',
'刷新'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
@@ -779,13 +777,13 @@ class _WifiPageState extends State<WifiPage> {
bool wifiStatus =
await getWifiStatus(blueteethBindController.currentDevice!);
blueteethBindController.wifiStatus.value = wifiStatus == true ? 1 : 0;
if (wifiStatus) {
Map connect_wifiInfo =
await getDeviceWifiStatus(blueteethBindController.currentDevice!);
if (connect_wifiInfo != null) {
blueteethBindController.connect_wifi.value = connect_wifiInfo;
}
}
// if (wifiStatus) {
// Map connect_wifiInfo =
// await getDeviceWifiStatus(blueteethBindController.currentDevice!);
// if (connect_wifiInfo != null) {
// blueteethBindController.connect_wifi.value = connect_wifiInfo;
// }
// }
List wifiList =
await getWifiList(blueteethBindController.currentDevice!);
if (wifiList.length > 0) {