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

@@ -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"),
);
}
}