Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release

This commit is contained in:
魏少阳 2024-05-24 10:59:53 +08:00
commit 9bce7316b9
25 changed files with 535 additions and 343 deletions

View File

@ -680,7 +680,7 @@
"密码生成后请在当日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点后未激活则失效。密码激活后有效期内不限次数使用。": "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.", "密码生成后请在当日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.",
"密码生成后请在当日2359前使用否则过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.", "密码生成后请在当日2359前使用否则过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 password is valid until 24 o 'clock on the day of emptying\nEmpty content 1: All passwords except custom generated before 0 o 'clock on the same day (passwords generated after 0 o 'clock on the same day are not affected by the empty password and can continue to be used) \nEmpty content 2: Clear passwords Clear all custom passwords (used and unused) immediately after use \nTo completely clear all passwords, use the Reset All Passwords feature", "清空密码底部提示": "The password is valid until 24 o 'clock on the day of emptying\n Empty Content 1: All passwords generated before 0:00 of the day (Passwords generated after 0:00 of the day are not affected by clearing passwords and can continue to be used) \nEmpty content 2: Clear passwords Clear all custom passwords (used and unused) immediately after use \nTo completely clear all passwords, use the Reset All Passwords feature",
"相机": "camera", "相机": "camera",
"相册": "photos", "相册": "photos",
"读写": "storage", "读写": "storage",

View File

@ -683,7 +683,7 @@
"密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。": "密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。", "密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。": "密码生成后请在当日2359前使用一次进行激活否则过0点后未激活则失效。密码激活后有效期内不限次数使用。",
"密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", "密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后请在当日2359前使用否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
"密码生成后请在当日2359前使用否则过0点后失效。": "密码生成后请在当日2359前使用否则过0点后失效。", "密码生成后请在当日2359前使用否则过0点后失效。": "密码生成后请在当日2359前使用否则过0点后失效。",
"清空密码底部提示": "清空密码当日24点前有效\n清空内容1当日0点前生成的除自定义以外所有密码当日0点后生成的密码不受清空密码影响可继续使用\n清空内容2清空密码使用后立即清除所有自定义密码含使用过和未使用过的\n如需彻底清除所有密码请使用重置所有密码功能", "清空密码底部提示": "清空密码当日24点前有效\n清空内容1当日0点前生成的所有密码当日0点后生成的密码不受清空密码影响可继续使用\n清空内容2清空密码使用后立即清除所有自定义密码含使用过和未使用过的\n如需彻底清除所有密码请使用重置所有密码功能",
"密码不一致哦": "密码不一致哦", "密码不一致哦": "密码不一致哦",
"相机": "相机", "相机": "相机",
"相册": "相册", "相册": "相册",

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

View File

@ -144,12 +144,11 @@ class BlueManage {
if (isAvailable) { if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
try { try {
//android 8 //android 3
final int divisor = Platform.isAndroid ? 3 : 1; final int divisor = Platform.isAndroid ? 3 : 1;
FlutterBluePlus.startScan( FlutterBluePlus.startScan(
continuousDivisor: divisor, continuousDivisor: divisor,
continuousUpdates: true, continuousUpdates: true,
// withServiceData:[ServiceDataFilter()],
withKeywords: <String>[deviceName], withKeywords: <String>[deviceName],
timeout: Duration(seconds: timeout)); timeout: Duration(seconds: timeout));
final Completer<dynamic> completer = Completer<dynamic>(); final Completer<dynamic> completer = Completer<dynamic>();
@ -317,7 +316,7 @@ class BlueManage {
if (isAddEquipment == false && isExistDevice == false) { if (isAddEquipment == false && isExistDevice == false) {
//使 //使
startScanSingle(deviceName, 10, (List<ScanResult> scanDevices) { startScanSingle(deviceName, 15, (List<ScanResult> scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack, _connectDevice(scanDevices, deviceName, connectStateCallBack,
isAddEquipment: isAddEquipment); isAddEquipment: isAddEquipment);
}); });

View File

@ -20,14 +20,13 @@ class AddICCardState{
final startDate = "".obs; final startDate = "".obs;
final weekDay = [].obs; final weekDay = [].obs;
final fromType = 0.obs; final fromType = 0.obs;
final effectiveDateTime = "".obs;// final effectiveDateTime = "".obs; //
final failureDateTime = "".obs;// final failureDateTime = "".obs; //
final selectType = "0".obs;// 0 1 2 final selectType = "0".obs; // 0 1 2
AddICCardState() { AddICCardState() {
Map map = Get.arguments; Map map = Get.arguments;
lockId.value = map["lockId"]; lockId.value = map["lockId"];
endDate.value = "${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
addType.value = map["addType"]; addType.value = map["addType"];
cardName.value = map["cardName"]; cardName.value = map["cardName"];
cardNumber.value = map["cardNumber"]; cardNumber.value = map["cardNumber"];
@ -40,5 +39,12 @@ class AddICCardState{
effectiveDateTime.value = map["effectiveTime"]; effectiveDateTime.value = map["effectiveTime"];
failureDateTime.value = map["failureTime"]; failureDateTime.value = map["failureTime"];
selectType.value = map["selectType"]; selectType.value = map["selectType"];
//
if (selectType.value == '2') {
endDate.value =
"${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
} else {
endDate.value = map["endDate"];
}
} }
} }

View File

@ -153,12 +153,15 @@ class _CardDetailPageState extends State<CardDetailPage> with RouteAware {
})))), })))),
Container(height: 10.h), Container(height: 10.h),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.additive!.tr, leftTitel: TranslationLoader.lanKeys!.additive!.tr,
rightTitle: state.adder.value,)), isHaveLine: true,
rightTitle: state.adder.value,
)),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.addTime!.tr, leftTitel: TranslationLoader.lanKeys!.addTime!.tr,
rightTitle: DateTool().dateToYMDHNString(state.addTime.value.toString()), rightTitle: DateTool()
)), .dateToYMDHNString(state.addTime.value.toString()),
)),
SizedBox(height: 10.h), SizedBox(height: 10.h),
Obx(() => CommonItem( Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr, leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,

View File

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:date_format/date_format.dart'; import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -409,10 +410,23 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
else else
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(100.w), borderRadius: BorderRadius.circular(100.w),
child: Image.network( child: CachedNetworkImage(
headUrl,
width: 60.w, width: 60.w,
height: 60.w, height: 60.w,
imageUrl: headUrl,
placeholder: (BuildContext context, String url) =>
const SizedBox(),
errorWidget:
(BuildContext context, String url, Object error) =>
Container(
color: const Color(0xffEBF4FF),
child: Center(
child: Text(
name!.substring(0, 2),
style: TextStyle(
fontSize: 22.sp, color: const Color(0xff7F9CF5)),
)),
),
), ),
), ),
SizedBox(width: 20.w), SizedBox(width: 20.w),

View File

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
@ -154,10 +155,23 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
else else
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(100.w), borderRadius: BorderRadius.circular(100.w),
child: Image.network( child: CachedNetworkImage(
staffListItem.headurl!,
width: 60.w, width: 60.w,
height: 60.w, height: 60.w,
imageUrl: staffListItem.headurl!,
placeholder: (BuildContext context, String url) =>
const SizedBox(),
errorWidget:
(BuildContext context, String url, Object error) =>
Container(
color: const Color(0xffEBF4FF),
child: Center(
child: Text(
staffListItem.staffName!.substring(0, 2),
style: TextStyle(
fontSize: 22.sp, color: const Color(0xff7F9CF5)),
)),
),
), ),
), ),
SizedBox( SizedBox(

View File

@ -26,14 +26,13 @@ class AddFaceState {
final startDate = "".obs; final startDate = "".obs;
final weekDay = [].obs; final weekDay = [].obs;
final fromType = 0.obs; final fromType = 0.obs;
final effectiveDateTime = "".obs;// final effectiveDateTime = "".obs; //
final failureDateTime = "".obs;// final failureDateTime = "".obs; //
final selectType = "0".obs;// 0 1 2 final selectType = "0".obs; // 0 1 2
AddFaceState() { AddFaceState() {
Map map = Get.arguments; Map map = Get.arguments;
lockId.value = map["lockId"]; lockId.value = map["lockId"];
endDate.value = "${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
addType.value = map["addType"]; addType.value = map["addType"];
faceName.value = map["faceName"]; faceName.value = map["faceName"];
faceType.value = map["faceType"]; faceType.value = map["faceType"];
@ -48,5 +47,12 @@ class AddFaceState {
effectiveDateTime.value = map["effectiveTime"]; effectiveDateTime.value = map["effectiveTime"];
failureDateTime.value = map["failureTime"]; failureDateTime.value = map["failureTime"];
selectType.value = map["selectType"]; selectType.value = map["selectType"];
//
if (selectType.value == '2') {
endDate.value =
"${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
} else {
endDate.value = map["endDate"];
}
} }
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -17,7 +16,8 @@ class AddFingerprintPage extends StatefulWidget {
State<AddFingerprintPage> createState() => _AddFingerprintPageState(); State<AddFingerprintPage> createState() => _AddFingerprintPageState();
} }
class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware { class _AddFingerprintPageState extends State<AddFingerprintPage>
with RouteAware {
final logic = Get.put(AddFingerprintLogic()); final logic = Get.put(AddFingerprintLogic());
final state = Get.find<AddFingerprintLogic>().state; final state = Get.find<AddFingerprintLogic>().state;
@ -26,7 +26,8 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}", barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}",
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor), backgroundColor: AppColors.mainColor),
body: ListView( body: ListView(
@ -35,62 +36,66 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
height: 50.h, height: 50.h,
), ),
Obx(() => Visibility( Obx(() => Visibility(
visible:logic.state.ifConnectScuess.value, visible: logic.state.ifConnectScuess.value,
child: Container( child: Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w), padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: Column( child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Expanded( Row(
child: Text( mainAxisAlignment: MainAxisAlignment.center,
"请将您的手指按下".tr, children: [
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, Expanded(
textAlign: TextAlign.center, child: Text(
maxLines:null, "请将您的手指按下".tr,
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600), // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
), textAlign: TextAlign.center,
maxLines: null,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w600),
),
),
],
),
SizedBox(height: 10.h),
Text(
"(${state.regIndex.value}/${state.maxRegCount.value})",
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
textAlign: TextAlign.center,
maxLines: null,
style: TextStyle(fontSize: 24.sp),
), ),
], ],
), ),
SizedBox(height: 10.h),
Text(
"(${state.regIndex.value}/${state.maxRegCount.value})",
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
textAlign: TextAlign.center,
maxLines:null,
style: TextStyle(fontSize: 24.sp),
),
],
),
),
)),
Obx(() => Visibility(
visible:!logic.state.ifConnectScuess.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Text(
"尝试连接设备...".tr,
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
textAlign: TextAlign.center,
maxLines:null,
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
),
), ),
], )),
), Obx(() => Visibility(
)), visible: !logic.state.ifConnectScuess.value,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Text(
"尝试连接设备...".tr,
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
textAlign: TextAlign.center,
maxLines: null,
style: TextStyle(
fontSize: 24.sp, fontWeight: FontWeight.w600),
),
),
],
),
)),
SizedBox( SizedBox(
height: 100.h, height: 100.h,
), ),
Obx(() => Image.asset( Obx(
getIconNumber(state.regIndex.value), () => Image.asset(
width: 185.w, getIconNumber(state.regIndex.value),
height: 295.h, width: 185.w,
),), height: 295.h,
),
),
SizedBox( SizedBox(
height: 120.h, height: 120.h,
), ),
@ -104,7 +109,7 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
"根据提示,抬起手指后再进行下一次指纹采集".tr, "根据提示,抬起手指后再进行下一次指纹采集".tr,
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, // TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
textAlign: TextAlign.center, textAlign: TextAlign.center,
maxLines:null, maxLines: null,
style: TextStyle(fontSize: 24.sp), style: TextStyle(fontSize: 24.sp),
), ),
), ),
@ -116,9 +121,9 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
); );
} }
String getIconNumber(int number){ String getIconNumber(int number) {
String iconPath = ""; String iconPath = "";
switch(number){ switch (number) {
case 0: case 0:
iconPath = 'images/main/icon_addFingerprint_fingerprint_one.png'; iconPath = 'images/main/icon_addFingerprint_fingerprint_one.png';
break; break;
@ -134,8 +139,11 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
case 4: case 4:
iconPath = 'images/main/icon_addFingerprint_fingerprint_five.png'; iconPath = 'images/main/icon_addFingerprint_fingerprint_five.png';
break; break;
case 5:
iconPath = 'images/main/icon_addFingerprint_fingerprint_six.png';
break;
default: default:
iconPath = 'images/main/icon_addFingerprint_fingerprint_four.png'; iconPath = 'images/main/icon_addFingerprint_fingerprint_six.png';
break; break;
} }
return iconPath; return iconPath;
@ -172,7 +180,7 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
logic.cancelBlueConnetctToastTimer(); logic.cancelBlueConnetctToastTimer();
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
if(state.ifAddState.value){ if (state.ifAddState.value) {
logic.senderCancelAddFingerprintCommand(); logic.senderCancelAddFingerprintCommand();
} }
} }
@ -192,5 +200,4 @@ class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
} }
} }

View File

@ -22,14 +22,13 @@ class AddFingerprintState{
final startDate = "".obs; final startDate = "".obs;
final weekDay = [].obs; final weekDay = [].obs;
final fromType = 1.obs; final fromType = 1.obs;
final effectiveDateTime = "".obs;// final effectiveDateTime = "".obs; //
final failureDateTime = "".obs;// final failureDateTime = "".obs; //
final selectType = "0".obs;// 0 1 2 final selectType = "0".obs; // 0 1 2
AddFingerprintState() { AddFingerprintState() {
Map map = Get.arguments; Map map = Get.arguments;
lockId.value = map["lockId"]; lockId.value = map["lockId"];
endDate.value = "${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
addType.value = map["addType"]; addType.value = map["addType"];
fingerprintName.value = map["fingerprintName"]; fingerprintName.value = map["fingerprintName"];
fingerprintType.value = map["fingerprintType"]; fingerprintType.value = map["fingerprintType"];
@ -42,5 +41,12 @@ class AddFingerprintState{
effectiveDateTime.value = map["effectiveTime"]; effectiveDateTime.value = map["effectiveTime"];
failureDateTime.value = map["failureTime"]; failureDateTime.value = map["failureTime"];
selectType.value = map["selectType"]; selectType.value = map["selectType"];
//
if (selectType.value == '2') {
endDate.value =
"${int.parse(map["endDate"]) + CommonDataManage().dayLatestTime}";
} else {
endDate.value = map["endDate"];
}
} }
} }

View File

@ -8,6 +8,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
import 'package:star_lock/tools/throttler.dart';
import 'package:star_lock/widget/permission/permission_dialog.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart';
@ -33,6 +34,10 @@ import 'lockNetToken_entity.dart';
class LockDetailLogic extends BaseGetXController { class LockDetailLogic extends BaseGetXController {
final LockDetailState state = LockDetailState(); final LockDetailState state = LockDetailState();
//
FunctionBlocker functionBlocker =
FunctionBlocker(duration: const Duration(seconds: 2));
// //
void initReplySubscription() { void initReplySubscription() {
state.replySubscription = state.replySubscription =
@ -114,10 +119,19 @@ class LockDetailLogic extends BaseGetXController {
break; break;
case 0x16: case 0x16:
// ... // ...
final int isOpen = reply.data[8];
String? msg;
if (isOpen == 0) {
msg = '正在开锁中...'.tr;
} else if (isOpen == 32) {
msg = '正在闭锁中...'.tr;
}
resetOpenDoorState(); resetOpenDoorState();
showToast('正在开锁中...'.tr, something: () { if (msg != null) {
cancelBlueConnetctToastTimer(); showToast(msg, something: () {
}); cancelBlueConnetctToastTimer();
});
}
break; break;
case 0x0d: case 0x0d:
// //
@ -161,14 +175,13 @@ class LockDetailLogic extends BaseGetXController {
void openDoorError() { void openDoorError() {
resetOpenDoorState(); resetOpenDoorState();
state.animationController!.stop(); state.animationController!.stop();
cancelBlueConnetctToastTimer(); blueManageDisconnect();
BlueManage().disconnect();
} }
// //
void closeLuckStatus() { void closeLuckStatus() {
state.openLockBtnState.value = 0; state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false; state.openDoorBtnisUneable.value = true;
state.animationController!.stop(canceled: true); state.animationController!.stop(canceled: true);
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
} }
@ -225,29 +238,28 @@ class LockDetailLogic extends BaseGetXController {
if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
senderReferEventRecordTime(); senderReferEventRecordTime();
} else { } else {
await BlueManage().disconnect(); await blueManageDisconnect();
} }
} }
break; break;
case 0x06: case 0x06:
// //
BlueManage().disconnect(); blueManageDisconnect();
cancelBlueConnetctToastTimer();
break; break;
default: default:
BlueManage().disconnect(); blueManageDisconnect();
cancelBlueConnetctToastTimer();
break; break;
} }
} }
// //
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
showBlueConnetctToastTimer(action: () { showBlueConnetctToastTimer(
resetOpenDoorState(); outTimer: 20,
closeLuckStatus(); action: () {
BlueManage().disconnect(); resetOpenDoorState();
}); blueManageDisconnect();
});
final List<String>? privateKey = final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -285,13 +297,20 @@ class LockDetailLogic extends BaseGetXController {
}); });
} }
//
Future<void> blueManageDisconnect() async {
//便
closeLuckStatus();
cancelBlueConnetctToastTimer();
await BlueManage().disconnect();
}
// () // ()
void senderReferEventRecordTime() { void senderReferEventRecordTime() {
showBlueConnetctToastTimer( showBlueConnetctToastTimer(
isShowBlueConnetctToast: false, isShowBlueConnetctToast: false,
action: () { action: () {
closeLuckStatus(); blueManageDisconnect();
BlueManage().disconnect();
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
@ -325,7 +344,7 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
void getServerDatetime() async { Future<void> getServerDatetime() async {
final GetServerDatetimeEntity entity = final GetServerDatetimeEntity entity =
await ApiRepository.to.getServerDatetimeData(); await ApiRepository.to.getServerDatetimeData();
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
@ -341,7 +360,7 @@ class LockDetailLogic extends BaseGetXController {
} }
// token // token
void getLockNetToken() async { Future<void> getLockNetToken() async {
final LockNetTokenEntity entity = await ApiRepository.to final LockNetTokenEntity entity = await ApiRepository.to
.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); .getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
@ -375,7 +394,7 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
void getLockRecordLastUploadDataTime() async { Future<void> getLockRecordLastUploadDataTime() async {
final LockOperatingRecordGetLastRecordTimeEntity entity = final LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime( await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: state.keyInfos.value.lockId.toString()); lockId: state.keyInfos.value.lockId.toString());
@ -402,7 +421,7 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
void deletKeyData() async { Future<void> deletKeyData() async {
final ElectronicKeyListEntity entity = await ApiRepository.to final ElectronicKeyListEntity entity = await ApiRepository.to
.deleteElectronicKey( .deleteElectronicKey(
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0); keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
@ -497,13 +516,6 @@ class LockDetailLogic extends BaseGetXController {
await PermissionDialog.request(Permission.location); await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth(); await PermissionDialog.requestBluetooth();
final String connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
if (!BlueManage().isExistScanDevices(connectDeviceName)) {
BlueManage().startScanSingle(
connectDeviceName, 15, (List<ScanResult> p0) => null);
}
} }
@override @override

View File

@ -250,21 +250,27 @@ class _LockDetailPageState extends State<LockDetailPage>
], ],
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
const Spacer(), const Spacer(),
GestureDetector( GestureDetector(
onTap: state.openDoorBtnisUneable.value == true onTap: () {
? isNeedRealNameAuthThenOpenLock if (state.openDoorBtnisUneable.value == true) {
: null, logic.functionBlocker.block(isNeedRealNameAuthThenOpenLock);
onLongPressStart: state.openDoorBtnisUneable.value == true }
? (LongPressStartDetails details) { },
setState(startUnLock); onLongPressStart: (LongPressStartDetails details) {
} if (state.openDoorBtnisUneable.value == true) {
: null, void callback() {
setState(startUnLock);
}
logic.functionBlocker.block(callback);
}
},
child: Container( child: Container(
width: 100.r, width: 200.r,
height: 100.r, height: 200.r,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(100.w), borderRadius: BorderRadius.circular(100.w),
@ -276,51 +282,47 @@ class _LockDetailPageState extends State<LockDetailPage>
spreadRadius: 0, spreadRadius: 0,
), ),
]), ]),
margin: EdgeInsets.only(left: 35.w, bottom: 15.h), margin: EdgeInsets.only(top: 20.h),
child: Stack( child: Stack(
alignment: AlignmentDirectional.center, alignment: AlignmentDirectional.center,
children: <Widget>[ children: <Widget>[
if (state.openDoorBtnisUneable.value == false) if (state.openDoorBtnisUneable.value == false)
Icon( Icon(
Icons.bluetooth_searching, Icons.bluetooth_searching,
size: 48.r, size: 78.r,
color: AppColors.mainColor, color: AppColors.mainColor.withOpacity(0.6),
) )
else else
Image.asset( Image.asset(
state.isOpenPassageMode.value == 1 state.isOpenPassageMode.value == 1
? 'images/icon_lock_err.png' ? 'images/icon_lock_err.png'
: 'images/icon_lock_fill.png', : 'images/icon_lock_fill.png',
width: 38.r, width: 68.r,
height: 38.r, height: 68.r,
color: AppColors.mainColor, color: AppColors.mainColor,
), ),
if (state.openDoorBtnisUneable.value == false) if (state.openLockBtnState.value == 1)
Positioned( xhjBuildRotationTransition(
child: Icon( width: 168.r,
Icons.bluetooth_searching, height: 168.r,
size: 96.r,
),
) )
else else
state.openLockBtnState.value == 1 Positioned(
? xhjBuildRotationTransition( child: Image.asset(
width: 88.r, 'images/icon_circle_dotted.png',
height: 88.r, width: 168.r,
) height: 168.r,
: Positioned( color: state.openDoorBtnisUneable.value == false
child: Image.asset( ? AppColors.mainColor.withOpacity(0.6)
'images/icon_circle_dotted.png', : state.isOpenPassageMode.value == 1
width: 88.r, ? Colors.red
height: 88.r, : AppColors.mainColor,
color: state.isOpenPassageMode.value == 1 )),
? Colors.red
: AppColors.mainColor,
)),
], ],
), ),
), ),
), ),
const Spacer(),
Padding( Padding(
padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h), padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h),
child: Row( child: Row(
@ -583,14 +585,20 @@ class _LockDetailPageState extends State<LockDetailPage>
children: <Widget>[ children: <Widget>[
Center( Center(
child: GestureDetector( child: GestureDetector(
onTap: state.openDoorBtnisUneable.value == true onTap: () {
? isNeedRealNameAuthThenOpenLock if (state.openDoorBtnisUneable.value == true) {
: null, logic.functionBlocker.block(isNeedRealNameAuthThenOpenLock);
onLongPressStart: state.openDoorBtnisUneable.value == true }
? (LongPressStartDetails details) { },
setState(startUnLock); onLongPressStart: (LongPressStartDetails details) {
} if (state.openDoorBtnisUneable.value == true) {
: null, void callback() {
setState(startUnLock);
}
logic.functionBlocker.block(callback);
}
},
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
FlavorsImg( FlavorsImg(
@ -1347,7 +1355,7 @@ class _LockDetailPageState extends State<LockDetailPage>
state.iSOpenLock.value = false; state.iSOpenLock.value = false;
state.openLockBtnState.value = 1; state.openLockBtnState.value = 1;
state.animationController!.forward(); state.animationController!.forward();
EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 2000.milliseconds); EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 1000.milliseconds);
AppLog.log('长按闭锁'); AppLog.log('长按闭锁');
if (state.isOpenLockNeedOnline.value == 0) { if (state.isOpenLockNeedOnline.value == 0) {
// //

View File

@ -48,16 +48,16 @@ class LockEscalationLogic extends BaseGetXController {
// //
Future<void> otaUpdate() async { Future<void> otaUpdate() async {
var status = await PermissionDialog.requestStorage(); final bool status = await PermissionDialog.requestStorage();
if (status != true) { if (status != true) {
return; return;
} }
FilePickerResult? result = await FilePicker.platform.pickFiles(); final FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result == null || result.files.single.path is! String) { if (result == null || result.files.single.path is! String) {
return; return;
} }
File file = File(result.files.single.path!); final File file = File(result.files.single.path!);
Uint8List data = await file.readAsBytes(); final Uint8List data = await file.readAsBytes();
headJson = await getHeadFile(data); headJson = await getHeadFile(data);
if (headJson is! Map) { if (headJson is! Map) {
return; return;
@ -66,15 +66,13 @@ class LockEscalationLogic extends BaseGetXController {
if (otaBin == null) { if (otaBin == null) {
return; return;
} }
String md5Str = md5.convert(otaBin!).toString(); final String md5Str = md5.convert(otaBin!).toString();
headJson!['fwMd5'] = md5Str; headJson!['fwMd5'] = md5Str;
ShowTipView().showIosTipWithContentDialog("未避免异常情况,请在门打开时升级".tr, () async { ShowTipView().showIosTipWithContentDialog('未避免异常情况,请在门打开时升级'.tr, () async {
blueOTAUpgrade(headJson!, [0, 0, 0, 0]); blueOTAUpgrade(headJson!, [0, 0, 0, 0]);
EasyLoading.show( EasyLoading.show(
status: '设备连接中...'.tr, maskType: EasyLoadingMaskType.black); status: '设备连接中...'.tr, maskType: EasyLoadingMaskType.black);
Future.delayed(const Duration(seconds: 4), () { Future.delayed(const Duration(seconds: 4), EasyLoading.dismiss);
EasyLoading.dismiss();
});
}); });
} }
@ -83,11 +81,11 @@ class LockEscalationLogic extends BaseGetXController {
BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); final privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey); final signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
String uid = await Storage.getUid() ?? ''; final String uid = await Storage.getUid() ?? '';
BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand( BlueManage().writeCharacteristicWithResponse(OTAUpgradeCommand(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: uid, userID: uid,
@ -113,30 +111,30 @@ class LockEscalationLogic extends BaseGetXController {
if (!state.otaUpdateIng.value) { if (!state.otaUpdateIng.value) {
return; return;
} }
int length = otaBin?.length ?? 0; final int length = otaBin?.length ?? 0;
if (otaCount == 0) { if (otaCount == 0) {
// //
int difference = length % 240; final int difference = length % 240;
otaCount = length ~/ 240 + (difference > 0 ? 1 : 0); otaCount = length ~/ 240 + (difference > 0 ? 1 : 0);
startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000; startSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000;
startOTAData(); startOTAData();
} }
if (otaCount <= otaIndex) { if (otaCount <= otaIndex) {
int now = DateTime.now().millisecondsSinceEpoch ~/ 1000; final int now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
String msg = final String msg =
'传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex '; '传输完成 时间:${now - startSecond}秒 otaCount:$otaCount otaIndex:$otaIndex ';
closeOTADAta(); closeOTADAta();
AppLog.log(msg); AppLog.log(msg);
// showToast(msg); // showToast(msg);
return; return;
} }
int star = otaIndex * 240; final int star = otaIndex * 240;
int end = (otaIndex + 1) * 240; int end = (otaIndex + 1) * 240;
if (end > length) { if (end > length) {
end = length; end = length;
} }
int size = end - star; final int size = end - star;
List<int> data = otaBin!.sublist(star, end); final List<int> data = otaBin!.sublist(star, end);
state.otaProgress.value = otaIndex / otaCount; state.otaProgress.value = otaIndex / otaCount;
await BlueManage().writeCharacteristicWithResponse( await BlueManage().writeCharacteristicWithResponse(
ProcessOtaUpgradeCommand(index: otaIndex, size: size, data: data) ProcessOtaUpgradeCommand(index: otaIndex, size: size, data: data)
@ -176,7 +174,8 @@ class LockEscalationLogic extends BaseGetXController {
// //
String header; String header;
try { try {
header = utf8.decode(data.sublist(0, 12)); final Uint8List list = data.sublist(0, 12);
header = utf8.decode(list);
} catch (e) { } catch (e) {
showToast('非SYD固件请选择正确的文件'.tr); showToast('非SYD固件请选择正确的文件'.tr);
return null; return null;
@ -210,7 +209,7 @@ class LockEscalationLogic extends BaseGetXController {
return null; return null;
} }
AppLog.log(metaStr); AppLog.log(metaStr);
var meta = jsonDecode(metaStr); final meta = jsonDecode(metaStr);
if (meta is! Map) { if (meta is! Map) {
showToast('解析元数据失败,请选择正确的文件'.tr); showToast('解析元数据失败,请选择正确的文件'.tr);
return null; return null;
@ -220,11 +219,11 @@ class LockEscalationLogic extends BaseGetXController {
// bin // bin
Future<Uint8List?> checkFile(Uint8List data, Map meta) async { Future<Uint8List?> checkFile(Uint8List data, Map meta) async {
num binOffset = 16 + (meta['metaLen'] ?? 0); final num binOffset = 16 + (meta['metaLen'] ?? 0);
// //
Uint8List bin = data.sublist(binOffset.toInt(), data.length); final Uint8List bin = data.sublist(binOffset.toInt(), data.length);
//md5 //md5
String md5Str = md5.convert(bin).toString().toUpperCase(); final String md5Str = md5.convert(bin).toString().toUpperCase();
AppLog.log('固件 md5 检验md5$md5Str 固件信息 md5${meta['fwMd5']}'); AppLog.log('固件 md5 检验md5$md5Str 固件信息 md5${meta['fwMd5']}');
if (md5Str != meta['fwMd5']) { if (md5Str != meta['fwMd5']) {
showToast('文件校验失败 0x02'.tr); showToast('文件校验失败 0x02'.tr);

View File

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
@ -24,7 +23,8 @@ import 'lockSetInfo_entity.dart';
import 'lockSet_state.dart'; import 'lockSet_state.dart';
typedef BlockSetStateCallback = void Function(); typedef BlockSetStateCallback = void Function();
typedef BlockSetCheckInCallback = void Function(CheckingInInfoDataEntity checkingInInfoDataEntity); typedef BlockSetCheckInCallback = void Function(
CheckingInInfoDataEntity checkingInInfoDataEntity);
class LockSetLogic extends BaseGetXController { class LockSetLogic extends BaseGetXController {
final LockSetState state = LockSetState(); final LockSetState state = LockSetState();
@ -40,12 +40,14 @@ class LockSetLogic extends BaseGetXController {
// } // }
// //
if (reply is FactoryDataResetReply && (state.ifCurrentScreen.value == true)) { if (reply is FactoryDataResetReply &&
(state.ifCurrentScreen.value == true)) {
_replyFactoryDataResetKey(reply); _replyFactoryDataResetKey(reply);
} }
// () // ()
if ((reply is SetSupportFunctionsNoParametersReply) && (state.ifCurrentScreen.value == true)) { if ((reply is SetSupportFunctionsNoParametersReply) &&
(state.ifCurrentScreen.value == true)) {
_replySetSupportFunctionsWithParameters(reply); _replySetSupportFunctionsWithParameters(reply);
} }
@ -124,7 +126,7 @@ class LockSetLogic extends BaseGetXController {
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: "1", keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: publicKeyDataList, publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
@ -241,11 +243,14 @@ class LockSetLogic extends BaseGetXController {
// //
Future<void> factoryDataResetAction() async { Future<void> factoryDataResetAction() async {
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){ showBlueConnetctToastTimer(
dismissEasyLoading(); isShowBlueConnetctToast: false,
showDeletAlertTipDialog(); action: () {
}); dismissEasyLoading();
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { showDeletAlertTipDialog();
});
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -259,7 +264,7 @@ class LockSetLogic extends BaseGetXController {
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: "1", keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: publicKeyDataList, publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
@ -267,7 +272,7 @@ class LockSetLogic extends BaseGetXController {
} else if (connectionState == BluetoothConnectionState.disconnected) { } else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){ if (state.ifCurrentScreen.value == true) {
showDeletAlertTipDialog(); showDeletAlertTipDialog();
} }
} }
@ -303,10 +308,11 @@ class LockSetLogic extends BaseGetXController {
// () // ()
Future<void> sendBurglarAlarm(int type) async { Future<void> sendBurglarAlarm(int type) async {
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(action: (){ showBlueConnetctToastTimer(action: () {
dismissEasyLoading(); dismissEasyLoading();
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -345,7 +351,7 @@ class LockSetLogic extends BaseGetXController {
} else if (connectionState == BluetoothConnectionState.disconnected) { } else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){ if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); showBlueConnetctToast();
} }
} }
@ -360,23 +366,28 @@ class LockSetLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockSetInfoData.value = entity.data!; state.lockSetInfoData.value = entity.data!;
CommonDataManage().currentLockSetInfoData = entity.data!; CommonDataManage().currentLockSetInfoData = entity.data!;
state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!; state.lockSettingInfo.value =
state.lockSetInfoData.value.lockSettingInfo!;
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!; state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!; state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!; state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!;
state.isAttendance.value = state.lockSettingInfo.value.attendance!; 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.isOpenBlueBroadcast.value =
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!; state.lockSettingInfo.value.bluetoothBroadcast!;
state.isOpenExceptionWarnings.value =
state.lockSettingInfo.value.bluetoothBroadcast!;
} }
return entity; return entity;
} }
// //
void openCheckingInData(BlockSetCheckInCallback blockSetCheckInCallback) async { void openCheckingInData(
BlockSetCheckInCallback blockSetCheckInCallback) async {
var entity = await ApiRepository.to.openCheckingInData( var entity = await ApiRepository.to.openCheckingInData(
lockId: state.lockSetInfoData.value.lockId.toString(), lockId: state.lockSetInfoData.value.lockId.toString(),
); );
@ -394,23 +405,26 @@ class LockSetLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.isAttendance.value = (state.isAttendance.value == 1 ? 0 : 1); state.isAttendance.value = (state.isAttendance.value == 1 ? 0 : 1);
state.lockSettingInfo.value.attendance = state.isAttendance.value; state.lockSettingInfo.value.attendance = state.isAttendance.value;
showToast("设置成功".tr, something: (){ showToast('设置成功'.tr, something: () {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, state.lockSettingInfo.value.attendance!.toString())); eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(
0, state.lockSettingInfo.value.attendance!.toString()));
}); });
} }
} }
// //
void setLockPickingReminder() async { Future<void> setLockPickingReminder() async {
var entity = await ApiRepository.to.setLockPickingReminderData( var entity = await ApiRepository.to.setLockPickingReminderData(
lockId: state.lockSetInfoData.value.lockId!, lockId: state.lockSetInfoData.value.lockId!,
unlockReminderPush: state.isLockPickingReminder.value == 1 ? 0 : 1, unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.isLockPickingReminder.value = (state.isLockPickingReminder.value == 1 ? 0 : 1); state.isLockPickingReminder.value =
state.lockSettingInfo.value.unlockReminderPush = state.isLockPickingReminder.value; (state.isLockPickingReminder.value == 1 ? 0 : 1);
showToast("设置成功".tr, something: (){ state.lockSettingInfo.value.unlockReminderPush =
state.isLockPickingReminder.value;
showToast('设置成功'.tr, something: () {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
}); });
} }
@ -423,11 +437,14 @@ class LockSetLogic extends BaseGetXController {
appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1, appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.isOpenLockNeedOnline.value = (state.isOpenLockNeedOnline.value == 1 ? 0 : 1); state.isOpenLockNeedOnline.value =
state.lockSettingInfo.value.appUnlockOnline = state.isOpenLockNeedOnline.value; (state.isOpenLockNeedOnline.value == 1 ? 0 : 1);
state.lockSettingInfo.value.appUnlockOnline =
state.isOpenLockNeedOnline.value;
showToast("设置成功".tr,something: (){ showToast('设置成功'.tr, something: () {
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(1, state.lockSettingInfo.value.appUnlockOnline!.toString())); eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(
1, state.lockSettingInfo.value.appUnlockOnline!.toString()));
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
}); });
} }
@ -437,37 +454,42 @@ class LockSetLogic extends BaseGetXController {
StreamSubscription? _passCurrentLockInformationEvent; StreamSubscription? _passCurrentLockInformationEvent;
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
// eventBus // eventBus
_passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) { _passCurrentLockInformationEvent =
eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
getLockSettingInfoData(); getLockSettingInfoData();
}); });
} }
void showDeletAlertTipDialog({String? showContent = ""}) { void showDeletAlertTipDialog({String? showContent = ''}) {
var content = showContent!.isEmpty ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" : showContent; var content = showContent!.isEmpty
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
: showContent;
ShowTipView().showSureAlertDialog(content); ShowTipView().showSureAlertDialog(content);
} }
///
/// deleyLockLogicOfRoles() {
deleyLockLogicOfRoles(){
if (state.lockBasicInfo.value.isLockOwner == 1) { if (state.lockBasicInfo.value.isLockOwner == 1) {
// //
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){ ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr,
() {
// //
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){ ShowTipView().showTFViewAlertDialog(
state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, () {
checkLoginPassword(); checkLoginPassword();
}); });
}); });
} else if (state.lockBasicInfo.value.keyRight == 1){ } else if (state.lockBasicInfo.value.keyRight == 1) {
// //
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){ ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (a) {
// //
state.deleteAdministratorIsHaveAllData.value = a; state.deleteAdministratorIsHaveAllData.value = a;
deletKeyData(); deletKeyData();
}); });
} else{ } else {
// //
ShowTipView().showIosTipWithContentDialog("是否删除钥匙?".tr, (){ ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, () {
deletKeyData(); deletKeyData();
}); });
} }

View File

@ -496,7 +496,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
child: CommonItem( child: CommonItem(
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
rightTitle: "", rightTitle: "",
isHaveLine: false, isHaveLine: true,
isHaveRightWidget: true, isHaveRightWidget: true,
rightWidget: _lockRemindSwitch())), rightWidget: _lockRemindSwitch())),
), ),
@ -661,7 +661,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
activeColor: CupertinoColors.activeBlue, activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5, trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white, thumbColor: CupertinoColors.white,
value: (state.isLockPickingReminder.value) == 1 ? true : false, value: state.isLockPickingReminder.value == 1 ? true : false,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
logic.setLockPickingReminder(); logic.setLockPickingReminder();

View File

@ -10,14 +10,15 @@ class LockUserLogic extends BaseGetXController {
final LockUserState state = LockUserState(); final LockUserState state = LockUserState();
// //
void getLockKeysList() async { Future<void> getLockKeysList() async {
LockUserEntity entity = await ApiRepository.to.getLockKeysList( final LockUserEntity entity = await ApiRepository.to.getLockKeysList(
lockId: state.getLockId.value, lockId: state.getLockId.value,
searchStr: state.searchController.text,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// 1: 2: 3: 4: 5: // 1: 2: 3: 4: 5:
LockUserData data1 = entity.data![0]; final LockUserData data1 = entity.data![0];
data1.lockUserList?.forEach((element) { data1.lockUserList?.forEach((LockUserListKeys element) {
element.currentKeyType = 1; element.currentKeyType = 1;
element.currentKeyTypeStr = '电子钥匙'.tr; element.currentKeyTypeStr = '电子钥匙'.tr;
element.currentTypeImg = 'images/controls_user.png'; element.currentTypeImg = 'images/controls_user.png';
@ -26,8 +27,8 @@ class LockUserLogic extends BaseGetXController {
element.currentDateType = element.keyType; element.currentDateType = element.keyType;
element.currentOpenDoorID = element.id; element.currentOpenDoorID = element.id;
}); });
LockUserData data2 = entity.data![1]; final LockUserData data2 = entity.data![1];
data2.lockUserList?.forEach((element) { data2.lockUserList?.forEach((LockUserListKeys element) {
element.currentKeyType = 2; element.currentKeyType = 2;
element.currentKeyTypeStr = '密码'.tr; element.currentKeyTypeStr = '密码'.tr;
element.currentTypeImg = 'images/icon_password.png'; element.currentTypeImg = 'images/icon_password.png';
@ -36,8 +37,8 @@ class LockUserLogic extends BaseGetXController {
element.currentDateType = element.keyboardPwdType; element.currentDateType = element.keyboardPwdType;
element.currentOpenDoorID = element.keyboardPwdId; element.currentOpenDoorID = element.keyboardPwdId;
}); });
LockUserData data3 = entity.data![2]; final LockUserData data3 = entity.data![2];
data3.lockUserList?.forEach((element) { data3.lockUserList?.forEach((LockUserListKeys element) {
element.currentKeyType = 3; element.currentKeyType = 3;
element.currentKeyTypeStr = '指纹'.tr; element.currentKeyTypeStr = '指纹'.tr;
element.currentTypeImg = 'images/icon_fingerprint.png'; element.currentTypeImg = 'images/icon_fingerprint.png';
@ -45,8 +46,8 @@ class LockUserLogic extends BaseGetXController {
element.isCurrentSelect = false; element.isCurrentSelect = false;
element.currentDateType = element.fingerprintType; element.currentDateType = element.fingerprintType;
}); });
LockUserData data4 = entity.data![3]; final LockUserData data4 = entity.data![3];
data4.lockUserList?.forEach((element) { data4.lockUserList?.forEach((LockUserListKeys element) {
element.currentKeyType = 4; element.currentKeyType = 4;
element.currentKeyTypeStr = ''.tr; element.currentKeyTypeStr = ''.tr;
element.currentTypeImg = 'images/icon_card.png'; element.currentTypeImg = 'images/icon_card.png';
@ -54,8 +55,8 @@ class LockUserLogic extends BaseGetXController {
element.isCurrentSelect = false; element.isCurrentSelect = false;
element.currentDateType = element.cardType; element.currentDateType = element.cardType;
}); });
LockUserData data5 = entity.data![4]; final LockUserData data5 = entity.data![4];
data5.lockUserList?.forEach((element) { data5.lockUserList?.forEach((LockUserListKeys element) {
element.currentKeyType = 5; element.currentKeyType = 5;
element.currentKeyTypeStr = '人脸'.tr; element.currentKeyTypeStr = '人脸'.tr;
element.currentTypeImg = 'images/icon_face.png'; element.currentTypeImg = 'images/icon_face.png';
@ -64,18 +65,18 @@ class LockUserLogic extends BaseGetXController {
element.currentDateType = element.faceType; element.currentDateType = element.faceType;
}); });
state.lockUserList.value.addAll(data1.lockUserList!); state.lockUserList.addAll(data1.lockUserList!);
state.lockUserList.value.addAll(data2.lockUserList!); state.lockUserList.addAll(data2.lockUserList!);
state.lockUserList.value.addAll(data3.lockUserList!); state.lockUserList.addAll(data3.lockUserList!);
state.lockUserList.value.addAll(data4.lockUserList!); state.lockUserList.addAll(data4.lockUserList!);
state.lockUserList.value.addAll(data5.lockUserList!); state.lockUserList.addAll(data5.lockUserList!);
state.lockUserList.refresh(); state.lockUserList.refresh();
} }
} }
String getKeyUseDateStr(LockUserListKeys itemData) { String getKeyUseDateStr(LockUserListKeys itemData) {
var keyDateTypeStr = ""; String keyDateTypeStr = '';
switch (itemData.currentKeyType) { switch (itemData.currentKeyType) {
case 1: // case 1: //
keyDateTypeStr = getElectronicKeyUseDateStr(itemData); keyDateTypeStr = getElectronicKeyUseDateStr(itemData);
@ -91,7 +92,7 @@ class LockUserLogic extends BaseGetXController {
keyDateTypeStr = getCardAndFaceDateType(itemData); keyDateTypeStr = getCardAndFaceDateType(itemData);
break; break;
default: default:
keyDateTypeStr = "".tr; keyDateTypeStr = ''.tr;
break; break;
} }
@ -103,18 +104,18 @@ class LockUserLogic extends BaseGetXController {
String useDateStr = ''; String useDateStr = '';
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
// //
DateTime startDateStr = final DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr = final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr = useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
// //
useDateStr = "永久".tr; useDateStr = '永久'.tr;
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
// //
useDateStr = "单次".tr; useDateStr = '单次'.tr;
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
// //
useDateStr = '循环'.tr; useDateStr = '循环'.tr;
@ -125,25 +126,23 @@ class LockUserLogic extends BaseGetXController {
// //
String getPasswordUseDateStr(LockUserListKeys itemData) { String getPasswordUseDateStr(LockUserListKeys itemData) {
int? getPwdType = itemData.keyboardPwdType; final int? getPwdType = itemData.keyboardPwdType;
String useDateStr = ''; String useDateStr = '';
DateTime sendDateStr = final DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(itemData.sendDate!);
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(itemData.startDate!); DateTime.fromMillisecondsSinceEpoch(itemData.startDate!);
DateTime endDateStr = final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(itemData.endDate!); DateTime.fromMillisecondsSinceEpoch(itemData.endDate!);
int starHour = startDateStr.hour; final int starHour = startDateStr.hour;
int endHour = endDateStr.hour; final int endHour = endDateStr.hour;
switch (getPwdType) { switch (getPwdType) {
case 1: case 1:
// 1 6使 // 1 6使
useDateStr = "单次".tr; useDateStr = '单次'.tr;
break; break;
case 2: case 2:
// 2 24使 // 2 24使
useDateStr = "永久".tr; useDateStr = '永久'.tr;
break; break;
case 3: case 3:
// 3 24使 // 3 24使
@ -213,30 +212,30 @@ class LockUserLogic extends BaseGetXController {
// //
String getfingerprintUseDateStr(LockUserListKeys fingerprintItemData) { String getfingerprintUseDateStr(LockUserListKeys fingerprintItemData) {
var keyDateTypeStr = ""; // :1;23:4 String keyDateTypeStr = ''; // :1;23:4
if (fingerprintItemData.fingerprintType! == 1) { if (fingerprintItemData.fingerprintType! == 1) {
keyDateTypeStr = "永久".tr; keyDateTypeStr = '永久'.tr;
} else if (fingerprintItemData.fingerprintType! == 2) { } else if (fingerprintItemData.fingerprintType! == 2) {
keyDateTypeStr = keyDateTypeStr =
"${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
} else if (fingerprintItemData.fingerprintType! == 4) { } else if (fingerprintItemData.fingerprintType! == 4) {
keyDateTypeStr = keyDateTypeStr =
"${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
} }
return keyDateTypeStr; return keyDateTypeStr;
} }
/// ///
String getCardAndFaceDateType(LockUserListKeys fingerprintItemData) { String getCardAndFaceDateType(LockUserListKeys fingerprintItemData) {
var keyDateTypeStr = ""; // :1;23:4 String keyDateTypeStr = ''; // :1;23:4
if (fingerprintItemData.cardType! == 1) { if (fingerprintItemData.cardType! == 1) {
keyDateTypeStr = "永久".tr; keyDateTypeStr = '永久'.tr;
} else if (fingerprintItemData.cardType! == 2) { } else if (fingerprintItemData.cardType! == 2) {
keyDateTypeStr = keyDateTypeStr =
"${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; '${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
} else if (fingerprintItemData.cardType! == 4) { } else if (fingerprintItemData.cardType! == 4) {
keyDateTypeStr = keyDateTypeStr =
"${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; '${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
} }
return keyDateTypeStr; return keyDateTypeStr;
} }

View File

@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart';
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart';
import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_state.dart';
import 'package:star_lock/tools/keySearchWidget.dart'; import 'package:star_lock/tools/keySearchWidget.dart';
import '../../../../app_settings/app_colors.dart'; import '../../../../app_settings/app_colors.dart';
import '../../../../tools/submitBtn.dart'; import '../../../../tools/submitBtn.dart';
@ -16,8 +17,8 @@ class LockUserPage extends StatefulWidget {
} }
class _LockUserPageState extends State<LockUserPage> { class _LockUserPageState extends State<LockUserPage> {
final logic = Get.put(LockUserLogic()); final LockUserLogic logic = Get.put(LockUserLogic());
final state = Get.find<LockUserLogic>().state; final LockUserState state = Get.find<LockUserLogic>().state;
@override @override
initState() { initState() {
@ -36,7 +37,7 @@ class _LockUserPageState extends State<LockUserPage> {
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
), ),
body: Column( body: Column(
children: [ children: <Widget>[
KeySearchWidget( KeySearchWidget(
editingController: state.searchController, editingController: state.searchController,
onSubmittedAction: () { onSubmittedAction: () {
@ -51,9 +52,7 @@ class _LockUserPageState extends State<LockUserPage> {
SubmitBtn( SubmitBtn(
btnName: '确定'.tr, btnName: '确定'.tr,
onClick: () { onClick: () {
Get.back( Get.back(result: state.lockUserList[state.isSelectIndex.value]);
result:
state.lockUserList.value[state.isSelectIndex.value]);
}, },
), ),
SizedBox( SizedBox(
@ -66,9 +65,9 @@ class _LockUserPageState extends State<LockUserPage> {
Widget _buildMainUI() { Widget _buildMainUI() {
return Obx(() => ListView.separated( return Obx(() => ListView.separated(
shrinkWrap: true, shrinkWrap: true,
itemCount: state.lockUserList.value.length, itemCount: state.lockUserList.length,
itemBuilder: (c, index) { itemBuilder: (BuildContext c, int index) {
return _electronicKeyItem(state.lockUserList.value[index], index); return _electronicKeyItem(state.lockUserList[index], index);
}, },
separatorBuilder: (BuildContext context, int index) { separatorBuilder: (BuildContext context, int index) {
return const Divider( return const Divider(
@ -82,8 +81,8 @@ class _LockUserPageState extends State<LockUserPage> {
Widget _electronicKeyItem(LockUserListKeys lockUserKeys, int selectIndex) { Widget _electronicKeyItem(LockUserListKeys lockUserKeys, int selectIndex) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
for (int i = 0; i < state.lockUserList.value.length; i++) { for (int i = 0; i < state.lockUserList.length; i++) {
LockUserListKeys item = state.lockUserList.value[i]; final LockUserListKeys item = state.lockUserList[i];
if (selectIndex == i) { if (selectIndex == i) {
item.isCurrentSelect = true; item.isCurrentSelect = true;
} else { } else {
@ -99,7 +98,7 @@ class _LockUserPageState extends State<LockUserPage> {
width: 1.sw, width: 1.sw,
height: 90.h, height: 90.h,
child: Row( child: Row(
children: [ children: <Widget>[
SizedBox( SizedBox(
width: 30.w, width: 30.w,
), ),
@ -114,9 +113,9 @@ class _LockUserPageState extends State<LockUserPage> {
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: <Widget>[
Row( Row(
children: [ children: <Widget>[
Text( Text(
lockUserKeys.currentKeyName ?? '', lockUserKeys.currentKeyName ?? '',
style: TextStyle( style: TextStyle(
@ -132,7 +131,7 @@ class _LockUserPageState extends State<LockUserPage> {
SizedBox(height: 10.h), SizedBox(height: 10.h),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: <Widget>[
Text( Text(
logic.getKeyUseDateStr(lockUserKeys), logic.getKeyUseDateStr(lockUserKeys),
style: TextStyle( style: TextStyle(

View File

@ -8,7 +8,9 @@ import 'package:get/get.dart';
import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart'; import 'package:star_lock/blue/io_protocol/io_changeAdministratorPassword.dart';
import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart'; import 'package:star_lock/blue/io_protocol/io_senderCustomPasswords.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/mine/addLock/saveLock/entity/SaveLockEntity.dart';
import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/commonDataManage.dart';
import '../../../app_settings/app_settings.dart'; import '../../../app_settings/app_settings.dart';
@ -33,7 +35,7 @@ class SaveLockLogic extends BaseGetXController {
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
if (reply is AddUserReply && state.ifCurrentScreen.value == true) { if (reply is AddUserReply && state.ifCurrentScreen.value == true) {
_replyAddUserKey(reply); _replyAddUserKey(reply);
} }
@ -50,16 +52,16 @@ class SaveLockLogic extends BaseGetXController {
// //
Future<void> _replyAddUserKey(Reply reply) async { Future<void> _replyAddUserKey(Reply reply) async {
var token = reply.data.sublist(42, 46); final List<int> token = reply.data.sublist(42, 46);
List<String> strTokenList = changeIntListToStringList(token); final List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList); Storage.setStringList(saveBlueToken, strTokenList);
int status = reply.data[46]; final int status = reply.data[46];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
state.lockUserNo = listChangInt(reply.data.sublist(47, 49)); state.lockUserNo = listChangInt(reply.data.sublist(47, 49));
AppLog.log("state.lockUserNo:${state.lockUserNo}"); AppLog.log('state.lockUserNo:${state.lockUserNo}');
// //
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
@ -67,16 +69,20 @@ class SaveLockLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList =
changeStringListToIntList(publicKey!);
IoSenderManage.senderAddUser( IoSenderManage.senderAddUser(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
authUserID: await Storage.getUid(), authUserID: await Storage.getUid(),
keyID: "1", keyID: '1',
userID: await Storage.getUid(), userID: await Storage.getUid(),
openMode: 1, openMode: 1,
keyType: 1, keyType: 1,
@ -216,21 +222,25 @@ class SaveLockLogic extends BaseGetXController {
(BluetoothConnectionState deviceConnectionState) async { (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { if (deviceConnectionState == BluetoothConnectionState.connected) {
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList =
changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = [0, 0, 0, 0]; List<int> getTokenList = <int>[0, 0, 0, 0];
if (token != null) { if (token != null) {
getTokenList = changeStringListToIntList(token); getTokenList = changeStringListToIntList(token);
} }
IoSenderManage.senderAddUser( IoSenderManage.senderAddUser(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
authUserID: await Storage.getUid(), authUserID: await Storage.getUid(),
keyID: "1", keyID: '1',
userID: await Storage.getUid(), userID: await Storage.getUid(),
openMode: 1, openMode: 1,
keyType: 1, keyType: 1,
@ -356,35 +366,37 @@ class SaveLockLogic extends BaseGetXController {
// } // }
void bindBlueAdmin() async { void bindBlueAdmin() async {
state.lockInfo["adminPwd"] = state.adminPassword; state.lockInfo['adminPwd'] = state.adminPassword;
var positionMap = {}; final Map<String, dynamic> positionMap = <String, dynamic>{};
positionMap['longitude'] = state.addressInfo["longitude"]; positionMap['longitude'] = state.addressInfo['longitude'];
positionMap['latitude'] = state.addressInfo["latitude"]; positionMap['latitude'] = state.addressInfo['latitude'];
positionMap['country'] = state.addressInfo["country"]; positionMap['country'] = state.addressInfo['country'];
positionMap['province'] = state.addressInfo["province"]; positionMap['province'] = state.addressInfo['province'];
positionMap['city'] = state.addressInfo["city"]; positionMap['city'] = state.addressInfo['city'];
positionMap['district'] = state.addressInfo["district"]; positionMap['district'] = state.addressInfo['district'];
positionMap['township'] = state.addressInfo["street"]; positionMap['township'] = state.addressInfo['street'];
positionMap['address'] = state.addressInfo["address"]; positionMap['address'] = state.addressInfo['address'];
var bluetooth = {}; final Map<String, dynamic> bluetooth = <String, dynamic>{};
bluetooth['bluetoothDeviceId'] = BlueManage().connectDeviceMacAddress; bluetooth['bluetoothDeviceId'] = BlueManage().connectDeviceMacAddress;
bluetooth['bluetoothDeviceName'] = BlueManage().connectDeviceName; bluetooth['bluetoothDeviceName'] = BlueManage().connectDeviceName;
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
bluetooth['publicKey'] = publicKeyDataList; bluetooth['publicKey'] = publicKeyDataList;
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
bluetooth['privateKey'] = getPrivateKeyList; bluetooth['privateKey'] = getPrivateKeyList;
var signKey = await Storage.getStringList(saveBlueSignKey); final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!); final List<int> signKeyDataList = changeStringListToIntList(signKey!);
bluetooth['signKey'] = signKeyDataList; bluetooth['signKey'] = signKeyDataList;
var entity = await ApiRepository.to.bindingBlueAdmin( final SaveLockEntity entity = await ApiRepository.to.bindingBlueAdmin(
lockAlias: state.aliName.value, lockAlias: state.aliName.value,
position: positionMap, position: positionMap,
bluetooth: bluetooth, bluetooth: bluetooth,
@ -464,11 +476,18 @@ class SaveLockLogic extends BaseGetXController {
eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true)); eventBus.fire(RefreshLockListInfoDataEvent(clearScanDevices: true));
BlueManage().disconnect(); BlueManage().disconnect();
Get.close(state.isFromMap == 1 ? 5 : 6); Get.close(state.isFromMap == 1 ? 5 : 6);
// 2
Future<void>.delayed(const Duration(milliseconds: 200), () {
if (Get.isRegistered<LockDetailLogic>()) {
Get.find<LockDetailLogic>()
.functionBlocker
.countdownProhibited(duration: const Duration(seconds: 2));
}
});
} }
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
@ -476,13 +495,11 @@ class SaveLockLogic extends BaseGetXController {
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
} }
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
super.onClose(); super.onClose();
} }

View File

@ -73,6 +73,7 @@ class RecordItem {
String? createdAt; String? createdAt;
String? updatedAt; String? updatedAt;
String? useDate; String? useDate;
String? buyDate;
RecordItem( RecordItem(
{this.id, {this.id,
@ -88,7 +89,8 @@ class RecordItem {
this.amount, this.amount,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.useDate}); this.useDate,
this.buyDate});
RecordItem.fromJson(Map<String, dynamic> json) { RecordItem.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];
@ -105,6 +107,7 @@ class RecordItem {
createdAt = json['created_at']; createdAt = json['created_at'];
updatedAt = json['updated_at']; updatedAt = json['updated_at'];
useDate = json['useDate']; useDate = json['useDate'];
buyDate = json['buyDate'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -123,6 +126,7 @@ class RecordItem {
data['created_at'] = createdAt; data['created_at'] = createdAt;
data['updated_at'] = updatedAt; data['updated_at'] = updatedAt;
data['useDate'] = useDate; data['useDate'] = useDate;
data['buyDate'] = buyDate;
return data; return data;
} }
} }

View File

@ -107,7 +107,7 @@ class _PurchaseRecords extends StatelessWidget {
Row( Row(
children: <Widget>[ children: <Widget>[
Text( Text(
itemData.createdAt?.substring(0, 10) ?? '', itemData.buyDate ?? '',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
color: AppColors.blackColor, color: AppColors.blackColor,

View File

@ -891,13 +891,12 @@ class ApiProvider extends BaseProvider {
isUnShowLoading: true); isUnShowLoading: true);
// //
Future<Response> setLockPickingReminderData( Future<Response> setLockPickingReminderData(int lockId, int unlockReminder) =>
int lockId, int unlockReminderPush) =>
post( post(
updateLockSettingUrl.toUrl, updateLockSettingUrl.toUrl,
jsonEncode({ jsonEncode({
'lockId': lockId, 'lockId': lockId,
'unlockReminderPush': unlockReminderPush, 'unlockReminder': unlockReminder,
})); }));
// //
@ -1945,8 +1944,9 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> getLockKeysList(int lockId) => Future<Response> getLockKeysList(int lockId, String searchStr) => post(
post(lockKeysListURL.toUrl, jsonEncode({'lockId': lockId})); lockKeysListURL.toUrl,
jsonEncode({'lockId': lockId, 'searchStr': searchStr}));
// //
Future<Response> addLockNoticeSetting( Future<Response> addLockNoticeSetting(

View File

@ -1095,10 +1095,10 @@ class ApiRepository {
// //
Future<LoginEntity> setLockPickingReminderData({ Future<LoginEntity> setLockPickingReminderData({
required int lockId, required int lockId,
required int unlockReminderPush, required int unlockReminder,
}) async { }) async {
final res = await apiProvider.setLockPickingReminderData( final res =
lockId, unlockReminderPush); await apiProvider.setLockPickingReminderData(lockId, unlockReminder);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
@ -1972,8 +1972,9 @@ class ApiRepository {
} }
// //
Future<LockUserEntity> getLockKeysList({required int lockId}) async { Future<LockUserEntity> getLockKeysList(
final res = await apiProvider.getLockKeysList(lockId); {required int lockId, required String searchStr}) async {
final res = await apiProvider.getLockKeysList(lockId, searchStr);
return LockUserEntity.fromJson(res.body); return LockUserEntity.fromJson(res.body);
} }

View File

@ -62,14 +62,16 @@ class UDPManage {
// AppLog.log('Udp ----> host:$host port:$port'); // AppLog.log('Udp ----> host:$host port:$port');
var addressIListenFrom = InternetAddress.anyIPv4; var addressIListenFrom = InternetAddress.anyIPv4;
int portIListenOn = 62288; int portIListenOn = 62288;
RawDatagramSocket.bind(addressIListenFrom, portIListenOn) if(addressIListenFrom.address != '0.0.0.0'){
.then((RawDatagramSocket socket) { RawDatagramSocket.bind(addressIListenFrom, portIListenOn)
_udpSocket = socket; .then((RawDatagramSocket socket) {
_udpSocket = socket;
///广 ///广
_udpSocket!.broadcastEnabled = true; _udpSocket!.broadcastEnabled = true;
_onReceiveData(socket); _onReceiveData(socket);
}); });
}
} }
void _onReceiveData(RawDatagramSocket socket) { void _onReceiveData(RawDatagramSocket socket) {

74
lib/tools/throttler.dart Normal file
View File

@ -0,0 +1,74 @@
import 'dart:async';
import 'package:star_lock/app_settings/app_settings.dart';
///
///
// 1
// Throttler throttler = Throttler(Duration(seconds: 1));
//
// //
// void myFunction() {
// print("函数被调用");
// }
//
// // 1
// throttler.throttle(myFunction);
//
// //
// Throttler customThrottler = Throttler(Duration(milliseconds: 500)); // 500
// customThrottler.throttle(myFunction); // 500
//
// //
// customThrottler.cancel(); //
class Throttler {
Throttler(this._delay);
final Duration _delay;
Timer? _timer;
late Function _callback;
void throttle(Function callback) {
if (_timer == null || !_timer!.isActive) {
_callback = callback;
_timer = Timer(_delay, () {
_callback();
_timer?.cancel();
});
}
}
void cancel() {
_timer?.cancel();
}
}
///
///
///
class FunctionBlocker {
FunctionBlocker({required this.duration});
bool _blocked = false;
Duration duration;
//
void block(Function function) {
if (!_blocked) {
_blocked = true;
function();
Timer(duration, () {
_blocked = false;
});
}
}
//
void countdownProhibited({required Duration duration}) {
_blocked = true;
Timer(duration, () {
_blocked = false;
});
}
}