更新分享
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:easydevice/easydevice.dart';
|
||||
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/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/component/tool/cmd.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_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';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
|
||||
class WifiPage extends StatefulWidget {
|
||||
BLEDevice bleDevice;
|
||||
WifiPage({super.key, required this.bleDevice});
|
||||
WifiPage({super.key});
|
||||
// WifiPage({super.key});
|
||||
|
||||
@override
|
||||
@@ -30,18 +31,29 @@ class _WifiPageState extends State<WifiPage> {
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
PersonController personController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
var lisObj;
|
||||
// List<String> _logBuffer = [];
|
||||
// bool _isCollecting = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// connectedDeviceProp = widget.connectedDeviceProp;
|
||||
Timer(const Duration(microseconds: 100), () {
|
||||
getWifiList();
|
||||
});
|
||||
blueteethBindController.wifiList = [].obs;
|
||||
initWifiStatusAndWifiList();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
if (lisObj != null) {
|
||||
lisObj.cancel();
|
||||
}
|
||||
blueteethBindController.currentDevice!.disconnect();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("object");
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
@@ -87,11 +99,19 @@ class _WifiPageState extends State<WifiPage> {
|
||||
child: CustomCard(
|
||||
borderRadius: 20.rpx,
|
||||
onTap: () async {
|
||||
Get.offAllNamed("/bindDeviceSuccess");
|
||||
if (blueteethBindController.wifiStatus.value != 1) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "wifi页.需配网".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
Get.toNamed("/personPage");
|
||||
// Get.toNamed("/bindDeviceSuccess");
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: 100.rpx,
|
||||
@@ -132,41 +152,87 @@ class _WifiPageState extends State<WifiPage> {
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF242835),
|
||||
borderRadius: BorderRadius.circular(20.rpx),
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 30.rpx, 30.rpx, 30.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"wifi页.WLAN".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize:
|
||||
AppConstants().title_text_fontSize,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"wifi页.未连接".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF242835),
|
||||
borderRadius: BorderRadius.circular(20.rpx),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 30.rpx, 30.rpx, 30.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"wifi页.WLAN".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize,
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return Text(
|
||||
blueteethBindController
|
||||
.wifiStatus.value ==
|
||||
0
|
||||
? "wifi页.未连接".tr
|
||||
: "wifi页.已连接".tr,
|
||||
style: TextStyle(
|
||||
color: blueteethBindController
|
||||
.wifiStatus.value ==
|
||||
0
|
||||
? themeController
|
||||
.currentColor.sc4
|
||||
: themeController
|
||||
.currentColor.sc2,
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize,
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
if (blueteethBindController
|
||||
.connect_wifi.value ==
|
||||
null ||
|
||||
blueteethBindController
|
||||
.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,
|
||||
),
|
||||
),
|
||||
getWifiIconByRsso(
|
||||
blueteethBindController
|
||||
.connect_wifi.value),
|
||||
],
|
||||
);
|
||||
}
|
||||
})
|
||||
],
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
@@ -190,7 +256,7 @@ class _WifiPageState extends State<WifiPage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
'可用WLAN',
|
||||
'可用WLAN'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
@@ -203,157 +269,436 @@ 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,
|
||||
// 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
|
||||
]..sort((a, b) => b['rssi']
|
||||
.compareTo(a['rssi'])); // 按 rssi 倒序
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: sortedList
|
||||
.map((wifiItem) => ClickableContainer(
|
||||
backgroundColor:
|
||||
Colors.transparent,
|
||||
highlightColor: themeController
|
||||
.currentColor.sc3,
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 0.rpx,
|
||||
horizontal: 20.rpx),
|
||||
borderRadius: 16.rpx,
|
||||
onTap: () {
|
||||
showWifiDialog(
|
||||
context,
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional
|
||||
.fromSTEB(
|
||||
0.rpx,
|
||||
41.rpx,
|
||||
0.rpx,
|
||||
0),
|
||||
child: Container(
|
||||
height: 80.rpx,
|
||||
decoration:
|
||||
BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius
|
||||
.circular(12
|
||||
.rpx), // 加圆角
|
||||
),
|
||||
child: Align(
|
||||
alignment:
|
||||
AlignmentDirectional(
|
||||
-1, 0),
|
||||
child: Obx(() {
|
||||
return TextFormField(
|
||||
onChanged:
|
||||
(value) {
|
||||
blueteethBindController
|
||||
.model
|
||||
.wifiPass =
|
||||
value;
|
||||
},
|
||||
autofocus:
|
||||
false,
|
||||
obscureText:
|
||||
blueteethBindController
|
||||
.model
|
||||
.wifiPassShow,
|
||||
decoration:
|
||||
InputDecoration(
|
||||
isDense:
|
||||
true,
|
||||
labelStyle: FlutterFlowTheme.of(
|
||||
context)
|
||||
.labelMedium
|
||||
.override(
|
||||
fontFamily:
|
||||
'Inter',
|
||||
fontSize:
|
||||
26.rpx,
|
||||
letterSpacing:
|
||||
0.0,
|
||||
),
|
||||
hintText:
|
||||
'蓝牙绑定.输入wifi密码'
|
||||
.tr,
|
||||
hintStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
||||
fontFamily:
|
||||
'Inter',
|
||||
fontSize: 26
|
||||
.rpx,
|
||||
letterSpacing:
|
||||
0.0,
|
||||
color: themeController
|
||||
.currentColor
|
||||
.sc4),
|
||||
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: FlutterFlowTheme.of(
|
||||
context)
|
||||
.secondaryBackground,
|
||||
suffixIcon:
|
||||
InkWell(
|
||||
onTap:
|
||||
() {
|
||||
blueteethBindController
|
||||
.model
|
||||
.wifiPassShow = !blueteethBindController.model.wifiPassShow;
|
||||
blueteethBindController
|
||||
.updateAll();
|
||||
},
|
||||
focusNode:
|
||||
FocusNode(
|
||||
skipTraversal: true),
|
||||
child:
|
||||
Icon(
|
||||
blueteethBindController.model.wifiPassShow
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
size: 30
|
||||
.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily:
|
||||
'Inter',
|
||||
fontSize: 26
|
||||
.rpx,
|
||||
letterSpacing:
|
||||
0.0,
|
||||
color: Colors
|
||||
.black),
|
||||
cursorColor:
|
||||
FlutterFlowTheme.of(
|
||||
context)
|
||||
.primaryText,
|
||||
);
|
||||
})),
|
||||
),
|
||||
),
|
||||
wifiItem['ssid'] ??
|
||||
'未命名'.tr,
|
||||
onConfirm: () async {
|
||||
showLoadingDialog(
|
||||
context); // 显示 loading
|
||||
bool flag = await sendWifiSetting(
|
||||
wifiItem,
|
||||
blueteethBindController
|
||||
.model.wifiPass!,
|
||||
blueteethBindController
|
||||
.currentDevice!);
|
||||
Navigator.pop(context);
|
||||
if (flag) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "wifi页.配网成功".tr,
|
||||
textColor:
|
||||
themeController
|
||||
.currentColor
|
||||
.sc2,
|
||||
);
|
||||
blueteethBindController
|
||||
.wifiStatus.value = 1;
|
||||
blueteethBindController
|
||||
.updateAll();
|
||||
} else {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "wifi页.配网失败".tr,
|
||||
textColor:
|
||||
themeController
|
||||
.currentColor
|
||||
.sc9,
|
||||
);
|
||||
blueteethBindController
|
||||
.wifiStatus.value = 0;
|
||||
blueteethBindController
|
||||
.updateAll();
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize:
|
||||
MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
wifiItem['ssid'] ?? '',
|
||||
style: FlutterFlowTheme
|
||||
.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color:
|
||||
themeController
|
||||
.currentColor
|
||||
.sc3,
|
||||
),
|
||||
),
|
||||
getWifiIconByRsso(wifiItem),
|
||||
],
|
||||
),
|
||||
))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 67.rpx)),
|
||||
);
|
||||
}),
|
||||
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20.rpx, vertical: 10.rpx),
|
||||
borderRadius: 20.rpx,
|
||||
onTap: () async {
|
||||
print("点击刷新");
|
||||
await initWifiList();
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "获取wifi列表成功".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc2,
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 25.rpx,
|
||||
height: 25.rpx,
|
||||
decoration: BoxDecoration(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/refresh.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: Colors.white, // 图标固定白色
|
||||
),
|
||||
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)),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.arrow_back,
|
||||
color: themeController.currentColor.sc3,
|
||||
size: 30.rpx,
|
||||
),
|
||||
Text(
|
||||
'刷新',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
),
|
||||
Text(
|
||||
'刷新',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3),
|
||||
),
|
||||
].divide(SizedBox(width: 26.rpx)),
|
||||
.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 26.rpx)),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 65.rpx)),
|
||||
),
|
||||
@@ -419,42 +764,143 @@ class _WifiPageState extends State<WifiPage> {
|
||||
);
|
||||
}
|
||||
|
||||
getWifiList({int time = 3}) {
|
||||
// LoadingDialog.show("扫描WIFI列表中...", icon: LoadingDialogIcon.wifi);
|
||||
void initWifiStatusAndWifiList() {
|
||||
if (lisObj != null) {
|
||||
lisObj!.cancel();
|
||||
}
|
||||
lisObj = blueteethBindController.currentDevice!.statusStream
|
||||
.listen((onData) async {
|
||||
if (onData.status == BleEventType.recvLineLog) {
|
||||
final line = onData.val;
|
||||
print("[bleee]:" + line);
|
||||
}
|
||||
if (onData.status == BleEventType.ready) {
|
||||
showLoadingDialog(context, title: "获取wifi列表中...".tr);
|
||||
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;
|
||||
}
|
||||
}
|
||||
List wifiList =
|
||||
await getWifiList(blueteethBindController.currentDevice!);
|
||||
if (wifiList.length > 0) {
|
||||
Navigator.pop(context);
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "获取wifi列表成功".tr,
|
||||
textColor: themeController.currentColor.sc2,
|
||||
);
|
||||
blueteethBindController.wifiList.value = wifiList;
|
||||
blueteethBindController.updateAll();
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "获取wifi列表失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initWifiList() async {
|
||||
try {
|
||||
// var device = widget.bluetoothDevice;
|
||||
// String log = "";
|
||||
// Function logAdd = (l) {
|
||||
// log += l;
|
||||
// };
|
||||
|
||||
var wifiList = await getWifiList(blueteethBindController.currentDevice!);
|
||||
print(wifiList);
|
||||
if (wifiList.length > 0) {
|
||||
blueteethBindController.wifiList.value = wifiList;
|
||||
blueteethBindController.updateAll();
|
||||
}
|
||||
return wifiList;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "获取wifi列表失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
checkIsCalibration() {
|
||||
// if (controller.model.bindArr[0] == "" ||
|
||||
// controller.model.bindArr[0] == null) {
|
||||
// return;
|
||||
// }
|
||||
// if (controller.model.bindArr[2] == "" ||
|
||||
// controller.model.bindArr[2] == null) {
|
||||
// return;
|
||||
// }
|
||||
// if (controller.model.connectedWifiName == "" ||
|
||||
// controller.model.connectedWifiName == null) {
|
||||
// return;
|
||||
// }
|
||||
showCustomConfirmAndCancelDialog(context, "是否进行设备校准?", confirmName: "去校准")
|
||||
.then((d) async {
|
||||
// if (d == "confirm") {
|
||||
// await Get.offAndToNamed("/calibration", arguments: [
|
||||
// controller.model.bindArr[1],
|
||||
// controller.model.bindArr[2]
|
||||
// ]);
|
||||
// Get.find<GlobalController>().getDeviceList();
|
||||
// }
|
||||
});
|
||||
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",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// return SvgPicture.asset(
|
||||
// 'assets/img/icon/wifi1.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/wifi1.png",
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user