Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release
This commit is contained in:
commit
9bce7316b9
@ -680,7 +680,7 @@
|
|||||||
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.",
|
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.",
|
||||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.",
|
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.",
|
||||||
"密码生成后,请在当日23:59前使用,否则过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.",
|
"密码生成后,请在当日23:59前使用,否则过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",
|
||||||
|
|||||||
@ -683,7 +683,7 @@
|
|||||||
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。",
|
"密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。",
|
||||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
|
"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。",
|
||||||
"密码生成后,请在当日23:59前使用,否则过0点后失效。": "密码生成后,请在当日23:59前使用,否则过0点后失效。",
|
"密码生成后,请在当日23:59前使用,否则过0点后失效。": "密码生成后,请在当日23:59前使用,否则过0点后失效。",
|
||||||
"清空密码底部提示": "清空密码当日24点前有效\n清空内容1:当日0点前生成的除自定义以外所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)\n清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)\n如需彻底清除所有密码,请使用重置所有密码功能",
|
"清空密码底部提示": "清空密码当日24点前有效\n清空内容1:当日0点前生成的所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)\n清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)\n如需彻底清除所有密码,请使用重置所有密码功能",
|
||||||
"密码不一致哦": "密码不一致哦",
|
"密码不一致哦": "密码不一致哦",
|
||||||
"相机": "相机",
|
"相机": "相机",
|
||||||
"相册": "相册",
|
"相册": "相册",
|
||||||
|
|||||||
BIN
images/main/icon_addFingerprint_fingerprint_six.png
Normal file
BIN
images/main/icon_addFingerprint_fingerprint_six.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 308 KiB |
@ -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);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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),
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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) {
|
||||||
// 不需要联网
|
// 不需要联网
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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;限时2,单次3,循环:4
|
String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环: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;限时2,单次3,循环:4
|
String keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环: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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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(
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
74
lib/tools/throttler.dart
Normal 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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user