优化蓝牙逻辑,添加开锁成功弹窗
This commit is contained in:
parent
5f1e594de3
commit
264bab98ae
@ -90,7 +90,7 @@ class BlueManage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 调用连接
|
/// 调用发送数据
|
||||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack) async {
|
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack) async {
|
||||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
if(deviceConnectionState != DeviceConnectionState.connected){
|
||||||
_connect(deviceName, (state){
|
_connect(deviceName, (state){
|
||||||
|
|||||||
@ -257,7 +257,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 删除用户
|
// 删除用户
|
||||||
Future<void> deletUserAction() async {
|
Future<void> deletUserAction() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
showBlueConnetctToastTimer();
|
showBlueConnetctToastTimer((){
|
||||||
|
|
||||||
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
@ -293,7 +295,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 恢复出厂设置
|
// 恢复出厂设置
|
||||||
Future<void> factoryDataResetAction() async {
|
Future<void> factoryDataResetAction() async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
showBlueConnetctToastTimer();
|
showBlueConnetctToastTimer((){
|
||||||
|
|
||||||
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
@ -351,7 +355,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
// 设置支持功能(带参数)
|
// 设置支持功能(带参数)
|
||||||
Future<void> sendBurglarAlarm(int type) async {
|
Future<void> sendBurglarAlarm(int type) async {
|
||||||
showEasyLoading();
|
showEasyLoading();
|
||||||
showBlueConnetctToastTimer();
|
showBlueConnetctToastTimer((){
|
||||||
|
|
||||||
|
});
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||||
cancelBlueConnetctToastTimer();
|
cancelBlueConnetctToastTimer();
|
||||||
if (connectionState == DeviceConnectionState.connected) {
|
if (connectionState == DeviceConnectionState.connected) {
|
||||||
|
|||||||
@ -4,12 +4,16 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||||
import 'package:star_lock/blue/io_type.dart';
|
import 'package:star_lock/blue/io_type.dart';
|
||||||
import 'package:star_lock/tools/toast.dart';
|
import 'package:star_lock/tools/toast.dart';
|
||||||
|
|
||||||
|
import '../../../app_settings/app_colors.dart';
|
||||||
import '../../../blue/blue_manage.dart';
|
import '../../../blue/blue_manage.dart';
|
||||||
import '../../../blue/io_protocol/io_addUser.dart';
|
import '../../../blue/io_protocol/io_addUser.dart';
|
||||||
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
|
||||||
@ -72,16 +76,17 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
//成功
|
//成功
|
||||||
print("${reply.commandType}数据解析成功");
|
print("${reply.commandType}数据解析成功");
|
||||||
|
_showFullScreenOverlay(Get.context!);
|
||||||
|
|
||||||
// 电量
|
// 电量
|
||||||
int power = reply.data[7];
|
int power = reply.data[7];
|
||||||
state.electricQuantity.value = power;
|
state.electricQuantity.value = power;
|
||||||
|
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
getLockRecordLastUploadDataTime();
|
getLockRecordLastUploadDataTime();
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
state.animationController.reset();
|
// state.animationController.reset();
|
||||||
state.animationController.forward();
|
// state.animationController.forward();
|
||||||
// state.animationController.isCompleted;
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
@ -343,15 +348,66 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加用户(普通用户接收电子钥匙)
|
||||||
|
Future<void> addUserConnectBlue() async {
|
||||||
|
showBlueConnetctToastTimer(() {
|
||||||
|
state.openLockBtnState.value = 0;
|
||||||
|
// state.animationController.reset();
|
||||||
|
// state.animationController.forward();
|
||||||
|
});
|
||||||
|
|
||||||
|
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
||||||
|
if (deviceConnectionState == DeviceConnectionState.connected) {
|
||||||
|
// 私钥
|
||||||
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
|
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
|
var token = await Storage.getStringList(saveBlueToken);
|
||||||
|
List<int> getTokenList = [0, 0, 0, 0];
|
||||||
|
if (token != null) {
|
||||||
|
getTokenList = changeStringListToIntList(token);
|
||||||
|
}
|
||||||
|
print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
||||||
|
IoSenderManage.senderAddUser(
|
||||||
|
lockID: BlueManage().connectDeviceName,
|
||||||
|
authUserID: state.senderUserId.toString(),
|
||||||
|
keyID: state.keyInfos.value.keyId.toString(),
|
||||||
|
userID: await Storage.getUid(),
|
||||||
|
openMode: 1,
|
||||||
|
keyType: 0,
|
||||||
|
startDate: DateTime.now().millisecondsSinceEpoch,
|
||||||
|
expireDate: 0x11223344,
|
||||||
|
role: 0,
|
||||||
|
password: "123456",
|
||||||
|
needAuthor: 1,
|
||||||
|
publicKey: publicKeyDataList,
|
||||||
|
privateKey: getPrivateKeyList,
|
||||||
|
token: getTokenList);
|
||||||
|
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
|
if(state.ifCurrentScreen.value == true){
|
||||||
|
showBlueConnetctToast();
|
||||||
|
}
|
||||||
|
|
||||||
|
state.openLockBtnState.value = 0;
|
||||||
|
// state.animationController.reset();
|
||||||
|
// state.animationController.forward();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 点击开门事件
|
// 点击开门事件
|
||||||
Future<void> openDoorAction() async {
|
Future<void> openDoorAction() async {
|
||||||
showBlueConnetctToastTimer();
|
showBlueConnetctToastTimer(() {
|
||||||
|
state.openLockBtnState.value = 0;
|
||||||
|
// state.animationController.reset();
|
||||||
|
// state.animationController.forward();
|
||||||
|
});
|
||||||
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (DeviceConnectionState deviceConnectionState) async {
|
||||||
cancelBlueConnetctToastTimer();
|
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||||
state.connectState.value = 1;
|
|
||||||
state.openLockBtnState.value = 0;
|
|
||||||
|
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
@ -374,14 +430,14 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
privateKey: getPrivateKeyList,
|
privateKey: getPrivateKeyList,
|
||||||
);
|
);
|
||||||
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
}else if (deviceConnectionState == DeviceConnectionState.disconnected){
|
||||||
// if(state.lockState.value != 2){
|
cancelBlueConnetctToastTimer();
|
||||||
// // 2的状态是从已经连接上了 然后没有进行任何操作 锁板主动断开了 所以只需要改变开锁按钮状态不需要弹出toast
|
if(state.ifCurrentScreen.value == true){
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
// }
|
}
|
||||||
state.connectState.value = 0;
|
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
state.animationController.reset();
|
// state.animationController.reset();
|
||||||
state.animationController.forward();
|
// state.animationController.forward();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -445,7 +501,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
// }, isShowLoading: false);
|
// }, isShowLoading: false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// 查询事件记录(时间查询)
|
// 查询事件记录(时间查询)
|
||||||
Future<void> senderReferEventRecordTime(int time) async {
|
Future<void> senderReferEventRecordTime(int time) async {
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||||
@ -475,54 +530,13 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加用户(普通用户接收电子钥匙)
|
//
|
||||||
Future<void> addUserConnectBlue() async {
|
|
||||||
// 进来之后首先连接
|
|
||||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
|
||||||
(DeviceConnectionState deviceConnectionState) async {
|
|
||||||
if (deviceConnectionState == DeviceConnectionState.connected) {
|
|
||||||
// 私钥
|
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
|
||||||
List<int> getTokenList = [0, 0, 0, 0];
|
|
||||||
if (token != null) {
|
|
||||||
getTokenList = changeStringListToIntList(token);
|
|
||||||
}
|
|
||||||
print(
|
|
||||||
"BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
|
||||||
IoSenderManage.senderAddUser(
|
|
||||||
lockID: BlueManage().connectDeviceName,
|
|
||||||
authUserID: state.senderUserId.toString(),
|
|
||||||
keyID: state.keyInfos.value.keyId.toString(),
|
|
||||||
userID: await Storage.getUid(),
|
|
||||||
openMode: 1,
|
|
||||||
keyType: 0,
|
|
||||||
startDate: DateTime.now().millisecondsSinceEpoch,
|
|
||||||
expireDate: 0x11223344,
|
|
||||||
role: 0,
|
|
||||||
password: "123456",
|
|
||||||
needAuthor: 1,
|
|
||||||
publicKey: publicKeyDataList,
|
|
||||||
privateKey: getPrivateKeyList,
|
|
||||||
token: getTokenList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击开锁
|
|
||||||
startOpenLock() {
|
startOpenLock() {
|
||||||
// if(state.lockState.value == 4){
|
if(state.openLockBtnState.value == 1){
|
||||||
// // 当状态为4的时候,代表是已经连接过一次了,但是连接失败了,所以要重新连接
|
return;
|
||||||
// state.lockState.value = 3;
|
}
|
||||||
// }else{
|
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||||
// 其他代表是第一次连接
|
state.openLockBtnState.value = 1;
|
||||||
state.openLockBtnState.value = 1;
|
|
||||||
// }
|
|
||||||
state.animationController.forward();
|
state.animationController.forward();
|
||||||
|
|
||||||
if (state.lockUserNo == 0) {
|
if (state.lockUserNo == 0) {
|
||||||
@ -609,9 +623,7 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
|
||||||
void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
|
void _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
|
||||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((event) {
|
||||||
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
|
||||||
.listen((event) {
|
|
||||||
if (event.type == 0) {
|
if (event.type == 0) {
|
||||||
// 0考勤
|
// 0考勤
|
||||||
state.isAttendance.value = event.setResult;
|
state.isAttendance.value = event.setResult;
|
||||||
@ -624,6 +636,90 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||||
|
void _scanListDiscoveredDeviceSubscriptionAction() {
|
||||||
|
_scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on<List<DiscoveredDevice>>().listen((List<DiscoveredDevice> list) {
|
||||||
|
final knownDeviceIndex = list.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
|
||||||
|
if (knownDeviceIndex >= 0) {
|
||||||
|
// 存在的时候赋值
|
||||||
|
state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//开锁成功弹出的小界面
|
||||||
|
void _showFullScreenOverlay(BuildContext context) {
|
||||||
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
|
if(state.iSClosedUnlockSuccessfulPopup.value == true){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||||
|
Get.back();
|
||||||
|
});
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if(state.iSClosedUnlockSuccessfulPopup.value == true){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
color: Colors.black.withOpacity(0.2),
|
||||||
|
child: _unlockSuccessWidget(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _unlockSuccessWidget() {
|
||||||
|
return Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
'images/main/unlocked_bg.png',
|
||||||
|
width: 358.w,
|
||||||
|
height: 348.h,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: ScreenUtil().screenHeight / 2,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
state.keyInfos.value.lockAlias!,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.placeholderTextColor, fontSize: 24.sp),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10.h,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
getCurrentFormattedTime(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getCurrentFormattedTime() {
|
||||||
|
// 获取当前时间
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
// 格式化日期和时间
|
||||||
|
String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||||
|
return formattedTime;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
@ -632,6 +728,10 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
_initReplySubscription();
|
_initReplySubscription();
|
||||||
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||||
|
_scanListDiscoveredDeviceSubscriptionAction();
|
||||||
|
Future.delayed(const Duration(seconds: 1)).then((value) {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -652,5 +752,6 @@ class LockDetailLogic extends BaseGetXController {
|
|||||||
|
|
||||||
_replySubscription.cancel();
|
_replySubscription.cancel();
|
||||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||||
|
_scanListDiscoveredDeviceSubscription.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,7 +121,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
child: Obx(() => Stack(
|
child: Obx(() => Stack(
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
// state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
|
||||||
|
'images/main/icon_main_openLockBtn_center.png',
|
||||||
width: 330.w,
|
width: 330.w,
|
||||||
height: 330.w,
|
height: 330.w,
|
||||||
),
|
),
|
||||||
@ -136,7 +137,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.log("点击开锁");
|
// Get.log("点击开锁");
|
||||||
logic.startOpenLock();
|
logic.startOpenLock();
|
||||||
},
|
},
|
||||||
onLongPressStart: (details) {
|
onLongPressStart: (details) {
|
||||||
@ -504,14 +505,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
color: Colors.black.withOpacity(0.5),
|
color: Colors.black.withOpacity(0.5),
|
||||||
child: unlockSuccessWidget(),
|
child: _unlockSuccessWidget(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget unlockSuccessWidget() {
|
Widget _unlockSuccessWidget() {
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -546,10 +547,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
String getCurrentFormattedTime() {
|
String getCurrentFormattedTime() {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
|
|
||||||
// 格式化日期和时间
|
// 格式化日期和时间
|
||||||
String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||||
|
|
||||||
return formattedTime;
|
return formattedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,15 +558,18 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
/// 路由订阅
|
/// 路由订阅
|
||||||
// AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
|
print("LockDetailPage===dispose");
|
||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
state.animationController.dispose();
|
// state.animationController.reset();
|
||||||
|
// state.animationController.forward();
|
||||||
|
// state.animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||||
}
|
}
|
||||||
@ -577,6 +579,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
void didPush() {
|
void didPush() {
|
||||||
super.didPush();
|
super.didPush();
|
||||||
print("LockDetailPage===didPush");
|
print("LockDetailPage===didPush");
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 返回上一个界面 当前界面即将消失
|
/// 返回上一个界面 当前界面即将消失
|
||||||
@ -584,13 +587,18 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
void didPop() {
|
void didPop() {
|
||||||
super.didPop();
|
super.didPop();
|
||||||
print("LockDetailPage===didPop");
|
print("LockDetailPage===didPop");
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
state.animationController.reset();
|
||||||
|
state.animationController.forward();
|
||||||
|
state.animationController.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 从下级返回 当前界面即将出现
|
/// 从下级返回 当前界面即将出现
|
||||||
@override
|
@override
|
||||||
void didPopNext() {
|
void didPopNext() {
|
||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
|
state.ifCurrentScreen.value = true;
|
||||||
print("LockDetailPage===didPopNext");
|
print("LockDetailPage===didPopNext");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,7 +607,10 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
|||||||
void didPushNext() {
|
void didPushNext() {
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
print("LockDetailPage===didPushNext");
|
print("LockDetailPage===didPushNext");
|
||||||
|
state.ifCurrentScreen.value = false;
|
||||||
logic.cancelBlueConnetctToastTimer();
|
logic.cancelBlueConnetctToastTimer();
|
||||||
|
state.animationController.reset();
|
||||||
|
state.animationController.forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,9 +26,12 @@ class LockDetailState {
|
|||||||
|
|
||||||
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
var currentDeviceUUid = "".obs;// 当前设备的uuid
|
||||||
|
|
||||||
|
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||||
|
var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗
|
||||||
|
|
||||||
//过渡动画控制器
|
//过渡动画控制器
|
||||||
late AnimationController animationController;
|
late AnimationController animationController;
|
||||||
// var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中
|
// var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中
|
||||||
var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态)
|
var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态)
|
||||||
var connectState = 0.obs;// 0未连接 1连接
|
// var connectState = 0.obs;// 0未连接 1连接
|
||||||
}
|
}
|
||||||
@ -45,10 +45,6 @@ class BaseGetXController extends GetxController{
|
|||||||
Get.log('onClose -----> $runtimeType');
|
Get.log('onClose -----> $runtimeType');
|
||||||
}
|
}
|
||||||
|
|
||||||
// operationFailedCallBack(e){
|
|
||||||
// showOperationFailed();
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
||||||
|
|
||||||
void showEasyLoading() => EasyLoading.show();
|
void showEasyLoading() => EasyLoading.show();
|
||||||
@ -57,12 +53,17 @@ class BaseGetXController extends GetxController{
|
|||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
// CancelableOperation? _operation;
|
// CancelableOperation? _operation;
|
||||||
void showBlueConnetctToastTimer() {
|
void showBlueConnetctToastTimer(Function? something) {
|
||||||
if(_timer != null && _timer!.isActive){
|
if(_timer != null){
|
||||||
_timer!.cancel();
|
_timer!.cancel();
|
||||||
|
_timer = null;
|
||||||
}
|
}
|
||||||
_timer = Timer.periodic(15.seconds, (timer) {
|
_timer = Timer.periodic(15.seconds, (timer) {
|
||||||
|
cancelBlueConnetctToastTimer();
|
||||||
showBlueConnetctToast();
|
showBlueConnetctToast();
|
||||||
|
if(something != null) {
|
||||||
|
something();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// _operation = CancelableOperation.fromFuture(
|
// _operation = CancelableOperation.fromFuture(
|
||||||
// Future.delayed(const Duration(seconds: 15), () {
|
// Future.delayed(const Duration(seconds: 15), () {
|
||||||
@ -74,7 +75,10 @@ class BaseGetXController extends GetxController{
|
|||||||
|
|
||||||
void cancelBlueConnetctToastTimer() {
|
void cancelBlueConnetctToastTimer() {
|
||||||
Get.log('cancelBlueConnetctToastTimer');
|
Get.log('cancelBlueConnetctToastTimer');
|
||||||
if(_timer != null && _timer!.isActive) _timer!.cancel();
|
if(_timer != null){
|
||||||
|
_timer!.cancel();
|
||||||
|
_timer = null;
|
||||||
|
}
|
||||||
// _operation?.cancel();
|
// _operation?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +140,6 @@ class BaseGetXController extends GetxController{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///Extension_Int
|
///Extension_Int
|
||||||
extension Extension_Int on int {
|
extension Extension_Int on int {
|
||||||
bool get codeIsSuccessful => this == 0;
|
bool get codeIsSuccessful => this == 0;
|
||||||
|
|||||||
@ -128,7 +128,7 @@ dependencies:
|
|||||||
# ffmpeg_kit_flutter: 5.1.0-LTS
|
# ffmpeg_kit_flutter: 5.1.0-LTS
|
||||||
fast_gbk: ^1.0.0
|
fast_gbk: ^1.0.0
|
||||||
flutter_pcm_sound: ^1.1.0
|
flutter_pcm_sound: ^1.1.0
|
||||||
intl: ^0.18.1
|
intl: ^0.18.0
|
||||||
# flutter_audio_capture: <1.1.5
|
# flutter_audio_capture: <1.1.5
|
||||||
|
|
||||||
flutter_voice_processor: ^1.1.0
|
flutter_voice_processor: ^1.1.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user