优化蓝牙协议,先扫描再连接然后才是发送
This commit is contained in:
parent
8f519adede
commit
11aeca1f31
@ -67,13 +67,15 @@ class BlueManage {
|
||||
|
||||
/// 开始扫描蓝牙设备
|
||||
void startScan({List<Uuid>? idList}) {
|
||||
// List<Service>? list = _flutterReactiveBle!.getDiscoveredServices("deviceId").then((value));
|
||||
|
||||
scanDevices.clear();
|
||||
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices: idList ?? []).listen((device) {
|
||||
_scanSubscription = _flutterReactiveBle!.scanForDevices(withServices:[]).listen((device) {
|
||||
// 判断名字为空的直接剔除
|
||||
if (device.name.isEmpty) {
|
||||
return;
|
||||
}
|
||||
// print("startScanDevice:$device");
|
||||
print("startScanDevice:$device");
|
||||
if (((device.serviceUuids.isNotEmpty ? device.serviceUuids[0] : "").toString().contains("758824")) && (device.rssi >= -100)) {
|
||||
// 查询id相同的元素
|
||||
final knownDeviceIndex = scanDevices.indexWhere((d) => d.id == device.id);
|
||||
@ -91,8 +93,12 @@ class BlueManage {
|
||||
}
|
||||
|
||||
/// 调用发送数据
|
||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack) async {
|
||||
Future<void> bludSendData(String deviceName, ConnectStateCallBack stateCallBack, {bool isAddEquipment = false}) async {
|
||||
if(deviceConnectionState != DeviceConnectionState.connected){
|
||||
if(isAddEquipment == false){
|
||||
startScan();
|
||||
}
|
||||
|
||||
_connect(deviceName, (state){
|
||||
stateCallBack(deviceConnectionState!);
|
||||
});
|
||||
@ -109,6 +115,7 @@ class BlueManage {
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候赋值
|
||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
||||
stopScan();
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
var index = 0;
|
||||
@ -116,9 +123,10 @@ class BlueManage {
|
||||
Timer.periodic(const Duration(milliseconds: 1000), (timer) {
|
||||
///定时任务
|
||||
// print("timer index0:$index");
|
||||
if(index >= 4){
|
||||
if(index >= 9){
|
||||
// 当超过5秒的时候取消定时任务 弹窗显示连接失败
|
||||
completer.complete();
|
||||
stopScan();
|
||||
timer.cancel();
|
||||
connectDeviceMacAddress = "";
|
||||
// deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
@ -130,6 +138,7 @@ class BlueManage {
|
||||
if (knownDeviceIndex >= 0) {
|
||||
// 存在的时候销毁定时器,赋值
|
||||
completer.complete();
|
||||
stopScan();
|
||||
timer.cancel();
|
||||
// print("timer index2:$index");
|
||||
connectDeviceMacAddress = scanDevices[knownDeviceIndex].id;
|
||||
@ -149,7 +158,7 @@ class BlueManage {
|
||||
return;
|
||||
}
|
||||
|
||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 10)).listen((connectionStateUpdate) async {
|
||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 5)).listen((connectionStateUpdate) async {
|
||||
// 获取状态
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
print('deviceConnectionState:$deviceConnectionState connectionStateUpdate.connectionState:${connectionStateUpdate.connectionState}');
|
||||
@ -181,9 +190,16 @@ class BlueManage {
|
||||
|
||||
// 听上报来的数据,参数来自前面扫描到的结果
|
||||
var allData = <int>[];
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
var lastTimeData = <int>[];
|
||||
int? dataLen;
|
||||
_subScribeToCharacteristic(QualifiedCharacteristic characteristic) {
|
||||
_flutterReactiveBle!.subscribeToCharacteristic(characteristic).listen((data) {
|
||||
if(data == lastTimeData){
|
||||
return;
|
||||
}else{
|
||||
lastTimeData = data;
|
||||
}
|
||||
// code to handle incoming data
|
||||
// print("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
|
||||
if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
|
||||
@ -277,15 +293,21 @@ class BlueManage {
|
||||
}
|
||||
|
||||
// 停止扫描蓝牙设备
|
||||
// Future<void> stopScan() async {
|
||||
// await _scanSubscription?.cancel();
|
||||
// _scanSubscription = null;
|
||||
// }
|
||||
Future<void> stopScan() async {
|
||||
if(_scanSubscription != null){
|
||||
_scanSubscription?.cancel();
|
||||
_scanSubscription = null;
|
||||
}
|
||||
}
|
||||
|
||||
// 断开连接
|
||||
Future<void> disconnect(String deviceMAC) async {
|
||||
try {
|
||||
_currentConnectionStream?.cancel();
|
||||
if(_currentConnectionStream != null){
|
||||
_currentConnectionStream?.cancel();
|
||||
_currentConnectionStream = null;
|
||||
}
|
||||
|
||||
print('disconnecting to device: $deviceMAC');
|
||||
} on Exception catch (e, _) {
|
||||
print("Error disconnecting from a device: $e");
|
||||
|
||||
@ -197,13 +197,13 @@ Future _setCommonServices() async {
|
||||
void openBlueScan() {
|
||||
if (Platform.isIOS) {
|
||||
print("有蓝牙权限开始扫描");
|
||||
startScanAction();
|
||||
// startScanAction();
|
||||
} else {
|
||||
getMicrophonePermission().then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
print("有蓝牙权限开始扫描");
|
||||
startScanAction();
|
||||
// startScanAction();
|
||||
} else {
|
||||
//没有权限
|
||||
openAppSettings(); //打开app系统设置
|
||||
|
||||
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
|
||||
@ -73,6 +74,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}解析成功");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletKeyData();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -96,19 +99,22 @@ class LockSetLogic extends BaseGetXController {
|
||||
token: tokenData);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
dismissEasyLoading();
|
||||
showToast("用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} ");
|
||||
dismissEasyLoading();
|
||||
showToast("权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
dismissEasyLoading();
|
||||
showToast("删除失败");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -127,6 +133,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletLockInfoData();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -153,17 +161,20 @@ class LockSetLogic extends BaseGetXController {
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
dismissEasyLoading();
|
||||
showToast("用户无权限");
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
print("${reply.commandType!.typeValue} ");
|
||||
dismissEasyLoading();
|
||||
showToast("权限校验错误");
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} 失败");
|
||||
|
||||
dismissEasyLoading();
|
||||
showToast("权限校验错误");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -257,13 +268,12 @@ class LockSetLogic extends BaseGetXController {
|
||||
// 删除用户
|
||||
Future<void> deletUserAction() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer((){
|
||||
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -287,6 +297,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
token: getTokenList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
@ -295,13 +306,12 @@ class LockSetLogic extends BaseGetXController {
|
||||
// 恢复出厂设置
|
||||
Future<void> factoryDataResetAction() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer((){
|
||||
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -321,6 +331,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
token: getTokenList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
});
|
||||
@ -355,9 +366,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm(int type) async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer((){
|
||||
|
||||
});
|
||||
showBlueConnetctToastTimer();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
@ -437,7 +446,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,11 +459,15 @@ class LockSetLogic extends BaseGetXController {
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Get.close(2);
|
||||
// Get.offAllNamed(Routers.starLockMain);
|
||||
}
|
||||
}
|
||||
|
||||
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||
// 点击删除 开始扫描
|
||||
BlueManage().startScan();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -470,6 +484,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
checkLoginPassword();
|
||||
},
|
||||
cancelClick: () {
|
||||
// 取消的时候停止扫描
|
||||
BlueManage().stopScan();
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
@ -485,25 +501,83 @@ class LockSetLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
Get.back();
|
||||
|
||||
if(state.currentDeviceUUid.value.isEmpty){
|
||||
// 扫描到的设备列表里面灭有 直接弹窗调用删除锁接口
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}else{
|
||||
// 当扫描的数组里面是否有当前设备
|
||||
if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
} else {
|
||||
// 不是锁拥有者,调用删除钥匙协议
|
||||
deletUserAction();
|
||||
}
|
||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
if(BlueManage().deviceConnectionState == DeviceConnectionState.connected){
|
||||
// 已连接
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
} else {
|
||||
// 不是锁拥有者,调用删除钥匙协议
|
||||
deletUserAction();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 当前设备是否已经扫描到了
|
||||
if (state.currentDeviceUUid.value.isNotEmpty) {
|
||||
// 已经扫描到了 停止扫描,直接删除锁
|
||||
BlueManage().stopScan();
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 未扫描到 然后循环5秒扫秒
|
||||
var index = 0;
|
||||
showEasyLoading();
|
||||
state.deletWaitScanCompleter = Completer();
|
||||
state.deletWaitScanTimer = Timer.periodic(const Duration(milliseconds: 1000), (timer) {
|
||||
///定时任务
|
||||
// print("timer index0:$index");
|
||||
if(index >= 5){
|
||||
// 当超过10秒的时候还是没有搜索到,完成任务,关闭扫描,取消定时器,弹窗提示
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}else{
|
||||
// 每秒判断获取是否搜到了当前设备
|
||||
if (state.currentDeviceUUid.isNotEmpty) {
|
||||
// 存在的时候销毁定时器,赋值
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
dismissEasyLoading();
|
||||
deletLockLogic();
|
||||
} else {
|
||||
// 不存在的时候返回-1 然后循环5秒
|
||||
index++;
|
||||
print("index:$index");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 等待Completer完成
|
||||
await state.deletWaitScanCompleter!.future;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deletLockLogic() {
|
||||
// 当扫描的数组里面是否有当前设备
|
||||
if(state.currentDeviceUUid.value[31] == "1"){
|
||||
// 已配对 表示这把锁未被初始化,还处于被添加状态
|
||||
if (state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1) {
|
||||
// 如果是锁拥有者直接删除锁,调用初始化协议
|
||||
factoryDataResetAction();
|
||||
} else {
|
||||
// 不是锁拥有者,调用删除钥匙协议
|
||||
deletUserAction();
|
||||
}
|
||||
}else if(state.currentDeviceUUid.value[31] == "0"){
|
||||
// 未配对 表示这把锁已被强制初始化 处于可添加状态 直接弹窗删除即可
|
||||
showDeletAlertTipDialog(Get.context!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/blue_manage.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -814,6 +816,14 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null && !state.deletWaitScanCompleter!.isCompleted){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
BlueManage().stopScan();
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@ -821,6 +831,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@ -829,5 +840,14 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if(state.deletWaitScanTimer != null){
|
||||
state.deletWaitScanTimer!.cancel();
|
||||
}
|
||||
if(state.deletWaitScanCompleter != null && !state.deletWaitScanCompleter!.isCompleted){
|
||||
state.deletWaitScanCompleter!.complete();
|
||||
}
|
||||
// BlueManage().stopScan();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'lockSetInfo_entity.dart';
|
||||
@ -25,6 +27,9 @@ class LockSetState {
|
||||
|
||||
var settingUpSupportFeatures = 0;
|
||||
|
||||
Completer? deletWaitScanCompleter;
|
||||
Timer? deletWaitScanTimer;
|
||||
|
||||
LockSetState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.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:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/toast.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
@ -76,7 +69,21 @@ class LockDetailLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
_showFullScreenOverlay(Get.context!);
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
if(state.closedUnlockSuccessfulTimer != null){
|
||||
state.closedUnlockSuccessfulTimer!.cancel();
|
||||
state.closedUnlockSuccessfulTimer = null;
|
||||
}
|
||||
// 如果没有点击关闭弹窗,3秒后自动关闭
|
||||
state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (timer) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
});
|
||||
// Future.delayed(const Duration(seconds: 3), () {
|
||||
// state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
// });
|
||||
|
||||
// 电量
|
||||
int power = reply.data[7];
|
||||
@ -350,7 +357,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 添加用户(普通用户接收电子钥匙)
|
||||
Future<void> addUserConnectBlue() async {
|
||||
showBlueConnetctToastTimer(() {
|
||||
showBlueConnetctToastTimer(action:() {
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
@ -401,7 +408,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 点击开门事件
|
||||
Future<void> openDoorAction() async {
|
||||
showBlueConnetctToastTimer(() {
|
||||
showBlueConnetctToastTimer(action:() {
|
||||
state.openLockBtnState.value = 0;
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
@ -584,9 +591,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
||||
.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000);
|
||||
}
|
||||
@ -650,11 +655,10 @@ class LockDetailLogic extends BaseGetXController {
|
||||
//开锁成功弹出的小界面
|
||||
void _showFullScreenOverlay(BuildContext context) {
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if(state.iSClosedUnlockSuccessfulPopup.value == true){
|
||||
return;
|
||||
if(state.iSClosedUnlockSuccessfulPopup.value != true){
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
}
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
});
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
@ -663,11 +667,10 @@ class LockDetailLogic extends BaseGetXController {
|
||||
builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if(state.iSClosedUnlockSuccessfulPopup.value == true){
|
||||
return;
|
||||
if(state.iSClosedUnlockSuccessfulPopup.value != true){
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
}
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
Get.back();
|
||||
},
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
@ -724,14 +727,13 @@ class LockDetailLogic extends BaseGetXController {
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
_initReplySubscription();
|
||||
_initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||
_scanListDiscoveredDeviceSubscriptionAction();
|
||||
Future.delayed(const Duration(seconds: 1)).then((value) {
|
||||
|
||||
});
|
||||
// Future.delayed(const Duration(seconds: 1)).then((value) {
|
||||
//
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
@ -739,8 +741,6 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
print("lockDetail_onInit()");
|
||||
|
||||
// 进来获取锁状态
|
||||
// connectBlue();
|
||||
}
|
||||
@ -748,7 +748,6 @@ class LockDetailLogic extends BaseGetXController {
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
print("锁详情界面销毁了");
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -69,16 +70,33 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 1.sw,
|
||||
height: 1.sh - ScreenUtil().statusBarHeight * 2,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
topWidget(),
|
||||
Expanded(child: Obx(() => bottomWidget()))
|
||||
],
|
||||
),
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 1.sh - ScreenUtil().statusBarHeight * 2,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
topWidget(),
|
||||
Expanded(child: Obx(() => bottomWidget())),
|
||||
],
|
||||
),
|
||||
),
|
||||
Obx(() => Visibility(
|
||||
visible: state.iSClosedUnlockSuccessfulPopup.value,
|
||||
child: GestureDetector(
|
||||
onTap: (){
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
},
|
||||
child: Container(
|
||||
width: 1.sw,
|
||||
height: 1.sh,
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
child: _unlockSuccessWidget()),
|
||||
),
|
||||
))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -522,13 +540,13 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
height: 348.h,
|
||||
),
|
||||
Positioned(
|
||||
top: ScreenUtil().screenHeight / 2 - 10.h,
|
||||
top: 1.sh / 2 - 70.h,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.lockListInfoItemEntity.lockAlias!,
|
||||
style: TextStyle(
|
||||
color: AppColors.placeholderTextColor, fontSize: 26.sp),
|
||||
color: AppColors.placeholderTextColor, fontSize: 24.sp),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
@ -536,7 +554,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
Text(
|
||||
getCurrentFormattedTime(),
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor, fontSize: 26.sp),
|
||||
color: AppColors.darkGrayTextColor, fontSize: 24.sp),
|
||||
)
|
||||
],
|
||||
))
|
||||
@ -565,8 +583,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
print("LockDetailPage===dispose");
|
||||
// print("LockDetailPage===dispose");
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
state.closedUnlockSuccessfulTimer?.cancel();
|
||||
// state.animationController.reset();
|
||||
// state.animationController.forward();
|
||||
// state.animationController.dispose();
|
||||
@ -578,7 +597,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
print("LockDetailPage===didPush");
|
||||
// print("LockDetailPage===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
@ -586,7 +605,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("LockDetailPage===didPop");
|
||||
// print("LockDetailPage===didPop");
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
state.animationController.reset();
|
||||
@ -599,14 +618,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
state.ifCurrentScreen.value = true;
|
||||
print("LockDetailPage===didPopNext");
|
||||
// print("LockDetailPage===didPopNext");
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("LockDetailPage===didPushNext");
|
||||
// print("LockDetailPage===didPushNext");
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
state.animationController.reset();
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -28,6 +30,7 @@ class LockDetailState {
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗
|
||||
Timer? closedUnlockSuccessfulTimer;
|
||||
|
||||
//过渡动画控制器
|
||||
late AnimationController animationController;
|
||||
|
||||
@ -16,6 +16,7 @@ import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../tools/toast.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -28,7 +29,7 @@ class LockAddressGaoDePage extends StatefulWidget {
|
||||
State<LockAddressGaoDePage> createState() => _LockAddressGaoDePageState();
|
||||
}
|
||||
|
||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage> with RouteAware{
|
||||
final logic = Get.put(LockAddressGaoDeLogic());
|
||||
final state = Get.find<LockAddressGaoDeLogic>().state;
|
||||
|
||||
@ -361,14 +362,55 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
|
||||
location.setLocationOption(locationOption);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
|
||||
location.stopLocation();
|
||||
location.destroy();
|
||||
print("地图界面销毁了");
|
||||
Get.log("地图界面销毁了");
|
||||
}
|
||||
|
||||
/// 从上级界面进入 当前界面即将出现
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
|
||||
location.stopLocation();
|
||||
location.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
// showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
@ -69,6 +69,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
var saveStrList = changeIntListToStringList(publicKey);
|
||||
Storage.setStringList(saveBluePublicKey, saveStrList);
|
||||
|
||||
// 获取私钥
|
||||
IoSenderManage.getPrivateKey(
|
||||
lockId: BlueManage().connectDeviceName,
|
||||
keyID: "1",
|
||||
@ -322,8 +323,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
Future<void> _getStarLockStatus() async {
|
||||
// print("connectDeviceMacAddress:${BlueManage().connectDeviceMacAddress} connectDeviceName:${BlueManage().connectDeviceName}");
|
||||
// 进来之后首先连接
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(DeviceConnectionState state) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
if (state == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -341,7 +341,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
} else if (state == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
}
|
||||
});
|
||||
}, isAddEquipment: true);
|
||||
}
|
||||
|
||||
late StreamSubscription<List<DiscoveredDevice>>_scanListDiscoveredDeviceSubscription;
|
||||
@ -357,6 +357,14 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
void startScanBlueList(){
|
||||
BlueManage().startScan();
|
||||
}
|
||||
|
||||
void stopScanBlueList(){
|
||||
BlueManage().stopScan();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@ -380,6 +388,5 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
_scanListDiscoveredDeviceSubscription.cancel();
|
||||
// BlueManage().stopScan();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
import 'nearbyLock_logic.dart';
|
||||
@ -20,7 +21,7 @@ class NearbyLockPage extends StatefulWidget {
|
||||
State<NearbyLockPage> createState() => _NearbyLockPageState();
|
||||
}
|
||||
|
||||
class _NearbyLockPageState extends State<NearbyLockPage> {
|
||||
class _NearbyLockPageState extends State<NearbyLockPage> with RouteAware {
|
||||
final logic = Get.put(NearbyLockLogic());
|
||||
final state = Get.find<NearbyLockLogic>().state;
|
||||
|
||||
@ -122,10 +123,59 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
Get.log("NearbyLockLogic dispose()");
|
||||
}
|
||||
|
||||
/// 从上级界面进入 当前界面即将出现
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
state.ifCurrentScreen.value = true;
|
||||
logic.startScanBlueList();
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.stopScanBlueList();
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
|
||||
state.ifCurrentScreen.value = true;
|
||||
logic.startScanBlueList();
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.stopScanBlueList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
||||
class NearbyLockState {
|
||||
|
||||
RxList<DiscoveredDevice> devices = <DiscoveredDevice>[].obs;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var seletLockName = "".obs;
|
||||
|
||||
var timestampValue = 0;
|
||||
|
||||
@ -51,6 +51,9 @@ class SaveLockLogic extends BaseGetXController {
|
||||
print("添加用户数据解析成功");
|
||||
state.lockUserNo = reply.data[47] + 1;
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
|
||||
bindBlueAdmin();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -81,17 +84,17 @@ class SaveLockLogic extends BaseGetXController {
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("用户无权限");
|
||||
|
||||
dismissEasyLoading();
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("添加用户权限校验错误");
|
||||
|
||||
dismissEasyLoading();
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("领锁失败");
|
||||
|
||||
dismissEasyLoading();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -106,11 +109,14 @@ class SaveLockLogic extends BaseGetXController {
|
||||
// print("111111");
|
||||
// 进来之后首先连接
|
||||
showEasyLoading();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState state) async {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.saveBtnIsUsable.value = true;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async {
|
||||
// print("222222");
|
||||
if (state == DeviceConnectionState.connected){
|
||||
if (deviceConnectionState == DeviceConnectionState.connected){
|
||||
// print("333333");
|
||||
dismissEasyLoading();
|
||||
// 私钥
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -140,10 +146,14 @@ class SaveLockLogic extends BaseGetXController {
|
||||
privateKey:getPrivateKeyList,
|
||||
token: getTokenList
|
||||
);
|
||||
} else if (state == DeviceConnectionState.disconnected) {
|
||||
} else if (deviceConnectionState == DeviceConnectionState.disconnected) {
|
||||
print("444444");
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.saveBtnIsUsable.value = true;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -192,10 +202,12 @@ class SaveLockLogic extends BaseGetXController {
|
||||
featureSettingParams: state.featureSettingParams,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
Future.delayed(const Duration(milliseconds: 200), () {
|
||||
Get.offAllNamed(Routers.starLockMain);
|
||||
});
|
||||
Get.close(5);
|
||||
// Future.delayed(const Duration(milliseconds: 200), () {
|
||||
// Get.offAllNamed(Routers.starLockMain);
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
import '../../../tools/appRouteObserver.dart';
|
||||
import '../../../tools/submitBtn.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
import '../../../translations/trans_lib.dart';
|
||||
@ -17,7 +18,7 @@ class SaveLockPage extends StatefulWidget {
|
||||
State<SaveLockPage> createState() => _SaveLockPageState();
|
||||
}
|
||||
|
||||
class _SaveLockPageState extends State<SaveLockPage> {
|
||||
class _SaveLockPageState extends State<SaveLockPage> with RouteAware {
|
||||
final logic = Get.put(SaveLockLogic());
|
||||
final state = Get.find<SaveLockLogic>().state;
|
||||
|
||||
@ -101,7 +102,9 @@ class _SaveLockPageState extends State<SaveLockPage> {
|
||||
bottom: 25.w
|
||||
),
|
||||
onClick: (){
|
||||
// Navigator.pop(context);
|
||||
if(state.saveBtnIsUsable.value == false){
|
||||
return;
|
||||
}
|
||||
logic.addUserConnectBlue();
|
||||
}
|
||||
),
|
||||
@ -110,5 +113,54 @@ class _SaveLockPageState extends State<SaveLockPage> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 从上级界面进入 当前界面即将出现
|
||||
@override
|
||||
void didPush() {
|
||||
super.didPush();
|
||||
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
|
||||
state.ifCurrentScreen.value = false;
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,9 @@ class SaveLockState {
|
||||
var featureSettingValue = '';
|
||||
var featureSettingParams = [];
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var saveBtnIsUsable = true.obs; // 保存按钮是否可用
|
||||
|
||||
SaveLockState() {
|
||||
aliName.value = BlueManage().connectDeviceName;
|
||||
aliNameController.text = aliName.value;
|
||||
|
||||
@ -63,8 +63,8 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
// Navigator.pushNamed(context, Routers.starLockLoginPage);
|
||||
Navigator.pushNamed(
|
||||
context, Routers.minePersonInfoPage);
|
||||
Get.back();
|
||||
Get.toNamed(Routers.minePersonInfoPage);
|
||||
},
|
||||
child: Container(
|
||||
width: 105.w,
|
||||
@ -119,6 +119,7 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
// }),
|
||||
mineItem('images/mine/icon_mine_main_addLock.png',
|
||||
TranslationLoader.lanKeys!.addDevice!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.seletLockTypePage);
|
||||
}),
|
||||
// mineItem('images/mine/icon_mine_main_gateway.png',
|
||||
@ -127,6 +128,7 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
// }),
|
||||
mineItem('images/mine/icon_mine_main_message.png',
|
||||
TranslationLoader.lanKeys!.message!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.messageListPage);
|
||||
// Toast.show(msg: "功能暂未开放");
|
||||
}),
|
||||
@ -137,14 +139,17 @@ class _StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
// }),
|
||||
mineItem('images/mine/icon_mine_main_set.png',
|
||||
TranslationLoader.lanKeys!.set!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.mineSetPage);
|
||||
}),
|
||||
mineItem('images/mine/icon_mine_main_vip.png',
|
||||
TranslationLoader.lanKeys!.valueAddedServices!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
}),
|
||||
mineItem('images/mine/icon_mine_main_about.png',
|
||||
TranslationLoader.lanKeys!.about!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.abountPage);
|
||||
}),
|
||||
],
|
||||
|
||||
@ -373,8 +373,7 @@ class ApiRepository {
|
||||
}
|
||||
|
||||
// 检查账户密码
|
||||
Future<LockListInfoEntity> checkLoginPassword(
|
||||
{required String password}) async {
|
||||
Future<LockListInfoEntity> checkLoginPassword({required String password}) async {
|
||||
final res = await apiProvider.checkLoginPassword(password);
|
||||
return LockListInfoEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
@ -53,16 +53,18 @@ class BaseGetXController extends GetxController{
|
||||
|
||||
Timer? _timer;
|
||||
// CancelableOperation? _operation;
|
||||
void showBlueConnetctToastTimer(Function? something) {
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true,Function? action}) {
|
||||
if(_timer != null){
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
_timer = Timer.periodic(15.seconds, (timer) {
|
||||
_timer = Timer.periodic(10.seconds, (timer) {
|
||||
if(action != null) {
|
||||
action();
|
||||
}
|
||||
cancelBlueConnetctToastTimer();
|
||||
showBlueConnetctToast();
|
||||
if(something != null) {
|
||||
something();
|
||||
if(isShowBlueConnetctToast == false){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
});
|
||||
// _operation = CancelableOperation.fromFuture(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user