更新登录对接

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

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