Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
77494e6630
@ -32,6 +32,7 @@ class BlueManage{
|
||||
// 监听发送事件
|
||||
StreamSubscription<EventSendModel>? _sendStreamSubscription;
|
||||
StreamSubscription? _scanSubscription;
|
||||
StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
|
||||
// 监听蓝牙连接状态
|
||||
DeviceConnectionState? deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
@ -126,7 +127,7 @@ class BlueManage{
|
||||
if(deviceConnectionState == DeviceConnectionState.connected){
|
||||
return;
|
||||
}
|
||||
_flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
|
||||
_currentConnectionStream = _flutterReactiveBle!.connectToDevice(id: connectDeviceMacAddress, connectionTimeout: const Duration(seconds: 100000)).listen((connectionStateUpdate) async {
|
||||
// 获取状态
|
||||
deviceConnectionState = connectionStateUpdate.connectionState;
|
||||
print('ConnectionState for device $deviceMAC : ${connectionStateUpdate.connectionState}');
|
||||
@ -206,16 +207,15 @@ class BlueManage{
|
||||
|
||||
// 断开连接
|
||||
Future<void> disconnect(String deviceMAC) async {
|
||||
|
||||
try {
|
||||
_currentConnectionStream?.cancel();
|
||||
print('disconnecting to device: $deviceMAC');
|
||||
} on Exception catch (e, _) {
|
||||
print("Error disconnecting from a device: $e");
|
||||
} finally {
|
||||
// EventBusManager().eventBusFir(ConnectionStateUpdate(
|
||||
// deviceId: deviceMAC,
|
||||
// connectionState: DeviceConnectionState.disconnected,
|
||||
// failure: null,
|
||||
// ));
|
||||
deviceConnectionState = DeviceConnectionState.disconnected;
|
||||
// _currentConnectionStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,5 +394,6 @@ class BlueManage{
|
||||
|
||||
disposed(){
|
||||
_sendStreamSubscription?.cancel();
|
||||
_currentConnectionStream?.cancel();
|
||||
}
|
||||
}
|
||||
@ -71,6 +71,7 @@ class AddCardTypeLogic extends BaseGetXController{
|
||||
fingerprintType = 4;
|
||||
}
|
||||
|
||||
var isCoerced = state.isStressFingerprint.value == false ? "1" : "2"; // 1:非胁迫卡 2:胁迫卡
|
||||
print("addOtherType startDate:$startDate endDate:$endDate");
|
||||
Get.toNamed(Routers.addICCardPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
@ -79,7 +80,7 @@ class AddCardTypeLogic extends BaseGetXController{
|
||||
"cardName": state.nameController.text,
|
||||
"cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(),
|
||||
"cardType": fingerprintType.toString(),
|
||||
"isCoerced": state.isStressFingerprint.value ? "1" : "2",
|
||||
"isCoerced": isCoerced,
|
||||
"startDate": startDate,
|
||||
"weekDay": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
|
||||
@ -74,8 +74,10 @@ class AddICCardLogic extends BaseGetXController{
|
||||
userID:await Storage.getUid(),
|
||||
fingerNo:1,
|
||||
useCountLimit:0xff,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
@ -258,8 +260,10 @@ class AddICCardLogic extends BaseGetXController{
|
||||
icCardNo:1,
|
||||
cardType:1,
|
||||
useCountLimit:1,
|
||||
startTime:int.parse(state.startDate.value)~/1000,
|
||||
endTime:int.parse(state.endDate.value)~/1000,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
// startTime:int.parse(state.startDate.value)~/1000,
|
||||
// endTime:int.parse(state.endDate.value)~/1000,
|
||||
needAuthor:1,
|
||||
publicKey:publicKeyDataList,
|
||||
privateKey:getPrivateKeyList,
|
||||
|
||||
@ -181,13 +181,13 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} 数据解析成功");
|
||||
// print("添加指纹确认成功,调用添加指纹接口");
|
||||
// if(state.isCoerced.value == "1"){
|
||||
if(state.isCoerced.value == "1"){
|
||||
// 非胁迫指纹
|
||||
addFingerprintsData(reply.data[6].toString());
|
||||
// }else{
|
||||
// // 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
// senderAddStressFingerprint();
|
||||
// }
|
||||
}else{
|
||||
// 如果是胁迫指纹在 添加完之后以后再调用添加胁迫指纹的
|
||||
senderAddStressFingerprint();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//需要权限
|
||||
|
||||
@ -338,8 +338,12 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
|
||||
// 重置所有的指纹
|
||||
void deletAllFingerprintsData() async{
|
||||
var fingerprintId = "";
|
||||
if(state.isDeletAll == false){
|
||||
// fingerprintId =
|
||||
}
|
||||
var entity = await ApiRepository.to.deletFingerprintsData(
|
||||
fingerprintId: "",
|
||||
fingerprintId: fingerprintId,
|
||||
lockId: state.lockId.value.toString(),
|
||||
type: "1",
|
||||
deleteType:"1"
|
||||
|
||||
@ -176,6 +176,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
state.deletFingerprintId = idStr;
|
||||
showIosTipViewDialog(context, idStr);
|
||||
},
|
||||
child: Container(
|
||||
@ -206,6 +207,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
Get.back();
|
||||
String? idStr = await Storage.getUid();
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = false;
|
||||
logic.senderAddFingerprint(keyId, idStr ?? "", 0);
|
||||
},
|
||||
cancelClick: () {
|
||||
@ -287,6 +289,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
state.isDeletFingerprintData = true;
|
||||
state.isDeletAll = true;
|
||||
logic.senderAddFingerprint("1", "DeleteAll!@#", 255);
|
||||
},
|
||||
),
|
||||
|
||||
@ -10,6 +10,7 @@ class FingerprintListState{
|
||||
// 因为删除跟添加指纹用的同一个协议 所以这里用做判断
|
||||
var isDeletFingerprintData = false;
|
||||
var isDeletAll = false;
|
||||
var deletFingerprintId = "0";
|
||||
|
||||
final fingerprintItemListData = <FingerprintItemData>[].obs;
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
|
||||
@ -404,6 +405,9 @@ class LockDetailLogic extends BaseGetXController{
|
||||
Future<void> connectBlue(String bluetoothDeviceId, String bluetoothDeviceName) async {
|
||||
// 进来之后首先连接
|
||||
BlueManage().connect(bluetoothDeviceId, bluetoothDeviceName, connectStateCallBack: (DeviceConnectionState state) async {
|
||||
if(EasyLoading.isShow){
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
if (state == DeviceConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -545,6 +549,14 @@ class LockDetailLogic extends BaseGetXController{
|
||||
_initReplySubscription();
|
||||
initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction();
|
||||
|
||||
EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.black, dismissOnTap: true);
|
||||
Future.delayed(const Duration(seconds: 12), () {
|
||||
if(EasyLoading.isShow){
|
||||
EasyLoading.dismiss();
|
||||
Toast.show(msg: "连接设备失败,请确保在设备附近,设备未被连接,设备已打开");
|
||||
}
|
||||
});
|
||||
|
||||
if(Platform.isIOS){
|
||||
print("有蓝牙权限开始扫描");
|
||||
startScanAction();
|
||||
@ -574,16 +586,6 @@ class LockDetailLogic extends BaseGetXController{
|
||||
// factoryDataResetAction();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
print("锁详情界面销毁了");
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
}
|
||||
|
||||
///请求录音相机权限
|
||||
Future<bool> getMicrophonePermission() async {
|
||||
// You can request multiple permissions at once.
|
||||
@ -602,4 +604,12 @@ class LockDetailLogic extends BaseGetXController{
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
print("锁详情界面销毁了");
|
||||
|
||||
_replySubscription.cancel();
|
||||
_lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent!.cancel();
|
||||
}
|
||||
}
|
||||
@ -25,8 +25,7 @@ class LockDetailPage extends StatefulWidget {
|
||||
State<LockDetailPage> createState() => _LockDetailPageState();
|
||||
}
|
||||
|
||||
class _LockDetailPageState extends State<LockDetailPage>
|
||||
with TickerProviderStateMixin {
|
||||
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
|
||||
// with RouteAware
|
||||
final logic = Get.put(LockDetailLogic());
|
||||
final state = Get.find<LockDetailLogic>().state;
|
||||
@ -471,22 +470,33 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
// AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
state.animationController.dispose();
|
||||
super.dispose();
|
||||
BlueManage().stopScan();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
}
|
||||
|
||||
///
|
||||
@override
|
||||
void didPush() {}
|
||||
void didPush() {
|
||||
print("LockDetailPage didPush");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPop() {}
|
||||
void didPop() {
|
||||
print("LockDetailPage didPop");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPopNext() {}
|
||||
void didPopNext() {
|
||||
print("LockDetailPage didPopNext");
|
||||
}
|
||||
|
||||
/// Called when the current route has been popped off.
|
||||
@override
|
||||
void didPushNext() {}
|
||||
void didPushNext() {
|
||||
print("LockDetailPage didPushNext");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user