This commit is contained in:
wyf
2025-05-15 13:57:42 +08:00
parent fb5c3864a3
commit 75ddfca402
51 changed files with 2451 additions and 1233 deletions

View File

@@ -7,7 +7,9 @@ import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/device/body_device_controller.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/controller/person/person_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
@@ -176,9 +178,34 @@ class _EPageState extends State<BindDeviceSuccess> {
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
print('Button pressed ...');
Get.toNamed("/deviceType");
onTap: () async {
PersonController personController = Get.find();
String deviceID =
personController.currentPersonId.value;
BodyDeviceController bodyDeviceController =
Get.find();
await bodyDeviceController.getDeviceList();
List deviceList =
bodyDeviceController.deviceList.value;
if (deviceList != null && deviceList.isNotEmpty) {
// 查找第一个 _id 匹配的设备
final matchedDevice = deviceList.firstWhere(
(element) => element['_id'] == deviceID,
orElse: () => null,
);
if (matchedDevice != null) {
// 跳转并传入设备
Get.toNamed("/deviceSharePage",
arguments: matchedDevice);
} else {
print("未找到匹配的设备");
}
} else {
print("设备列表为空");
}
},
colors: [
// 渐变色

View File

@@ -494,9 +494,8 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
fontSize: 26.rpx,
letterSpacing: 0.0,
),
cursorColor:
FlutterFlowTheme.of(context)
.primaryText,
cursorColor: themeController
.currentColor.sc3,
// validator: _model
// .textControllerValidator
// .asValidator(context),

View File

@@ -69,7 +69,7 @@ class _FancyCircleCheckboxState extends State<FancyCircleCheckbox>
color: widget.value
? widget.borderColor
: widget.borderColor.withOpacity(0.5),
width: 1,
width: 1.rpx,
),
),
child: ScaleTransition(

View File

@@ -15,6 +15,7 @@ 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';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
class CalibrationPage extends StatefulWidget {
int? type; //1.绑定时 2.绑定后
@@ -26,16 +27,21 @@ class CalibrationPage extends StatefulWidget {
class _CalibrationPageState extends State<CalibrationPage> {
DeviceCalibrationController deviceCalibrationController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
@override
void initState() {
super.initState();
deviceCalibrationController.process.value = 0;
deviceCalibrationController.bed_calibration.value = 0;
deviceCalibrationController.position_calibration.value = 0;
blueteethBindController.cid!.value = "";
deviceCalibrationController.complete = false;
}
@override
void dispose() {
blueteethBindController.cid!.value = "";
deviceCalibrationController.complete = false;
super.dispose();
}
@@ -144,8 +150,8 @@ class _CalibrationPageState extends State<CalibrationPage> {
padding: EdgeInsets.symmetric(
vertical: 10.rpx), // 可自定义内边距
onTap: () {
deviceCalibrationController.process.value = 0;
deviceCalibrationController.updateAll();
// deviceCalibrationController.process.value = 0;
// deviceCalibrationController.updateAll();
},
child: Row(
mainAxisAlignment:
@@ -213,8 +219,8 @@ class _CalibrationPageState extends State<CalibrationPage> {
padding: EdgeInsets.symmetric(
vertical: 10.rpx), // 可根据需要调整上下内边距
onTap: () {
deviceCalibrationController.process.value = 1;
deviceCalibrationController.updateAll();
// deviceCalibrationController.process.value = 1;
// deviceCalibrationController.updateAll();
},
child: Row(
mainAxisAlignment:
@@ -483,56 +489,221 @@ class _CalibrationPageState extends State<CalibrationPage> {
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
// onTap: () async {
// BlueteethBindController blueteethBindController =
// Get.find();
// String serviceAddress = "http://192.168.1.80:8086";
// String serviceApi = ServiceConstant.start_calibration;
// String queryUrl = "${serviceAddress}${serviceApi}";
// requestWithLog(
// logTitle: "设备校准",
// method: MyHttpMethod.post,
// queryUrl: queryUrl,
// data: {
// "macA": blueteethBindController.currentDeviceMac,
// if (blueteethBindController.cid!.value.isNotEmpty)
// "id": blueteethBindController.cid!.value,
// },
// onSuccess: (res) {
// String cid = res.rawResponse.data['cid'];
// blueteethBindController.cid!.value = cid;
// final ValueNotifier<double> progressNotifier =
// ValueNotifier<double>(0.0);
// final ValueNotifier<bool> failureNotifier =
// ValueNotifier<bool>(false);
// Timer? pollingTimer;
// // 定义请求函数
// void requestCalibrationProgress() {
// String serviceAddress =
// "http://192.168.1.80:8086";
// String serviceApi =
// ServiceConstant.calibration_process;
// String queryUrl =
// "${serviceAddress}${serviceApi}?id=$cid";
// requestWithLog(
// logTitle: "设备校准进度",
// method: MyHttpMethod.get,
// queryUrl: queryUrl,
// onSuccess: (res) {
// print(res);
// deviceCalibrationController.tips.value =
// res.data['statusText'];
// if (res.data['per'] == 100) {
// TopSlideNotification.show(context,
// text: deviceCalibrationController
// .tips.value);
// }
// double process =
// (res.data['per'] ?? 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();
// }
// deviceCalibrationController
// .process.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,
// );
// },
// );
// },
onTap: () async {
if (deviceCalibrationController.complete) {
showConfirmDialog(
context, Container(), "校准已经完成,是否重新开始校准?",
onConfirm: () {
BlueteethBindController blueteethBindController =
Get.find();
deviceCalibrationController.process.value = 0;
deviceCalibrationController
.bed_calibration.value = 0;
deviceCalibrationController
.position_calibration.value = 0;
blueteethBindController.cid!.value = "";
deviceCalibrationController.complete = false;
}, onCancel: () {});
}
BlueteethBindController blueteethBindController =
Get.find();
String serviceAddress = "https://caibration.he-info.cn/";
String calibrationApi =
ServiceConstant.start_calibration;
String progressApi =
ServiceConstant.calibration_process;
String queryUrl = "$serviceAddress$calibrationApi";
final ValueNotifier<double> progressNotifier =
ValueNotifier<double>(0.0);
final ValueNotifier<bool> failureNotifier =
ValueNotifier<bool>(false);
Timer? pollingTimer;
Map<String, dynamic> data = {
"macA": blueteethBindController.currentDeviceMac,
};
// 是否是二次点击有cid表示进行第二阶段
bool isSecondStep =
blueteethBindController.cid?.value.isNotEmpty ??
false;
if (isSecondStep) {
data["id"] = blueteethBindController.cid!.value;
}
// 发起校准请求
requestWithLog(
logTitle: "设备校准",
method: MyHttpMethod.post,
queryUrl: ServiceConstant.start_calibration,
data: {
"deviceId":
blueteethBindController.currentDeviceMac
},
queryUrl: queryUrl,
data: data,
onSuccess: (res) {
final ValueNotifier<double> progressNotifier =
ValueNotifier<double>(0.0);
final ValueNotifier<bool> failureNotifier =
ValueNotifier<bool>(false);
Timer? pollingTimer;
if (!isSecondStep) {
// 保存第一次获取的 cid
String cid = res.rawResponse.data['cid'];
blueteethBindController.cid!.value = cid;
}
// 定义请求函数
void requestCalibrationProgress() {
String cid = blueteethBindController.cid!.value;
String progressUrl =
"$serviceAddress$progressApi?id=$cid";
requestWithLog(
logTitle: "设备校准进度",
method: MyHttpMethod.post,
queryUrl: ServiceConstant.calibration_process,
data: {
"deviceId":
blueteethBindController.currentDeviceMac
},
method: MyHttpMethod.get,
queryUrl: progressUrl,
onSuccess: (res) {
double process =
(res.data['process'] ?? 0).toDouble();
progressNotifier.value = process;
final data = res.data;
double per = (data['per'] ?? 0).toDouble();
int currStep = data['currStep'] ?? -1;
bool status = data['status'] ?? false;
String tips = data['statusText'] ?? '';
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();
}
deviceCalibrationController.tips.value =
tips;
// progressNotifier.value =
// (res.data['per'] ?? 0) / 100.0;
progressNotifier.value = per;
if (!isSecondStep && per >= 100) {
// 第一步完成:仅 per >= 100
pollingTimer?.cancel();
TopSlideNotification.show(context,
text: tips);
deviceCalibrationController
.process.value = 1;
deviceCalibrationController
.bed_calibration.value = 1;
deviceCalibrationController.updateAll();
}
if (isSecondStep &&
per >= 100 &&
currStep == 5 &&
status == true) {
// 第二步完成per >= 100 && currStep == 5 && status == true
pollingTimer?.cancel();
TopSlideNotification.show(context,
text: "设备校准完成".tr);
// 可在这里执行校准完成后的业务逻辑更新
deviceCalibrationController
.bed_calibration.value = 1;
deviceCalibrationController
.position_calibration.value = 1;
deviceCalibrationController
.process.value = 1;
deviceCalibrationController.complete =
true;
deviceCalibrationController.updateAll();
}
},
onFailure: (res) {
@@ -548,15 +719,15 @@ class _CalibrationPageState extends State<CalibrationPage> {
);
}
// 启动轮询
pollingTimer =
Timer.periodic(Duration(seconds: 2), (timer) {
requestCalibrationProgress();
});
// 初始调用一次
requestCalibrationProgress();
// 开始轮询
pollingTimer =
Timer.periodic(Duration(seconds: 2), (_) {
requestCalibrationProgress();
});
// 显示进度弹窗
showProgressDialog(
context, progressNotifier, failureNotifier);
@@ -570,6 +741,7 @@ class _CalibrationPageState extends State<CalibrationPage> {
},
);
},
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,

View File

@@ -207,9 +207,8 @@ class _DeviceShareListPageState extends State<DeviceShareListPage> {
fontSize: 26.rpx,
letterSpacing: 0.0,
),
cursorColor:
FlutterFlowTheme.of(context)
.primaryText,
cursorColor: themeController
.currentColor.sc3,
),
),
),

View File

@@ -1,6 +1,8 @@
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:fluwx/fluwx.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
@@ -8,6 +10,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/device_share_controller.dart';
import 'package:vbvs_app/controller/login/login_controller.dart';
import 'package:vbvs_app/model/api_response.dart';
import 'package:vbvs_app/pages/device_bind/componnet/FancyCircleCheckbox.dart';
@@ -180,7 +183,9 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.rpx),
border: Border.all(
color: Color(0xFFF3EDED),
color: themeController.currentColor.sc4
.withOpacity(0.5),
width: AppConstants().border_width,
),
),
child: Align(
@@ -250,8 +255,7 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
color: themeController.currentColor.sc3,
),
textAlign: TextAlign.center,
cursorColor:
FlutterFlowTheme.of(context).primaryText,
cursorColor: themeController.currentColor.sc3,
// validator: _model.textController1Validator
// .asValidator(context),
),
@@ -371,9 +375,15 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
TopSlideNotification.show(context,
text: "待开发功能".tr);
onTap: () async {
// TopSlideNotification.show(context,
// text: "待开发功能".tr);
LoginController loginController = Get.find();
// loginController.fluwx.share(WeChatShareTextModel(
// "太和e护分享链接",
// scene: WeChatScene.session));
final Uint8List data = await rootBundle.load('assets/img/camera.png').then((bd) => bd.buffer.asUint8List());
loginController.fluwx.share(WeChatShareWebPageModel("https://www.baidu.com",title: "标题",description: "描述",thumbData: data));
},
colors: [
// 渐变色

View File

@@ -18,7 +18,8 @@ import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
class WifiPage extends StatefulWidget {
WifiPage({super.key});
var type;
WifiPage({super.key, required this.type});
@override
State<WifiPage> createState() => _WifiPageState();
@@ -36,6 +37,8 @@ class _WifiPageState extends State<WifiPage> {
void initState() {
super.initState();
blueteethBindController.wifiList = [].obs;
blueteethBindController.wifiStatus = 0.obs;
blueteethBindController.connect_wifi.value = {};
initWifiStatusAndWifiList();
}
@@ -91,45 +94,45 @@ class _WifiPageState extends State<WifiPage> {
left: 0,
child: returnIconButtom,
),
Positioned(
right: 20.rpx,
child: CustomCard(
borderRadius: 20.rpx,
onTap: () async {
if (blueteethBindController.wifiStatus.value != 1) {
TopSlideNotification.show(
context,
text: "wifi页.需配网".tr,
textColor: themeController.currentColor.sc9,
);
}
Get.toNamed("/calibrationPage",arguments: 1);
// Get.toNamed("/personPage");
// Get.toNamed("/bindDeviceSuccess");
},
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(
'wifi页.跳过'.tr,
style: FlutterFlowTheme.of(context)
.titleSmall
.override(
fontFamily: 'Inter Tight',
color: themeController.currentColor.sc3,
letterSpacing: 0.0,
),
if (widget.type == null)
Positioned(
right: 20.rpx,
child: CustomCard(
borderRadius: 20.rpx,
onTap: () async {
if (blueteethBindController.wifiStatus.value != 1) {
TopSlideNotification.show(
context,
text: "wifi页.需配网".tr,
textColor: themeController.currentColor.sc9,
);
} else {
Get.toNamed("/calibrationPage", arguments: 1);
}
},
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(
'wifi页.跳过'.tr,
style: FlutterFlowTheme.of(context)
.titleSmall
.override(
fontFamily: 'Inter Tight',
color: themeController.currentColor.sc3,
letterSpacing: 0.0,
),
),
),
),
),
),
],
),
),
@@ -207,25 +210,29 @@ class _WifiPageState extends State<WifiPage> {
.connect_wifi.value.isEmpty) {
return Container();
} else {
return Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
blueteethBindController
.connect_wifi.value['ssid'] ??
'未命名'.tr,
style: TextStyle(
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
return Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 30.rpx),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
blueteethBindController.connect_wifi
.value['ssid'] ??
'未命名'.tr,
style: TextStyle(
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
),
),
),
getWifiIconByRsso(
blueteethBindController
.connect_wifi.value),
],
getWifiIconByRsso(
blueteethBindController
.connect_wifi.value),
],
),
);
}
})
@@ -267,136 +274,6 @@ class _WifiPageState extends State<WifiPage> {
),
],
),
// Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '6503',
// style: FlutterFlowTheme.of(context)
// .bodyMedium
// .override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController
// .currentColor.sc3,
// ),
// ),
// Icon(
// Icons.wifi_outlined,
// size: 30.rpx,
// color: themeController
// .currentColor.sc3,
// ),
// ],
// ),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '6503',
// style: FlutterFlowTheme.of(context)
// .bodyMedium
// .override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController
// .currentColor.sc3,
// ),
// ),
// Icon(
// Icons.wifi_outlined,
// size: 30.rpx,
// color: themeController
// .currentColor.sc3,
// ),
// ],
// ),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '6503',
// style: FlutterFlowTheme.of(context)
// .bodyMedium
// .override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController
// .currentColor.sc3,
// ),
// ),
// Icon(
// Icons.wifi_outlined,
// size: 30.rpx,
// color: themeController
// .currentColor.sc3,
// ),
// ],
// ),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '6503',
// style: FlutterFlowTheme.of(context)
// .bodyMedium
// .override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController
// .currentColor.sc3,
// ),
// ),
// Icon(
// Icons.wifi_outlined,
// size: 30.rpx,
// color: themeController
// .currentColor.sc3,
// ),
// ],
// ),
// Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '6503',
// style: FlutterFlowTheme.of(context)
// .bodyMedium
// .override(
// fontFamily: 'Inter',
// fontSize: 30.rpx,
// letterSpacing: 0.0,
// color: themeController
// .currentColor.sc3,
// ),
// ),
// Icon(
// Icons.wifi_outlined,
// size: 30.rpx,
// color: themeController
// .currentColor.sc3,
// ),
// ],
// ),
// ].divide(SizedBox(height: 67.rpx)),
// ),
Obx(() {
final sortedList = [
...blueteethBindController.wifiList.value
@@ -413,7 +290,7 @@ class _WifiPageState extends State<WifiPage> {
.currentColor.sc3,
padding: EdgeInsets.symmetric(
vertical: 0.rpx,
horizontal: 20.rpx),
horizontal: 0.rpx),
borderRadius: 16.rpx,
onTap: () {
showWifiDialog(
@@ -573,9 +450,9 @@ class _WifiPageState extends State<WifiPage> {
color: Colors
.black),
cursorColor:
FlutterFlowTheme.of(
context)
.primaryText,
themeController
.currentColor
.sc3,
);
})),
),
@@ -591,21 +468,75 @@ class _WifiPageState extends State<WifiPage> {
.model.wifiPass!,
blueteethBindController
.currentDevice!);
Navigator.pop(context);
// Navigator.pop(context);
if (flag) {
TopSlideNotification.show(
context,
text: "wifi页.配网成功".tr,
textColor:
themeController
.currentColor
.sc2,
);
// bool wifiStatus =
// await getWifiStatus(
// blueteethBindController
// .currentDevice!);
bool wifiStatus = false;
var aa = await getDeviceWifiStatus(
blueteethBindController
.currentDevice!,
20);
if (aa != null &&
aa is Map) {
wifiStatus = true;
blueteethBindController
.connect_wifi
.value = aa;
} else {
blueteethBindController
.connect_wifi
.value = {};
}
blueteethBindController
.wifiStatus.value = 1;
.wifiStatus
.value =
wifiStatus == true
? 1
: 0;
blueteethBindController
.updateAll();
.wifiStatus
.value =
wifiStatus == true
? 1
: 0;
if (wifiStatus) {
Navigator.pop(context);
TopSlideNotification
.show(
context,
text: "wifi页.配网成功".tr,
textColor:
themeController
.currentColor
.sc2,
);
blueteethBindController
.wifiStatus
.value = 1;
blueteethBindController
.updateAll();
} else {
Navigator.pop(context);
TopSlideNotification
.show(
context,
text: "wifi页.配网失败".tr,
textColor:
themeController
.currentColor
.sc9,
);
blueteethBindController
.wifiStatus
.value = 0;
blueteethBindController
.updateAll();
}
} else {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "wifi页.配网失败".tr,
@@ -651,7 +582,6 @@ class _WifiPageState extends State<WifiPage> {
.divide(SizedBox(height: 67.rpx)),
);
}),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white,
@@ -774,16 +704,14 @@ class _WifiPageState extends State<WifiPage> {
}
if (onData.status == BleEventType.ready) {
showLoadingDialog(context, title: "获取wifi列表中...".tr);
bool wifiStatus =
await getWifiStatus(blueteethBindController.currentDevice!);
bool wifiStatus = false;
var aa = await getDeviceWifiStatus(
blueteethBindController.currentDevice!, 10);
if (aa != null && aa is Map) {
wifiStatus = true;
blueteethBindController.connect_wifi.value = aa;
}
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;
// }
// }
List wifiList =
await getWifiList(blueteethBindController.currentDevice!);
if (wifiList.length > 0) {
@@ -827,77 +755,50 @@ class _WifiPageState extends State<WifiPage> {
}
getWifiIconByRsso(wifiItem) {
if (wifiItem['rssi'] >= -30) {
// return SvgPicture.asset(
// 'assets/img/icon/wifi4.svg',
// width: 25.rpx,
// height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
// color: themeController.currentColor.sc3,
// );
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset(
"assets/img/wifi4.png",
),
);
} else if (wifiItem['rssi'] >= -45) {
// return SvgPicture.asset(
// 'assets/img/icon/wifi3.svg',
// width: 25.rpx,
// height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
// color: themeController.currentColor.sc3,
// );
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset(
"assets/img/wifi3.png",
),
);
} else if (wifiItem['rssi'] >= -60) {
// return SvgPicture.asset(
// 'assets/img/icon/wifi2.svg',
// width: 25.rpx,
// height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
// color: themeController.currentColor.sc3,
// );
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset(
"assets/img/wifi3.png",
),
);
int? rssi = int.tryParse(wifiItem['rssi'].toString());
if (rssi != null) {
if (rssi >= -30) {
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/img/wifi4.png"),
);
} else if (rssi >= -45) {
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/img/wifi3.png"),
);
} else if (rssi >= -60) {
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/img/wifi3.png"),
);
} else {
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/img/wifi1.png"),
);
}
} else {
// return SvgPicture.asset(
// 'assets/img/icon/wifi1.svg',
// width: 25.rpx,
// height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
// color: themeController.currentColor.sc3,
// );
// RSSI 无法解析时的默认显示
return Container(
width: 40.rpx,
height: 40.rpx,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset(
"assets/img/wifi1.png",
),
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset("assets/img/wifi1.png"),
);
}
}