更新分享
This commit is contained in:
255
lib/pages/device_bind/MobileScannerTestPage.dart
Normal file
255
lib/pages/device_bind/MobileScannerTestPage.dart
Normal file
@@ -0,0 +1,255 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:img_picker/img_picker.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
|
||||
class MobileScannerTestPage extends StatefulWidget {
|
||||
const MobileScannerTestPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MobileScannerTestPage> createState() => _MobileScannerTestPageState();
|
||||
}
|
||||
|
||||
class _MobileScannerTestPageState extends State<MobileScannerTestPage>
|
||||
with TickerProviderStateMixin {
|
||||
String? scannedText;
|
||||
bool isScanning = true;
|
||||
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
late MobileScannerController _scannerController;
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
|
||||
final double scanAreaSize = 480.rpx;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_scannerController = MobileScannerController();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(seconds: 2),
|
||||
vsync: this,
|
||||
)..repeat(reverse: true);
|
||||
|
||||
_animation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.easeInOut,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_scannerController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onDetect(BarcodeCapture capture) {
|
||||
if (!isScanning) return;
|
||||
|
||||
final Barcode? barcode = capture.barcodes.first;
|
||||
final String? value = barcode?.rawValue;
|
||||
|
||||
if (value != null) {
|
||||
setState(() {
|
||||
scannedText = value;
|
||||
isScanning = false;
|
||||
if (scannedText != null && scannedText!.isNotEmpty) {
|
||||
blueteethBindController.scanMac.value = scannedText!;
|
||||
showConfirmDialog(
|
||||
context,
|
||||
Container(),
|
||||
'蓝牙绑定.确定绑定提示'.tr,
|
||||
onConfirm: () async {
|
||||
ApiResponse response =
|
||||
await blueteethBindController.bindDeviceByScan(scannedText!);
|
||||
if (response.code == HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "蓝牙绑定.连接成功".tr,
|
||||
textColor: themeController.currentColor.sc2,
|
||||
);
|
||||
} else {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: response.msg ?? "蓝牙绑定.连接异常".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
},
|
||||
onCancel: () {
|
||||
print('用户点击了取消');
|
||||
// 执行取消后的处理逻辑
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
setState(() {
|
||||
isScanning = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
titleSpacing: 0,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'扫一扫.标题'.tr,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtom,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
MobileScanner(
|
||||
controller: _scannerController,
|
||||
onDetect: _onDetect,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.topCenter, // 使扫描框位于顶部居中
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 219.rpx), // 向上移动扫描框
|
||||
child: SizedBox(
|
||||
width: scanAreaSize,
|
||||
height: scanAreaSize,
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
),
|
||||
),
|
||||
AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (context, child) {
|
||||
return Positioned(
|
||||
top: scanAreaSize * _animation.value,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
height: 2,
|
||||
color: themeController.currentColor.sc2,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 31.rpx),
|
||||
Text(
|
||||
'扫一扫.提示'.tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc2,
|
||||
fontSize: 26.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 0, 0, 83.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final picker = ImagePicker();
|
||||
final pickedFile =
|
||||
await picker.pickImage(source: ImageSource.gallery);
|
||||
if (pickedFile != null) {
|
||||
final bytes = await pickedFile.readAsBytes();
|
||||
final image = await decodeImageFromList(bytes);
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.photo,
|
||||
color: themeController.currentColor.sc2,
|
||||
size: 60.rpx),
|
||||
SizedBox(height: 10.rpx),
|
||||
Text(
|
||||
'扫一扫.相册'.tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc2,
|
||||
fontSize: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 80.rpx),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
_scannerController.toggleTorch();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(Icons.flashlight_on,
|
||||
color: themeController.currentColor.sc2,
|
||||
size: 60.rpx),
|
||||
SizedBox(height: 10.rpx),
|
||||
Text(
|
||||
'扫一扫.手电筒'.tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc2,
|
||||
fontSize: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class _EPageState extends State<BindDeviceSuccess> {
|
||||
'assets/img/icon/share.svg',
|
||||
width: 25.rpx,
|
||||
height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||||
color: themeController.currentColor.sc3,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'绑定成功.立即分享'.tr,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
@@ -14,19 +13,17 @@ import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/BleDeviceData.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/SingleBlueteethDeviceCompoentWidget.dart';
|
||||
import 'package:vbvs_app/common/util/Ble.dart' as ble;
|
||||
|
||||
class BlueteethDevicePage extends StatefulWidget {
|
||||
int tid = -1;
|
||||
BlueteethDevicePage({super.key, this.tid = -1});
|
||||
|
||||
@override
|
||||
State<BlueteethDevicePage> createState() => _EPageState();
|
||||
State<BlueteethDevicePage> createState() => _BlueteethDevicePageState();
|
||||
}
|
||||
|
||||
class _EPageState extends State<BlueteethDevicePage> {
|
||||
class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
||||
GlobalController globalController = Get.find();
|
||||
UserInfoController userInfoController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
@@ -49,6 +46,8 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
blueteethBindController.model.devicelist = [];
|
||||
blueteethBindController.model.betDevicelist = [];
|
||||
flutterBlue = FlutterBluePlus(); // 初始化flutterBlue实例
|
||||
_checkBluetoothPermission(); // 检查蓝牙权限
|
||||
Get.find<BlueteethBindController>().startStatusPolling();
|
||||
@@ -114,6 +113,7 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
|
||||
// 开始扫描蓝牙设备
|
||||
void _startScanning() async {
|
||||
if (!mounted) return;
|
||||
var bluetoothState = await FlutterBluePlus.isOn;
|
||||
if (!bluetoothState && !_isDialogShowing) {
|
||||
_isDialogShowing = true;
|
||||
@@ -128,8 +128,9 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
});
|
||||
|
||||
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
||||
// await FlutterBluePlus.startScan(timeout: Duration(minutes: 30));
|
||||
|
||||
FlutterBluePlus.scanResults.listen((results) {
|
||||
_scanSubscription = FlutterBluePlus.scanResults.listen((results) {
|
||||
final signalThreshold = blueteethBindController.model.singal!;
|
||||
final filteredResults = results
|
||||
.where((r) =>
|
||||
@@ -149,6 +150,9 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
deviceData.rssi = r.rssi;
|
||||
deviceData.mac = deviceData.deviceId.replaceAll(':', '');
|
||||
parsedDeviceList.add(deviceData);
|
||||
if (deviceData.mac!.toLowerCase() == 'b43a45c3dfa0') {
|
||||
print('匹配设备数据: ${deviceData.mac}-->sn:${deviceData.sn}');
|
||||
}
|
||||
} catch (e) {
|
||||
print("设备数据解析失败: $e");
|
||||
}
|
||||
@@ -188,13 +192,15 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
|
||||
// 等待扫描完成
|
||||
await Future.delayed(Duration(seconds: 10));
|
||||
// await Future.delayed(Duration(minutes: 30));
|
||||
await FlutterBluePlus.stopScan();
|
||||
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
|
||||
print("扫描完成");
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
}
|
||||
// print("扫描完成");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,10 +216,13 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
// 停止扫描
|
||||
void _stopScanning() {
|
||||
if (isScanning) {
|
||||
FlutterBluePlus.stopScan(); // 停止扫描
|
||||
setState(() {
|
||||
isScanning = false; // 更新扫描状态
|
||||
});
|
||||
FlutterBluePlus.stopScan();
|
||||
_scanSubscription?.cancel(); // 取消订阅
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isScanning = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,396 +231,15 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
_timer?.cancel();
|
||||
}
|
||||
|
||||
StreamSubscription<List<ScanResult>>? _scanSubscription; // 添加扫描订阅变量
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_stopPeriodicScan(); // 停止定时扫描
|
||||
_stopScanning(); // 确保离开页面时停止扫描
|
||||
}
|
||||
|
||||
connectToDevice(device, {int time = 5}) {
|
||||
ble.connectToDevice(
|
||||
{
|
||||
"device": device,
|
||||
'success': (ble.ConnectedDeviceProp deviceProp) {
|
||||
if (deviceProp.connectedDevicePropType ==
|
||||
ble.ConnectedDevicePropType.JunHe) {
|
||||
currentConnectedDeviceProp = deviceProp;
|
||||
deviceProp.write3OfString("blog enable");
|
||||
deviceProp.write3OfString("blog rlmax=128");
|
||||
Timer(const Duration(microseconds: 100), () async {
|
||||
String log = "";
|
||||
Function logAdd = (l) {
|
||||
log += l;
|
||||
};
|
||||
deviceProp.receiveLogArr.add(logAdd);
|
||||
deviceProp.encodeType = 1;
|
||||
deviceProp.deviceType = 1;
|
||||
Timer.periodic(const Duration(milliseconds: 300), (timer) async {
|
||||
if (timer.tick > 20) {
|
||||
ble.disconnect(currentConnectedDeviceProp);
|
||||
failSelectDialog();
|
||||
timer.cancel();
|
||||
}
|
||||
if (log.contains("GB2312") || log.contains("UTF-8")) {
|
||||
timer.cancel();
|
||||
if (log.contains('CHARSET:UTF-8')) {
|
||||
deviceProp.encodeType = 2;
|
||||
}
|
||||
if (log.contains('TARGET:ESPXX')) {
|
||||
deviceProp.deviceType = 2;
|
||||
}
|
||||
log = "";
|
||||
bool isSuccess = false;
|
||||
for (var i = 0; i < 4; i++) {
|
||||
deviceProp.write3OfString("at+system info");
|
||||
await Future.delayed(const Duration(milliseconds: 400));
|
||||
RegExp regExp = RegExp(r"Target Mac:(\S*)");
|
||||
RegExpMatch? regExpMatch = regExp.firstMatch(log);
|
||||
if (regExpMatch != null && regExpMatch.group(1) != null) {
|
||||
String? mac = regExpMatch.group(1);
|
||||
if (mac?.length == 12 && mac != "000000000000") {
|
||||
bindArr[2] = "$mac".toUpperCase();
|
||||
}
|
||||
isSuccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
deviceProp.receiveLogArr.remove(logAdd);
|
||||
print("$bindArr");
|
||||
RegExp regExp = RegExp(
|
||||
r"WIFI CONNECTED INFO:SSID=([^\t\n]*)\s*,RSSI=(\S*)\s*,");
|
||||
RegExpMatch? regExpMatch = regExp.firstMatch(log);
|
||||
if (regExpMatch != null && log.contains("Status=connect")) {
|
||||
blueteethBindController.model.connectedWifiName =
|
||||
regExpMatch.group(1) ?? "";
|
||||
if (int.tryParse("${regExpMatch.group(2)}") != null) {
|
||||
blueteethBindController.model.connectedRssi =
|
||||
int.parse("${regExpMatch.group(2)}");
|
||||
}
|
||||
blueteethBindController.updateAll();
|
||||
}
|
||||
ble.bleParse();
|
||||
if (bindArr[0] != null &&
|
||||
bindArr[0] != "" &&
|
||||
bindArr[1] != "") {
|
||||
setState(() {
|
||||
currentMsg = "绑定中...";
|
||||
});
|
||||
blueteethBindController.bindDevice({
|
||||
"tid": widget.tid,
|
||||
"name": blueteethBindController.model.deviceName,
|
||||
"mac": bindArr[0],
|
||||
"macA": bindArr[1],
|
||||
"macB": bindArr[2]
|
||||
}).then((d) {
|
||||
blueteethBindController.model.bindArr = bindArr;
|
||||
globalController.getDeviceList();
|
||||
LoadingDialog.hide();
|
||||
showCustomConfirmDialog(context, "设备添加成功!",
|
||||
btnName: "打开WIFI配置",
|
||||
icon: ConfirmDialogIcon.success)
|
||||
.then((d) {
|
||||
if (d == "confirm") {
|
||||
Get.offAndToNamed("/wifi", arguments: deviceProp);
|
||||
}
|
||||
});
|
||||
}).catchError((d) {
|
||||
print("$d");
|
||||
currentMsg = "绑定失败: ${d.message}";
|
||||
ble.disconnect(currentConnectedDeviceProp);
|
||||
failSelectDialog(title: "${d.message}");
|
||||
});
|
||||
} else {
|
||||
LoadingDialog.hide();
|
||||
Get.offAndToNamed("/wifi", arguments: deviceProp);
|
||||
}
|
||||
} else {
|
||||
deviceProp.read6();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (deviceProp.connectedDevicePropType ==
|
||||
ble.ConnectedDevicePropType.QuanShi) {
|
||||
List receive = [];
|
||||
Function fun = (d) {
|
||||
receive.add(d);
|
||||
};
|
||||
deviceProp.receiveLogArr.add(fun);
|
||||
List<int> head = [
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
1,
|
||||
0,
|
||||
12,
|
||||
17,
|
||||
];
|
||||
Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (timer.tick > 20) {
|
||||
timer.cancel();
|
||||
currentMsg = "错误:未能获取到MAC";
|
||||
failSelectDialog();
|
||||
}
|
||||
deviceProp.write(
|
||||
Uint8List.fromList([
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x01,
|
||||
0x00,
|
||||
0x0C,
|
||||
0x0B,
|
||||
0x0F,
|
||||
0x23,
|
||||
0x04
|
||||
]),
|
||||
null,
|
||||
null);
|
||||
if (receive.length > 0) {
|
||||
receive.forEach((data) {
|
||||
if (data.length != 17) {
|
||||
return;
|
||||
}
|
||||
bool r = true;
|
||||
for (var i = 0; i < head.length; i++) {
|
||||
if (head[i] != data[i]) {
|
||||
r = false;
|
||||
}
|
||||
}
|
||||
if (r == false) {
|
||||
return;
|
||||
}
|
||||
bindArr[1] = ble.ab2str(data.sublist(9, 15)).toUpperCase();
|
||||
timer.cancel();
|
||||
deviceProp.receiveLogArr.remove(fun);
|
||||
blueteethBindController.model.deviceName =
|
||||
deviceProp.connectDevice?.advName;
|
||||
ble.disconnect(deviceProp);
|
||||
toFindJunhe();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
List receive = [];
|
||||
Function fun = (d) {
|
||||
receive.add(d);
|
||||
};
|
||||
deviceProp.receiveLogArr.add(fun);
|
||||
List<int> head = [255, 255, 255, 255, 0x00, 0x08, 0x40, 0x01];
|
||||
Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (timer.tick > 20) {
|
||||
timer.cancel();
|
||||
currentMsg = "错误:未能获取到MAC";
|
||||
failSelectDialog();
|
||||
}
|
||||
deviceProp.write(
|
||||
Uint8List.fromList([
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
0x00,
|
||||
0x03,
|
||||
0x40,
|
||||
0x01,
|
||||
0x01,
|
||||
0x00,
|
||||
0x45,
|
||||
0xfd
|
||||
]),
|
||||
null,
|
||||
null);
|
||||
if (receive.length > 0) {
|
||||
receive.forEach((data) {
|
||||
if (data.length != 17) {
|
||||
return;
|
||||
}
|
||||
bool r = true;
|
||||
for (var i = 0; i < head.length; i++) {
|
||||
if (head[i] != data[i]) {
|
||||
r = false;
|
||||
}
|
||||
}
|
||||
if (r == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindArr[1] = ble.ab2str(data.sublist(8, 14)).toUpperCase();
|
||||
print("$bindArr");
|
||||
timer.cancel();
|
||||
deviceProp.receiveLogArr.remove(fun);
|
||||
blueteethBindController.model.deviceName =
|
||||
deviceProp.connectDevice?.advName;
|
||||
ble.disconnect(deviceProp);
|
||||
toFindJunhe();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'fail': (e) {
|
||||
print(e);
|
||||
if (time > 0) {
|
||||
connectToDevice(device, time: time - 1);
|
||||
} else {
|
||||
currentMsg = "蓝牙无法连接上设备";
|
||||
failSelectDialog(title: currentMsg);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
isBind() {
|
||||
return !(blueteethBindController.model.bindArr[1]?.length == 12);
|
||||
}
|
||||
|
||||
failSelectDialog({String title = ""}) {
|
||||
LoadingDialog.hide();
|
||||
setState(() {});
|
||||
showCustomConfirmAndCancelDialog(
|
||||
context, title == "" ? (isBind() ? "绑定失败" : "连接失败") : title,
|
||||
confirmName: "重试", cancelName: "返回")
|
||||
.then((d) {
|
||||
if (d == "confirm") {
|
||||
if (connectDeviceCurrent != null) {
|
||||
ble.bleParse();
|
||||
ble.start((List d) {
|
||||
setState(() {
|
||||
bleDevice = d;
|
||||
});
|
||||
}, bleOnCall: () {
|
||||
LoadingDialog.show("连接中...\n靠近设备2米内",
|
||||
icon:
|
||||
isBind() ? LoadingDialogIcon.ble : LoadingDialogIcon.wifi);
|
||||
setState(() {
|
||||
currentMsg = "连接设备中...";
|
||||
});
|
||||
connectToDevice(connectDeviceCurrent);
|
||||
});
|
||||
} else {
|
||||
bleExec();
|
||||
}
|
||||
} else if (d == "cancel") {
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bleExec() {
|
||||
ble.bleParse();
|
||||
connectTimer?.cancel();
|
||||
int index = 0;
|
||||
bool isCloseLoadingDialog = false;
|
||||
isFind = false;
|
||||
blueteethBindController.model.bindArr = bindArrBackup;
|
||||
bindArr = ["", "", ""];
|
||||
ble.start((List d) {
|
||||
setState(() {
|
||||
bleDevice = d;
|
||||
});
|
||||
if (isBind()) {
|
||||
if (isCloseLoadingDialog == false &&
|
||||
bleDevice.indexWhere((item) {
|
||||
if (widget.tid == 1) {
|
||||
return ble.isQuanShiDevice(item["name"]);
|
||||
} else {
|
||||
return ble.isMHTSWES(item["name"]);
|
||||
}
|
||||
}) !=
|
||||
-1) {
|
||||
isCloseLoadingDialog = true;
|
||||
LoadingDialog.hide();
|
||||
}
|
||||
}
|
||||
}, bleOnCall: () {
|
||||
if (isBind()) {
|
||||
LoadingDialog.show("搜索蓝牙设备中...\n请打开蓝牙开关、定位开关\n与设备距离在2米内",
|
||||
icon: isBind() ? LoadingDialogIcon.ble : LoadingDialogIcon.wifi);
|
||||
Timer.periodic(const Duration(seconds: 1), (t) {
|
||||
if (t.tick > 15) {
|
||||
t.cancel();
|
||||
isCloseLoadingDialog = true;
|
||||
LoadingDialog.hide();
|
||||
showCustomConfirmAndCancelDialog(context, "未发现设备",
|
||||
confirmName: "重试", cancelName: "返回")
|
||||
.then((d) {
|
||||
if (d == "confirm") {
|
||||
bleExec();
|
||||
} else if (d == "cancel") {
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (isCloseLoadingDialog == true) {
|
||||
t.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
LoadingDialog.show(
|
||||
"${isBind() ? "绑定中...\n与设备距离在2米内" : "连接中...\n请打开蓝牙开关、定位开关\n与设备距离在2米内"}",
|
||||
icon: isBind() ? LoadingDialogIcon.ble : LoadingDialogIcon.wifi);
|
||||
connectTimer = Timer.periodic(const Duration(seconds: 1), (t) {
|
||||
index++;
|
||||
if (index > 15) {
|
||||
connectTimer = null;
|
||||
t.cancel();
|
||||
failSelectDialog();
|
||||
}
|
||||
var d = bleDevice;
|
||||
if (d != null && d.length > 0) {
|
||||
if (isBind()) {
|
||||
var deviceble = d.firstWhere((item) {
|
||||
bool isFF = false;
|
||||
if (widget.tid == 1) {
|
||||
isFF = ble.isQuanShiDevice(item["name"]);
|
||||
} else {
|
||||
isFF = ble.isMHTSWES(item["name"]);
|
||||
}
|
||||
if (isFF) {
|
||||
isFF = globalController.model.deviceList.indexWhere(
|
||||
(d) => d["mac"] == item["adData"]["deviceId"]) ==
|
||||
-1
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
return isFF;
|
||||
}, orElse: () => null);
|
||||
if (!isFind && deviceble != null) {
|
||||
print("quanshidevice");
|
||||
isFind = true;
|
||||
setState(() {
|
||||
currentMsg = "连接设备中...";
|
||||
});
|
||||
t.cancel();
|
||||
connectToDevice(deviceble["device"]);
|
||||
bindArr[0] = deviceble["adData"]["deviceId"];
|
||||
}
|
||||
} else {
|
||||
var deviceble = d.firstWhere(
|
||||
(item) =>
|
||||
item["adData"]["deviceId"] ==
|
||||
blueteethBindController.model.bindArr[1],
|
||||
orElse: () => null);
|
||||
if (!isFind && deviceble != null) {
|
||||
print("junhedevice");
|
||||
isFind = true;
|
||||
t.cancel();
|
||||
setState(() {
|
||||
currentMsg = "连接设备中...";
|
||||
});
|
||||
connectToDevice(deviceble["device"]);
|
||||
bindArr[1] = deviceble["adData"]["deviceId"];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
_stopScanning(); // 停止扫描
|
||||
_scanSubscription?.cancel(); // 取消扫描订阅
|
||||
connectTimer?.cancel(); // 取消连接定时器
|
||||
blueteethBindController.stopStatusPolling(); // 停止状态轮询
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -679,7 +307,7 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 30.rpx, 0, 30.rpx),
|
||||
child: Text(
|
||||
'蓝牙绑定.扫描蓝牙设备中…'.tr,
|
||||
'蓝牙绑定.扫描'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
@@ -917,42 +545,48 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(19.rpx, 0, 0, 0),
|
||||
child: Text(
|
||||
'匹配出的外围设备(${blueteethBindController.model.devicelist!.length})',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
child: Obx(() {
|
||||
return Text(
|
||||
'匹配出的外围设备(${blueteethBindController.model.betDevicelist!.length})',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
...blueteethBindController.model.blelist!
|
||||
.map((device) =>
|
||||
SingleBlueteethDeviceCompoentWidget(
|
||||
// device: device,
|
||||
bleDevice: device,
|
||||
))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 30.rpx))
|
||||
.addToEnd(SizedBox(height: 30.rpx)),
|
||||
],
|
||||
if (blueteethBindController
|
||||
.model.betDevicelist!.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
...blueteethBindController.model.blelist!
|
||||
.map((device) =>
|
||||
SingleBlueteethDeviceCompoentWidget(
|
||||
// device: device,
|
||||
bleDevice: device,
|
||||
))
|
||||
.toList()
|
||||
.divide(SizedBox(height: 30.rpx))
|
||||
.addToEnd(SizedBox(height: 30.rpx)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
}),
|
||||
].divide(SizedBox(height: 30.rpx)),
|
||||
),
|
||||
@@ -979,38 +613,6 @@ class _EPageState extends State<BlueteethDevicePage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
toFindJunhe() {
|
||||
bool isSuccess = false;
|
||||
int i = 0;
|
||||
Timer.periodic(const Duration(seconds: 1), (t) async {
|
||||
i++;
|
||||
if (isSuccess) {
|
||||
return;
|
||||
}
|
||||
if (i > 8) {
|
||||
if (!isSuccess) {
|
||||
currentMsg = "错误:未找到关联设备";
|
||||
failSelectDialog(title: "绑定失败:未找到关联设备");
|
||||
}
|
||||
t.cancel();
|
||||
return;
|
||||
}
|
||||
bleDevice.forEach((item) {
|
||||
if (isSuccess) {
|
||||
return;
|
||||
}
|
||||
if (item['adData']['deviceId'] == bindArr[1]) {
|
||||
isSuccess = true;
|
||||
t.cancel();
|
||||
setState(() {
|
||||
currentMsg = "寻找关联设备中...";
|
||||
});
|
||||
connectToDevice(item["device"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
BleDeviceData parseBleData(List<int> data) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class _FancyCircleCheckboxState extends State<FancyCircleCheckbox>
|
||||
child: ScaleTransition(
|
||||
scale: _scaleAnimation,
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(8.rpx),
|
||||
margin: EdgeInsets.all(6.rpx),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: widget.fillColor,
|
||||
|
||||
@@ -41,7 +41,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
deviceData.rssi = widget.bleDevice.rssi;
|
||||
deviceData.mac = deviceData.deviceId.replaceAll(':', '');
|
||||
BleDeviceData device = deviceData;
|
||||
device = blueteethBindController.model.devicelist!.firstWhere(
|
||||
device = blueteethBindController.model.betDevicelist!.firstWhere(
|
||||
(d) => d.mac == device.mac,
|
||||
orElse: () => device,
|
||||
);
|
||||
@@ -64,15 +64,12 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
onConfirm: () async {
|
||||
ApiResponse response =
|
||||
await blueteethBindController.bindDeviceAndMAC(device);
|
||||
TopSlideNotification.show(context, text: response.msg!);
|
||||
if (response.code == HttpStatusCodes.ok) {
|
||||
showLoadingDialog(context); // 显示 loading
|
||||
BLEDevice bledevice =
|
||||
BLEDevice(device: widget.bleDevice.device);
|
||||
var res1 = bledevice.isConnected;
|
||||
print("res1: $res1");
|
||||
THapp bledevice = THapp(device: widget.bleDevice.device);
|
||||
await bledevice.device.connect();
|
||||
var res2 = bledevice.isConnected;
|
||||
print("res2: $res2");
|
||||
if (res2) {
|
||||
Navigator.pop(context);
|
||||
TopSlideNotification.show(
|
||||
@@ -94,7 +91,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
} else {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "蓝牙绑定.连接异常".tr,
|
||||
text: response.msg ?? "蓝牙绑定.连接异常".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
@@ -104,6 +101,7 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
// 执行取消后的处理逻辑
|
||||
},
|
||||
);
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
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:loading_indicator/loading_indicator.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/FrostedDialog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/model/BleDeviceData.dart';
|
||||
@@ -248,7 +251,7 @@ void showHaveBindDialog(BuildContext context) {
|
||||
);
|
||||
}
|
||||
|
||||
void showLoadingDialog(BuildContext context) {
|
||||
void showLoadingDialog(BuildContext context, {String? title}) {
|
||||
ThemeController themeController = Get.find();
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -310,7 +313,7 @@ void showLoadingDialog(BuildContext context) {
|
||||
child: RichText(
|
||||
text: TextSpan(children: [
|
||||
TextSpan(
|
||||
text: "连接中...".tr,
|
||||
text: title ?? "连接中...".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
@@ -433,6 +436,30 @@ void showConfirmDialog(
|
||||
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(
|
||||
@@ -457,9 +484,10 @@ void showConfirmDialog(
|
||||
children: [
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
onTap: () async {
|
||||
onConfirm();
|
||||
// await Future.delayed(Duration(milliseconds: 300));
|
||||
Get.back();
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
@@ -542,3 +570,141 @@ void showConfirmDialog(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showWifiDialog(
|
||||
BuildContext context,
|
||||
Widget widget,
|
||||
String title, {
|
||||
required VoidCallback onConfirm,
|
||||
}) {
|
||||
ThemeController themeController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: Colors.black.withOpacity(0.5), // 背景模糊色
|
||||
builder: (BuildContext context) {
|
||||
return FrostedDialog(
|
||||
blurSigma: 3.0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc17,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
),
|
||||
padding: EdgeInsetsDirectional.fromSTEB(64.rpx, 0, 64.rpx, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.656,
|
||||
),
|
||||
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, 40.rpx, 0, 0),
|
||||
child: Text(
|
||||
title,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
widget,
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 58.rpx, 0, 60.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CustomCard(
|
||||
borderRadius: AppConstants().button_container_radius,
|
||||
onTap: () {
|
||||
if (blueteethBindController.model.wifiPass == null ||
|
||||
blueteethBindController.model.wifiPass!.isEmpty) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "wifi页.密码为空".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
} else {
|
||||
Get.back();
|
||||
onConfirm();
|
||||
}
|
||||
},
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.115,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"蓝牙绑定.连接".tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 70.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
421
lib/pages/device_bind/device_share_page.dart
Normal file
421
lib/pages/device_bind/device_share_page.dart
Normal file
@@ -0,0 +1,421 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.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';
|
||||
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/model/api_response.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/FancyCircleCheckbox.dart';
|
||||
|
||||
class DeviceSharePage extends StatefulWidget {
|
||||
var device;
|
||||
DeviceSharePage({super.key, required this.device});
|
||||
|
||||
@override
|
||||
State<DeviceSharePage> createState() => _DeviceSharePageState();
|
||||
}
|
||||
|
||||
class _DeviceSharePageState extends State<DeviceSharePage> {
|
||||
DeviceShareController deviceShareController = Get.find();
|
||||
@override
|
||||
void initState() {
|
||||
deviceShareController.msg = "".obs;
|
||||
deviceShareController.code = 0.obs;
|
||||
deviceShareController.account = "".obs;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var device = widget.device;
|
||||
RxBool flag1 = true.obs;
|
||||
RxBool flag2 = false.obs;
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
titleSpacing: 0,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'设备分享'.tr,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtom,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(47.rpx, 0, 47.rpx, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 28.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
'要分享的设备'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 62.rpx, 0, 62.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() => FancyCircleCheckbox(
|
||||
borderColor:
|
||||
themeController.currentColor.sc3,
|
||||
fillColor:
|
||||
themeController.currentColor.sc2,
|
||||
value: flag1.value,
|
||||
onChanged: (value) {
|
||||
flag1.value = !flag1.value;
|
||||
deviceShareController.updateAll();
|
||||
},
|
||||
)),
|
||||
Text(
|
||||
'主设备'.tr +
|
||||
"${device['person']?['name'] == null ? '未命名'.tr : device['person']['name']}",
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color:
|
||||
themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 20.rpx)),
|
||||
),
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Obx(() => FancyCircleCheckbox(
|
||||
// borderColor:
|
||||
// themeController.currentColor.sc3,
|
||||
// fillColor:
|
||||
// themeController.currentColor.sc2,
|
||||
// value: true,
|
||||
// onChanged: (value) {},
|
||||
// )),
|
||||
// Text(
|
||||
// '主设备:蓝盈盈(A9876451)',
|
||||
// style: FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: 26.rpx,
|
||||
// letterSpacing: 0.0,
|
||||
// color:
|
||||
// themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(width: 20.rpx)),
|
||||
// ),
|
||||
].divide(SizedBox(height: 64.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 58.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
height: 100.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(50.rpx),
|
||||
border: Border.all(
|
||||
color: Color(0xFFF3EDED),
|
||||
),
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: TextFormField(
|
||||
// controller: _model.textController1,
|
||||
// focusNode: _model.textFieldFocusNode1,
|
||||
initialValue: deviceShareController.account.value,
|
||||
onChanged: (Value) {
|
||||
deviceShareController.account.value = Value;
|
||||
},
|
||||
autofocus: false,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.transparent,
|
||||
isDense: true,
|
||||
labelStyle: FlutterFlowTheme.of(context)
|
||||
.labelMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
hintText: '请输入对方手机号或邮箱'.tr,
|
||||
hintStyle: FlutterFlowTheme.of(context)
|
||||
.labelMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
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: true,
|
||||
),
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
cursorColor:
|
||||
FlutterFlowTheme.of(context).primaryText,
|
||||
// validator: _model.textController1Validator
|
||||
// .asValidator(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 15.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 30.rpx,
|
||||
),
|
||||
child: deviceShareController.code != 0
|
||||
? Align(
|
||||
alignment: AlignmentDirectional(0, 0),
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text:
|
||||
'${deviceShareController.code == 1 ? "邀请成功".tr : "邀请失败".tr}',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: deviceShareController
|
||||
.code ==
|
||||
1
|
||||
? themeController
|
||||
.currentColor.sc2
|
||||
: themeController
|
||||
.currentColor.sc9,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
'${deviceShareController.msg}',
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc9,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
),
|
||||
);
|
||||
}),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 58.rpx, 0, 0),
|
||||
child: CustomCard(
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () async {
|
||||
ApiResponse apiResponse =
|
||||
await deviceShareController
|
||||
.shareDevice(device['mac']);
|
||||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(context,
|
||||
text: apiResponse.msg!);
|
||||
} else {
|
||||
TopSlideNotification.show(context,
|
||||
text: apiResponse.msg!,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
},
|
||||
colors: [
|
||||
// 渐变色
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.214,
|
||||
height: MediaQuery.sizeOf(context).height * 0.037,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 160.rpx,
|
||||
minHeight: 60.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'发送邀请'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize, // 自定义字体大小
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 379.rpx, 0, 0),
|
||||
child: CustomCard(
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () {
|
||||
TopSlideNotification.show(context,
|
||||
text: "待开发功能".tr);
|
||||
},
|
||||
colors: [
|
||||
// 渐变色
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 500.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'微信好友一键分享'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize, // 自定义字体大小
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,21 @@ 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/color/app_uri_status.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';
|
||||
import 'package:vbvs_app/component/tool/FrostedDialog.dart';
|
||||
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_type_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
|
||||
class DeviceTypePage extends StatefulWidget {
|
||||
int type = 0;//0绑定设备 1.查询我的设备
|
||||
DeviceTypePage({super.key,this.type = 0});
|
||||
int type = 0; //0绑定设备 1.查询我的设备
|
||||
DeviceTypePage({super.key, this.type = 0});
|
||||
|
||||
@override
|
||||
State<DeviceTypePage> createState() => _EPageState();
|
||||
@@ -25,10 +28,20 @@ class _EPageState extends State<DeviceTypePage> {
|
||||
UserInfoController userInfoController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
DeviceTypeController deviceTypeController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
deviceTypeController.getDeviceType().then((response) {
|
||||
if (response.code != HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
Get.context!,
|
||||
text: response.msg ?? "服务器.失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
});
|
||||
// 延迟到 build 完成后执行弹窗逻辑
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (blueteethBindController.model.read == 1 && widget.type == 0) {
|
||||
@@ -349,28 +362,29 @@ class _EPageState extends State<DeviceTypePage> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
_buildDeviceCard(
|
||||
context,
|
||||
title: '设备类型.体征监测设备'.tr,
|
||||
imageUrl: 'assets/img/device.png',
|
||||
type: '1',
|
||||
),
|
||||
_buildDeviceCard(
|
||||
context,
|
||||
title: '设备类型.智能床/床垫'.tr,
|
||||
imageUrl: 'assets/img/bed.png',
|
||||
type: '2',
|
||||
),
|
||||
_buildDeviceCard(
|
||||
context,
|
||||
title: '设备类型.摄像头'.tr,
|
||||
imageUrl: 'assets/img/camera.png',
|
||||
type: '3',
|
||||
),
|
||||
]
|
||||
.divide(SizedBox(height: 26.rpx))
|
||||
.addToStart(SizedBox(height: 26.rpx))
|
||||
.addToEnd(SizedBox(height: 26.rpx)),
|
||||
// 使用 Obx 来监听 deviceTypeList 的变化
|
||||
Obx(() {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(height: 26.rpx), // 开始的间隔
|
||||
...deviceTypeController.deviceTypeList.value
|
||||
.map((device) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 26.rpx), // 添加每个设备之间的间隔
|
||||
child: _buildDeviceCard(
|
||||
context,
|
||||
title: device['name'], // 这里假设 device 是一个 Map
|
||||
imageUrl: device['image'],
|
||||
type: device['type'],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
SizedBox(height: 26.rpx), // 结束的间隔
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -382,16 +396,20 @@ class _EPageState extends State<DeviceTypePage> {
|
||||
}
|
||||
|
||||
Widget _buildDeviceCard(BuildContext context,
|
||||
{required String title, required String imageUrl, required String type}) {
|
||||
{required String title, required String imageUrl, required double type}) {
|
||||
return CustomCard(
|
||||
borderRadius: 20.rpx, // 圆角大小
|
||||
onTap: () {
|
||||
if (type != null) {
|
||||
if (type == '1') {
|
||||
if (type == 1) {
|
||||
Get.toNamed("/blueteethDevice");
|
||||
}
|
||||
if (type == '2') {
|
||||
Get.toNamed("/wifiPage");
|
||||
if (type == 2) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "待开发.提示".tr,
|
||||
textColor: themeController.currentColor.sc2,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -418,8 +436,14 @@ class _EPageState extends State<DeviceTypePage> {
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.rpx),
|
||||
child: Image.asset(
|
||||
// child: Image.asset(
|
||||
// imageUrl,
|
||||
// width: 212.rpx,
|
||||
// height: 168.rpx,
|
||||
// ),
|
||||
child: Image.network(
|
||||
imageUrl,
|
||||
// fit: BoxFit.cover,
|
||||
width: 212.rpx,
|
||||
height: 168.rpx,
|
||||
),
|
||||
|
||||
192
lib/pages/device_bind/device_type_list.dart
Normal file
192
lib/pages/device_bind/device_type_list.dart
Normal file
@@ -0,0 +1,192 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.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';
|
||||
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_type_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
|
||||
class DeviceTypeListPage extends StatefulWidget {
|
||||
DeviceTypeListPage({super.key});
|
||||
|
||||
@override
|
||||
State<DeviceTypeListPage> createState() => _DeviceTypeListPageState();
|
||||
}
|
||||
|
||||
class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
|
||||
GlobalController globalController = Get.find();
|
||||
UserInfoController userInfoController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
DeviceTypeController deviceTypeController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
deviceTypeController.getDeviceType().then((response) {
|
||||
if (response.code != HttpStatusCodes.ok) {
|
||||
TopSlideNotification.show(
|
||||
Get.context!,
|
||||
text: response.msg ?? "服务器.失败".tr,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'), // 本地图片
|
||||
fit: BoxFit.fill, // 填满整个 Container
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent, // 加上这一行
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
// backgroundColor: Colors.transparent,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
|
||||
titleSpacing: 0,
|
||||
// leading: returnIconButtom,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
/// 居中标题
|
||||
Text(
|
||||
'设备列表',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
|
||||
/// 左边返回按钮
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtom,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
// 使用 Obx 来监听 deviceTypeList 的变化
|
||||
Obx(() {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(height: 26.rpx), // 开始的间隔
|
||||
...deviceTypeController.deviceTypeList.value
|
||||
.map((device) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 26.rpx), // 添加每个设备之间的间隔
|
||||
child: _buildDeviceCard(
|
||||
context,
|
||||
title: device['name'], // 这里假设 device 是一个 Map
|
||||
imageUrl: device['image'],
|
||||
type: device['type'],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
SizedBox(height: 26.rpx), // 结束的间隔
|
||||
],
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDeviceCard(BuildContext context,
|
||||
{required String title, required String imageUrl, required double type}) {
|
||||
return CustomCard(
|
||||
borderRadius: 20.rpx, // 圆角大小
|
||||
onTap: () {
|
||||
if (type != null) {
|
||||
if (type == 1) {
|
||||
Get.toNamed("/bodyDevice");
|
||||
}
|
||||
if (type == 2) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "待开发.提示".tr,
|
||||
textColor: themeController.currentColor.sc2,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
colors: [themeController.currentColor.sc17], // 背景色
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: MediaQuery.sizeOf(context).height * 0.135,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 220.rpx,
|
||||
),
|
||||
padding: EdgeInsetsDirectional.fromSTEB(77.rpx, 0, 21.rpx, 0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
color: const Color(0xFFC2CED7),
|
||||
fontSize: 30.rpx,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.rpx),
|
||||
// child: Image.asset(
|
||||
// imageUrl,
|
||||
// width: 212.rpx,
|
||||
// height: 168.rpx,
|
||||
// ),
|
||||
child: Image.network(
|
||||
imageUrl,
|
||||
// fit: BoxFit.cover,
|
||||
width: 212.rpx,
|
||||
height: 168.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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