更新登录对接

This commit is contained in:
wyf
2025-04-18 18:13:21 +08:00
parent 1765403f21
commit 850c34b408
40 changed files with 2101 additions and 1745 deletions

View File

@@ -1,11 +1,10 @@
import 'dart:async';
import 'package:easydevice/easydevice.dart';
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/Ble.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
@@ -14,14 +13,12 @@ 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/common/util/Ble.dart' as ble;
import 'package:vbvs_app/pages/common/selectDialog.dart';
class WifiPage extends StatefulWidget {
// ble.ConnectedDeviceProp connectedDeviceProp;
BluetoothDevice bluetoothDevice;
// WifiPage({super.key, required this.connectedDeviceProp});
WifiPage({super.key, required this.bluetoothDevice});
BLEDevice bleDevice;
WifiPage({super.key, required this.bleDevice});
// WifiPage({super.key});
@override
State<WifiPage> createState() => _WifiPageState();
@@ -33,12 +30,10 @@ class _WifiPageState extends State<WifiPage> {
BlueteethBindController blueteethBindController = Get.find();
PersonController personController = Get.find();
ThemeController themeController = Get.find();
late ble.ConnectedDeviceProp connectedDeviceProp;
@override
void initState() {
super.initState();
connectToDevice(widget.bluetoothDevice);
// connectedDeviceProp = widget.connectedDeviceProp;
Timer(const Duration(microseconds: 100), () {
getWifiList();
@@ -60,14 +55,12 @@ class _WifiPageState extends State<WifiPage> {
child: Scaffold(
backgroundColor: Colors.transparent, // 加上这一行
appBar: AppBar(
backgroundColor: stringToColor("#242835"),
// backgroundColor: Colors.transparent,
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
titleSpacing: 0,
// leading: returnIconButtom,
title: Container(
// color: Colors.grey,
width: double.infinity,
height: 180.rpx,
child: Stack(
@@ -78,7 +71,7 @@ class _WifiPageState extends State<WifiPage> {
'wifi页.标题'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: Colors.white,
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
@@ -97,8 +90,8 @@ class _WifiPageState extends State<WifiPage> {
Get.offAllNamed("/bindDeviceSuccess");
},
colors: [
stringToColor("#45D989"),
stringToColor("#00C1AA"),
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: 100.rpx,
@@ -112,7 +105,7 @@ class _WifiPageState extends State<WifiPage> {
.titleSmall
.override(
fontFamily: 'Inter Tight',
color: Colors.white,
color: themeController.currentColor.sc3,
letterSpacing: 0.0,
),
),
@@ -390,8 +383,7 @@ class _WifiPageState extends State<WifiPage> {
}
}
},
// colors: [Colors.white.withOpacity(0.06)], // 背景色
colors: [stringToColor("#242835")], // 背景色
colors: [themeController.currentColor.sc17], // 背景色
child: Container(
width: double.infinity,
@@ -430,46 +422,12 @@ class _WifiPageState extends State<WifiPage> {
getWifiList({int time = 3}) {
// LoadingDialog.show("扫描WIFI列表中...", icon: LoadingDialogIcon.wifi);
try {
var device = widget.bluetoothDevice;
String log = "";
Function logAdd = (l) {
log += l;
};
connectedDeviceProp.receiveLogArr.add(logAdd);
connectedDeviceProp.write3OfString("wscan scan", success: () {
Timer.periodic(const Duration(milliseconds: 1000), (timer) async {
if (timer.tick > 8) {
timer.cancel();
connectedDeviceProp.receiveLogArr.remove(logAdd);
LoadingDialog.hide();
if (time > 0) {
getWifiList(time: time - 1);
}
}
Iterable<RegExpMatch> a = RegExp(
r'ITEM:SSID=([^\t]*)\s*RSSI=(\S*)\s*(,\s*auth\s*=\s*(\S*))?')
.allMatches(log);
if (a.isEmpty == false) {
await Future.delayed(const Duration(milliseconds: 500));
a = RegExp(
r'ITEM:SSID=([^\t]*)\s*RSSI=(\S*)\s*(,\s*auth\s*=\s*(\S*))?')
.allMatches(log);
List arr = [];
for (RegExpMatch one in a) {
arr.add({"name": one[1], "num": one[2], "auth": one[4]});
}
LoadingDialog.hide();
blueteethBindController.model.wifiList = arr;
blueteethBindController.updateAll();
connectedDeviceProp.receiveLogArr.remove(logAdd);
timer.cancel();
checkIsCalibration();
}
});
}, fail: () {
connectedDeviceProp.receiveLogArr.remove(logAdd);
LoadingDialog.hide();
});
// var device = widget.bluetoothDevice;
// String log = "";
// Function logAdd = (l) {
// log += l;
// };
} catch (e) {
print(e);
}