This commit is contained in:
魏少阳 2024-05-14 15:11:20 +08:00
commit 79b51b00dc
10 changed files with 268 additions and 175 deletions

View File

@ -125,6 +125,8 @@ PODS:
- Flutter
- package_info_plus (0.4.5):
- Flutter
- partial_media_permissions (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
@ -184,6 +186,7 @@ DEPENDENCIES:
- just_audio (from `.symlinks/plugins/just_audio/ios`)
- network_info_plus (from `.symlinks/plugins/network_info_plus/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- partial_media_permissions (from `.symlinks/plugins/partial_media_permissions/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
@ -274,6 +277,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/network_info_plus/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
partial_media_permissions:
:path: ".symlinks/plugins/partial_media_permissions/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
@ -335,6 +340,7 @@ SPEC CHECKSUMS:
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
partial_media_permissions: 0fd34002b1dbfd5e8b4c60eb0d99e8e755a77f76
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149

View File

@ -233,7 +233,9 @@ class AuthorizedAdminLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) {
//
state.isRequireAuth.value = true;
state.isAuthentication.value = true;
} else {
//432--
ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () {

View File

@ -471,11 +471,11 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
value: state.isAuthentication.value,
onChanged: (value) {
setState(() {
state.isAuthentication.value = !state.isAuthentication.value;
if (state.isAuthentication.value == true) {
if (logic.state.isAuthentication.value == false) {
logic.keyCheckFace();
} else {
state.isRequireAuth.value = false;
logic.state.isAuthentication.value = false;
logic.state.isRequireAuth.value = false;
}
});
},

View File

@ -190,7 +190,9 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
if (entity.errorCode!.codeIsSuccessful) {
//
state.isRequireAuth.value = true;
state.isAuthentication.value = true;
} else {
//432--
ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () {

View File

@ -285,6 +285,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
rightTitle:
"${logic.state.effectiveDateTime}-${logic.state.failureDateTime}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
@ -552,11 +553,10 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
if (isRemote) {
logic.state.isRemoteUnlock.value = !logic.state.isRemoteUnlock.value;
} else {
logic.state.isAuthentication.value =
!logic.state.isAuthentication.value;
if (logic.state.isAuthentication.value == true) {
if (logic.state.isAuthentication.value == false) {
logic.keyCheckFace();
} else {
logic.state.isAuthentication.value = false;
logic.state.isRequireAuth.value = false;
}
}

View File

@ -121,11 +121,7 @@ class MinePersonInfoLogic extends BaseGetXController {
// 访
Future<void> _checkPhotoPermission() async {
bool isAndroid33 =
AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
var status = isAndroid33
? await PermissionDialog.request(Permission.photos)
: await PermissionDialog.request(Permission.storage);
var status = await PermissionDialog.requestPhotos();
if (status) {
selectImage();
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
@ -23,8 +22,8 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
final state = Get.find<ExpireFingerprintLogic>().state;
Future<void> getHttpData() async {
logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value){
if(mounted) setState(() {});
logic.expirFingerprintListRequest().then((ExpireFingerprintEntity value) {
if (mounted) setState(() {});
});
}
@ -38,56 +37,62 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
onRefresh: () {
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
onLoad: () {
getHttpData();
},
child: Obx(() => _buildMainUI())
);
child: Obx(() => _buildMainUI()));
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
? NoData(
noDataHeight: 1.sh -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight -
190.h -
64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireFingerprintItemEntity indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除卡吗?", (){
state.deletExpireFingerprintItemEntity = indexEntity;
logic.senderAddFingerprint();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpireFingerprintItemEntity indexEntity = state.dataList[index];
return Slidable(
key: ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog("确定删除指纹吗?",
() {
state.deletExpireFingerprintItemEntity =
indexEntity;
logic.senderAddFingerprint();
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpireFingerprintItemEntity itemData) {
@ -156,8 +161,8 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
),
Expanded(
child: SizedBox(
width: 10.w,
)),
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
@ -216,8 +221,7 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
style: TextStyle(color: Colors.white, fontSize: 13.sp),
),
);
} else {
@ -229,12 +233,10 @@ class _ExpireFingerprintPageState extends State<ExpireFingerprintPage> {
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
style: TextStyle(color: Colors.white, fontSize: 13.sp),
),
);
}
// }
}
}

View File

@ -1,4 +1,3 @@
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/dateTool.dart';
@ -13,8 +12,9 @@ class ExpirePasswordLogic extends BaseGetXController {
//
Future<ExpirePasswordEntity> expirePasswordListRequest() async {
ExpirePasswordEntity entity = await ApiRepository.to.expirePasswordList(pageNo.toString(), pageSize.toString());
if(entity.errorCode!.codeIsSuccessful){
ExpirePasswordEntity entity = await ApiRepository.to
.expirePasswordList(pageNo.toString(), pageSize.toString());
if (entity.errorCode!.codeIsSuccessful) {
if (pageNo == 1) {
state.dataList.value = entity.data!.list!;
pageNo++;
@ -29,11 +29,12 @@ class ExpirePasswordLogic extends BaseGetXController {
}
// deleteType:1- 2-
Future<void> deletePwdRequest(ExpirePasswordItemData expirePasswordItemData) async {
Future<void> deletePwdRequest(
ExpirePasswordItemData expirePasswordItemData) async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
lockId:expirePasswordItemData.lockId.toString(),
keyboardPwdId:expirePasswordItemData.pwdId.toString(),
deleteType:1);
lockId: expirePasswordItemData.lockId.toString(),
keyboardPwdId: expirePasswordItemData.pwdId.toString(),
deleteType: 1);
if (entity.errorCode!.codeIsSuccessful) {
showToast("删除成功", something: () {
pageNo = 1;
@ -46,12 +47,13 @@ class ExpirePasswordLogic extends BaseGetXController {
//使
String getExpireDateStr(ExpirePasswordItemData itemData) {
String useDateStr = '';
if(itemData.keyboardPwdType == 4){
//* getKeyType 1 2 3 4 5 6 7 8 9 10 11 12 13 14
if (itemData.keyboardPwdType! > 4) {
useDateStr = '循环';
}else{
useDateStr = '${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
} else {
useDateStr =
'${DateTool().dateToYMDString(itemData.startDate.toString())}-${DateTool().dateToYMDString(itemData.endDate.toString())}';
}
return useDateStr;
}
}
}

View File

@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/tools/EasyRefreshTool.dart';
import 'package:star_lock/tools/noData.dart';
@ -24,8 +24,8 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
final state = Get.find<ExpirePasswordLogic>().state;
Future<void> getHttpData() async {
logic.expirePasswordListRequest().then((ExpirePasswordEntity value){
if(mounted) setState(() {});
logic.expirePasswordListRequest().then((ExpirePasswordEntity value) {
if (mounted) setState(() {});
});
}
@ -39,67 +39,73 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
@override
Widget build(BuildContext context) {
return EasyRefreshTool(
onRefresh: (){
onRefresh: () {
logic.pageNo = 1;
getHttpData();
},
onLoad: (){
onLoad: () {
getHttpData();
},
child: Obx(() => _buildMainUI())
);
child: Obx(() => _buildMainUI()));
}
Widget _buildMainUI() {
return state.dataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
? NoData(
noDataHeight: 1.sh -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight -
190.h -
64.h)
: SlidableAutoCloseBehavior(
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpirePasswordItemData indexEntity = state.dataList[index];
return Slidable(
key:ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context){
ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?", (){
logic.deletePwdRequest(indexEntity);
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
child: ListView.separated(
itemCount: state.dataList.length,
itemBuilder: (c, index) {
ExpirePasswordItemData indexEntity = state.dataList[index];
return Slidable(
key: ValueKey(indexEntity.uid),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
SlidableAction(
onPressed: (BuildContext context) {
ShowTipView().showIosTipWithContentDialog("确定删除该密码吗?",
() {
logic.deletePwdRequest(indexEntity);
});
},
backgroundColor: Colors.red,
foregroundColor: Colors.white,
label: '删除',
padding: EdgeInsets.only(left: 5.w, right: 5.w),
),
],
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
child: _electronicKeyItem(indexEntity),
);
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
},
),
);
}
Widget _electronicKeyItem(ExpirePasswordItemData itemData) {
return GestureDetector(
onTap: () async {
// if(itemData.keyboardPwdType! == 4){
// if (itemData.keyboardPwdType! > 4) {
// //
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// var data = await Get.toNamed(Routers.electronicKeyPeriodValidityPage,
// arguments: {
// "pushType": 0,
// "expirePasswordItem": itemData,
// });
// if (data != null) {
// // setState(() {
// // state.starDate.value = data["starDate"];
// // state.endDate.value = data["endDate"];
@ -110,19 +116,20 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
// logic.pageNo = 1;
// getHttpData();
// }
// }else{
// var data = await Get.toNamed(Routers.electronicKeyDetailChangeDate, arguments: {
// "pushType": 0,
// "expireLockItem": itemData,
// });
// if(data != null) {
// setState(() {
// // state.starDate.value = data["beginTimeTimestamp"].toString();
// // state.endDate.value = data["endTimeTimestamp"].toString();
// // state.keyType.value = 2;
// logic.pageNo = 1;
// getHttpData();
// });
// } else {
// var backData = await Get.toNamed(
// Routers.passwordKeyDetailChangeDatePage,
// arguments: {
// 'itemData': itemData,
// });
// if (backData != null) {
// itemData.startDate =
// int.parse(backData["beginTimeTimestamp"]) * 1000;
// itemData.endDate = int.parse(backData["endTimeTimestamp"]) * 1000;
// //
// itemData.keyboardPwdType = 3;
// setState(() {});
// }
// }
},
@ -156,8 +163,8 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
),
Expanded(
child: SizedBox(
width: 10.w,
)),
width: 10.w,
)),
Text(
itemData.lockAlias ?? '',
style: TextStyle(
@ -193,48 +200,36 @@ class _ExpirePasswordPageState extends State<ExpirePasswordPage> {
}
Widget getStatus(ExpirePasswordItemData itemData) {
// if (itemData.keyboardPwdStatus! == 1) {
// return Container(
// padding: EdgeInsets.only(left: 5.w, right: 5.w),
// decoration: BoxDecoration(
// color: Colors.red,
// borderRadius: BorderRadius.circular(2.0),
// ),
// child: Text(
// '未生效',
// style: TextStyle(
// color: Colors.white, fontSize: 13.sp),
// ),
// );
// } else {
if (itemData.expireDate! > 0) {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
} else {
return Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期',
style: TextStyle(
color: Colors.white, fontSize: 13.sp),
),
);
}
// }
//keyboardPwdStatus 1 2
return Row(
children: [
Visibility(
visible: itemData.expireDate! > 0 ? true : false,
child: Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: AppColors.expireTextBgColor,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'${itemData.expireDate.toString()}',
style: TextStyle(color: Colors.white, fontSize: 13.sp),
),
)),
Visibility(
visible: itemData.keyboardPwdStatus! == 2 ? true : false,
child: Container(
padding: EdgeInsets.only(left: 5.w, right: 5.w),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(2.0),
),
child: Text(
'已过期'.tr,
style: TextStyle(color: Colors.white, fontSize: 13.sp),
),
))
],
);
}
}

View File

@ -83,6 +83,94 @@ class PermissionDialog {
return false;
}
//
static Future<bool> requestPhotos() async {
if (Get.context == null) {
return false;
}
bool isAndroid33 =
AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33;
//
List<Permission> requestPermission() {
List<Permission> permissions;
if (isAndroid33) {
permissions = [
Permission.mediaLibrary,
Permission.photos,
Permission.videos,
];
} else {
permissions = [
Permission.storage,
];
}
return permissions;
}
Future<bool> permissionStatus(List<Permission> permissions) async {
bool isGranted = true;
for (Permission permission in permissions) {
isGranted =
isGranted && (await permission.status) == PermissionStatus.granted;
}
if (isAndroid33) {
// android 33
isGranted =
(await Permission.mediaLibrary.status) == PermissionStatus.granted;
}
return isGranted;
}
bool application = true;
Permission permission = Permission.photos;
List<Permission> permissions = requestPermission();
dynamic cache = await Storage.getString(titles[permission]);
bool isGranted = await permissionStatus(permissions);
if (AppPlatform.isAndroid && !isGranted && cache is! String) {
application = await showCupertinoDialog(
context: Get.context!,
builder: (context) {
return PopScope(
canPop: false,
child: CupertinoAlertDialog(
title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'),
content: Text(contents[permission] ?? ''),
actions: [
CupertinoDialogAction(
child: Text('不允许'.tr),
onPressed: () {
Get.back(result: false);
},
),
CupertinoDialogAction(
child: Text('允许'.tr),
onPressed: () {
Get.back(result: true);
},
),
],
));
},
);
if (application) {
await Storage.setString(titles[permission], titles[permission]);
}
} else if (cache is String) {
bool isDenied = !(await permissionStatus(permissions));
if (isDenied) {
showSet(permission);
return false;
}
}
if (application) {
Map<Permission, PermissionStatus> statuses = await permissions.request();
bool isGranted = await permissionStatus(statuses.keys.toList());
return isGranted;
}
return false;
}
//
static Future<bool> request(Permission permission, [String? content]) async {
if (Get.context == null) {