优化锁设置里面蓝牙连接逻辑
This commit is contained in:
parent
543700e961
commit
b92857d193
@ -144,9 +144,7 @@ class _CardListPageState extends State<CardListPage> {
|
||||
child: _keyItem(
|
||||
'images/icon_card.png',
|
||||
fingerprintItemData.cardName!,
|
||||
fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch
|
||||
? "已失效"
|
||||
: "",
|
||||
(fingerprintItemData.cardType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "",
|
||||
fingerprintItemData.validTimeStr!,
|
||||
// fingerprintItemData.cardType! == 1
|
||||
// ? "永久"
|
||||
|
||||
@ -144,9 +144,7 @@ class _FingerprintListPageState extends State<FingerprintListPage> {
|
||||
child: _keyItem(
|
||||
'images/icon_fingerprint.png',
|
||||
fingerprintItemData.fingerprintName!,
|
||||
fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch
|
||||
? "已失效"
|
||||
: "",
|
||||
(fingerprintItemData.fingerprintType! != 1) ? (fingerprintItemData.endDate! < DateTime.now().millisecondsSinceEpoch ? "已失效" : "") : "",
|
||||
fingerprintItemData.validTimeStr!,
|
||||
// fingerprintItemData.fingerprintType! == 1
|
||||
// ? "永久"
|
||||
|
||||
@ -26,6 +26,10 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
}else{
|
||||
if(state.isCustomLockTime.value == true){
|
||||
autoTime = state.timeController.text;
|
||||
if(int.parse(autoTime) >= 1000){
|
||||
showToast("请输入小于1000的数字");
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
@ -38,7 +42,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
|
||||
state.autoLockTime.value = state.isOpen.value == false ? "0" : state.autoLockTime.value;
|
||||
state.autoLockTime.value = autoTime;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = int.parse(state.autoLockTime.value);
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
@ -66,10 +70,11 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
state.autoLockTime.value = reply.data[7].toString();
|
||||
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -101,6 +106,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
setAutoUnLock();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -154,10 +160,18 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -177,7 +191,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
}
|
||||
print("autoTimeautoTimeautoTime:${autoTime}");
|
||||
// print("autoTimeautoTimeautoTime:${autoTime}");
|
||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
userID: await Storage.getUid(),
|
||||
@ -190,7 +204,11 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/showBottomSheetTool.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
@ -20,7 +22,7 @@ class AutomaticBlockingPage extends StatefulWidget {
|
||||
State<AutomaticBlockingPage> createState() => _AutomaticBlockingPageState();
|
||||
}
|
||||
|
||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with RouteAware {
|
||||
final logic = Get.put(AutomaticBlockingLogic());
|
||||
final state = Get.find<AutomaticBlockingLogic>().state;
|
||||
|
||||
@ -124,6 +126,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.timeController,
|
||||
keyboardType: TextInputType.number,
|
||||
autofocus: false,
|
||||
readOnly: state.isJustForShow.value == true ? true : false,
|
||||
decoration: InputDecoration(
|
||||
@ -177,4 +180,63 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ class AutomaticBlockingState {
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
var isOpen = false.obs;// 是否开启自动落锁
|
||||
var autoLockTime = "5".obs;
|
||||
@ -40,4 +42,5 @@ class AutomaticBlockingState {
|
||||
timeController.text = autoLockTime.value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -85,6 +85,8 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -138,10 +140,18 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -162,7 +172,11 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -15,7 +18,7 @@ class BurglarAlarmPage extends StatefulWidget {
|
||||
State<BurglarAlarmPage> createState() => _BurglarAlarmPageState();
|
||||
}
|
||||
|
||||
class _BurglarAlarmPageState extends State<BurglarAlarmPage> {
|
||||
class _BurglarAlarmPageState extends State<BurglarAlarmPage> with RouteAware{
|
||||
final logic = Get.put(BurglarAlarmLogic());
|
||||
final state = Get.find<BurglarAlarmLogic>().state;
|
||||
|
||||
@ -69,6 +72,65 @@ class _BurglarAlarmPageState extends State<BurglarAlarmPage> {
|
||||
})),
|
||||
],
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,9 @@ class BurglarAlarmState{
|
||||
|
||||
var burglarAlarmEnable = 0.obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
BurglarAlarmState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
|
||||
@ -70,6 +70,8 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
Toast.show(msg: "配网成功");
|
||||
break;
|
||||
case 0x06:
|
||||
@ -143,10 +145,18 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
|
||||
// 点击配置wifi
|
||||
Future<void> senderConfiguringWifiAction() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected){
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -206,7 +216,11 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -257,5 +271,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,12 @@
|
||||
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
@ -17,7 +20,7 @@ class ConfiguringWifiPage extends StatefulWidget {
|
||||
State<ConfiguringWifiPage> createState() => _ConfiguringWifiPageState();
|
||||
}
|
||||
|
||||
class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> {
|
||||
class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> with RouteAware {
|
||||
final logic = Get.put(ConfiguringWifiLogic());
|
||||
final state = Get.find<ConfiguringWifiLogic>().state;
|
||||
|
||||
@ -89,4 +92,60 @@ class _ConfiguringWifiPageState extends State<ConfiguringWifiPage> {
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -11,6 +10,9 @@ class ConfiguringWifiState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var lockBasicInfo = LockBasicInfo().obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
TextEditingController wifiNameController = TextEditingController();
|
||||
TextEditingController wifiPWDController = TextEditingController();
|
||||
ConfiguringWifiState() {
|
||||
|
||||
@ -419,20 +419,16 @@ class LockSetLogic extends BaseGetXController {
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockSetInfoData.value = entity.data!;
|
||||
state.lockSettingInfo.value =
|
||||
state.lockSetInfoData.value.lockSettingInfo!;
|
||||
state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!;
|
||||
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
|
||||
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
|
||||
state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!;
|
||||
|
||||
state.isAttendance.value = state.lockSettingInfo.value.attendance!;
|
||||
state.isOpenLockNeedOnline.value =
|
||||
state.lockSettingInfo.value.appUnlockOnline!;
|
||||
state.isOpenLockNeedOnline.value = state.lockSettingInfo.value.appUnlockOnline!;
|
||||
|
||||
state.isOpenBlueBroadcast.value =
|
||||
state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
state.isOpenExceptionWarnings.value =
|
||||
state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
|
||||
|
||||
// await _readSupportFunctionsNoParameters(56);
|
||||
// _readSupportFunctionsNoParameters(62);
|
||||
@ -646,7 +642,8 @@ class LockSetLogic extends BaseGetXController {
|
||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
|
||||
// state.lockSetInfoData.value = event.keyInfo;
|
||||
state.lockSetInfoData.value = event.lockSetInfoData;
|
||||
// print("event.lockSetInfoData.lockSettingInfo!.autoLockSecond:${event.lockSetInfoData.lockSettingInfo!.autoLockSecond}");
|
||||
blockSetStateCallback();
|
||||
});
|
||||
}
|
||||
|
||||
@ -63,8 +63,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
List<Widget> getListWidget() {
|
||||
print(
|
||||
"state.lockBasicInfo.value.isLockOwner:${state.lockBasicInfo.value.isLockOwner} state.lockBasicInfo.value.keyRight:${state.lockBasicInfo.value.keyRight}");
|
||||
if (state.lockBasicInfo.value.isLockOwner == 1 ||
|
||||
state.lockBasicInfo.value.keyRight == 1) {
|
||||
if (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) {
|
||||
// 超级管理员、授权管理员
|
||||
return getAllWidget();
|
||||
} else {
|
||||
@ -248,10 +247,10 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
titleStr = TranslationLoader.lanKeys!.medium!.tr;
|
||||
break;
|
||||
case 4:
|
||||
titleStr = TranslationLoader.lanKeys!.high!.tr;
|
||||
titleStr = TranslationLoader.lanKeys!.higher!.tr;
|
||||
break;
|
||||
case 5:
|
||||
titleStr = TranslationLoader.lanKeys!.higher!.tr;
|
||||
titleStr = TranslationLoader.lanKeys!.high!.tr;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -288,8 +287,8 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
SizedBox(height: 10.h),
|
||||
// 常开模式
|
||||
Obx(() => Visibility(
|
||||
visible: state.lockFeature.value.passageMode == 1 ? true : false,
|
||||
// visible:true,
|
||||
// visible: state.lockFeature.value.passageMode == 1 ? true : false,
|
||||
visible:true,
|
||||
child: CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr,
|
||||
rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1
|
||||
@ -786,6 +785,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
|
||||
@ -7,7 +7,6 @@ import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_manager.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
@ -93,6 +92,8 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -146,10 +147,18 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendLockSound() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -179,7 +188,11 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
@ -17,7 +20,7 @@ class LockSoundSetPage extends StatefulWidget {
|
||||
State<LockSoundSetPage> createState() => _LockSoundSetPageState();
|
||||
}
|
||||
|
||||
class _LockSoundSetPageState extends State<LockSoundSetPage> {
|
||||
class _LockSoundSetPageState extends State<LockSoundSetPage> with RouteAware {
|
||||
final logic = Get.put(LockSoundSetLogic());
|
||||
final state = Get.find<LockSoundSetLogic>().state;
|
||||
|
||||
@ -203,4 +206,61 @@ class _LockSoundSetPageState extends State<LockSoundSetPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ class LockSoundSetState {
|
||||
|
||||
var isOpenLockSound = false.obs;// 是否开启声音
|
||||
var lockSoundLevel = 0.obs;// 音量等级
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
LockSoundSetState() {
|
||||
var map = Get.arguments;
|
||||
|
||||
@ -102,7 +102,8 @@ class LockTimeLogic extends BaseGetXController{
|
||||
// String dataEime = DateTool().dateToYMDHNSString("$value");
|
||||
// state.dateTime.value = dataEime;
|
||||
|
||||
// _getLockStatus();
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
Toast.show(msg:"锁时间更新成功");
|
||||
break;
|
||||
case 0x06:
|
||||
@ -146,10 +147,18 @@ class LockTimeLogic extends BaseGetXController{
|
||||
|
||||
// 校验时间
|
||||
Future<void> sendTiming() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -170,7 +179,11 @@ class LockTimeLogic extends BaseGetXController{
|
||||
);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -15,7 +18,7 @@ class LockTimePage extends StatefulWidget {
|
||||
State<LockTimePage> createState() => _LockTimePageState();
|
||||
}
|
||||
|
||||
class _LockTimePageState extends State<LockTimePage> {
|
||||
class _LockTimePageState extends State<LockTimePage> with RouteAware{
|
||||
final logic = Get.put(LockTimeLogic());
|
||||
final state = Get.find<LockTimeLogic>().state;
|
||||
|
||||
@ -69,6 +72,65 @@ class _LockTimePageState extends State<LockTimePage> {
|
||||
// ),
|
||||
],
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ class LockTimeState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var dateTime = "".obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
LockTimeState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
}
|
||||
|
||||
}
|
||||
@ -112,6 +112,8 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
configPassageMode();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -165,10 +167,18 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -178,13 +188,37 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var weekStr = "00000000";
|
||||
for (var day in state.weekDays.value) {
|
||||
int index = day % 7; // 将周日的索引转换为 0
|
||||
weekStr = '${weekStr.substring(0, index)}1${weekStr.substring(index + 1)}';
|
||||
}
|
||||
// print("weekStrweekStrweekStr:$weekStr");
|
||||
int number = int.parse(weekStr, radix: 2);
|
||||
|
||||
List<int> list = [];
|
||||
list.add(state.isOpenNormallyOpenMode.value == true ? 1:0);
|
||||
list.add(state.beginTimeMinute.value);
|
||||
list.add(state.endTimeMinute.value);
|
||||
|
||||
int bieginTime = state.beginTimeMinute.value;
|
||||
double bieginDouble = bieginTime / 256;
|
||||
int biegin1 = bieginDouble.toInt();
|
||||
int biegin2 = bieginTime % 256;
|
||||
list.add(biegin1);
|
||||
list.add(biegin2);
|
||||
// list.add(state.beginTimeMinute.value);
|
||||
|
||||
int endTime = state.endTimeMinute.value;
|
||||
double endDouble = endTime / 256;
|
||||
int end1 = endDouble.toInt();
|
||||
int end2 = endTime % 256;
|
||||
list.add(end1);
|
||||
list.add(end2);
|
||||
// list.add(state.endTimeMinute.value);
|
||||
|
||||
list.add(state.isAllDay.value == 1 ? 1:0);
|
||||
list.add(number);
|
||||
list.add(0);
|
||||
list.add(0);
|
||||
print("listlistlistlist:$list");
|
||||
|
||||
IoSenderManage.setSupportFunctionsWithParametersCommand(
|
||||
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
|
||||
@ -198,7 +232,11 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_pickers/pickers.dart';
|
||||
// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
@ -21,7 +23,7 @@ class NormallyOpenModePage extends StatefulWidget {
|
||||
State<NormallyOpenModePage> createState() => _NormallyOpenModePageState();
|
||||
}
|
||||
|
||||
class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
class _NormallyOpenModePageState extends State<NormallyOpenModePage> with RouteAware{
|
||||
final logic = Get.put(NormallyOpenModeLogic());
|
||||
final state = Get.find<NormallyOpenModeLogic>().state;
|
||||
|
||||
@ -318,17 +320,61 @@ class _NormallyOpenModePageState extends State<NormallyOpenModePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// CupertinoSwitch _autoUnlockSwitch() {
|
||||
// return CupertinoSwitch(
|
||||
// activeColor: CupertinoColors.activeBlue,
|
||||
// trackColor: CupertinoColors.systemGrey5,
|
||||
// thumbColor: CupertinoColors.white,
|
||||
// value: state.isOpenAutomaticUnLock.value,
|
||||
// onChanged: (value) {
|
||||
// setState(() {
|
||||
// state.isOpenAutomaticUnLock.value = value;
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import '../lockSet/lockSetInfo_entity.dart';
|
||||
|
||||
class NormallyOpenModeState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
final lockBasicInfo = LockBasicInfo().obs;
|
||||
var lockBasicInfo = LockBasicInfo().obs;
|
||||
var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改
|
||||
|
||||
// var getPassageModeConfigData = GetPassageModeConfigEntity().obs;
|
||||
@ -17,11 +17,17 @@ class NormallyOpenModeState{
|
||||
var beginTimeMinute = 0.obs;// 开始时间分钟
|
||||
var endTimeMinute = 0.obs;// 结束时间分钟
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
NormallyOpenModeState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
lockBasicInfo = lockSetInfoData.value.lockBasicInfo!.obs;
|
||||
|
||||
isOpenNormallyOpenMode.value = lockSetInfoData.value.lockSettingInfo!.passageMode! == 1 ? true : false;
|
||||
|
||||
print("lockBasicInfo.value.isLockOwner:${lockBasicInfo.value.isLockOwner} lockBasicInfo.value.keyRight:${lockBasicInfo.value.keyRight}");
|
||||
if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){
|
||||
isJustForShow.value = false;
|
||||
}else{
|
||||
|
||||
@ -85,6 +85,8 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
_remoteUnlockingOpenOrClose();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -138,7 +140,16 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数) 远程开锁
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -161,7 +172,11 @@ class RemoteUnlockingLogic extends BaseGetXController{
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
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/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -15,7 +18,7 @@ class RemoteUnlockingPage extends StatefulWidget {
|
||||
State<RemoteUnlockingPage> createState() => _RemoteUnlockingPageState();
|
||||
}
|
||||
|
||||
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> {
|
||||
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> with RouteAware {
|
||||
final logic = Get.put(RemoteUnlockingLogic());
|
||||
final state = Get.find<RemoteUnlockingLogic>().state;
|
||||
|
||||
@ -69,6 +72,65 @@ class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> {
|
||||
})),
|
||||
],
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ class RemoteUnlockingState{
|
||||
var lockSetInfoData = LockSetInfoData().obs;
|
||||
var remoteEnable = 1.obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
RemoteUnlockingState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
|
||||
@ -87,6 +87,8 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
_setLockSetGeneralSetting();
|
||||
break;
|
||||
case 0x06:
|
||||
@ -140,10 +142,18 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendBurglarAlarm() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
|
||||
if (connectionState == DeviceConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -164,7 +174,11 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
privateKey: getPrivateKeyList);
|
||||
} else if (connectionState == DeviceConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
showBlueConnetctToast();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
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 '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
@ -15,7 +19,7 @@ class ResetButtonPage extends StatefulWidget {
|
||||
State<ResetButtonPage> createState() => _ResetButtonPageState();
|
||||
}
|
||||
|
||||
class _ResetButtonPageState extends State<ResetButtonPage> {
|
||||
class _ResetButtonPageState extends State<ResetButtonPage> with RouteAware {
|
||||
final logic = Get.put(ResetButtonLogic());
|
||||
final state = Get.find<ResetButtonLogic>().state;
|
||||
|
||||
@ -78,10 +82,96 @@ class _ResetButtonPageState extends State<ResetButtonPage> {
|
||||
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
logic.sendBurglarAlarm();
|
||||
showDeletAlertTipDialog(context);
|
||||
})),
|
||||
],
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertTipDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: Text('确定要${state.resetButtonEnable.value == 1 ? TranslationLoader.lanKeys!.open!.tr : TranslationLoader.lanKeys!.close!.tr}重置键?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
logic.sendBurglarAlarm();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
print("lockSet===didPush");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 返回上一个界面 当前界面即将消失
|
||||
@override
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
print("lockSet===didPop");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
print("lockSet===didPopNext");
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
print("lockSet===didPushNext");
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
BlueManage().stopScan();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@ class ResetButtonState{
|
||||
|
||||
var resetButtonEnable = 1.obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
ResetButtonState() {
|
||||
var map = Get.arguments;
|
||||
lockSetInfoData.value = map["lockSetInfoData"];
|
||||
|
||||
@ -55,7 +55,6 @@ class MineSetLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
UdpHelp().closeUDP();
|
||||
logOut();
|
||||
// BlueManage().stopScan();
|
||||
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
||||
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
||||
}
|
||||
|
||||
@ -53,7 +53,9 @@ class UdpHelp {
|
||||
}
|
||||
|
||||
void closeUDP() {
|
||||
udpHeartTimer!.cancel();
|
||||
if(udpHeartTimer != null){
|
||||
udpHeartTimer!.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user