Merge branch 'master' of https://gitee.com/starlock-cn/app-starlock
# Conflicts: # star_lock/images/lan/lan_en.json # star_lock/images/lan/lan_keys.json # star_lock/images/lan/lan_zh.json # star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart
This commit is contained in:
commit
bf349e6413
1
star_lock/.fvm/flutter_sdk
Symbolic link
1
star_lock/.fvm/flutter_sdk
Symbolic link
@ -0,0 +1 @@
|
||||
/Users/mac/fvm/versions/3.16.5
|
||||
3
star_lock/.fvm/fvm_config.json
Normal file
3
star_lock/.fvm/fvm_config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"flutterSdkVersion": "3.16.5"
|
||||
}
|
||||
1
star_lock/.fvm/release
Normal file
1
star_lock/.fvm/release
Normal file
@ -0,0 +1 @@
|
||||
3.16.5
|
||||
1
star_lock/.fvm/version
Normal file
1
star_lock/.fvm/version
Normal file
@ -0,0 +1 @@
|
||||
3.16.5
|
||||
1
star_lock/.fvm/versions/3.16.5
Symbolic link
1
star_lock/.fvm/versions/3.16.5
Symbolic link
@ -0,0 +1 @@
|
||||
/Users/mac/fvm/versions/3.16.5
|
||||
@ -614,6 +614,7 @@
|
||||
"跳过": "Skip",
|
||||
"还未获取到位置信息哦,请耐心等待一下!": "The location information has not been obtained yet, please wait patiently!",
|
||||
"请填写信息": "Please fill in the information",
|
||||
<<<<<<< HEAD
|
||||
"有效期": "Validity period",
|
||||
"生效时间": "Effective time",
|
||||
"失效时间": "Expiration time",
|
||||
@ -627,4 +628,22 @@
|
||||
"根据提示,抬起手指后再进行下一次指纹采集": "According to the prompt, lift your finger and then collect the fingerprint again",
|
||||
"添加成功": "Add success",
|
||||
"搜索": "Search"
|
||||
|
||||
"permission_dialog_camera": "camera",
|
||||
"permission_dialog_photos": "photos",
|
||||
"permission_dialog_storage": "storage",
|
||||
"permission_dialog_location": "location",
|
||||
"permission_dialog_camera_text": "Access to the camera is required to take photos and upload files, such as uploading a profile picture",
|
||||
"permission_dialog_photos_text": "Access to camera is required to upload files and avatars using album images",
|
||||
"permission_dialog_storage_text": "Access to read and write permissions is required to upload avatars using local images",
|
||||
"permission_dialog_location_text": "Access to location information is required to use the add key function",
|
||||
"permission_dialog_application": "application",
|
||||
"permission_dialog_authority": "permission",
|
||||
"permission_dialog_not_allowed": "Not Allowed",
|
||||
"permission_dialog_allowed": "Allowed",
|
||||
"permission_dialog_permission_denied": "Permission denied",
|
||||
"permission_dialog_open_permissions": "Please manually enable it in the system settings",
|
||||
"permission_dialog_permission_continue_text": "Permission to continue using the application.",
|
||||
"permission_dialog_go_set_up": "Go set it up"
|
||||
|
||||
}
|
||||
|
||||
@ -615,6 +615,7 @@
|
||||
"跳过": "跳过",
|
||||
"还未获取到位置信息哦,请耐心等待一下!": "还未获取到位置信息哦,请耐心等待一下!",
|
||||
"请填写信息": "请填写信息",
|
||||
<<<<<<< HEAD
|
||||
"有效期": "有效期",
|
||||
"生效时间": "生效时间",
|
||||
"失效时间": "失效时间",
|
||||
@ -628,4 +629,21 @@
|
||||
"根据提示,抬起手指后再进行下一次指纹采集": "根据提示,抬起手指后再进行下一次指纹采集",
|
||||
"添加成功": "添加成功",
|
||||
"搜索": "搜索"
|
||||
|
||||
"permission_dialog_camera": "相机",
|
||||
"permission_dialog_photos": "相册",
|
||||
"permission_dialog_storage": "读写",
|
||||
"permission_dialog_location": "定位",
|
||||
"permission_dialog_camera_text": "需要访问相机权限才能拍照上传文件例如头像上传",
|
||||
"permission_dialog_photos_text": "需要访问相机权限才能使用相册图片上传文件上传头像",
|
||||
"permission_dialog_storage_text": "需要访问读写权限才能使用本地图片上传头像",
|
||||
"permission_dialog_location_text": "需要访问定位权限才能使用添加钥匙功能的位置信息",
|
||||
"permission_dialog_application": "申请",
|
||||
"permission_dialog_authority": "权限",
|
||||
"permission_dialog_not_allowed": "不允许",
|
||||
"permission_dialog_allowed": "允许",
|
||||
"permission_dialog_permission_denied": "权限被拒绝",
|
||||
"permission_dialog_open_permissions": "请手动在系统设置中开启",
|
||||
"permission_dialog_permission_continue_text": "权限以继续使用应用。",
|
||||
"permission_dialog_go_set_up": "去设置"
|
||||
}
|
||||
|
||||
@ -616,6 +616,7 @@
|
||||
"跳过": "跳过",
|
||||
"还未获取到位置信息哦,请耐心等待一下!": "还未获取到位置信息哦,请耐心等待一下!",
|
||||
"请填写信息": "请填写信息",
|
||||
<<<<<<< HEAD
|
||||
"有效期": "有效期",
|
||||
"生效时间": "生效时间",
|
||||
"失效时间": "失效时间",
|
||||
@ -629,4 +630,22 @@
|
||||
"根据提示,抬起手指后再进行下一次指纹采集": "根据提示,抬起手指后再进行下一次指纹采集",
|
||||
"添加成功": "添加成功",
|
||||
"搜索": "搜索"
|
||||
|
||||
"permission_dialog_camera": "相机",
|
||||
"permission_dialog_photos": "相册",
|
||||
"permission_dialog_storage": "读写",
|
||||
"permission_dialog_location": "定位",
|
||||
"permission_dialog_camera_text": "需要访问相机权限才能拍照上传文件例如头像上传",
|
||||
"permission_dialog_photos_text": "需要访问相机权限才能使用相册图片上传文件上传头像",
|
||||
"permission_dialog_storage_text": "需要访问读写权限才能使用本地图片上传头像",
|
||||
"permission_dialog_location_text": "需要访问定位权限才能使用添加钥匙功能的位置信息",
|
||||
"permission_dialog_application": "申请",
|
||||
"permission_dialog_authority": "权限",
|
||||
"permission_dialog_not_allowed": "不允许",
|
||||
"permission_dialog_allowed": "允许",
|
||||
"permission_dialog_permission_denied": "权限被拒绝",
|
||||
"permission_dialog_open_permissions": "请手动在系统设置中开启",
|
||||
"permission_dialog_permission_continue_text": "权限以继续使用应用。",
|
||||
"permission_dialog_go_set_up": "去设置"
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +25,9 @@ import 'package:star_lock/main/lockDetail/lockSet/msgNotification/msgNotificatio
|
||||
import 'package:star_lock/main/lockDetail/lockSet/notificationMode/notificationMode_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/openDoorDirection/openDoorDirection_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmTypeManage/addPalmTypeManage_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/palmList/palmList_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart';
|
||||
import 'package:star_lock/mine/about/webviewShow_page.dart';
|
||||
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
|
||||
@ -423,7 +426,11 @@ abstract class Routers {
|
||||
|
||||
static const irisListPage = '/IrisListPage'; // 虹膜列表
|
||||
static const addIrisTypeManagePage = '/AddIrisTypeManagePage'; // 添加虹膜
|
||||
static const addIrisPage = '/AddIrisPage'; // 添加虹膜
|
||||
static const addIrisPage = '/AddIrisPage'; // 添加虹膜过程
|
||||
|
||||
static const palmListPage = '/PalmListPage'; // 手掌列表
|
||||
static const addPalmTypeManagePage = '/AddPalmTypeManagePage'; // 添加手掌
|
||||
static const addPalmPage = '/AddPalmPage'; // 添加手掌过程
|
||||
|
||||
static const passwordKeyDetailChangeDatePage =
|
||||
'/passwordKeyDetailChangeDatePage'; //密码更改时间
|
||||
@ -1044,6 +1051,11 @@ abstract class AppRouters {
|
||||
GetPage(
|
||||
name: Routers.addIrisTypeManagePage,
|
||||
page: (() => const AddIrisTypeManagePage())),
|
||||
GetPage(name: Routers.addIrisPage, page: (() => const AddIrisPage()))
|
||||
GetPage(name: Routers.addIrisPage, page: (() => const AddIrisPage())),
|
||||
GetPage(name: Routers.palmListPage, page: (() => const PalmListPage())),
|
||||
GetPage(
|
||||
name: Routers.addPalmTypeManagePage,
|
||||
page: (() => const AddPalmTypeManagePage())),
|
||||
GetPage(name: Routers.addPalmPage, page: (() => const AddPalmPage()))
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -42,7 +41,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
Widget build(BuildContext context) {
|
||||
state.selectType.value = widget.selectType;
|
||||
state.lockId.value = widget.lockId;
|
||||
if(widget.fromTypeTwoStaffName.isNotEmpty){
|
||||
if (widget.fromTypeTwoStaffName.isNotEmpty) {
|
||||
state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
}
|
||||
state.fromType.value = widget.fromType;
|
||||
@ -56,12 +55,14 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if(state.selectType.value == "1"){
|
||||
state.beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
state.endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString());//默认为当前时间
|
||||
}else{
|
||||
if (state.selectType.value == "1") {
|
||||
state.beginTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
state.endTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
} else {
|
||||
state.beginTime.value = ""; //默认为当前时间
|
||||
state.endTime.value = "";//默认为当前时间
|
||||
state.endTime.value = ""; //默认为当前时间
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -141,7 +142,8 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
@ -150,7 +152,8 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
@ -160,7 +163,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
}
|
||||
|
||||
// 循环顶部选择日期
|
||||
Widget keyCyclicDate(){
|
||||
Widget keyCyclicDate() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
@ -169,21 +172,22 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if(result != null && result.isNotEmpty){
|
||||
var result =
|
||||
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
Get.log(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
@ -202,20 +206,20 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if(result != null && result.isNotEmpty){
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
}
|
||||
})
|
||||
)),
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.effectiveDateTime.value.isNotEmpty,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效时间".tr,
|
||||
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
||||
rightTitle:
|
||||
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
@ -226,7 +230,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if(result != null && result.isNotEmpty){
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
@ -234,8 +238,7 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.back(result: result);
|
||||
}
|
||||
})
|
||||
)),
|
||||
}))),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -248,8 +251,8 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _isAdmin()))),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.stressCard!.tr,
|
||||
@ -318,7 +321,8 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
LengthLimitingTextInputFormatter(18),
|
||||
],
|
||||
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
@ -327,10 +331,18 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
),
|
||||
@ -368,5 +380,4 @@ class _AddCardPageState extends State<AddCardPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
|
||||
@ -12,18 +13,28 @@ class AddFaceTypeLogic extends BaseGetXController {
|
||||
var faceType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
var startTime = "";
|
||||
var endTime = "";
|
||||
if (state.selectType.value == "0") {
|
||||
faceType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
} else if (state.seletType.value == "1") {
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
} else if (state.selectType.value == "1") {
|
||||
faceType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
showToast("请选择开始时间");
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast("请选择开始时间".tr);
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
showToast("请选择结束时间");
|
||||
if (endDate.isEmpty) {
|
||||
showToast("请选择结束时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,45 +43,25 @@ class AddFaceTypeLogic extends BaseGetXController {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
showToast("请选择生效时间");
|
||||
} else if (state.selectType.value == "2") {
|
||||
if (state.beginTime.value.isEmpty) {
|
||||
showToast("请选择有效期".tr);
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
showToast("请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
showToast("请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = DateTool()
|
||||
.dateToTimestamp(state.effectiveDateTime.value, 0)
|
||||
.toString();
|
||||
endTime =
|
||||
DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
|
||||
faceType = 4;
|
||||
}
|
||||
|
||||
print(
|
||||
"传出去的给你限时人脸开始时间:${int.parse(startDate) ~/ 1000} 限时人脸结束时间:${int.parse(endDate) ~/ 1000}");
|
||||
// 人脸
|
||||
Get.toNamed(Routers.addFacePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
@ -37,9 +39,9 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.selectType;
|
||||
state.selectType.value = widget.selectType;
|
||||
state.lockId.value = widget.lockId;
|
||||
if(widget.fromTypeTwoStaffName.isNotEmpty){
|
||||
if (widget.fromTypeTwoStaffName.isNotEmpty) {
|
||||
state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
}
|
||||
state.fromType.value = widget.fromType;
|
||||
@ -47,12 +49,29 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (state.selectType.value == "1") {
|
||||
state.beginTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
state.endTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
} else {
|
||||
state.beginTime.value = ""; //默认为当前时间
|
||||
state.endTime.value = ""; //默认为当前时间
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.selectType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
@ -86,21 +105,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(
|
||||
Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value =
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
print(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
keyCyclicDate(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
@ -139,12 +144,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -154,12 +154,7 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
@ -167,16 +162,90 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 循环顶部选择日期
|
||||
Widget keyCyclicDate() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result =
|
||||
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.log(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: state.weekdaysList.isNotEmpty ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效日",
|
||||
rightTitle: state.weekdaysList.value.join(",").toString(),
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
}
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.effectiveDateTime.value.isNotEmpty,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效时间".tr,
|
||||
rightTitle:
|
||||
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.back(result: result);
|
||||
}
|
||||
}))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.face!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(
|
||||
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
@ -205,97 +274,48 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成'.tr,
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
// color: Colors.red,
|
||||
height: 65.h,
|
||||
width: 300.w,
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
LengthLimitingTextInputFormatter(18),
|
||||
],
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
|
||||
class AddFaceTypeState {
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs; // 0永久 1显示 2循环
|
||||
final selectType = "0".obs; // 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "".obs; // 考勤添加人脸员工名字
|
||||
final isStressFingerprint = false.obs;
|
||||
@ -11,11 +11,8 @@ class AddFaceTypeState {
|
||||
|
||||
var beginTime = "".obs; // 开始时间
|
||||
var endTime = "".obs; // 结束时间
|
||||
var beginTimeTimestamp = "".obs; // 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs; // 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs; // 生效时间
|
||||
var failureDateTime = 0.obs; // 失效时间
|
||||
var effectiveDateTime = "".obs; // 生效时间
|
||||
var failureDateTime = "".obs; // 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
|
||||
@ -1,24 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'package:star_lock/main/lockDetail/iris/addIris/addIris_state.dart';
|
||||
|
||||
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/face/addFace/addFace_state.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
|
||||
import '../../../../../blue/blue_manage.dart';
|
||||
import '../../../../../blue/io_reply.dart';
|
||||
import '../../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../../blue/sender_manage.dart';
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
import '../../../../../tools/storage.dart';
|
||||
|
||||
class AddIrisLogic extends BaseGetXController {
|
||||
final AddFaceState state = AddFaceState();
|
||||
final AddIrisState state = AddIrisState();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
|
||||
@ -22,10 +22,10 @@ class AddIrisTypeManageTabbar extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<AddIrisTypeManageTabbar> createState() =>
|
||||
_AddFaceTypeManageTabbarState();
|
||||
_AddIrisTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddFaceTypeManageTabbarState extends State<AddIrisTypeManageTabbar>
|
||||
class _AddIrisTypeManageTabbarState extends State<AddIrisTypeManageTabbar>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
|
||||
@ -1,29 +1,40 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/face/addFaceType/addFaceType_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/iris/addIrisType/addIrisType_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
|
||||
class AddIrisTypeLogic extends BaseGetXController {
|
||||
AddFaceTypeState state = AddFaceTypeState();
|
||||
AddIrisTypeState state = AddIrisTypeState();
|
||||
|
||||
// 添加指纹
|
||||
void addFaceData() async {
|
||||
var faceType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
// 添加虹膜
|
||||
void addIrisData() async {
|
||||
var irisType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
if (state.seletType.value == "0") {
|
||||
faceType = 1;
|
||||
var startTime = "";
|
||||
var endTime = "";
|
||||
if (state.selectType.value == "0") {
|
||||
irisType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
} else if (state.seletType.value == "1") {
|
||||
faceType = 2;
|
||||
if (state.beginTimeTimestamp.value.isEmpty) {
|
||||
showToast("请选择开始时间");
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
} else if (state.selectType.value == "1") {
|
||||
irisType = 2;
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast("请选择开始时间".tr);
|
||||
return;
|
||||
}
|
||||
if (state.endTimeTimestamp.value.isEmpty) {
|
||||
showToast("请选择结束时间");
|
||||
if (endDate.isEmpty) {
|
||||
showToast("请选择结束时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,53 +43,33 @@ class AddIrisTypeLogic extends BaseGetXController {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(state.beginTimeTimestamp.value) >=
|
||||
int.parse(state.endTimeTimestamp.value)) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
startDate = state.beginTimeTimestamp.value;
|
||||
endDate = state.endTimeTimestamp.value;
|
||||
} else if (state.seletType.value == "2") {
|
||||
if (state.effectiveDateTime.value <= 0) {
|
||||
showToast("请选择生效时间");
|
||||
} else if (state.selectType.value == "2") {
|
||||
if (state.beginTime.value.isEmpty) {
|
||||
showToast("请选择有效期".tr);
|
||||
return;
|
||||
}
|
||||
if (state.failureDateTime.value <= 0) {
|
||||
showToast("请选择失效时间");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.weekdaysList.value.isEmpty) {
|
||||
showToast("请选择有效日");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch >= state.effectiveDateTime.value){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (state.effectiveDateTime.value >= state.failureDateTime.value) {
|
||||
showToast("失效时间要大于生效时间");
|
||||
return;
|
||||
}
|
||||
startDate = state.effectiveDateTime.value.toString();
|
||||
endDate = state.failureDateTime.value.toString();
|
||||
faceType = 4;
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = DateTool()
|
||||
.dateToTimestamp(state.effectiveDateTime.value, 0)
|
||||
.toString();
|
||||
endTime =
|
||||
DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
|
||||
irisType = 4;
|
||||
}
|
||||
|
||||
print(
|
||||
"传出去的给你限时人脸开始时间:${int.parse(startDate) ~/ 1000} 限时人脸结束时间:${int.parse(endDate) ~/ 1000}");
|
||||
// 人脸
|
||||
// 虹膜
|
||||
Get.toNamed(Routers.addIrisPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": int.parse(endDate),
|
||||
"addType": "1",
|
||||
"faceName": state.nameController.text,
|
||||
"faceNumber": "123456",
|
||||
"faceType": faceType,
|
||||
"faceType": irisType,
|
||||
"startDate": int.parse(startDate),
|
||||
"cyclicConfig": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
@ -87,13 +78,13 @@ class AddIrisTypeLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 校验指纹名字是否重复
|
||||
void checkFaceNameDuplicated(String faceName) async {
|
||||
void checkIrisNameDuplicated(String irisName) async {
|
||||
var entity = await ApiRepository.to.checkFaceNameDuplicatedData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
faceName: faceName,
|
||||
faceName: irisName,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
addFaceData();
|
||||
addIrisData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/iris/addIrisType/addIrisType_logic.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
@ -28,16 +30,16 @@ class AddIrisTypePage extends StatefulWidget {
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<AddIrisTypePage> createState() => _AddFaceTypePageState();
|
||||
State<AddIrisTypePage> createState() => _AddIrisTypePageState();
|
||||
}
|
||||
|
||||
class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
class _AddIrisTypePageState extends State<AddIrisTypePage> {
|
||||
final logic = Get.put(AddIrisTypeLogic());
|
||||
final state = Get.find<AddIrisTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.seletType.value = widget.selectType;
|
||||
state.selectType.value = widget.selectType;
|
||||
state.lockId.value = widget.lockId;
|
||||
if (widget.fromTypeTwoStaffName.isNotEmpty) {
|
||||
state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
@ -47,12 +49,29 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (state.selectType.value == "1") {
|
||||
state.beginTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
state.endTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
} else {
|
||||
state.beginTime.value = ""; //默认为当前时间
|
||||
state.endTime.value = ""; //默认为当前时间
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.selectType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
// return sendElectronicKeySucceed();
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
@ -86,21 +105,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Map result = await Get.toNamed(
|
||||
Routers.electronicKeyPeriodValidityPage);
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.effectiveDateTime.value =
|
||||
result['starDate'].millisecondsSinceEpoch;
|
||||
state.failureDateTime.value =
|
||||
result['endDate'].millisecondsSinceEpoch;
|
||||
print(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}),
|
||||
keyCyclicDate(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
@ -139,12 +144,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.beginTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.beginTimeTimestamp.value =
|
||||
DateTime.parse(state.beginTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
@ -154,12 +154,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.endTime.value =
|
||||
'${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}';
|
||||
state.endTimeTimestamp.value =
|
||||
DateTime.parse(state.endTime.value)
|
||||
.millisecondsSinceEpoch
|
||||
.toString();
|
||||
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
@ -167,16 +162,90 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 循环顶部选择日期
|
||||
Widget keyCyclicDate() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result =
|
||||
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.log(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: state.weekdaysList.isNotEmpty ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效日",
|
||||
rightTitle: state.weekdaysList.value.join(",").toString(),
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
}
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.effectiveDateTime.value.isNotEmpty,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效时间".tr,
|
||||
rightTitle:
|
||||
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.back(result: result);
|
||||
}
|
||||
}))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
// CommonItem(
|
||||
// leftTitel: TranslationLoader.lanKeys!.face!.tr,
|
||||
// rightTitle: "",
|
||||
// isTipsImg: false,
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: SizedBox(
|
||||
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
@ -195,7 +264,7 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
logic.showToast("请输入姓名");
|
||||
return;
|
||||
}
|
||||
logic.checkFaceNameDuplicated(state.nameController.text);
|
||||
logic.checkIrisNameDuplicated(state.nameController.text);
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
@ -205,97 +274,48 @@ class _AddFaceTypePageState extends State<AddIrisTypePage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 300.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_main_addLock.png',
|
||||
width: 150.w,
|
||||
height: 150.w,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Text(
|
||||
"操作成功,密码为",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Text(
|
||||
"62689876",
|
||||
style: TextStyle(
|
||||
fontSize: 60.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
SubmitBtn(
|
||||
btnName: '完成',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '分享',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
SubmitBtn(
|
||||
btnName: '标记为:已入住',
|
||||
fontSize: 28.sp,
|
||||
borderRadius: 20.w,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
onClick: () {}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
// color: Colors.red,
|
||||
height: 65.h,
|
||||
width: 300.w,
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
LengthLimitingTextInputFormatter(18),
|
||||
],
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddFaceTypeState {
|
||||
class AddIrisTypeState {
|
||||
final lockId = 0.obs;
|
||||
final seletType = "0".obs; // 0永久 1显示 2循环
|
||||
final selectType = "0".obs; // 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "".obs; // 考勤添加人脸员工名字
|
||||
final isStressFingerprint = false.obs;
|
||||
@ -11,15 +11,12 @@ class AddFaceTypeState {
|
||||
|
||||
var beginTime = "".obs; // 开始时间
|
||||
var endTime = "".obs; // 结束时间
|
||||
var beginTimeTimestamp = "".obs; // 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs; // 结束时间时间戳
|
||||
|
||||
var effectiveDateTime = 0.obs; // 生效时间
|
||||
var failureDateTime = 0.obs; // 失效时间
|
||||
var effectiveDateTime = "".obs; // 生效时间
|
||||
var failureDateTime = "".obs; // 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddFaceTypeState() {
|
||||
AddIrisTypeState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
|
||||
@ -299,7 +299,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 删除人脸
|
||||
Future<void> senderAddFace() async {
|
||||
Future<void> senderAddIris() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
@ -339,8 +339,8 @@ class IrisListLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
// 获取人脸列表
|
||||
void getFaceListData() async {
|
||||
// 获取虹膜列表
|
||||
void getIrisListData() async {
|
||||
var entity = await ApiRepository.to.getFaceListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
@ -368,7 +368,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功");
|
||||
state.isDeletFaceData = false;
|
||||
getFaceListData();
|
||||
getIrisListData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,7 +387,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("重置成功");
|
||||
state.isDeletFaceData = false;
|
||||
getFaceListData();
|
||||
getIrisListData();
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
getFaceListData();
|
||||
getIrisListData();
|
||||
});
|
||||
}
|
||||
|
||||
@ -409,11 +409,11 @@ class IrisListLogic extends BaseGetXController {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
// print("aaaaaaa:$isDemoMode");
|
||||
if (isDemoMode == false) {
|
||||
_initReplySubscription();
|
||||
// _initReplySubscription();
|
||||
|
||||
_initRefreshAction();
|
||||
// _initRefreshAction();
|
||||
|
||||
getFaceListData();
|
||||
// getFaceListData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ class _IrisListPageState extends State<IrisListPage> {
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
onSubmittedAction: () {
|
||||
logic.getFaceListData();
|
||||
// logic.getFaceListData();
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
@ -79,7 +79,7 @@ class _IrisListPageState extends State<IrisListPage> {
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFaceListData();
|
||||
// logic.getFaceListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -127,7 +127,7 @@ class _IrisListPageState extends State<IrisListPage> {
|
||||
"faceItemData": getFaceItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getFaceListData();
|
||||
// logic.getFaceListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
@ -182,7 +182,7 @@ class _IrisListPageState extends State<IrisListPage> {
|
||||
state.isDeletFaceData = true;
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
logic.senderAddFace();
|
||||
// logic.senderAddFace();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
@ -269,7 +269,7 @@ class _IrisListPageState extends State<IrisListPage> {
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletFaceNo = 255;
|
||||
logic.senderAddFace();
|
||||
// logic.senderAddFace();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -688,12 +688,12 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
);
|
||||
|
||||
showWidgetArr.add(
|
||||
bottomItem(
|
||||
'images/main/icon_face.png',
|
||||
'手掌',
|
||||
state.openDoorBtnisUneable.value,
|
||||
state.bottomBtnisEable.value,
|
||||
() {}),
|
||||
bottomItem('images/main/icon_face.png', '手掌',
|
||||
state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.palmListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
//可视对讲门锁新增->监控
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_state.dart';
|
||||
|
||||
import '../../../../../tools/baseGetXController.dart';
|
||||
|
||||
class AddPalmLogic extends BaseGetXController {
|
||||
final AddPalmState state = AddPalmState();
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
// _initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
//开始添加后发送指令
|
||||
// senderAddFace();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
// _replySubscription.cancel();
|
||||
}
|
||||
}
|
||||
94
star_lock/lib/main/lockDetail/palm/addPalm/addPalm_page.dart
Normal file
94
star_lock/lib/main/lockDetail/palm/addPalm/addPalm_page.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalm/addPalm_logic.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/submitBtn.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
|
||||
class AddPalmPage extends StatefulWidget {
|
||||
const AddPalmPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddPalmPage> createState() => _AddPalmPageState();
|
||||
}
|
||||
|
||||
class _AddPalmPageState extends State<AddPalmPage> {
|
||||
final logic = Get.put(AddPalmLogic());
|
||||
final state = Get.find<AddPalmLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}手掌",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50.h,
|
||||
),
|
||||
Obx(() => Image.asset(
|
||||
state.isClickAddFace.value == false
|
||||
? 'images/main/icon_addFace_step1.png'
|
||||
: 'images/main/icon_addFace_step2.png',
|
||||
width: 100.w,
|
||||
height: 457.h,
|
||||
fit: BoxFit.fitHeight,
|
||||
)),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"请单人正对门锁,距离一个成年人手臂长度\n(约0.6米)。\n保持脸部无遮挡,露出五官。",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: null,
|
||||
style:
|
||||
TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 120.h,
|
||||
),
|
||||
Obx(
|
||||
() => state.isClickAddFace.value == false
|
||||
? Container(
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
||||
child: SubmitBtn(
|
||||
btnName: "准备好了,开始添加",
|
||||
borderRadius: 20.w,
|
||||
onClick: () {
|
||||
state.isClickAddFace.value = true;
|
||||
}),
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'正在录入中...',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor,
|
||||
fontSize: 22.sp),
|
||||
textAlign: TextAlign.center,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddPalmState {
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
|
||||
var ifConnectScuess = false.obs;
|
||||
var maxRegCount = 0.obs; // 最大注册次数
|
||||
var regIndex = 0.obs; // 当前注册次数
|
||||
|
||||
var faceNumber = "".obs;
|
||||
|
||||
final lockId = 0.obs;
|
||||
final endDate = 0.obs;
|
||||
final addType = "".obs;
|
||||
final faceName = "".obs;
|
||||
final faceType = 0.obs;
|
||||
final startDate = 0.obs;
|
||||
final cyclicConfig = [].obs;
|
||||
final fromType = 1.obs;
|
||||
final featureData = ''.obs;
|
||||
final isClickAddFace = false.obs;
|
||||
final isAdministrator = false.obs;
|
||||
|
||||
AddPalmState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
endDate.value = map["endDate"];
|
||||
addType.value = map["addType"];
|
||||
faceName.value = map["faceName"];
|
||||
faceType.value = map["faceType"];
|
||||
startDate.value = map["startDate"];
|
||||
lockId.value = map["lockId"];
|
||||
cyclicConfig.value = map["cyclicConfig"];
|
||||
fromType.value = map["fromType"];
|
||||
isAdministrator.value = map["isAdministrator"];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmTypeManage/addPalmTypeManage_tabbar.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/titleAppBar.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
|
||||
class AddPalmTypeManagePage extends StatefulWidget {
|
||||
const AddPalmTypeManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddPalmTypeManagePage> createState() => _AddPalmTypeManagePageState();
|
||||
}
|
||||
|
||||
class _AddPalmTypeManagePageState extends State<AddPalmTypeManagePage> {
|
||||
var index = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Map map = Get.arguments;
|
||||
var lockId = map["lockId"];
|
||||
var fromType = map["fromType"]; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "";
|
||||
if (fromType == 2) {
|
||||
fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: "${TranslationLoader.lanKeys!.addTip!.tr}手掌",
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
AddPalmTypeManageTabbar(
|
||||
lockId: lockId,
|
||||
fromType: fromType,
|
||||
fromTypeTwoStaffName: fromTypeTwoStaffName,
|
||||
initialIndex: index),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_page.dart';
|
||||
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
import '../../../../../tools/CustomUnderlineTabIndicator.dart';
|
||||
import '../../../../../translations/trans_lib.dart';
|
||||
|
||||
class AddPalmTypeManageTabbar extends StatefulWidget {
|
||||
var initialIndex = 1;
|
||||
var lockId = 0;
|
||||
var fromType = 1; // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = ""; // 从添加员工进入 传入员工名字
|
||||
AddPalmTypeManageTabbar(
|
||||
{Key? key,
|
||||
required this.lockId,
|
||||
required this.fromType,
|
||||
required this.fromTypeTwoStaffName,
|
||||
required this.initialIndex})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<AddPalmTypeManageTabbar> createState() =>
|
||||
_AddPalmTypeManageTabbarState();
|
||||
}
|
||||
|
||||
class _AddPalmTypeManageTabbarState extends State<AddPalmTypeManageTabbar>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
|
||||
ItemView(
|
||||
title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"),
|
||||
];
|
||||
|
||||
final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
|
||||
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
|
||||
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
vsync: this,
|
||||
length: _itemTabs.length,
|
||||
initialIndex: widget.initialIndex);
|
||||
|
||||
_tabController.addListener(() {
|
||||
// print("_tabController.animation!.value:${_tabController.animation!.value} _tabController.index:${_tabController.index}");
|
||||
if (_tabController.animation!.value == _tabController.index) {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
TabBar _tabBar() {
|
||||
return TabBar(
|
||||
controller: _tabController,
|
||||
tabs: widget.fromType == 1
|
||||
? _itemTabs.map((ItemView item) => _tab(item)).toList()
|
||||
: _fromCheckInTypeItemTabs
|
||||
.map((ItemView item) => _tab(item))
|
||||
.toList(),
|
||||
isScrollable: true,
|
||||
indicatorColor: Colors.red,
|
||||
unselectedLabelColor: Colors.black,
|
||||
unselectedLabelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
),
|
||||
automaticIndicatorColorAdjustment: true,
|
||||
labelColor: AppColors.mainColor,
|
||||
labelStyle: TextStyle(
|
||||
color: AppColors.mainColor,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
indicator: CustomUnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
|
||||
strokeCap: StrokeCap.round,
|
||||
width: 30.w),
|
||||
);
|
||||
}
|
||||
|
||||
Tab _tab(ItemView item) {
|
||||
return Tab(
|
||||
child: SizedBox(
|
||||
width: 1.sw / 5,
|
||||
child: Text(item.title, textAlign: TextAlign.center)));
|
||||
}
|
||||
|
||||
Widget _pageWidget() {
|
||||
return Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: widget.fromType == 1
|
||||
? _itemTabs
|
||||
.map((ItemView item) => AddPalmTypePage(
|
||||
selectType: item.selectType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName: widget.fromTypeTwoStaffName))
|
||||
.toList()
|
||||
: _itemTabs
|
||||
.map((ItemView item) => AddPalmTypePage(
|
||||
selectType: item.selectType,
|
||||
lockId: widget.lockId,
|
||||
fromType: widget.fromType,
|
||||
fromTypeTwoStaffName: widget.fromTypeTwoStaffName))
|
||||
.toList(),
|
||||
|
||||
// _itemTabs.map((ItemView item) => AddFaceTypePage(selectType: item.selectType, lockId: widget.lockId, fromType: widget.fromType, fromTypeTwoStaffName:widget.fromTypeTwoStaffName)).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemView {
|
||||
const ItemView({required this.title, required this.selectType});
|
||||
|
||||
final String title;
|
||||
final String selectType;
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
|
||||
class AddPalmTypeLogic extends BaseGetXController {
|
||||
AddPalmTypeState state = AddPalmTypeState();
|
||||
|
||||
// 添加指纹
|
||||
void addPalmData() async {
|
||||
var palmType = 0; // 永久:1;限时2,单次3,循环:4
|
||||
var startDate = "";
|
||||
var endDate = "";
|
||||
var startTime = "";
|
||||
var endTime = "";
|
||||
if (state.selectType.value == "0") {
|
||||
palmType = 1;
|
||||
startDate = "0";
|
||||
endDate = "0";
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
} else if (state.selectType.value == "1") {
|
||||
palmType = 2;
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = "0";
|
||||
endTime = "0";
|
||||
|
||||
if (startDate.isEmpty) {
|
||||
showToast("请选择开始时间".tr);
|
||||
return;
|
||||
}
|
||||
if (endDate.isEmpty) {
|
||||
showToast("请选择结束时间".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
|
||||
// Toast.show(msg: "生效时间要大于当前时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (int.parse(startDate) >= int.parse(endDate)) {
|
||||
showToast("失效时间要大于生效时间".tr);
|
||||
return;
|
||||
}
|
||||
} else if (state.selectType.value == "2") {
|
||||
if (state.beginTime.value.isEmpty) {
|
||||
showToast("请选择有效期".tr);
|
||||
return;
|
||||
}
|
||||
startDate =
|
||||
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
|
||||
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
|
||||
startTime = DateTool()
|
||||
.dateToTimestamp(state.effectiveDateTime.value, 0)
|
||||
.toString();
|
||||
endTime =
|
||||
DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
|
||||
palmType = 4;
|
||||
}
|
||||
// 人脸
|
||||
Get.toNamed(Routers.addPalmPage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"endDate": int.parse(endDate),
|
||||
"addType": "1",
|
||||
"faceName": state.nameController.text,
|
||||
"faceNumber": "123456",
|
||||
"faceType": palmType,
|
||||
"startDate": int.parse(startDate),
|
||||
"cyclicConfig": state.weekdaysList.value,
|
||||
"fromType": state.fromType.value,
|
||||
"isAdministrator": state.isAdministrator.value,
|
||||
});
|
||||
}
|
||||
|
||||
// 校验手掌名字是否重复
|
||||
void checkPalmNameDuplicated(String palmName) async {
|
||||
var entity = await ApiRepository.to.checkFaceNameDuplicatedData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
faceName: palmName,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
addPalmData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,342 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/addPalmType/addPalmType_logic.dart';
|
||||
import 'package:star_lock/tools/dateTool.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
|
||||
class AddPalmTypePage extends StatefulWidget {
|
||||
final String selectType; // 永久限时循环下标
|
||||
final int lockId;
|
||||
final int fromType; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
final String fromTypeTwoStaffName; // 从添加员工进入 传入员工名字
|
||||
|
||||
const AddPalmTypePage(
|
||||
{Key? key,
|
||||
required this.selectType,
|
||||
required this.lockId,
|
||||
required this.fromType,
|
||||
required this.fromTypeTwoStaffName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<AddPalmTypePage> createState() => _AddPalmTypePageState();
|
||||
}
|
||||
|
||||
class _AddPalmTypePageState extends State<AddPalmTypePage> {
|
||||
final logic = Get.put(AddPalmTypeLogic());
|
||||
final state = Get.find<AddPalmTypeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
state.selectType.value = widget.selectType;
|
||||
state.lockId.value = widget.lockId;
|
||||
if (widget.fromTypeTwoStaffName.isNotEmpty) {
|
||||
state.nameController.text = widget.fromTypeTwoStaffName;
|
||||
}
|
||||
state.fromType.value = widget.fromType;
|
||||
|
||||
return indexChangeWidget();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (state.selectType.value == "1") {
|
||||
state.beginTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
state.endTime.value = DateTool().dateToYMDHNString(
|
||||
DateTime.now().millisecondsSinceEpoch.toString()); //默认为当前时间
|
||||
} else {
|
||||
state.beginTime.value = ""; //默认为当前时间
|
||||
state.endTime.value = ""; //默认为当前时间
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget indexChangeWidget() {
|
||||
switch (int.parse(widget.selectType)) {
|
||||
case 0:
|
||||
{
|
||||
// 永久
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyTimeLimitWidget(),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
// 循环
|
||||
return Column(
|
||||
children: [
|
||||
perpetualKeyWidget(
|
||||
TranslationLoader.lanKeys!.name!.tr,
|
||||
TranslationLoader.lanKeys!.pleaseEnter!.tr,
|
||||
state.nameController),
|
||||
keyCyclicDate(),
|
||||
SizedBox(height: 10.h),
|
||||
keyBottomWidget()
|
||||
],
|
||||
);
|
||||
}
|
||||
default:
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
// 密码命名输入框
|
||||
Widget perpetualKeyWidget(
|
||||
String titleStr, String rightTitle, TextEditingController controller) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(height: 10.h),
|
||||
CommonItem(
|
||||
leftTitel: titleStr,
|
||||
rightTitle: "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(rightTitle)),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 限时顶部选择日期
|
||||
Widget keyTimeLimitWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
||||
rightTitle: state.beginTime.value,
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
||||
rightTitle: state.endTime.value,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
||||
onConfirm: (p) {
|
||||
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
|
||||
});
|
||||
})),
|
||||
Container(height: 10.h),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 循环顶部选择日期
|
||||
Widget keyCyclicDate() {
|
||||
return Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
||||
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result =
|
||||
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.log(
|
||||
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
|
||||
}
|
||||
})),
|
||||
Obx(() => Visibility(
|
||||
visible: state.weekdaysList.isNotEmpty ? true : false,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效日",
|
||||
rightTitle: state.weekdaysList.value.join(",").toString(),
|
||||
isHaveDirection: true,
|
||||
isHaveLine: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
}
|
||||
}))),
|
||||
Obx(() => Visibility(
|
||||
visible: state.effectiveDateTime.value.isNotEmpty,
|
||||
child: CommonItem(
|
||||
leftTitel: "有效时间".tr,
|
||||
rightTitle:
|
||||
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
|
||||
arguments: {
|
||||
'validityValue': state.weekdaysList.value,
|
||||
'starDate': state.beginTime.value,
|
||||
'endDate': state.endTime.value,
|
||||
'starTime': state.effectiveDateTime.value,
|
||||
'endTime': state.failureDateTime.value
|
||||
});
|
||||
if (result != null && result.isNotEmpty) {
|
||||
state.weekdaysList.value = result['validityValue'];
|
||||
state.beginTime.value = result['starDate'];
|
||||
state.endTime.value = result['endDate'];
|
||||
state.effectiveDateTime.value = result['starTime'];
|
||||
state.failureDateTime.value = result['endTime'];
|
||||
Get.back(result: result);
|
||||
}
|
||||
}))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: "是否是管理员",
|
||||
rightTitle: "",
|
||||
isTipsImg: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: SizedBox(
|
||||
width: 60.w, height: 50.h, child: Obx(() => _isAdmin()))),
|
||||
SizedBox(height: 30.h),
|
||||
SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
onClick: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// print("state.selectType:${state.selectType.value}");
|
||||
if (state.nameController.text.isEmpty) {
|
||||
logic.showToast("请输入姓名");
|
||||
return;
|
||||
}
|
||||
logic.checkPalmNameDuplicated(state.nameController.text);
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
// color: Colors.red,
|
||||
height: 65.h,
|
||||
width: 300.w,
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
LengthLimitingTextInputFormatter(18),
|
||||
],
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
controller: state.nameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 是否是管理员
|
||||
CupertinoSwitch _isAdmin() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isAdministrator.value,
|
||||
onChanged: (value) {
|
||||
state.isAdministrator.value = value;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AddPalmTypeState {
|
||||
final lockId = 0.obs;
|
||||
final selectType = "0".obs; // 0永久 1显示 2循环
|
||||
final fromType = 1.obs; // // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
var fromTypeTwoStaffName = "".obs; // 考勤添加人脸员工名字
|
||||
final isStressFingerprint = false.obs;
|
||||
final isAdministrator = false.obs; // 是否是管理员
|
||||
|
||||
var beginTime = "".obs; // 开始时间
|
||||
var endTime = "".obs; // 结束时间
|
||||
var effectiveDateTime = "".obs; // 生效时间
|
||||
var failureDateTime = "".obs; // 失效时间
|
||||
var weekdaysList = [].obs;
|
||||
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
AddPalmTypeState() {
|
||||
// Map map = Get.arguments;
|
||||
// lockId.value = map["lockId"];
|
||||
// fromType.value = map["fromType"];
|
||||
// if(fromType.value == 2){
|
||||
// fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; // 从添加员工进入 传入员工名字
|
||||
// // nameController.text = fromTypeTwoStaffName.value;
|
||||
// }
|
||||
|
||||
// print("lockId:${lockId.value} fromType:${fromType.value}");
|
||||
}
|
||||
}
|
||||
445
star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart
Normal file
445
star_lock/lib/main/lockDetail/palm/palmList/palmList_logic.dart
Normal file
@ -0,0 +1,445 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_addFace.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/palmList/palmList_state.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
import '../../../../blue/io_tool/io_tool.dart';
|
||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||
import '../../../../blue/sender_manage.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
|
||||
class PalmListLogic extends BaseGetXController {
|
||||
PalmListState state = PalmListState();
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
// 添加人脸开始(此处用作删除人脸)
|
||||
if ((reply is SenderAddFaceReply) && (state.isDeletFaceData == true)) {
|
||||
_replyAddFaceBegin(reply);
|
||||
}
|
||||
|
||||
if (reply is SenderQueryingFaceStatusReply) {
|
||||
// 获取人脸状态
|
||||
_replyQueryingFaceStatus(reply);
|
||||
}
|
||||
|
||||
if (reply is SenderCheckingUserInfoCountReply) {
|
||||
_replyCheckingUserInfoCount(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 添加人脸开始---这里用作删除人脸
|
||||
Future<void> _replyAddFaceBegin(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
print("status:$status");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType!.typeValue} list人脸数据解析成功");
|
||||
state.isDeletFaceData = false;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
if (state.isDeletAll == false) {
|
||||
deletFacesData();
|
||||
} else {
|
||||
clearAllFacesData();
|
||||
}
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 需要鉴权");
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFaceCommand(
|
||||
keyID: state.deletKeyID,
|
||||
userID: state.deletUserID,
|
||||
faceNo: state.deletFaceNo,
|
||||
useCountLimit: 0,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType!.typeValue} 用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType!.typeValue} 权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType!.typeValue} list人脸失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> _replyQueryingFaceStatus(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取卡片状态
|
||||
Future<void> _replyReferEventRecordNumber(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> _replyCheckingUserInfoCount(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
|
||||
// 用户数量
|
||||
int userNum = reply.data[5];
|
||||
// print("userNum:$userNum");
|
||||
|
||||
// 指纹数量
|
||||
int fingerNum = reply.data[6];
|
||||
// print("fingerNum:$fingerNum");
|
||||
|
||||
// 密码数量
|
||||
int pwdNum = reply.data[7];
|
||||
|
||||
// 卡片数量
|
||||
int cardNum = reply.data[8];
|
||||
|
||||
// 记录数量
|
||||
int logsNum = reply.data[9];
|
||||
|
||||
// 版本
|
||||
int verNo = reply.data[10];
|
||||
|
||||
// 最大管理员指纹数量
|
||||
int maxAdminFingerNum = reply.data[11];
|
||||
|
||||
// 最大用户指纹数量
|
||||
int maxUserFingerNum = reply.data[12];
|
||||
|
||||
// 最大管理员密码数量
|
||||
int maxAdminPassNum = reply.data[13];
|
||||
|
||||
// 最大用户密码数量
|
||||
int maxUserPassNum = reply.data[14];
|
||||
|
||||
// 最大管理员卡片数量
|
||||
int maxAdminCardNum = reply.data[15];
|
||||
|
||||
// 最大用户卡片数量
|
||||
int maxUserCardNum = reply.data[16];
|
||||
|
||||
// 序列号
|
||||
var serialNo = reply.data.sublist(17, 21);
|
||||
print("serialNo:$serialNo");
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
print("${reply.commandType}数据解析成功");
|
||||
// _getLockStatus();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
print("${reply.commandType}需要鉴权");
|
||||
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
print("${reply.commandType}用户无权限");
|
||||
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
print("${reply.commandType}权限校验错误");
|
||||
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
print("${reply.commandType}失败");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderQueryingFaceStatusCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
role: 0xff,
|
||||
faceCount: 20,
|
||||
faceNo: 1,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderCheckingUserInfoCountCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
role: 0xff,
|
||||
nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
privateKey: getPrivateKeyList,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 删除人脸
|
||||
Future<void> senderAddFace() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderAddFaceCommand(
|
||||
keyID: state.deletKeyID,
|
||||
userID: state.deletUserID,
|
||||
faceNo: state.deletFaceNo,
|
||||
useCountLimit: 0,
|
||||
startTime: 0x11223344,
|
||||
endTime: 0x11223344,
|
||||
needAuthor: 1,
|
||||
publicKey: publicKeyDataList,
|
||||
privateKey: getPrivateKeyList,
|
||||
token: getTokenList,
|
||||
);
|
||||
} else if (deviceConnectionState ==
|
||||
BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 获取人脸列表
|
||||
void getFaceListData() async {
|
||||
var entity = await ApiRepository.to.getFaceListData(
|
||||
lockId: state.lockId.value.toString(),
|
||||
pageNo: '1',
|
||||
pageSize: '20',
|
||||
searchStr: state.searchController.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.faceItemListData.value = entity.data!.list!;
|
||||
}
|
||||
}
|
||||
|
||||
// 删除的人脸
|
||||
void deletFacesData() async {
|
||||
var faceId = "";
|
||||
var type = "1";
|
||||
if (state.isDeletAll == false) {
|
||||
faceId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet faceId $faceId");
|
||||
var entity = await ApiRepository.to.deleteFaceData(
|
||||
faceId: int.parse(faceId),
|
||||
lockId: state.lockId.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功");
|
||||
state.isDeletFaceData = false;
|
||||
getFaceListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 重置所有的人脸
|
||||
void clearAllFacesData() async {
|
||||
var faceId = "";
|
||||
var type = "1";
|
||||
if (state.isDeletAll == false) {
|
||||
faceId = state.deletKeyID;
|
||||
type = "0";
|
||||
}
|
||||
print("delet faceId $faceId");
|
||||
var entity = await ApiRepository.to.clearFaceData(
|
||||
lockId: state.lockId.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("重置成功");
|
||||
state.isDeletFaceData = false;
|
||||
getFaceListData();
|
||||
}
|
||||
}
|
||||
|
||||
// 监听修改完详情之后刷新列表
|
||||
late StreamSubscription _teamEvent;
|
||||
void _initRefreshAction() {
|
||||
_teamEvent = eventBus.on<OtherTypeRefreshListEvent>().listen((event) {
|
||||
getFaceListData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReady() async {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
print("onReady()");
|
||||
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
// print("aaaaaaa:$isDemoMode");
|
||||
if (isDemoMode == false) {
|
||||
// _initReplySubscription();
|
||||
|
||||
// _initRefreshAction();
|
||||
|
||||
// getFaceListData();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onInit() async {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
print("onInit()");
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
// senderQueryingFingerprintStatus();
|
||||
// senderCheckingCardStatus();
|
||||
|
||||
// senderCheckingUserInfoCount();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onClose() async {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
_replySubscription.cancel();
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
280
star_lock/lib/main/lockDetail/palm/palmList/palmList_page.dart
Normal file
280
star_lock/lib/main/lockDetail/palm/palmList/palmList_page.dart
Normal file
@ -0,0 +1,280 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/palm/palmList/palmList_logic.dart';
|
||||
import 'package:star_lock/tools/keySearchWidget.dart';
|
||||
import 'package:star_lock/tools/left_slide_actions.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../tools/noData.dart';
|
||||
import '../../../../tools/showIosTipView.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import '../../../../tools/submitBtn.dart';
|
||||
import '../../../../tools/titleAppBar.dart';
|
||||
import '../../../../translations/trans_lib.dart';
|
||||
|
||||
class PalmListPage extends StatefulWidget {
|
||||
const PalmListPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PalmListPage> createState() => _PalmListPageState();
|
||||
}
|
||||
|
||||
class _PalmListPageState extends State<PalmListPage> {
|
||||
final logic = Get.put(PalmListLogic());
|
||||
final state = Get.find<PalmListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: '手掌',
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
onPressed: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showDeletAlertDialog(context);
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
onSubmittedAction: () {
|
||||
// logic.getFaceListData();
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: _buildMainUI()),
|
||||
AddBottomWhiteBtn(
|
||||
btnName: '${TranslationLoader.lanKeys!.add!.tr}手掌',
|
||||
onClick: () async {
|
||||
// var data =
|
||||
// await Get.toNamed(Routers.addFaceTypeManagePage, arguments: {
|
||||
// "lockId": state.lockId.value,
|
||||
// "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
// });
|
||||
var data =
|
||||
await Get.toNamed(Routers.addPalmTypeManagePage, arguments: {
|
||||
"lockId": state.lockId.value,
|
||||
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
});
|
||||
if (data != null) {
|
||||
// logic.getFaceListData();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 64.h)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainUI() {
|
||||
{
|
||||
return Obx(() => state.faceItemListData.value.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.faceItemListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
FingerprintItemData getFaceItemData =
|
||||
state.faceItemListData.value[index];
|
||||
// 人脸
|
||||
if (index < state.faceItemListData.value.length) {
|
||||
return LeftSlideActions(
|
||||
key: Key(getFaceItemData.faceName!),
|
||||
actionsWidth: 60,
|
||||
actions: [
|
||||
_buildDeleteBtn(getFaceItemData),
|
||||
],
|
||||
decoration: const BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1)),
|
||||
),
|
||||
child: _keyItem(
|
||||
'images/icon_face.png',
|
||||
getFaceItemData.faceName!,
|
||||
(getFaceItemData.faceType! != 1)
|
||||
? (getFaceItemData.endDate! <
|
||||
DateTime.now().millisecondsSinceEpoch
|
||||
? "已失效"
|
||||
: "")
|
||||
: "",
|
||||
getFaceItemData.validTimeStr!,
|
||||
// fingerprintItemData.fingerprintType! == 1
|
||||
// ? "永久"
|
||||
// : "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())}",
|
||||
() async {
|
||||
var data =
|
||||
await Get.toNamed(Routers.faceDetailPage, arguments: {
|
||||
"faceItemData": getFaceItemData,
|
||||
});
|
||||
if (data != null) {
|
||||
// logic.getFaceListData();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
},
|
||||
)
|
||||
: NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 170.h));
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildDeleteBtn(FingerprintItemData faceItemData) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 省略: 弹出是否删除的确认对话框。
|
||||
state.deletKeyID = faceItemData.faceId.toString();
|
||||
state.deletFaceNo = int.parse(faceItemData.faceNumber!);
|
||||
showIosTipViewDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
color: const Color(0xFFF20101),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'删除',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showIosTipViewDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "确定要删除吗?",
|
||||
sureClick: () async {
|
||||
Get.back();
|
||||
state.isDeletFaceData = true;
|
||||
state.isDeletAll = false;
|
||||
state.deletUserID = (await Storage.getUid())!;
|
||||
// logic.senderAddFace();
|
||||
},
|
||||
cancelClick: () {
|
||||
Get.back();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _keyItem(String lockTypeIcon, String lockTypeTitle,
|
||||
String ifInvalidation, String showTime, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
height: 90.h,
|
||||
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
color: Colors.white,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // borderRadius: BorderRadius.circular(10.w),
|
||||
// ),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(lockTypeTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp, color: AppColors.blackColor)),
|
||||
Expanded(child: Container()),
|
||||
Text(ifInvalidation,
|
||||
style: TextStyle(fontSize: 22.sp, color: Colors.red)),
|
||||
SizedBox(width: 10.w),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(showTime,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.placeholderTextColor)),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showDeletAlertDialog(BuildContext context) {
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text("提示"),
|
||||
content: const Text('重置后,该锁的人脸都将被删除哦,确认要重置吗?'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
state.isDeletFaceData = true;
|
||||
state.isDeletAll = true;
|
||||
state.deletKeyID = "1";
|
||||
state.deletUserID = "DeleteAll!@#";
|
||||
state.deletFaceNo = 255;
|
||||
// logic.senderAddFace();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/fingerprint/fingerprintList/fingerprintListData_entity.dart';
|
||||
|
||||
class PalmListState {
|
||||
final TextEditingController searchController = TextEditingController();
|
||||
final lockId = 0.obs;
|
||||
|
||||
// 因为删除跟添加人脸用的同一个协议 所以这里用做判断
|
||||
var isDeletFaceData = false;
|
||||
var isDeletAll = false;
|
||||
var deletKeyID = "";
|
||||
var deletUserID = "DeleteAll!@#";
|
||||
var deletFaceNo = 0;
|
||||
|
||||
final faceItemListData = <FingerprintItemData>[].obs;
|
||||
|
||||
var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示
|
||||
|
||||
PalmListState() {
|
||||
Map map = Get.arguments;
|
||||
lockId.value = map["lockId"];
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_state.dart';
|
||||
import 'package:star_lock/permission/permission_dialog.dart';
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
import '../../../tools/eventBusEventManage.dart';
|
||||
@ -33,15 +37,20 @@ class MinePersonInfoLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 上传头像
|
||||
void uploadFile(MinePersonGetUploadFileInfoEntity minePersonGetUploadFileInfoEntity) async {
|
||||
Map<String, dynamic> user = minePersonGetUploadFileInfoEntity.data!.formData!;
|
||||
void uploadFile(
|
||||
MinePersonGetUploadFileInfoEntity
|
||||
minePersonGetUploadFileInfoEntity) async {
|
||||
Map<String, dynamic> user =
|
||||
minePersonGetUploadFileInfoEntity.data!.formData!;
|
||||
var bytes = File(state.image!.path);
|
||||
var enc = await bytes.readAsBytes();
|
||||
user[minePersonGetUploadFileInfoEntity.data!.fileField!] = enc;
|
||||
final form = FormData({
|
||||
'file': MultipartFile(enc, filename: minePersonGetUploadFileInfoEntity.data!.formData!["key"]),
|
||||
'file': MultipartFile(enc,
|
||||
filename: minePersonGetUploadFileInfoEntity.data!.formData!["key"]),
|
||||
});
|
||||
var entity = await ApiRepository.to.uploadFile(url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form);
|
||||
var entity = await ApiRepository.to.uploadFile(
|
||||
url: minePersonGetUploadFileInfoEntity.data!.uploadUrl!, body: form);
|
||||
if (entity.errorCode! == -1) {
|
||||
// 没有返回 返回null成功
|
||||
updateUserInfoRequest(minePersonGetUploadFileInfoEntity.data!.fileUrl!);
|
||||
@ -50,12 +59,10 @@ class MinePersonInfoLogic extends BaseGetXController {
|
||||
|
||||
//更新个人信息-头像
|
||||
Future<void> updateUserInfoRequest(String headUrl) async {
|
||||
var entity = await ApiRepository.to.updateUserHeadUrlInfo(
|
||||
headUrl: headUrl
|
||||
);
|
||||
var entity = await ApiRepository.to.updateUserHeadUrlInfo(headUrl: headUrl);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.headUrl.value = headUrl;
|
||||
state.mineInfoData.value.headUrl = state.headUrl.value!;
|
||||
state.mineInfoData.value.headUrl = state.headUrl.value;
|
||||
final loginData = await Storage.getLoginData();
|
||||
loginData!.headUrl = headUrl;
|
||||
await Storage.saveLoginData(loginData);
|
||||
@ -64,11 +71,67 @@ class MinePersonInfoLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
//上传头像选择
|
||||
Future<void> chooseCallback(int index) async {
|
||||
if (index == 0) {
|
||||
//拍照选项
|
||||
_checkCameraPermission();
|
||||
} else if (index == 1) {
|
||||
_checkPhotoPermission();
|
||||
}
|
||||
}
|
||||
|
||||
///拍摄照片
|
||||
Future<void> selectCamera() async {
|
||||
XFile? photo = await state.imagePicker.pickImage(
|
||||
source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
||||
if (photo != null) {
|
||||
state.image = photo;
|
||||
var bytes = File(state.image!.path);
|
||||
var enc = await bytes.readAsBytes();
|
||||
getUpTokenRequest(state.image!.name, enc.length);
|
||||
}
|
||||
}
|
||||
|
||||
///从相册选取
|
||||
Future<void> selectImage() async {
|
||||
XFile? image = await state.imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
maxHeight: 250,
|
||||
maxWidth: 250,
|
||||
);
|
||||
if (image != null) {
|
||||
state.image = image;
|
||||
var bytes = File(state.image!.path);
|
||||
var enc = await bytes.readAsBytes();
|
||||
getUpTokenRequest(state.image!.name, enc.length);
|
||||
}
|
||||
}
|
||||
|
||||
//权限判断 访问相机
|
||||
Future<void> _checkCameraPermission() async {
|
||||
var status = await PermissionDialog.request(Permission.camera);
|
||||
if (status) {
|
||||
selectCamera();
|
||||
}
|
||||
}
|
||||
|
||||
//权限判断 访问相册
|
||||
Future<void> _checkPhotoPermission() async {
|
||||
bool isAndroid33 =
|
||||
AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
|
||||
var status = isAndroid33
|
||||
? await PermissionDialog.request(Permission.photos)
|
||||
: await PermissionDialog.request(Permission.storage);
|
||||
if (status) {
|
||||
selectImage();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -30,6 +30,14 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
final state = Get.find<MinePersonInfoLogic>().state;
|
||||
|
||||
@override
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
>>>>>>> fa316cb889104cbd0029a178352847359e728a77
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
@ -51,16 +59,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
child: CustomNetworkImage(url:state.headUrl.value, defaultUrl: 'images/controls_user.png', width:72.w, height:72.w),
|
||||
),
|
||||
action: () async {
|
||||
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
||||
if (Platform.isAndroid) {
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreeCamera);
|
||||
var getFlag = await Storage.getString(isAgreeCamera);
|
||||
if (getFlag == isAgreeCamera) {
|
||||
_openModalBottomSheet();
|
||||
}
|
||||
} else {
|
||||
_openModalBottomSheet();
|
||||
}
|
||||
_openModalBottomSheet();
|
||||
},
|
||||
)),
|
||||
Obx(() => CommonItem(
|
||||
@ -141,70 +140,9 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
));
|
||||
}
|
||||
|
||||
// Future<void> requestCameraPermission() async {
|
||||
// var status = await Permission.camera.status;
|
||||
// if (status.isGranted) {
|
||||
// selectCamera();
|
||||
// } else {
|
||||
// status = await Permission.camera.request();
|
||||
// if (status.isGranted) {
|
||||
// selectCamera();
|
||||
// } else {
|
||||
// showPermissionDeniedDialog();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> _requestCameraPermission() async {
|
||||
var status = await Permission.camera.request();
|
||||
if (status.isGranted) {
|
||||
setState(() {
|
||||
state.hasCameraPermission.value = true; // 如果权限被授予,更新状态变量
|
||||
});
|
||||
} else {
|
||||
// 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框
|
||||
showPermissionDeniedDialog();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _requestPhotoPermission() async {
|
||||
//针对andriud33以下的设备兼容
|
||||
bool isAndroid33 = AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
|
||||
var status = isAndroid33 ? await Permission.photos.request() : await Permission.storage.request();
|
||||
if (status.isGranted) {
|
||||
setState(() {
|
||||
state.hasPhotoPermission.value = true; // 如果权限被授予,更新状态变量
|
||||
});
|
||||
} else {
|
||||
// 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框
|
||||
showPermissionDeniedDialog();
|
||||
}
|
||||
|
||||
// 请求相册权限
|
||||
// PermissionStatus photosStatus = await Permission.photos.request();
|
||||
//
|
||||
// if (photosStatus.isGranted) {
|
||||
// // 相册权限已被授予
|
||||
// state.hasPhotoPermission.value = true;
|
||||
// } else {
|
||||
// // 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框
|
||||
// showPermissionDeniedDialog();
|
||||
// }
|
||||
}
|
||||
|
||||
// Future<void> requestPhotoPermission() async {
|
||||
// var status = await Permission.photos.status;
|
||||
// if (status.isGranted) {
|
||||
// selectImage();
|
||||
// } else {
|
||||
// status = await Permission.photos.request();
|
||||
// if (status.isGranted) {
|
||||
// selectImage();
|
||||
// } else {
|
||||
// showPermissionDeniedDialog();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 显示权限被永久拒绝的提示对话框
|
||||
void showPermissionDeniedDialog() {
|
||||
@ -236,47 +174,14 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
return AlertBottomWidget(
|
||||
topTitle: '',
|
||||
items: const ['拍照', '从相册选择'],
|
||||
chooseCallback: (value) {
|
||||
int getSelectIndex = value;
|
||||
if (getSelectIndex == 0) {
|
||||
//拍照选项
|
||||
// state.hasCameraPermission.value == true ? selectCamera() : _requestCameraPermission();
|
||||
_checkCameraPermission();
|
||||
} else if (getSelectIndex == 1) {
|
||||
// state.hasPhotoPermission.value == true ? selectImage() : _requestPhotoPermission();
|
||||
_checkPhotoPermission();
|
||||
}
|
||||
},
|
||||
chooseCallback: logic.chooseCallback,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
///拍摄照片
|
||||
selectCamera() async {
|
||||
XFile? photo = await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
||||
if (photo != null) {
|
||||
state.image = photo;
|
||||
var bytes = File(state.image!.path);
|
||||
var enc = await bytes.readAsBytes();
|
||||
logic.getUpTokenRequest(state.image!.name, enc.length);
|
||||
}
|
||||
}
|
||||
|
||||
///从相册选取
|
||||
selectImage() async {
|
||||
XFile? image = await state.imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
maxHeight: 250,
|
||||
maxWidth: 250,
|
||||
);
|
||||
if (image != null) {
|
||||
state.image = image;
|
||||
var bytes = File(state.image!.path);
|
||||
var enc = await bytes.readAsBytes();
|
||||
logic.getUpTokenRequest(state.image!.name, enc.length);
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
Future<void> _checkCameraPermission() async {
|
||||
var status = await Permission.camera.status;
|
||||
if (status.isGranted) {
|
||||
@ -294,6 +199,8 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
_requestPhotoPermission();
|
||||
}
|
||||
}
|
||||
=======
|
||||
>>>>>>> fa316cb889104cbd0029a178352847359e728a77
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
9
star_lock/lib/permission/README.md
Normal file
9
star_lock/lib/permission/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
## [permission_dialog.dart](permission_dialog.dart) 权限弹出的使用
|
||||
```bash
|
||||
//判断是否被拒绝,判断有权限后返回 true
|
||||
var status = await PermissionDialog.request(Permission.camera);
|
||||
if (status) {
|
||||
selectCamera();
|
||||
}
|
||||
```
|
||||
@ -1,21 +1,28 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/app_settings/app_settings.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
class PermissionDialog {
|
||||
static Map<Permission, String> titles = {
|
||||
Permission.camera: '相机',
|
||||
Permission.photos: '相册',
|
||||
Permission.storage: '读写',
|
||||
Permission.location: '定位',
|
||||
Permission.camera: TranslationLoader.lanKeys!.permissionDialogCamera!.tr,
|
||||
Permission.photos: TranslationLoader.lanKeys!.permissionDialogPhotos!.tr,
|
||||
Permission.storage: TranslationLoader.lanKeys!.permissionDialogStorage!.tr,
|
||||
Permission.location:
|
||||
TranslationLoader.lanKeys!.permissionDialogLocation!.tr,
|
||||
};
|
||||
|
||||
static Map<Permission, String> contents = {
|
||||
Permission.camera: '需要访问相机权限才能拍照上传文件例如头像上传',
|
||||
Permission.photos: '需要访问相机权限才能使用相册图片上传文件上传头像',
|
||||
Permission.storage: '需要访问读写权限才能使用本地图片上传头像',
|
||||
Permission.location: '需要访问定位权限才能使用添加钥匙功能的位置信息',
|
||||
Permission.camera:
|
||||
TranslationLoader.lanKeys!.permissionDialogCameraText!.tr,
|
||||
Permission.photos: TranslationLoader.lanKeys!.permissionDialogPhotos!.tr,
|
||||
Permission.storage:
|
||||
TranslationLoader.lanKeys!.permissionDialogStorageText!.tr,
|
||||
Permission.location:
|
||||
TranslationLoader.lanKeys!.permissionDialogLocationText!.tr,
|
||||
};
|
||||
|
||||
//显示权限判断申请框
|
||||
@ -24,37 +31,51 @@ class PermissionDialog {
|
||||
return false;
|
||||
}
|
||||
bool application = true;
|
||||
if (AppPlatform.isAndroid) {
|
||||
application = await showDialog(
|
||||
PermissionStatus status = await permission.status;
|
||||
dynamic cache = await Storage.getString(titles[permission]);
|
||||
if (AppPlatform.isAndroid && !status.isGranted && cache is! String) {
|
||||
application = await showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('申请${titles[permission] ?? ''}权限'),
|
||||
content: Text(contents[permission] ?? ''),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('不允许'),
|
||||
onPressed: () {
|
||||
Get.back(result: false);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('允许'),
|
||||
onPressed: () {
|
||||
Get.back(result: true);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
builder: (context) {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: CupertinoAlertDialog(
|
||||
title: Text(
|
||||
'${TranslationLoader.lanKeys!.permissionDialogApplication!.tr}${titles[permission] ?? ''}${TranslationLoader.lanKeys!.permissionDialogAuthority!.tr}'),
|
||||
content: Text(contents[permission] ?? ''),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader
|
||||
.lanKeys!.permissionDialogNotAllowed!.tr),
|
||||
onPressed: () {
|
||||
Get.back(result: false);
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.permissionDialogAllowed!.tr),
|
||||
onPressed: () {
|
||||
Get.back(result: true);
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
},
|
||||
);
|
||||
if(application){
|
||||
await Storage.setString(titles[permission], titles[permission]);
|
||||
}
|
||||
} else if (cache is String) {
|
||||
if (status.isDenied) {
|
||||
showSet(permission);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!application) {
|
||||
showSet(permission);
|
||||
return false;
|
||||
} else {
|
||||
return await permission.request().isGranted;
|
||||
if (application) {
|
||||
PermissionStatus status = await permission.request();
|
||||
return status.isGranted;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//显示设置页面
|
||||
@ -62,22 +83,27 @@ class PermissionDialog {
|
||||
if (Get.context == null) {
|
||||
return;
|
||||
}
|
||||
showDialog(
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('${titles[permission] ?? ''}权限被拒绝'),
|
||||
content: Text('${contents[permission] ?? ''},请手动在系统设置中开启${titles[permission]}权限以继续使用应用。'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('去设置'),
|
||||
onPressed: () {
|
||||
Get.back(); // 关闭对话框
|
||||
openAppSettings(); // 打开系统设置页面
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
builder: (context) {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: CupertinoAlertDialog(
|
||||
title: Text(
|
||||
'${titles[permission] ?? ''}${TranslationLoader.lanKeys!.permissionDialogPermissionDenied!.tr}'),
|
||||
content: Text(
|
||||
'${contents[permission] ?? ''},${TranslationLoader.lanKeys!.permissionDialogOpenPermissions!.tr}${titles[permission]}${TranslationLoader.lanKeys!.permissionDialogCameraText!.tr}'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.permissionDialogGoSetUp!.tr),
|
||||
onPressed: () {
|
||||
Get.back(); // 关闭对话框
|
||||
openAppSettings(); // 打开系统设置页面
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -946,6 +946,24 @@ class LanKeyEntity {
|
||||
judgmentMethodContent = json['judgmentMethodContent'];
|
||||
stressPassword = json['stressPassword'];
|
||||
stressCard = json['stressCard'];
|
||||
|
||||
permissionDialogCamera = json['permission_dialog_camera'];
|
||||
permissionDialogPhotos = json['permission_dialog_photos'];
|
||||
permissionDialogStorage = json['permission_dialog_storage'];
|
||||
permissionDialogLocation = json['permission_dialog_location'];
|
||||
permissionDialogCameraText = json['permission_dialog_camera_text'];
|
||||
permissionDialogPhotosText = json['permission_dialog_photos_text'];
|
||||
permissionDialogStorageText = json['permission_dialog_storage_text'];
|
||||
permissionDialogLocationText = json['permission_dialog_location_text'];
|
||||
permissionDialogApplication = json['permission_dialog_application'];
|
||||
permissionDialogAuthority = json['permission_dialog_authority'];
|
||||
permissionDialogNotAllowed = json['permission_dialog_not_allowed'];
|
||||
permissionDialogAllowed = json['permission_dialog_allowed'];
|
||||
permissionDialogPermissionDenied = json['permission_dialog_permission_denied'];
|
||||
permissionDialogOpenPermissions = json['permission_dialog_open_permissions'];
|
||||
permissionDialogPermissionContinueText = json['permission_dialog_permission_continue_text'];
|
||||
permissionDialogGoSetUp = json['permission_dialog_go_set_up'];
|
||||
|
||||
}
|
||||
String? starLock;
|
||||
String? clickUnlockAndHoldDownClose;
|
||||
@ -1424,6 +1442,23 @@ class LanKeyEntity {
|
||||
String? stressPassword;
|
||||
String? stressCard;
|
||||
|
||||
String? permissionDialogCamera;
|
||||
String? permissionDialogPhotos;
|
||||
String? permissionDialogStorage;
|
||||
String? permissionDialogLocation;
|
||||
String? permissionDialogCameraText;
|
||||
String? permissionDialogPhotosText;
|
||||
String? permissionDialogStorageText;
|
||||
String? permissionDialogLocationText;
|
||||
String? permissionDialogApplication;
|
||||
String? permissionDialogAuthority;
|
||||
String? permissionDialogNotAllowed;
|
||||
String? permissionDialogAllowed;
|
||||
String? permissionDialogPermissionDenied;
|
||||
String? permissionDialogOpenPermissions;
|
||||
String? permissionDialogPermissionContinueText;
|
||||
String? permissionDialogGoSetUp;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['starLock'] = starLock;
|
||||
@ -1913,6 +1948,23 @@ class LanKeyEntity {
|
||||
map['stressPassword'] = stressPassword;
|
||||
map['stressCard'] = stressCard;
|
||||
|
||||
map['permission_dialog_camera'] = permissionDialogCamera;
|
||||
map['permission_dialog_photos'] = permissionDialogPhotos;
|
||||
map['permission_dialog_storage'] = permissionDialogStorage;
|
||||
map['permission_dialog_location'] = permissionDialogLocation;
|
||||
map['permission_dialog_camera_text'] = permissionDialogCameraText;
|
||||
map['permission_dialog_photos_text'] = permissionDialogPhotosText;
|
||||
map['permission_dialog_storage_text'] = permissionDialogStorageText;
|
||||
map['permission_dialog_location_text'] = permissionDialogLocationText;
|
||||
map['permission_dialog_application'] = permissionDialogApplication;
|
||||
map['permission_dialog_authority'] = permissionDialogAuthority;
|
||||
map['permission_dialog_not_allowed'] = permissionDialogNotAllowed;
|
||||
map['permission_dialog_allowed'] = permissionDialogAllowed;
|
||||
map['permission_dialog_permission_denied'] = permissionDialogPermissionDenied;
|
||||
map['permission_dialog_open_permissions'] = permissionDialogOpenPermissions;
|
||||
map['permission_dialog_permission_continue_text'] = permissionDialogPermissionContinueText;
|
||||
map['permission_dialog_go_set_up'] = permissionDialogGoSetUp;
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user