更新登录对接

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

@@ -8,6 +8,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
class BindDeviceSuccess extends StatefulWidget {
@@ -21,6 +22,7 @@ class _EPageState extends State<BindDeviceSuccess> {
GlobalController globalController = Get.find();
UserInfoController userInfoController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
ThemeController themeController = Get.find();
@override
void initState() {
@@ -42,14 +44,14 @@ class _EPageState extends State<BindDeviceSuccess> {
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(
@@ -60,7 +62,7 @@ class _EPageState extends State<BindDeviceSuccess> {
'绑定成功.标题'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: Colors.white,
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
@@ -98,7 +100,7 @@ class _EPageState extends State<BindDeviceSuccess> {
child: SvgPicture.asset(
'assets/img/icon/tick.svg',
fit: BoxFit.cover,
color: Colors.white,
color: themeController.currentColor.sc3,
),
),
),
@@ -118,7 +120,7 @@ class _EPageState extends State<BindDeviceSuccess> {
fontFamily: 'Inter',
fontSize: 48.rpx,
letterSpacing: 0.0,
color: Colors.white,
color: themeController.currentColor.sc3,
),
),
),
@@ -140,7 +142,7 @@ class _EPageState extends State<BindDeviceSuccess> {
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: Colors.white,
color: themeController.currentColor.sc3,
),
),
),
@@ -162,7 +164,7 @@ class _EPageState extends State<BindDeviceSuccess> {
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: Colors.white,
color: themeController.currentColor.sc3,
),
),
),
@@ -180,9 +182,9 @@ class _EPageState extends State<BindDeviceSuccess> {
},
colors: [
// 渐变色
stringToColor("45D989"), // 左侧渐变色
stringToColor("00C1AA"), // 右侧渐变色
],
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: MediaQuery.sizeOf(context).width * 0.66,
height: MediaQuery.sizeOf(context).height * 0.055,
@@ -198,14 +200,14 @@ class _EPageState extends State<BindDeviceSuccess> {
'assets/img/icon/share.svg',
width: 25.rpx,
height: 25.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: Colors.white, // 设置图标颜色为白色
color: themeController.currentColor.sc3,
),
Text(
'绑定成功.立即分享'.tr,
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
color: Colors.white, // 文字颜色
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize: AppConstants()
.normal_text_fontSize, // 自定义字体大小
@@ -223,13 +225,13 @@ class _EPageState extends State<BindDeviceSuccess> {
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
onTap: () {
Get.offAllNamed("/mianPageBottomChange");
},
colors: [
// 渐变色
stringToColor("45D989"), // 左侧渐变色
stringToColor("00C1AA"), // 右侧渐变色
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
@@ -248,7 +250,7 @@ class _EPageState extends State<BindDeviceSuccess> {
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
color: Colors.white, // 文字颜色
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize: AppConstants()
.normal_text_fontSize, // 自定义字体大小
@@ -282,8 +284,8 @@ class _EPageState extends State<BindDeviceSuccess> {
}
}
},
// colors: [Colors.white.withOpacity(0.06)], // 背景色
colors: [stringToColor("#242835")], // 背景色
colors: [themeController.currentColor.sc17], // 背景色
child: Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.135,

View File

@@ -1,6 +1,7 @@
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';
@@ -10,6 +11,7 @@ import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.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/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';
@@ -28,6 +30,7 @@ class _EPageState extends State<BlueteethDevicePage> {
GlobalController globalController = Get.find();
UserInfoController userInfoController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
ThemeController themeController = Get.find();
late FlutterBluePlus flutterBlue; // 声明 flutterBlue 实例
List<ScanResult> scanResults = []; // 存储扫描到的设备
bool isScanning = false; // 扫描状态控制
@@ -48,6 +51,7 @@ class _EPageState extends State<BlueteethDevicePage> {
super.initState();
flutterBlue = FlutterBluePlus(); // 初始化flutterBlue实例
_checkBluetoothPermission(); // 检查蓝牙权限
Get.find<BlueteethBindController>().startStatusPolling();
}
// 检查蓝牙权限
@@ -125,29 +129,6 @@ class _EPageState extends State<BlueteethDevicePage> {
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
// FlutterBluePlus.scanResults.listen((results) {
// // 使用 controller 中设定的最小信号强度过滤
// final signalThreshold = blueteethBindController.model.singal!;
// final filteredResults = results
// .where((r) =>
// r.rssi > signalThreshold &&
// r.advertisementData.localName == "AITH-V2")
// .toList();
// setState(() {
// scanResults = filteredResults;
// print("过滤后设备数量:${filteredResults.length}");
// blueteethBindController.model.devicelist = filteredResults;
// blueteethBindController.updateAll();
// if (filteredResults.isNotEmpty) {
// for (var r in filteredResults) {
// print("设备名: ${r.device.name}, RSSI: ${r.rssi}");
// }
// } else {
// print("没有找到符合条件的设备");
// }
// });
// });
FlutterBluePlus.scanResults.listen((results) {
final signalThreshold = blueteethBindController.model.singal!;
final filteredResults = results
@@ -173,24 +154,35 @@ class _EPageState extends State<BlueteethDevicePage> {
}
}
// 使用一个临时变量 lastDeviceList 来比较是否有变化
setState(() {
scanResults = filteredResults;
bool hasChanges = false;
// 存入 controller 中
blueteethBindController.model.blelist = filteredResults;
blueteethBindController.model.devicelist = parsedDeviceList;
blueteethBindController.updateDeviceStatus();
blueteethBindController.updateAll();
// 如果 devicelist 长度不同或内容有差异,认为有变化
if (blueteethBindController.model.devicelist?.length !=
parsedDeviceList.length) {
hasChanges = true;
} else {
// 深度比较每个设备的属性(比如 mac, rssi
for (int i = 0;
i < blueteethBindController.model.devicelist!.length;
i++) {
if (blueteethBindController.model.devicelist![i].mac !=
parsedDeviceList[i].mac ||
blueteethBindController.model.devicelist![i].rssi !=
parsedDeviceList[i].rssi) {
hasChanges = true;
break;
}
}
}
// print("过滤并解析后设备数量:${parsedDeviceList.length}");
// for (var device in parsedDeviceList) {
// print(
// "设备: ${device.deviceId}, HR: ${device.ht}, BRE: ${device.bre}, Seq: ${device.fullSeq}");
// }
// if (parsedDeviceList.isEmpty) {
// print("没有符合条件的 BLE 广播数据");
// }
// 如果有变化,更新 devicelist 和 blelist
if (hasChanges) {
blueteethBindController.model.devicelist = parsedDeviceList;
blueteethBindController.model.blelist = filteredResults;
// blueteethBindController.updateDeviceStatus();
}
});
});
@@ -206,7 +198,7 @@ class _EPageState extends State<BlueteethDevicePage> {
}
}
// 定时每10秒进行一次扫描
// 定时每10秒进行一次扫描
void _startPeriodicScan() {
_timer = Timer.periodic(Duration(seconds: 10), (timer) {
if (!isScanning) {
@@ -637,8 +629,8 @@ class _EPageState extends State<BlueteethDevicePage> {
child: Scaffold(
backgroundColor: Colors.transparent, // 加上这一行
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.white),
backgroundColor: stringToColor("#242835"),
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
titleSpacing: 0,
title: Container(
@@ -651,7 +643,7 @@ class _EPageState extends State<BlueteethDevicePage> {
'蓝牙绑定.标题'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: Colors.white,
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
@@ -763,7 +755,7 @@ class _EPageState extends State<BlueteethDevicePage> {
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
color: themeController.currentColor.sc3,
borderRadius: BorderRadius.circular(20.rpx),
),
child: Padding(
@@ -776,7 +768,7 @@ class _EPageState extends State<BlueteethDevicePage> {
Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
@@ -788,7 +780,7 @@ class _EPageState extends State<BlueteethDevicePage> {
child: SvgPicture.asset(
'assets/img/icon/query.svg',
fit: BoxFit.cover,
color: Colors.black,
color: stringToColor("#333333"), //固定
),
),
),
@@ -861,10 +853,9 @@ class _EPageState extends State<BlueteethDevicePage> {
borderRadius:
BorderRadius.circular(8.rpx),
),
filled: true,
fillColor:
FlutterFlowTheme.of(context)
.secondaryBackground,
filled: false,
fillColor: themeController
.currentColor.sc22,
),
style: FlutterFlowTheme.of(context)
.bodyMedium
@@ -896,8 +887,7 @@ class _EPageState extends State<BlueteethDevicePage> {
height: 50.rpx,
child: VerticalDivider(
thickness: 2.rpx,
color: FlutterFlowTheme.of(context)
.alternate,
color: stringToColor("#333333"), //固定
),
),
Text(
@@ -908,6 +898,7 @@ class _EPageState extends State<BlueteethDevicePage> {
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: stringToColor("#333333"), //固定
),
),
].divide(SizedBox(width: 26.rpx)),
@@ -931,35 +922,38 @@ class _EPageState extends State<BlueteethDevicePage> {
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: Colors.white),
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
),
),
),
),
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)),
],
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)),
],
),
),
),
),
),
);
}),
].divide(SizedBox(height: 30.rpx)),
),
),

View File

@@ -2,15 +2,25 @@ import 'package:ef/base/widget/flutterflow/FlutterFlowTheme.dart';
import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/model/BleDeviceData.dart';
class DoubleBlueteethDeviceCompoentWidget extends StatefulWidget {
const DoubleBlueteethDeviceCompoentWidget({super.key});
final BleDeviceData masterDevice; // 主设备
final BleDeviceData? slaveDevice; // 从设备(可为空)
// 构造函数,接受参数
const DoubleBlueteethDeviceCompoentWidget({
super.key,
required this.masterDevice,
this.slaveDevice,
});
@override
State<DoubleBlueteethDeviceCompoentWidget> createState() =>
_DoubleBlueteethDeviceCompoentWidgetState();
}
class _DoubleBlueteethDeviceCompoentWidgetState
extends State<DoubleBlueteethDeviceCompoentWidget> {
@override

View File

@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
class FancyCircleCheckbox extends StatefulWidget {
final bool value;
@@ -59,8 +61,8 @@ class _FancyCircleCheckboxState extends State<FancyCircleCheckbox>
return GestureDetector(
onTap: () => widget.onChanged(!widget.value),
child: Container(
width: 24,
height: 24,
width: 32.rpx,
height: 32.rpx,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
@@ -73,7 +75,7 @@ class _FancyCircleCheckboxState extends State<FancyCircleCheckbox>
child: ScaleTransition(
scale: _scaleAnimation,
child: Container(
margin: EdgeInsets.all(5),
margin: EdgeInsets.all(8.rpx),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.fillColor,

View File

@@ -1,22 +1,25 @@
import 'package:ef/base/widget/flutterflow/FlutterFlowTheme.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
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/app_uri_status.dart';
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.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';
import 'package:vbvs_app/model/api_response.dart';
import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
class SingleBlueteethDeviceCompoentWidget extends StatefulWidget {
// final BleDeviceData device;
final bleDevice;
const SingleBlueteethDeviceCompoentWidget({
super.key,
// required this.device,
required this.bleDevice,
});
@@ -27,9 +30,10 @@ class SingleBlueteethDeviceCompoentWidget extends StatefulWidget {
class _SingleBlueteethDeviceCompoentWidgetState
extends State<SingleBlueteethDeviceCompoentWidget> {
ThemeController themeController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
@override
Widget build(BuildContext context) {
var bleDevice = widget.bleDevice;
List<int> rawData =
widget.bleDevice.advertisementData.manufacturerData[0xFFED]!;
BleDeviceData deviceData = parseBleData(rawData);
@@ -37,45 +41,80 @@ class _SingleBlueteethDeviceCompoentWidgetState
deviceData.rssi = widget.bleDevice.rssi;
deviceData.mac = deviceData.deviceId.replaceAll(':', '');
BleDeviceData device = deviceData;
device = blueteethBindController.model.devicelist!.firstWhere(
(d) => d.mac == device.mac,
orElse: () => device,
);
ThemeController themeController = Get.find();
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: Colors.white,
highlightColor: themeController.currentColor.sc21,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 36.rpx, 0, 52.rpx),
onTap: () async {
//todo 请求绑定
print(device.mac);
// try {
// await bleDevice.device.connect(autoConnect: false);
// List<BluetoothService> services =
// await bleDevice.device.discoverServices();
// BluetoothCharacteristic? wifiListChar;
// BluetoothCharacteristic? wifiSsidChar;
// BluetoothCharacteristic? wifiPasswordChar;
// BluetoothCharacteristic? startProvisionChar;
// for (BluetoothService service in services) {
// for (BluetoothCharacteristic c in service.characteristics) {
// if (c.uuid.toString() == 'YOUR_WIFI_LIST_UUID') {
// wifiListChar = c;
// } else if (c.uuid.toString() == 'YOUR_WIFI_SSID_UUID') {
// wifiSsidChar = c;
// } else if (c.uuid.toString() == 'YOUR_WIFI_PWD_UUID') {
// wifiPasswordChar = c;
// } else if (c.uuid.toString() == 'YOUR_WIFI_START_UUID') {
// startProvisionChar = c;
// }
// }
// }
// } catch (e) {
// print("蓝牙连接失败");
// }
//
// Get.toNamed('/wifiPage', arguments: bleDevice.device);
showBindDoubleDialog(context,[]);
// showHaveBindDialog(context);
try {
if (device.bind == true) {
showHaveBindDialog(context);
// showBindDoubleDialog(context, []);
} else {
showConfirmDialog(
context,
Container(),
'蓝牙绑定.确定绑定提示'.tr,
onConfirm: () async {
ApiResponse response =
await blueteethBindController.bindDeviceAndMAC(device);
if (response.code == HttpStatusCodes.ok) {
showLoadingDialog(context); // 显示 loading
BLEDevice bledevice =
BLEDevice(device: widget.bleDevice.device);
var res1 = bledevice.isConnected;
print("res1: $res1");
await bledevice.device.connect();
var res2 = bledevice.isConnected;
print("res2: $res2");
if (res2) {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接成功".tr,
textColor: themeController.currentColor.sc2,
);
blueteethBindController.currentDevice = bledevice;
// Get.toNamed("/wifiPage", arguments: {bledevice});
Get.toNamed("/wifiPage");
} else {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接失败".tr,
textColor: themeController.currentColor.sc9,
);
}
} else {
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
}
},
onCancel: () {
print('用户点击了取消');
// 执行取消后的处理逻辑
},
);
}
} catch (e) {
Navigator.pop(context);
TopSlideNotification.show(
context,
text: "蓝牙绑定.连接异常".tr,
textColor: themeController.currentColor.sc9,
);
edm.EasyDartModule.logger.info("蓝牙绑定.连接异常: $e");
DailyLogUtils.writeLog("蓝牙绑定.连接异常: $e");
}
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -156,10 +195,12 @@ class _SingleBlueteethDeviceCompoentWidgetState
),
),
Text(
device.status == 1 ? '蓝牙绑定.可绑定'.tr : '蓝牙绑定.已被绑定'.tr,
device.bind == false ? '蓝牙绑定.可绑定'.tr : '蓝牙绑定.已被绑定'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: const Color(0xFF1AD2B5),
color: device.bind == false
? const Color(0xFF1AD2B5)
: themeController.currentColor.sc9,
fontSize: 26.rpx,
letterSpacing: 0.0,
),

View File

@@ -1,8 +1,7 @@
import 'dart:ui';
import 'package:ef/ef.dart';
import 'package:flutter/material.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/CustomCard.dart';
@@ -45,7 +44,8 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
Align(
alignment: AlignmentDirectional(0, 0),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 0),
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 93.rpx, 0, 0),
child: Text(
'蓝牙绑定.双人版绑定标题'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
@@ -74,7 +74,7 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
// 主设备
_buildCheckboxRow(
context,
title: '蓝牙绑定.主设备'.tr,
title: '蓝牙绑定.主设备'.tr + "asasasasasas(已被绑定)",
value: () => blueteethBindController.model.deviceIndex1!,
onChanged: (v) {
if (!blueteethBindController.model.deviceIndex1!) {
@@ -130,8 +130,6 @@ void showBindDoubleDialog(BuildContext context, List<BleDeviceData> devices) {
);
}
void showHaveBindDialog(BuildContext context) {
ThemeController themeController = Get.find();
@@ -187,7 +185,7 @@ void showHaveBindDialog(BuildContext context) {
TextSpan(
text: "蓝牙绑定.无法绑定2".tr,
style: TextStyle(
color: themeController.currentColor.sc10,
color: themeController.currentColor.sc8,
fontSize: AppConstants().normal_text_fontSize,
),
),
@@ -228,10 +226,9 @@ void showHaveBindDialog(BuildContext context) {
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
color: Colors.white,
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
fontSize: AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
@@ -251,6 +248,85 @@ void showHaveBindDialog(BuildContext context) {
);
}
void showLoadingDialog(BuildContext context) {
ThemeController themeController = 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: Colors.transparent,
borderRadius: BorderRadius.circular(20.0),
),
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 0, 60.rpx, 0),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height * 0.656,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Align(
// alignment: AlignmentDirectional(0, 0),
// child: Padding(
// padding: EdgeInsetsDirectional.fromSTEB(
// 0.rpx, 93.rpx, 0.rpx, 0.rpx),
// 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.rpx, 93.rpx, 0.rpx, 0.rpx),
child: SizedBox(
width: 120.rpx,
height: 120.rpx,
child: LoadingIndicator(
indicatorType: Indicator.ballSpinFadeLoader,
colors: [
themeController.currentColor.sc3,
],
strokeWidth: 1,
backgroundColor: Colors.transparent,
pathBackgroundColor: themeController.currentColor.sc3),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 27.rpx, 0.rpx, 56.rpx),
child: RichText(
text: TextSpan(children: [
TextSpan(
text: "连接中...".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
]),
),
),
],
),
),
),
);
},
);
}
Widget _buildCheckboxRow(
BuildContext context, {
@@ -260,7 +336,7 @@ Widget _buildCheckboxRow(
}) {
ThemeController themeController = Get.find();
return Padding(
padding: EdgeInsetsDirectional.fromSTEB(60.rpx, 64.rpx, 0.rpx, 0.rpx),
padding: EdgeInsetsDirectional.fromSTEB(20.rpx, 64.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
@@ -270,14 +346,16 @@ Widget _buildCheckboxRow(
value: value(),
onChanged: onChanged,
)),
Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
letterSpacing: 0.0,
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
),
Expanded(
child: Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
letterSpacing: 0.0,
fontSize: AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3,
),
),
),
].divide(SizedBox(width: 21.rpx)),
),
@@ -311,7 +389,7 @@ Widget _buildActionButton(
Text(
text,
style: FlutterFlowTheme.of(context).bodyMedium.override(
color: Colors.white,
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize: AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
@@ -322,3 +400,145 @@ Widget _buildActionButton(
),
);
}
void showConfirmDialog(
BuildContext context,
Widget widget,
String title, {
required VoidCallback onConfirm,
required VoidCallback onCancel,
}) {
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: [
// 标题
Align(
alignment: AlignmentDirectional(0, 0),
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 93.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: () {
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)),
),
),
),
CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back();
onCancel();
},
colors: [
themeController.currentColor.sc1,
themeController.currentColor.sc2,
],
child: Container(
width: MediaQuery.sizeOf(context).width * 0.215,
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,
)),
),
),
],
),
),
),
);
},
);
}

View File

@@ -13,7 +13,8 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
class DeviceTypePage extends StatefulWidget {
const DeviceTypePage({super.key});
int type = 0;//0绑定设备 1.查询我的设备
DeviceTypePage({super.key,this.type = 0});
@override
State<DeviceTypePage> createState() => _EPageState();
@@ -30,7 +31,7 @@ class _EPageState extends State<DeviceTypePage> {
super.initState();
// 延迟到 build 完成后执行弹窗逻辑
WidgetsBinding.instance.addPostFrameCallback((_) {
if (blueteethBindController.model.read == 1) {
if (blueteethBindController.model.read == 1 && widget.type == 0) {
showDialog(
context: context,
barrierDismissible: false,
@@ -71,7 +72,7 @@ class _EPageState extends State<DeviceTypePage> {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
@@ -84,8 +85,7 @@ class _EPageState extends State<DeviceTypePage> {
child: SvgPicture.asset(
'assets/img/icon/sound.svg',
fit: BoxFit.fill,
color: themeController
.currentColor.sc8,
color: stringToColor("#ff9f66"),
),
),
),
@@ -97,17 +97,19 @@ class _EPageState extends State<DeviceTypePage> {
children: [
Text(
'绑定引导.说明标题'.tr,
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.normal_text_fontSize,
letterSpacing: 0.0,
fontWeight:
FontWeight.w500,
color: Colors.orange),
style:
FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.normal_text_fontSize,
letterSpacing: 0.0,
fontWeight:
FontWeight.w500,
color: stringToColor(
"#916d46"),
),
),
Text(
'绑定引导.说明正文'.tr,
@@ -119,6 +121,8 @@ class _EPageState extends State<DeviceTypePage> {
fontSize: AppConstants()
.normal_text_fontSize,
letterSpacing: 0.0,
color: stringToColor(
"#916d46"),
),
),
].divide(SizedBox(
@@ -223,10 +227,12 @@ class _EPageState extends State<DeviceTypePage> {
style: FlutterFlowTheme.of(context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: Colors.white),
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController
.currentColor.sc3,
),
),
].divide(SizedBox(width: 22.rpx)),
),
@@ -239,9 +245,8 @@ class _EPageState extends State<DeviceTypePage> {
Get.back(); // 关闭当前弹窗或页面
},
colors: [
//todo 颜色
stringToColor("45D989"),
stringToColor("00C1AA")
themeController.currentColor.sc1,
themeController.currentColor.sc2,
], // 单色背景也用渐变写法
child: Container(
@@ -300,14 +305,13 @@ class _EPageState extends State<DeviceTypePage> {
child: Scaffold(
backgroundColor: Colors.transparent, // 加上这一行
appBar: AppBar(
backgroundColor: stringToColor("#242835"),
backgroundColor: themeController.currentColor.sc17,
// backgroundColor: Colors.transparent,
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(
@@ -318,7 +322,7 @@ class _EPageState extends State<DeviceTypePage> {
'设备列表',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: Colors.white,
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
@@ -391,7 +395,7 @@ class _EPageState extends State<DeviceTypePage> {
}
}
},
colors: [stringToColor("#242835")], // 背景色
colors: [themeController.currentColor.sc17], // 背景色
child: Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.135,

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);
}