Merge branch 'master' of gitee.com:starlock-cn/app-starlock

This commit is contained in:
Daisy 2024-04-29 15:10:00 +08:00
commit dd93c64ea5
30 changed files with 396 additions and 307 deletions

View File

@ -703,6 +703,8 @@
"编辑成功": "Edit success",
"厂商": "Manufacturer",
"型号": "Model",
"密码生成后请在当日2359前使用一次进行激活否则过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.",
"密码生成后请在当日2359前使用否则过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",

View File

@ -705,6 +705,8 @@
"请输入wifi名称": "请输入wifi名称",
"厂商": "厂商",
"型号": "型号",
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。": "密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。",
"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
"相机": "相机",
"相册": "相册",

View File

@ -707,6 +707,8 @@
"请输入wifi名称": "请输入wifi名称",
"厂商": "厂商",
"型号": "型号",
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。": "密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。",
"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
"相机": "相机",
"相册": "相册",

View File

@ -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);

View File

@ -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,

View File

@ -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();
}
}

View File

@ -47,6 +47,8 @@ class DoorLockLogState {
];
var ifCurrentScreen = true.obs; // ,
var operateDate = 0; //
var ifHaveNext = false; //
DoorLockLogState() {
keyInfos.value = Get.arguments["keyInfo"];

View File

@ -245,7 +245,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProv
return Column(
children: [
CommonItem(
leftTitel: "是否是管理员",
leftTitel: "是否是管理员".tr,
rightTitle: "",
isTipsImg: false,
isHaveRightWidget: true,

View File

@ -245,7 +245,7 @@ class _AddIrisTypePageState extends State<AddIrisTypePage> {
return Column(
children: [
CommonItem(
leftTitel: "是否是管理员",
leftTitel: "是否是管理员".tr,
rightTitle: "",
isTipsImg: false,
isHaveRightWidget: true,

View File

@ -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();
}
}

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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,
),

View File

@ -245,7 +245,7 @@ class _AddPalmTypePageState extends State<AddPalmTypePage> {
return Column(
children: [
CommonItem(
leftTitel: "是否是管理员",
leftTitel: "是否是管理员".tr,
rightTitle: "",
isTipsImg: false,
isHaveRightWidget: true,

View File

@ -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,

View File

@ -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();
},
);
},

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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走蓝牙修改1APP 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"];
// }
}
}

View File

@ -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:

View File

@ -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,
),
],
),
);
}
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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("密码生成后请在当日2359前使用一次进行激活否则过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("密码生成后请在当日2359前使用一次进行激活否则过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("密码生成后请在当日2359前使用一次进行激活否则过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("密码生成后请在当日2359前使用否则过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,

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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}) {