更新设备校准
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.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';
|
||||
|
||||
class CalibrationProgressWidget extends StatelessWidget {
|
||||
final ValueNotifier<double> progressNotifier;
|
||||
final ValueNotifier<bool> failureNotifier;
|
||||
|
||||
const CalibrationProgressWidget({
|
||||
Key? key,
|
||||
required this.progressNotifier,
|
||||
required this.failureNotifier,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<double>(
|
||||
valueListenable: progressNotifier,
|
||||
builder: (context, progress, _) {
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: failureNotifier,
|
||||
builder: (context, isFailure, __) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
isFailure ? '失败'.tr : '${progress.toStringAsFixed(0)}%',
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: isFailure
|
||||
? Colors.red
|
||||
: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40.rpx),
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 21.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: stringToColor("#D9D9D9"),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().button_container_radius,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: progress / 100 *
|
||||
MediaQuery.of(context).size.width *
|
||||
0.8,
|
||||
height: 21.rpx,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: isFailure
|
||||
? [themeController.currentColor.sc9]
|
||||
: [
|
||||
themeController.currentColor.sc2,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().button_container_radius,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
showConfirmDialog(
|
||||
context, Container(), "其他设备正在绑定中,是否终止其他设备绑定?".tr,
|
||||
onConfirm: () {
|
||||
blueteethBindController.currentDeviceMac = null;
|
||||
blueteethBindController.currentDeviceMac.value = "";
|
||||
blueteethBindController.updateAll();
|
||||
}, onCancel: () {});
|
||||
}
|
||||
@@ -76,7 +76,9 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
}
|
||||
|
||||
if (device.bind == true) {
|
||||
showHaveBindDialog(context);
|
||||
await showHaveBindDialog(context);
|
||||
blueteethBindController.currentDeviceMac.value = "";
|
||||
blueteethBindController.updateAll();
|
||||
} else {
|
||||
showConfirmDialog(
|
||||
context,
|
||||
@@ -87,52 +89,14 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
await blueteethBindController.bindDeviceAndMAC(device);
|
||||
TopSlideNotification.show(context, text: response.msg!);
|
||||
if (response.code == HttpStatusCodes.ok) {
|
||||
// showLoadingDialog(context); // 显示 loading
|
||||
// Get.toNamed("/personPage");
|
||||
|
||||
Get.toNamed("/wifiPage");
|
||||
THapp bledevice = THapp(device: widget.bleDevice.device);
|
||||
blueteethBindController.currentDevice = bledevice;
|
||||
// await bledevice.device.connect();
|
||||
// var res2 = bledevice.isConnected;
|
||||
// if (res2) {
|
||||
// // Navigator.pop(context);
|
||||
// TopSlideNotification.show(
|
||||
// context,
|
||||
// text: "蓝牙绑定.连接成功".tr,
|
||||
// textColor: themeController.currentColor.sc2,
|
||||
// );
|
||||
// blueteethBindController.currentDevice = bledevice;
|
||||
|
||||
// if (lisObj != null) {
|
||||
// lisObj!.cancel();
|
||||
// }
|
||||
// var aa;
|
||||
// lisObj = blueteethBindController.currentDevice!.statusStream
|
||||
// .listen((onData) async {
|
||||
// if (onData.status == BleEventType.recvLineLog) {
|
||||
// final line = onData.val;
|
||||
// print("[bleee]:" + line);
|
||||
// }
|
||||
// if (onData.status == BleEventType.ready) {
|
||||
// aa = await getDeviceNetVersion(
|
||||
// blueteethBindController.currentDevice!, 1);
|
||||
// if (aa == "4g") {
|
||||
// Get.toNamed("/calibrationPage", arguments: 1);
|
||||
// } else {
|
||||
// Get.toNamed("/wifiPage");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// // Navigator.pop(context);
|
||||
// TopSlideNotification.show(
|
||||
// context,
|
||||
// text: "蓝牙绑定.连接失败".tr,
|
||||
// textColor: themeController.currentColor.sc9,
|
||||
// );
|
||||
// }
|
||||
// blueteethBindController.currentDeviceMac.value = "";
|
||||
|
||||
} else {
|
||||
blueteethBindController.currentDeviceMac = null;
|
||||
blueteethBindController.currentDeviceMac.value = "";
|
||||
blueteethBindController.updateAll();
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
@@ -143,7 +107,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
},
|
||||
onCancel: () {
|
||||
print('用户点击了取消');
|
||||
blueteethBindController.currentDeviceMac?.value = "";
|
||||
blueteethBindController.currentDeviceMac.value = "";
|
||||
blueteethBindController.updateAll();
|
||||
},
|
||||
);
|
||||
@@ -179,7 +143,8 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
if (blueteethBindController.currentDeviceMac == device.mac) {
|
||||
if (blueteethBindController.currentDeviceMac.value ==
|
||||
device.mac) {
|
||||
return SizedBox(
|
||||
width: 24.rpx,
|
||||
height: 24.rpx,
|
||||
|
||||
@@ -133,10 +133,10 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
|
||||
);
|
||||
}
|
||||
|
||||
void showHaveBindDialog(BuildContext context) {
|
||||
Future<void> showHaveBindDialog(BuildContext context) async {
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
showDialog(
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
@@ -207,7 +207,7 @@ void showHaveBindDialog(BuildContext context) {
|
||||
child: CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.back(result: true);
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
@@ -860,27 +860,24 @@ void showWifiDialog(
|
||||
);
|
||||
}
|
||||
|
||||
String showTipDialog(
|
||||
Future<void> showTipDialog(
|
||||
BuildContext context,
|
||||
Widget widget, {
|
||||
Color? backgroundColor, // 新增可选参数
|
||||
}
|
||||
// String title,
|
||||
) {
|
||||
Color? backgroundColor,
|
||||
}) {
|
||||
ThemeController themeController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
|
||||
showDialog(
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5), // 背景模糊色
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
builder: (BuildContext context) {
|
||||
return FrostedDialog(
|
||||
blurSigma: 3.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
backgroundColor ?? themeController.currentColor.sc17, // 使用默认颜色
|
||||
color: backgroundColor ?? themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
),
|
||||
padding: EdgeInsetsDirectional.fromSTEB(64.rpx, 0, 64.rpx, 0),
|
||||
@@ -892,63 +889,20 @@ String showTipDialog(
|
||||
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),
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 74.rpx),
|
||||
child: widget,
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 19.rpx, 0, 60.rpx),
|
||||
child: CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Get.back(); // 关闭对话框
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
@@ -972,13 +926,12 @@ String showTipDialog(
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 17.rpx,
|
||||
)),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -990,5 +943,4 @@ String showTipDialog(
|
||||
);
|
||||
},
|
||||
);
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user