Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
dd93c64ea5
@ -703,6 +703,8 @@
|
||||
"编辑成功": "Edit success",
|
||||
"厂商": "Manufacturer",
|
||||
"型号": "Model",
|
||||
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.",
|
||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.",
|
||||
|
||||
"相机": "camera",
|
||||
"相册": "photos",
|
||||
|
||||
@ -705,6 +705,8 @@
|
||||
"请输入wifi名称": "请输入wifi名称",
|
||||
"厂商": "厂商",
|
||||
"型号": "型号",
|
||||
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。",
|
||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
|
||||
|
||||
"相机": "相机",
|
||||
"相册": "相册",
|
||||
|
||||
@ -707,6 +707,8 @@
|
||||
"请输入wifi名称": "请输入wifi名称",
|
||||
"厂商": "厂商",
|
||||
"型号": "型号",
|
||||
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。",
|
||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
|
||||
|
||||
"相机": "相机",
|
||||
"相册": "相册",
|
||||
|
||||
@ -72,11 +72,13 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
|
||||
// PwdNo
|
||||
subData.add(pwdNo!);
|
||||
AppLog.log("pwdNo:$pwdNo");
|
||||
|
||||
// pwd 20
|
||||
int pwdLength = utf8.encode(pwd!).length;
|
||||
subData.addAll(utf8.encode(pwd!));
|
||||
subData = getFixedLengthList(subData, 20 - pwdLength);
|
||||
AppLog.log("pwd:$pwd");
|
||||
|
||||
// UseCountLimit
|
||||
subData.add(useCountLimit!);
|
||||
@ -84,6 +86,8 @@ class SenderCustomPasswordsCommand extends SenderProtocol {
|
||||
// token
|
||||
subData.addAll(token!);
|
||||
|
||||
AppLog.log("startTime:$startTime endTime:$endTime");
|
||||
|
||||
// startTime 4
|
||||
subData.add((startTime! & 0xff000000) >> 24);
|
||||
subData.add((startTime! & 0xff0000) >> 16);
|
||||
|
||||
@ -49,8 +49,8 @@ class _AddICCardPageState extends State<AddICCardPage> with RouteAware {
|
||||
SizedBox(height: 120.h),
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 50.h,
|
||||
// padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h),
|
||||
// height: 50.h,
|
||||
padding: EdgeInsets.all(10.w),
|
||||
margin: EdgeInsets.only(
|
||||
left: 15.w, right: 15.w, top: 10.h, bottom: 10.h),
|
||||
// color: AppColors.blackColor,
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart';
|
||||
@ -64,13 +61,18 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
cancelBlueConnetctToastTimer();
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
if (reply.data[5] > 0) {
|
||||
var dataLength = reply.data[5];
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
if(reply.data.length < 8){
|
||||
return;
|
||||
}
|
||||
var getList = splitList(reply.data, 8);
|
||||
// AppLog.log("getList:$getList");
|
||||
var uploadList = [];
|
||||
@ -94,11 +96,34 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
|
||||
if(dataLength == 20){
|
||||
state.ifHaveNext = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限 需要鉴权
|
||||
|
||||
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
//
|
||||
// var token = await Storage.getStringList(saveBlueToken);
|
||||
// List<int> getTokenList = changeStringListToIntList(token!);
|
||||
//
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
//
|
||||
// IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
// keyID: BlueManage().connectDeviceName,
|
||||
// userID: await Storage.getUid(),
|
||||
// logsCount: int.parse(pageSize),
|
||||
// // time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
// time: state.operateDate,
|
||||
// token: getTokenList,
|
||||
// needAuthor: 1,
|
||||
// publicKey: getPublicKeyList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// );
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
@ -134,7 +159,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
@ -151,13 +176,12 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
EasyLoading.show();
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: 20,
|
||||
logsCount: int.parse(pageSize),
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
@ -216,7 +240,8 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000);
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
senderReferEventRecordTime();
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +251,12 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
mockNetworkDataRequest();
|
||||
if(state.ifHaveNext == true){
|
||||
getLockRecordLastUploadDataTime();
|
||||
}else{
|
||||
pageNo = 1;
|
||||
mockNetworkDataRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,6 +294,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
getLockRecordLastUploadDataTime();
|
||||
// senderReferEventRecordTime();
|
||||
// senderReferEventRecordNumber();
|
||||
_initReplySubscription();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,8 @@ class DoorLockLogState {
|
||||
];
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var operateDate = 0; // 按日期查询消息记录的时间戳
|
||||
var ifHaveNext = false; // 页码
|
||||
|
||||
DoorLockLogState() {
|
||||
keyInfos.value = Get.arguments["keyInfo"];
|
||||
|
||||
@ -245,7 +245,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
leftTitel: "是否是管理员".tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
|
||||
@ -245,7 +245,7 @@ class _AddIrisTypePageState extends State<AddIrisTypePage> {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
leftTitel: "是否是管理员".tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
|
||||
@ -108,7 +108,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: state.netTime,
|
||||
openTime: getNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: tokenData,
|
||||
needAuthor: 1,
|
||||
@ -160,10 +160,16 @@ class LockDetailLogic extends BaseGetXController {
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
if (reply.data[5] > 0) {
|
||||
var dataLength = reply.data[5];
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 6);
|
||||
// 把得到的数据按8位分割成数组 然后塞进一个新的数组里面
|
||||
var getList = splitList(reply.data, 8);
|
||||
if(reply.data.length < 8){
|
||||
await BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
return;
|
||||
}
|
||||
var uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
var indexList = getList[i];
|
||||
@ -184,14 +190,22 @@ class LockDetailLogic extends BaseGetXController {
|
||||
uploadList.add(indexMap);
|
||||
}
|
||||
lockRecordUploadData(uploadList);
|
||||
await BlueManage().disconnect();
|
||||
|
||||
if(dataLength == 20){
|
||||
senderReferEventRecordTime();
|
||||
}else{
|
||||
await BlueManage().disconnect();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
default:
|
||||
BlueManage().disconnect();
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -329,7 +343,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
openMode: state.openDoorModel,
|
||||
openTime: state.netTime,
|
||||
openTime: getNetTime(),
|
||||
onlineToken: state.lockNetToken,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
@ -351,10 +365,12 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime(int time) async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: () {
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -369,7 +385,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
userID: await Storage.getUid(),
|
||||
logsCount: 20,
|
||||
// time:DateTime.now().millisecondsSinceEpoch~/1000,
|
||||
time: time,
|
||||
time: state.operateDate,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
@ -379,17 +395,21 @@ class LockDetailLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async{
|
||||
var entity = await ApiRepository.to.getServerDatetimeData(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
state.netTime = entity.data!.date!.toString().length > 10 ? entity.data!.date!~/ 1000 : entity.data!.date!;
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
|
||||
}
|
||||
}
|
||||
|
||||
int getNetTime(){
|
||||
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
|
||||
}
|
||||
|
||||
// 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口
|
||||
void getLockNetToken() async {
|
||||
LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
|
||||
@ -430,7 +450,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000);
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
senderReferEventRecordTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
});
|
||||
}
|
||||
|
||||
void loadData() {
|
||||
Future<void> loadData() async {
|
||||
state.keyInfos.value = widget.lockListInfoItemEntity;
|
||||
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
|
||||
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||
@ -126,8 +126,11 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
|
||||
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
|
||||
Storage.setStringList(saveBlueToken, saveTokenList);
|
||||
bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken);
|
||||
if(!ifHaveKey){
|
||||
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
|
||||
Storage.setStringList(saveBlueToken, saveTokenList);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -14,7 +14,7 @@ class LockDetailState {
|
||||
StreamSubscription? lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent;
|
||||
|
||||
String lockNetToken = "";
|
||||
int netTime = 0;
|
||||
int differentialTime = 0;
|
||||
int lockUserNo = 0;
|
||||
var senderUserId = 0;
|
||||
var isOnlyOneData = false;
|
||||
@ -46,6 +46,7 @@ class LockDetailState {
|
||||
final PageController pageController = PageController();
|
||||
var currentPage = 0.obs;
|
||||
|
||||
var operateDate = 0; // 按日期查询消息记录的时间戳
|
||||
|
||||
// LockDetailState() {
|
||||
// Map map = Get.arguments;
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
import '../../lockSet/lockSet_logic.dart';
|
||||
@ -24,6 +26,7 @@ class BasicInformationLogic extends BaseGetXController{
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
AppLog.log("厂商 vendor:${state.lockBasicInfo.value.vendor} 型号 model:${state.lockBasicInfo.value.model}");
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -53,16 +53,16 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
|
||||
"${state.lockBasicInfo.value.mac??""}/${state.lockBasicInfo.value.lockId??""}",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "厂商".tr,
|
||||
rightTitle: state.lockBasicInfo.value.vendor ??"",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: true)),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "型号".tr,
|
||||
rightTitle: state.lockBasicInfo.value.model ??"",
|
||||
allHeight: 70.h,
|
||||
isHaveLine: false)),
|
||||
// Obx(() => CommonItem(
|
||||
// leftTitel: "厂商".tr,
|
||||
// rightTitle: state.lockBasicInfo.value.vendor ??"",
|
||||
// allHeight: 70.h,
|
||||
// isHaveLine: true)),
|
||||
// Obx(() => CommonItem(
|
||||
// leftTitel: "型号".tr,
|
||||
// rightTitle: state.lockBasicInfo.value.model ??"",
|
||||
// allHeight: 70.h,
|
||||
// isHaveLine: false)),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
|
||||
@ -245,7 +245,7 @@ class _AddPalmTypePageState extends State<AddPalmTypePage> {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
leftTitel: "是否是管理员".tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
|
||||
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
@ -24,11 +25,8 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 设置自定义密码
|
||||
AppLog.log("ifCurrentScreen:${state.ifCurrentScreen.value}");
|
||||
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
@ -36,7 +34,11 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
deletePwdRequest();
|
||||
if(state.isDeletPasswordKey.value == true){
|
||||
deletePwdRequest();
|
||||
}else{
|
||||
updatePwdRequest(2);
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
@ -46,14 +48,18 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
keyID:state.itemData.value.keyboardPwdId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.keyboardUserNo.value,
|
||||
pwd: "000000",
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
pwdNo: state.itemData.value.pwdUserNo!,
|
||||
pwd: state.isDeletPasswordKey.value == true ? "000000" : state.inputPwdController.text,
|
||||
useCountLimit: state.isDeletPasswordKey.value == true ? 0 : 0xff,
|
||||
startTime:state.itemData.value.startDate! ~/ 1000,
|
||||
endTime:state.itemData.value.endDate! ~/ 1000,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
@ -77,6 +83,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
deleteType:1);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功".tr, something: (){
|
||||
eventBus.fire(GetPasswordListRefreshUI());
|
||||
Get.back(result: "deletScuess");
|
||||
});
|
||||
}
|
||||
@ -111,7 +118,7 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作删除密码
|
||||
// 设置自定义密码 这里用作修改或者删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
|
||||
showEasyLoading();
|
||||
@ -130,14 +137,27 @@ class PasswordKeyDetailLogic extends BaseGetXController {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
// IoSenderManage.senderCustomPasswordsCommand(
|
||||
// keyID:state.keyId.value.toString(),
|
||||
// userID:await Storage.getUid(),
|
||||
// pwdNo: state.keyboardUserNo.value,
|
||||
// pwd: "000000",
|
||||
// useCountLimit: 0,
|
||||
// startTime:0x11223344,
|
||||
// endTime:0x11223344,
|
||||
// needAuthor: 1,
|
||||
// isBeforeAddUser: false,
|
||||
// signKey: signKeyDataList,
|
||||
// privateKey: getPrivateKeyList,
|
||||
// token: getTokenList);
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.keyId.value.toString(),
|
||||
keyID:state.itemData.value.keyboardPwdId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.keyboardUserNo.value,
|
||||
pwd: "000000",
|
||||
useCountLimit: 0,
|
||||
startTime:0x11223344,
|
||||
endTime:0x11223344,
|
||||
pwdNo: state.itemData.value.pwdUserNo!,
|
||||
pwd: state.isDeletPasswordKey.value == true ? "000000" : state.inputPwdController.text,
|
||||
useCountLimit: state.isDeletPasswordKey.value == true ? 0 : 0xff,
|
||||
startTime:state.itemData.value.startDate! ~/ 1000,
|
||||
endTime:state.itemData.value.endDate! ~/ 1000,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
|
||||
@ -201,7 +201,15 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> with Rout
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, (){
|
||||
logic.senderCustomPasswords();
|
||||
state.isDeletPasswordKey.value = true;
|
||||
state.ifCurrentScreen.value = true;
|
||||
if(state.itemData.value.isCustom! == 1){
|
||||
// 自定义密码
|
||||
logic.senderCustomPasswords();
|
||||
}else{
|
||||
// 非自定义密码
|
||||
logic.deletePwdRequest();
|
||||
}
|
||||
});
|
||||
}),
|
||||
],
|
||||
@ -243,11 +251,18 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> with Rout
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
logic.updatePwdRequest(inputController == state.inputNameController ? 1 : 2);
|
||||
state.isDeletPasswordKey.value = false;
|
||||
if(inputController == state.inputNameController){
|
||||
// 修改密码名称
|
||||
logic.updatePwdRequest(1);
|
||||
}else{
|
||||
// 修改密码
|
||||
state.ifCurrentScreen.value = true;
|
||||
logic.senderCustomPasswords();
|
||||
}
|
||||
},
|
||||
cancelClick: () {
|
||||
Navigator.pop(context);
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@ -17,6 +17,7 @@ class PasswordKeyDetailState {
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
final passwordKeyNumber = "".obs;// 密码号
|
||||
var isDeletPasswordKey = true.obs;// 是否删除卡
|
||||
|
||||
PasswordKeyDetailState() {
|
||||
Map map = Get.arguments;
|
||||
|
||||
@ -1,14 +1,74 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_senderCustomPasswords.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
|
||||
class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
|
||||
PasswordKeyDetailChangeDateState state = PasswordKeyDetailChangeDateState();
|
||||
|
||||
// 监听设备返回的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
// 设置自定义密码
|
||||
if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
state.sureBtnState.value = 0;
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
updatePwdRequest();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = reply.data.sublist(5, 9);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.itemData.value.keyboardPwdId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.itemData.value.pwdUserNo!,
|
||||
pwd: state.itemData.value.keyboardPwd!.toString(),
|
||||
useCountLimit: 0xff,
|
||||
startTime:state.itemData.value.startDate! ~/ 1000,
|
||||
endTime:state.itemData.value.endDate! ~/ 1000,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: token);
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
cancelBlueConnetctToastTimer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//更新密码请求
|
||||
Future<void> updatePwdRequest() async {
|
||||
var beginTimeTimestamp = state.itemData.value.startDate! ~/ 1000;
|
||||
@ -47,5 +107,67 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自定义密码 这里用作修改或者删除密码
|
||||
Future<void> senderCustomPasswords() async {
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderCustomPasswordsCommand(
|
||||
keyID:state.itemData.value.keyboardPwdId!.toString(),
|
||||
userID:await Storage.getUid(),
|
||||
pwdNo: state.itemData.value.pwdUserNo!,
|
||||
pwd: state.itemData.value.keyboardPwd!.toString(),
|
||||
useCountLimit: 0xff,
|
||||
startTime:state.itemData.value.startDate! ~/ 1000,
|
||||
endTime:state.itemData.value.endDate! ~/ 1000,
|
||||
needAuthor: 1,
|
||||
isBeforeAddUser: false,
|
||||
signKey: signKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList);
|
||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
// getPasswordTypeUpdateIndexAction();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/commonItem.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/dateTool.dart';
|
||||
|
||||
class PasswordKeyDetailChangeDatePage extends StatefulWidget {
|
||||
const PasswordKeyDetailChangeDatePage({Key? key}) : super(key: key);
|
||||
@ -19,8 +21,7 @@ class PasswordKeyDetailChangeDatePage extends StatefulWidget {
|
||||
_PasswordKeyDetailChangeDatePage();
|
||||
}
|
||||
|
||||
class _PasswordKeyDetailChangeDatePage
|
||||
extends State<PasswordKeyDetailChangeDatePage> {
|
||||
class _PasswordKeyDetailChangeDatePage extends State<PasswordKeyDetailChangeDatePage> with RouteAware {
|
||||
final logic = Get.put(PasswordKeyDetailChangeDateLogic());
|
||||
final state = Get.find<PasswordKeyDetailChangeDateLogic>().state;
|
||||
|
||||
@ -41,7 +42,7 @@ class _PasswordKeyDetailChangeDatePage
|
||||
),
|
||||
onPressed: () {
|
||||
// if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) {
|
||||
logic.updatePwdRequest();
|
||||
logic.senderCustomPasswords();
|
||||
// }
|
||||
},
|
||||
),
|
||||
@ -91,12 +92,10 @@ class _PasswordKeyDetailChangeDatePage
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDH,
|
||||
onConfirm: (p) {
|
||||
state.selectEffectiveDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) {
|
||||
state.selectEffectiveDate.value = DateTool().getYMDHNDateString(p, 1);
|
||||
// state.effectiveDateTime = DateTime.parse(state.selectEffectiveDate.value);
|
||||
state.itemData.value.startDate = DateTime.parse(state.selectEffectiveDate.value).millisecondsSinceEpoch; //更新开始时间
|
||||
state.itemData.value.startDate = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1); //更新开始时间
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -106,19 +105,63 @@ class _PasswordKeyDetailChangeDatePage
|
||||
: getEndDate,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDH,
|
||||
onConfirm: (p) {
|
||||
state.selectFailureDate.value =
|
||||
'${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
|
||||
// state.failureDateTime = DateTime.parse(state.selectFailureDate.value);
|
||||
state.itemData.value.endDate = DateTime.parse(state.selectFailureDate.value).millisecondsSinceEpoch; //更新结束时间
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) {
|
||||
state.selectFailureDate.value = DateTool().getYMDHNDateString(p, 1);
|
||||
state.itemData.value.endDate = DateTool().dateToTimestamp(state.selectFailureDate.value, 1); //更新结束时间
|
||||
});
|
||||
})),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
@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();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
/// 从下级返回 当前界面即将出现
|
||||
@override
|
||||
void didPopNext() {
|
||||
super.didPopNext();
|
||||
state.ifCurrentScreen.value = true;
|
||||
}
|
||||
|
||||
/// 进入下级界面 当前界面即将消失
|
||||
@override
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
logic.dismissEasyLoading();
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,36 +4,17 @@ import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKe
|
||||
|
||||
class PasswordKeyDetailChangeDateState {
|
||||
final itemData = PasswordKeyListItem().obs;
|
||||
// final TextEditingController inputPwdController = TextEditingController();
|
||||
// final TextEditingController inputNameController = TextEditingController();
|
||||
// final changeType = '1'.obs; //1-通过APP走蓝牙修改,不传默认1,必需先通过APP SDK蓝牙修改后调用该接口 2-通过网关或WiFi锁修改,如果是WiFi锁或有连接网关,则可以传2,直接调用该接口修改生效
|
||||
// final isCoerced = '1'.obs; //胁迫指纹:1;非胁迫指纹:2(胁迫指纹开锁触发报警)
|
||||
// final hoursStart = 0.obs;
|
||||
// final hoursEnd = 0.obs;
|
||||
// final startDate = 0.obs;
|
||||
// final endDate = 0.obs;
|
||||
// final pwdId = ''.obs;
|
||||
// final lockId = 0.obs;
|
||||
// final fromType = ''.obs;
|
||||
|
||||
final selectEffectiveDate = ''.obs; //生效时间
|
||||
final selectFailureDate = ''.obs; //失效时间
|
||||
// DateTime effectiveDateTime = DateTime.now();
|
||||
// DateTime failureDateTime = DateTime.now();
|
||||
// final endDay = ''.obs;
|
||||
// final startDay = ''.obs;
|
||||
// final weekDays = [].obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用)
|
||||
|
||||
PasswordKeyDetailChangeDateState() {
|
||||
Map map = Get.arguments;
|
||||
// itemData.value = map["itemData"];
|
||||
if ((map["itemData"] != null)) {
|
||||
itemData.value = map["itemData"];
|
||||
}
|
||||
// if ((map["pwdId"] != null)) {
|
||||
// pwdId.value = map["pwdId"];
|
||||
// }
|
||||
// if ((map["lockId"] != null)) {
|
||||
// lockId.value = map["lockId"];
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart';
|
||||
@ -183,8 +184,9 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
DateTime sendDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
|
||||
DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
|
||||
DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
|
||||
int starHour = startDateStr.hour;
|
||||
int endHour = endDateStr.hour;
|
||||
int starHour = indexEntity.hoursStart!;
|
||||
int endHour = indexEntity.hoursEnd!;
|
||||
// AppLog.log('indexEntity.keyboardPwdName:${indexEntity.keyboardPwdName} indexEntity.keyboardPwdStatus:${indexEntity.keyboardPwdStatus} indexEntity.startDate!${indexEntity.startDate!} indexEntity.endDate!${indexEntity.endDate!} starHour:$starHour endHour:$endHour');
|
||||
|
||||
switch (getPwdType) {
|
||||
case 1:
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../../../../lockMian/entity/lockListInfo_entity.dart';
|
||||
|
||||
class PasswordKeyManagePage extends StatefulWidget {
|
||||
const PasswordKeyManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PasswordKeyManagePage> createState() => _PasswordKeyManagePageState();
|
||||
}
|
||||
|
||||
class _PasswordKeyManagePageState extends State<PasswordKeyManagePage> {
|
||||
var index = 0;
|
||||
late LockListInfoItemEntity keyInfo;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
dynamic obj = ModalRoute.of(context)?.settings.arguments;
|
||||
if (obj != null && (obj["keyInfo"] != null)) {
|
||||
keyInfo = obj["keyInfo"];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.getPassword!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
PasswordKeyManageTabbarPage(
|
||||
initialIndex: index,
|
||||
keyInfo: keyInfo,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,128 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
import '../passwordKey_perpetual_page.dart';
|
||||
|
||||
class PasswordKeyManageTabbarPage extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
final LockListInfoItemEntity keyInfo;
|
||||
|
||||
PasswordKeyManageTabbarPage(
|
||||
{Key? key, required this.initialIndex, required this.keyInfo})
|
||||
: super(key: key);
|
||||
@override
|
||||
State<PasswordKeyManageTabbarPage> createState() =>
|
||||
_PasswordKeyManageTabbarPageState();
|
||||
}
|
||||
|
||||
class _PasswordKeyManageTabbarPageState extends State<PasswordKeyManageTabbarPage> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "1"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: "3"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "4"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: "5"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
|
||||
_tabController.addListener(() {
|
||||
if (_tabController.animation!.value==_tabController.index){
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
}
|
||||
});
|
||||
// _tabController.addListener(handleTabIndex);
|
||||
}
|
||||
|
||||
// int handleTabIndex() {
|
||||
// // 获取当前选定的标签索引
|
||||
// int currentIndex = _tabController.index;
|
||||
// // 根据索引可以得知用户点击了哪个 item
|
||||
// eventBus.fire(GetPasswordTypeUpdateIndex(currentIndex));
|
||||
// return currentIndex;
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
onTap: (index){
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
|
||||
isScrollable: true,
|
||||
indicatorColor: Colors.red,
|
||||
unselectedLabelColor: Colors.black,
|
||||
unselectedLabelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
),
|
||||
automaticIndicatorColorAdjustment: true,
|
||||
labelColor: AppColors.mainColor,
|
||||
labelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
indicator: CustomUnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
|
||||
strokeCap: StrokeCap.round,
|
||||
width: 30.w),
|
||||
);
|
||||
}
|
||||
|
||||
Tab _tab(ItemView item) {
|
||||
return Tab(
|
||||
// text: item.title,
|
||||
child: Container(
|
||||
// width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12,
|
||||
// margin: EdgeInsets.all(10.w),
|
||||
// color: Colors.red,
|
||||
child: Text(
|
||||
item.title,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: _itemTabs.map((ItemView item) => PasswordKeyPerpetualPage()).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.type});
|
||||
|
||||
final String title;
|
||||
final String type;
|
||||
}
|
||||
@ -4,7 +4,6 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
@ -26,27 +25,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController {
|
||||
|
||||
/// 收到点击密码类型更新
|
||||
/**
|
||||
单次 1 只能在开始时间后6小时内使用一次
|
||||
永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效
|
||||
删除 4 在锁上使用后会删除之前在锁上使用过的密码
|
||||
周未循环 5 在周未开始和结束时间指定时间段内有效
|
||||
每日循环 6 每天开始和结束时间指定时间段内有效
|
||||
工作日循环 7 工作日开始和结束时间指定的时间段内有效
|
||||
周一循环 8 每周一开始和结束时间指定时间段内有效
|
||||
周二循环 9 每周二开始和结束时间指定时间段内有效
|
||||
周三循环 10 每周三开始和结束时间指定时间段内有效
|
||||
周四循环 11 每周四开始和结束时间指定时间段内有效
|
||||
周五循环 12 每周五开始和结束时间指定时间段内有效
|
||||
周六循环 13 每周六开始和结束时间指定时间段内有效
|
||||
周天循环 14 每周日开始和结束时间指定时间段内有效
|
||||
* getKeyType 单次1 永久2 限期3 删除4 周未循环5 每日循环6 工作日循环7 周一循环8 周二循环9 周三循环10 周四循环11 周五循环12 周六循环13 周天循环14
|
||||
*/
|
||||
//获取密码请求
|
||||
Future<void> getKeyboardPwdRequest() async {
|
||||
var startDate = DateTool().dateToTimestamp(state.beginTime.value, 1);
|
||||
var endDate = DateTool().dateToTimestamp(state.endTime.value, 1);
|
||||
String lockId = state.keyInfo.value.lockId.toString();
|
||||
String getKeyType = state.widgetType.value.toString();
|
||||
String getKeyType = "0";
|
||||
|
||||
if (state.nameController.text.isEmpty) {
|
||||
showToast("请输入姓名".tr);
|
||||
|
||||
@ -93,7 +93,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr)
|
||||
keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr)
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -110,7 +110,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
|
||||
keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr)
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -169,7 +169,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
|
||||
keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr)
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -185,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr)
|
||||
keyBottomWidget("密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr)
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -286,7 +286,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> wit
|
||||
children: [
|
||||
// SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
leftTitel: "是否是管理员".tr,
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
@ -22,7 +23,17 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
|
||||
// 点击连接设备
|
||||
void connect(String deviceName) {
|
||||
showEasyLoading();
|
||||
showTitleEasyLoading("获取锁信息 1/3");
|
||||
// if(state.sureBtnState.value == 1){
|
||||
// return;
|
||||
// }
|
||||
// state.sureBtnState.value = 1;
|
||||
|
||||
// showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
// state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(deviceName, (BluetoothConnectionState state) async {
|
||||
AppLog.log("点击要添加的设备了");
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
@ -37,8 +48,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if (reply is GetPublicKeyReply) {
|
||||
_replyGetPublicKey(reply);
|
||||
}
|
||||
@ -55,6 +65,8 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> _replyGetPublicKey(Reply reply) async {
|
||||
// dismissEasyLoading();
|
||||
|
||||
// 获取公钥
|
||||
switch (reply.status) {
|
||||
case 0x00:
|
||||
@ -67,6 +79,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
|
||||
// 获取私钥
|
||||
AppLog.log("开始获取私钥");
|
||||
showTitleEasyLoading("获取锁信息 2/3");
|
||||
IoSenderManage.getPrivateKey(
|
||||
lockId: BlueManage().connectDeviceName,
|
||||
keyID: "1",
|
||||
@ -76,6 +89,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
needAuthor: 1);
|
||||
break;
|
||||
default:
|
||||
// state.sureBtnState.value = 0;
|
||||
AppLog.log("获取公钥失败");
|
||||
break;
|
||||
}
|
||||
@ -105,9 +119,11 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
(0xff & timestamp[2]) << 8 |
|
||||
(0xFF & timestamp[3]));
|
||||
|
||||
showTitleEasyLoading("获取锁信息 3/3");
|
||||
_getStarLockStatus();
|
||||
break;
|
||||
default:
|
||||
// state.sureBtnState.value = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -286,6 +302,7 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
// state.sureBtnState.value = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ class NearbyLockState {
|
||||
|
||||
RxList<ScanResult> devices = <ScanResult>[].obs;
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
// var sureBtnState = 0.obs;// 0可点击 1 不可点击
|
||||
|
||||
var selectLockName = "".obs;
|
||||
|
||||
var timestampValue = 0;
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
|
||||
FutureOr<dynamic> responseLogInterceptor(Request request, Response response) {
|
||||
AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}');
|
||||
print('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}');
|
||||
EasyLoading.dismiss(animation: true);
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -57,6 +57,8 @@ class BaseGetXController extends GetxController {
|
||||
|
||||
void dismissEasyLoading() => EasyLoading.dismiss();
|
||||
|
||||
void showTitleEasyLoading(String showContent) => EasyLoading.show(status: showContent);
|
||||
|
||||
Timer? _timer;
|
||||
// CancelableOperation? _operation;
|
||||
void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user