密码详情及电子钥匙详情问题及梳理修改

This commit is contained in:
Daisy 2023-12-15 11:58:15 +08:00
parent cacf3528e3
commit f0a90edb6e
11 changed files with 501 additions and 382 deletions

View File

@ -0,0 +1,34 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
class ElectronicKeyDetailLogic extends BaseGetXController {
final ElectronicKeyDetailState state = ElectronicKeyDetailState();
//
Future<void> modifyKeyNameRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
.modifyKeyNameForAdmin(state.itemData.value.keyId.toString(),
state.changeNameController.text, '');
if (entity.errorCode!.codeIsSuccessful) {
print("修改要是名称成功啦啦啦啦啦");
Toast.show(msg: "修改成功");
Get.back();
}
}
//
Future<void> deleteKeyRequest() async {
ElectronicKeyListEntity entity = await ApiRepository.to
.deleteElectronicKey(state.itemData.value.keyId.toString());
if (entity.errorCode!.codeIsSuccessful) {
print("删除电子钥匙成功");
Toast.show(msg: "删除成功");
Get.back();
}
}
}

View File

@ -3,12 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/jh_pop_menus.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
@ -28,16 +25,11 @@ class ElectronicKeyDetailPage extends StatefulWidget {
}
class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
final TextEditingController _changeNameController = TextEditingController();
ElectronicKeyListItem itemData = ElectronicKeyListItem();
final logic = Get.put(ElectronicKeyDetailLogic());
final state = Get.find<ElectronicKeyDetailLogic>().state;
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["itemData"] != null)) {
itemData = obj["itemData"];
}
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: AppColors.mainBackgroundColor,
@ -68,38 +60,29 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: _changeNameController.text.isNotEmpty
? _changeNameController.text
: itemData.keyName,
rightTitle: state.changeNameController.text.isNotEmpty
? state.changeNameController.text
: state.itemData.value.keyName,
isHaveDirection: true,
isHaveLine: true,
action: () {
showCupertinoAlertDialog(context);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
allHeight: 90.h,
rightTitle: getUseDateStr(itemData),
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.electronicKeyDetailChangeDate,
arguments: {"itemData": itemData});
}),
getPeriodValidityWidget(),
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
rightTitle: itemData.username,
rightTitle: state.itemData.value.username,
action: () {}),
const SizedBox(height: 1),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
rightTitle: itemData.senderUsername,
rightTitle: state.itemData.value.senderUsername,
action: () {}),
const SizedBox(height: 1),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
rightTitle: getSenderDate(itemData),
rightTitle: getSenderDate(state.itemData.value),
action: () {}),
Container(height: 10.h),
CommonItem(
@ -108,8 +91,9 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
child:
_switch(itemData.faceAuthentication == 1 ? true : false)),
child: _switch(state.itemData.value.faceAuthentication == 1
? true
: false)),
action: () {}),
Container(height: 10.h),
CommonItem(
@ -119,8 +103,8 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
action: () {
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
arguments: {
'lockId': itemData.lockId.toString(),
'keyId': itemData.keyId.toString()
'lockId': state.itemData.value.lockId.toString(),
'keyId': state.itemData.value.keyId.toString()
});
}),
Container(height: 40.h),
@ -139,106 +123,136 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
);
}
//使
String getUseDateStr(ElectronicKeyListItem indexEntity) {
String useDateStr = '';
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
//
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
//
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 永久';
useDateStr = '永久';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
//
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n 单次';
useDateStr = '单次';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
//
useDateStr = '循环';
//
Widget getPeriodValidityWidget() {
int? dateType = state.itemData.value.keyType;
if (dateType == XSConstantMacro.keyTypeLong) {
return getLongTypeDateWidget();
} else if (dateType == XSConstantMacro.keyTypeTime) {
return getTimeLimitTypeDateWidget();
} else if (dateType == XSConstantMacro.keyTypeOnce) {
return getOnceTypeDateWidget();
} else if (dateType == XSConstantMacro.keyTypeLoop) {
return getLoopTypeDateWidget();
}
return useDateStr;
return Container();
}
//
Widget getLongTypeDateWidget() {
return CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: '永久',
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
arguments: {"itemData": state.itemData.value});
});
}
//
Widget getTimeLimitTypeDateWidget() {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
String useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
return CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
allHeight: 90.h,
rightTitle: useDateStr,
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.electronicKeyDetailChangeDate,
arguments: {"itemData": state.itemData.value});
});
}
//
Widget getOnceTypeDateWidget() {
return CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: '单次',
isHaveDirection: false,
);
}
//
Widget getLoopTypeDateWidget() {
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
String useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)} \n ${endDateStr.toLocal().toString().substring(0, 16)}';
List getEffectiveDateList = [];
List weekDaysList = state.itemData.value.weekDays!;
if (weekDaysList.isNotEmpty) {
String effectiveDateStr = '';
for (int i = 0; i < weekDaysList.length; i++) {
if (weekDaysList[i] == 1) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 2) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 3) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 4) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 5) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 6) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
} else if (weekDaysList[i] == 7) {
effectiveDateStr = '';
getEffectiveDateList.add(effectiveDateStr);
}
}
}
return Column(
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
allHeight: 90.h,
rightTitle: useDateStr,
isHaveDirection: true,
isHaveLine: true,
action: () {
Navigator.pushNamed(
context, Routers.electronicKeyPeriodValidityPage);
}),
CommonItem(
leftTitel: '有效日',
rightTitle: getEffectiveDateList.map((e) => e.toString()).join(','),
isHaveDirection: true,
isHaveLine: true,
action: () {
Navigator.pushNamed(
context, Routers.electronicKeyPeriodValidityPage);
}),
],
);
}
//
String getSenderDate(ElectronicKeyListItem indexEntity) {
String senderDate = '';
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
senderDate = dateStr.toLocal().toString().substring(0, 16);
return senderDate;
}
// Widget commonItem(String leftTitle, String rightTitle,
// {bool isHaveDirection = false,
// bool isHaveLine = false,
// bool isHaveRightWidget = false,
// Widget? rightWidget,
// Function()? action}) {
// return GestureDetector(
// onTap: action,
// child: Column(
// // mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Container(
// // height: 80.h,
// color: Colors.white,
// padding: EdgeInsets.only(
// left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
// child: Row(
// children: [
// SizedBox(width: 20.w),
// Text(
// leftTitle,
// style:
// TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
// ),
// SizedBox(width: 20.w),
// Expanded(
// child: Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// isHaveRightWidget
// ? rightWidget!
// : Text(
// rightTitle,
// textAlign: TextAlign.end,
// style: TextStyle(
// fontSize: 28.sp, fontWeight: FontWeight.w500),
// )
// ],
// ),
// ),
// SizedBox(width: 5.w),
// isHaveDirection
// ? Image.asset(
// 'images/icon_right.png',
// width: 50.w,
// height: 50.w,
// )
// : SizedBox(width: 10.w),
// // SizedBox(width:10.w),
// ],
// ),
// ),
// isHaveLine
// ? Container(
// height: 0.5.h,
// color: Colors.grey,
// )
// : Container()
// ],
// ),
// );
// }
CupertinoSwitch _switch(isOn) {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
@ -253,33 +267,6 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
);
}
//
Future<void> modifyKeyNameRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to
.modifyKeyNameForAdmin(
itemData.keyId.toString(), _changeNameController.text, '');
if (entity.errorCode!.codeIsSuccessful) {
print("修改要是名称成功啦啦啦啦啦");
Toast.show(msg: "修改成功");
setState(() {
Navigator.pop(context);
});
}
}
//
Future<void> deleteKeyRequest() async {
ElectronicKeyListEntity entity =
await ApiRepository.to.deleteElectronicKey(itemData.keyId.toString());
if (entity.errorCode!.codeIsSuccessful) {
print("删除电子钥匙成功");
Toast.show(msg: "删除成功");
setState(() {
Navigator.pop(context, true);
});
}
}
void showCupertinoAlertDialog(BuildContext context) {
showDialog(
context: context,
@ -288,11 +275,11 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
title:
"${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}",
tipTitle: "请输入",
controller: _changeNameController,
controller: state.changeNameController,
sureClick: () {
//
if (_changeNameController.text.isNotEmpty) {
modifyKeyNameRequest();
if (state.changeNameController.text.isNotEmpty) {
logic.modifyKeyNameRequest();
}
},
cancelClick: () {
@ -304,7 +291,7 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
}
void showIosTipViewDialog(BuildContext context) {
showDialog(
showDialog(
context: context,
builder: (BuildContext context) {
return ShowIosTipView(
@ -312,14 +299,12 @@ class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
tipTitle: "确定要删除吗?",
sureClick: () {
Get.back();
deleteKeyRequest();
logic.deleteKeyRequest();
},
cancelClick: () {
Get.back();
},
);
}
);
});
}
}

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
class ElectronicKeyDetailState {
final itemData = ElectronicKeyListItem().obs;
final TextEditingController changeNameController = TextEditingController();
ElectronicKeyDetailState() {
Map map = Get.arguments;
itemData.value = map["itemData"];
}
}

View File

@ -270,6 +270,8 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
//使
String getUseDateStr(ElectronicKeyListItem indexEntity) {
String useDateStr = '';
DateTime sendDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
//
DateTime startDateStr =
@ -280,14 +282,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
//
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
useDateStr = "永久";
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
//
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
useDateStr = "单次";
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
//
useDateStr = '循环';

View File

@ -0,0 +1,38 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
class PasswordKeyDetailLogic extends BaseGetXController {
final PasswordKeyDetailState state = PasswordKeyDetailState();
// deleteType:1- 2-
Future<void> deletePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
state.itemData.value.lockId.toString(),
state.itemData.value.keyboardPwdId.toString(),
1);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功");
Get.back();
}
}
//
Future<void> updatePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
state.itemData.value.lockId.toString(),
state.itemData.value.keyboardPwdId.toString(),
state.inputNameController.text,
state.inputPwdController.text,
'',
'',
'');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
Get.back();
}
}
}

View File

@ -2,12 +2,9 @@ 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/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/showTFView.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -25,25 +22,12 @@ class PasswordKeyDetailPage extends StatefulWidget {
}
class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
PasswordKeyListItem itemData = PasswordKeyListItem();
late TextEditingController _inputPwdController;
late TextEditingController _inputNameController;
static const methodChannel = MethodChannel('talkPlugin');
@override
void initState() {
super.initState();
_inputPwdController = TextEditingController();
_inputNameController = TextEditingController();
}
final logic = Get.put(PasswordKeyDetailLogic());
final state = Get.find<PasswordKeyDetailLogic>().state;
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["itemData"] != null)) {
itemData = obj["itemData"];
}
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
@ -68,45 +52,52 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.password!.tr,
rightTitle: _inputPwdController.text.isNotEmpty
? _inputPwdController.text
: itemData.keyboardPwd,
rightTitle: state.inputPwdController.text.isNotEmpty
? state.inputPwdController.text
: state.itemData.value.keyboardPwd,
isHaveDirection: true,
isHaveLine: true,
action: () {
showCupertinoAlertDialog(context, _inputPwdController);
showCupertinoAlertDialog(context, state.inputPwdController);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: _inputNameController.text.isNotEmpty
? _inputNameController.text
: itemData.keyboardPwdName,
rightTitle: state.inputNameController.text.isNotEmpty
? state.inputNameController.text
: state.itemData.value.keyboardPwdName,
isHaveDirection: true,
isHaveLine: true,
action: () {
showCupertinoAlertDialog(context, _inputNameController);
showCupertinoAlertDialog(
context, state.inputNameController);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: "永久",
rightTitle: getUseDateStr(),
isHaveDirection: true,
allHeight:
state.itemData.value.keyboardPwdType == 3 ? 90.h : 65.h,
action: () {
if (state.itemData.value.keyboardPwdType! > 4 &&
state.itemData.value.keyboardPwdType! < 15) {
return;
}
Navigator.pushNamed(
context, Routers.electronicKeyDetailChangeDate,
arguments: {
'lockId': itemData.lockId.toString(),
'pwdId': itemData.keyboardPwdId.toString()
'lockId': state.itemData.value.lockId.toString(),
'pwdId': state.itemData.value.keyboardPwdId.toString()
});
}),
Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.sender!.tr,
rightTitle: itemData.senderUsername,
rightTitle: state.itemData.value.senderUsername,
isHaveLine: true,
action: () {}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.senderTime!.tr,
rightTitle: getSenderDate(itemData),
rightTitle: getSenderDate(state.itemData.value),
action: () {}),
Container(height: 10.h),
CommonItem(
@ -116,8 +107,8 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
action: () {
Navigator.pushNamed(context, Routers.keyOperationRecordPage,
arguments: {
'lockId': itemData.lockId.toString(),
'keyId': itemData.keyboardPwdId.toString()
'lockId': state.itemData.value.lockId.toString(),
'keyId': state.itemData.value.keyboardPwdId.toString()
});
}),
Container(height: 40.h),
@ -129,9 +120,10 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
// backgroundColor: Colors.white,
side: BorderSide(width: 1, color: AppColors.mainColor)),
onPressed: () {
Navigator.pushNamed(context, Routers.cardListPage, arguments: {
"lockId": itemData.lockId,
});
Navigator.pushNamed(context, Routers.cardListPage,
arguments: {
"lockId": state.itemData.value.lockId,
});
},
child: Text(
'设置卡',
@ -150,12 +142,15 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
// backgroundColor: Colors.white,
side: BorderSide(width: 1, color: AppColors.mainColor)),
onPressed: () {
Navigator.pushNamed(
context, Routers.fingerprintListPage,arguments: {
"lockId": itemData.lockId,
});
Navigator.pushNamed(context, Routers.fingerprintListPage,
arguments: {
"lockId": state.itemData.value.lockId,
});
},
child: Text('设置指纹', style: TextStyle(color: AppColors.mainColor, fontSize: 24.sp),
child: Text(
'设置指纹',
style: TextStyle(
color: AppColors.mainColor, fontSize: 24.sp),
)),
),
SizedBox(
@ -169,9 +164,11 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
// backgroundColor: Colors.white,
side: BorderSide(width: 1, color: AppColors.mainColor)),
onPressed: () {
Navigator.pushNamed(context, Routers.remoteControlListPage, arguments: {
"lockId": itemData.lockId,
});
Navigator.pushNamed(
context, Routers.remoteControlListPage,
arguments: {
"lockId": state.itemData.value.lockId,
});
},
child: Text(
'设置遥控',
@ -197,6 +194,83 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
));
}
//使
String getUseDateStr() {
int? getPwdType = state.itemData.value.keyboardPwdType;
String useDateStr = '';
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(state.itemData.value.endDate!);
int starHour = startDateStr.hour;
int endHour = endDateStr.hour;
switch (getPwdType) {
case 1:
// 1 6使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
break;
case 2:
// 2 24使
useDateStr = '永久';
break;
case 3:
// 3 24使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
break;
case 4:
// 4 使使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}\n${endDateStr.toLocal().toString().substring(0, 16)}';
break;
case 5:
// 5
useDateStr = '周末 $starHour:00-$endHour:00';
break;
case 6:
// 6
useDateStr = '周日 $starHour:00-$endHour:00';
break;
case 7:
// 7
useDateStr = '工作日 $starHour:00-$endHour:00';
break;
case 8:
// 8
useDateStr = '周一 $starHour:00-$endHour:00';
break;
case 9:
// 9
useDateStr = '周二 $starHour:00-$endHour:00';
break;
case 10:
// 10
useDateStr = '周三 $starHour:00-$endHour:00';
break;
case 11:
// 11
useDateStr = '周四 $starHour:00-$endHour:00';
break;
case 12:
// 12
useDateStr = '周五 $starHour:00-$endHour:00';
break;
case 13:
// 13
useDateStr = '周六 $starHour:00-$endHour:00';
break;
case 14:
// 14
useDateStr = '周天 $starHour:00-$endHour:00';
break;
default:
}
return useDateStr;
}
//
String getSenderDate(PasswordKeyListItem indexEntity) {
String senderDate = '';
@ -206,106 +280,13 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
return senderDate;
}
Widget commonItem(String leftTitle, String rightTitle,
{bool isHaveDirection = false,
bool isHaveLine = false,
bool isHaveRightWidget = false,
Widget? rightWidget,
Function()? action}) {
return GestureDetector(
onTap: action,
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
// height: 80.h,
color: Colors.white,
padding: EdgeInsets.only(
left: 20.w, right: 10.w, top: 20.w, bottom: 20.w),
child: Row(
children: [
SizedBox(width: 20.w),
Text(
leftTitle,
style:
TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w500),
),
SizedBox(width: 20.w),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
isHaveRightWidget
? rightWidget!
: Text(
rightTitle,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 28.sp, fontWeight: FontWeight.w500),
)
],
),
),
SizedBox(width: 5.w),
isHaveDirection
? Image.asset(
'images/icon_right.png',
width: 50.w,
height: 50.w,
)
: SizedBox(width: 10.w),
// SizedBox(width:10.w),
],
),
),
isHaveLine
? Container(
height: 0.5.h,
color: Colors.grey,
)
: Container()
],
),
);
}
// deleteType:1- 2-
Future<void> deletePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.deleteKeyboardPwd(
itemData.lockId.toString(), itemData.keyboardPwdId.toString(), 1);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功");
setState(() {
Navigator.pop(context, true);
});
}
}
//
Future<void> updatePwdRequest() async {
PasswordKeyEntity entity = await ApiRepository.to.updatePasswordKey(
itemData.lockId.toString(),
itemData.keyboardPwdId.toString(),
_inputNameController.text,
_inputPwdController.text,
'',
'',
'');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "修改成功");
setState(() {
Navigator.pop(context);
});
}
}
void showCupertinoAlertDialog(
BuildContext context, TextEditingController inputController) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: inputController == _inputNameController
title: inputController == state.inputNameController
? "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}"
: "${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.password!.tr}",
tipTitle: "请输入",
@ -313,7 +294,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
sureClick: () {
//
if (inputController.text.isNotEmpty) {
updatePwdRequest();
logic.updatePwdRequest();
}
},
cancelClick: () {
@ -411,7 +392,7 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
{
Navigator.pop(context);
String pwdShareStr =
'您好,您的密码是:${itemData.keyboardPwd}\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}';
'您好,您的密码是:${state.itemData.value.keyboardPwd}\n生效时间:${state.itemData.value.startDate}\n类型:永久\n锁名:${state.itemData.value.keyboardPwdName}';
tokNative('flutter_sharePassword_to_ios',
arguments: {'pwdShareStr': pwdShareStr}).then((result) {
print('$result');
@ -456,13 +437,12 @@ class _PasswordKeyDetailPageState extends State<PasswordKeyDetailPage> {
tipTitle: "确定要删除吗?",
sureClick: () {
Get.back();
deletePwdRequest();
logic.deletePwdRequest();
},
cancelClick: () {
Get.back();
},
);
}
);
});
}
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
class PasswordKeyDetailState {
final itemData = PasswordKeyListItem().obs;
final TextEditingController inputPwdController = TextEditingController();
final TextEditingController inputNameController = TextEditingController();
// final keyInfo = LockListInfoItemEntity().obs;
// var pageNum = 1.obs; //
// final pageSize = 20.obs; //
// final itemDataList = <PasswordKeyListItem>[].obs;
// final TextEditingController searchController = TextEditingController();
PasswordKeyDetailState() {
Map map = Get.arguments;
itemData.value = map["itemData"];
}
}

View File

@ -248,54 +248,89 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
}
//使
/**
1 6使
2 24使
3 24使
4 使使
5
6
7
8
9
10
11
12
13
14
*/
String getUseDateStr(PasswordKeyListItem indexEntity) {
int? getPwdType = indexEntity.keyboardPwdType;
String useDateStr = '';
if (indexEntity.keyboardPwdType == 3) {
//
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyboardPwdType == 2) {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久';
} else if (indexEntity.keyboardPwdType == 1) {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次';
} else if (indexEntity.keyboardPwdType == 4) {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 清空码';
} else {
//
DateTime dateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 循环';
}
DateTime sendDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!);
DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
int starHour = startDateStr.hour;
int endHour = endDateStr.hour;
switch (getPwdType) {
case 1:
// 1 6使
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 单次';
break;
case 2:
// 2 24使
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 永久';
break;
case 3:
// 3 24使
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} 限时';
break;
case 4:
// 4 使使
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} 清空码';
break;
case 5:
// 5
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周末$starHour:00-$endHour:00 循环';
break;
case 6:
// 6
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周日$starHour:00-$endHour:00 循环';
break;
case 7:
// 7
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 工作日$starHour:00-$endHour:00 循环';
break;
case 8:
// 8
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周一$starHour:00-$endHour:00 循环';
break;
case 9:
// 9
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周二$starHour:00-$endHour:00 循环';
break;
case 10:
// 10
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周三$starHour:00-$endHour:00 循环';
break;
case 11:
// 11
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周四$starHour:00-$endHour:00 循环';
break;
case 12:
// 12
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周五$starHour:00-$endHour:00 循环';
break;
case 13:
// 13
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周六$starHour:00-$endHour:00 循环';
break;
case 14:
// 14
useDateStr =
'${sendDateStr.toLocal().toString().substring(0, 16)} 周天$starHour:00-$endHour:00 循环';
break;
default:
}
return useDateStr;
}

View File

@ -404,53 +404,62 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
int getWidgetNumber = int.parse(widget.type);
if (state.nameController.text.isEmpty) {
Toast.show(msg: '请输入姓名');
return;
}
//
if (getWidgetNumber == 1) {
if (!state.effectiveDateTime.value
.isBefore(state.failureDateTime.value)) {
Toast.show(msg: '失效时间需大于生效时间');
return;
}
}
//
if (getWidgetNumber == 3) {
logic.getStartDate(state.effectiveDateTime.value);
if (state.nameController.text.isEmpty) {
Toast.show(msg: '请输入姓名');
return;
}
if (state.pwdController.text.isEmpty) {
Toast.show(msg: '请输入密码');
return;
}
//
if (state.isPermanent.value == false) {
print('自定义密码输出********有时限');
if (!state.effectiveDateTime.value
.isBefore(state.failureDateTime.value)) {
.isBefore(state.failureDateTime.value) ||
state.effectiveDateTime.value
.isAtSameMomentAs(state.failureDateTime.value)) {
Toast.show(msg: '失效时间需大于生效时间');
return;
}
}
logic.addKeyboardPwdRequest();
}
//
if (getWidgetNumber == 4) {
if (!state.effectiveDateTime.value
.isBefore(state.failureDateTime.value)) {
Toast.show(msg: '结束时间需大于当前时间');
} else {
if (state.nameController.text.isEmpty) {
Toast.show(msg: '请输入姓名');
return;
}
if (state.loopEndHours.value <= state.loopStartHours.value) {
Toast.show(msg: '失效时间需大于生效时间');
return;
}
}
logic.getKeyboardPwdRequest();
//
if (getWidgetNumber == 1) {
if (!state.effectiveDateTime.value
.isBefore(state.failureDateTime.value) ||
state.effectiveDateTime.value
.isAtSameMomentAs(state.failureDateTime.value)) {
Toast.show(msg: '失效时间需大于生效时间');
return;
}
}
//
if (getWidgetNumber == 4) {
if (!state.effectiveDateTime.value
.isBefore(state.failureDateTime.value)) {
Toast.show(msg: '结束时间需大于当前时间');
return;
}
if (state.loopEndHours.value <=
state.loopStartHours.value) {
Toast.show(msg: '失效时间需大于生效时间');
return;
}
}
logic.getKeyboardPwdRequest();
}
} else {
Toast.show(msg: '演示模式');
}

View File

@ -9,7 +9,7 @@ class PasswordKeyPerpetualState {
final isInitialized = false.obs;
final isSendSuccess = false.obs; //
final isPermanent = false.obs; //
final isPermanent = true.obs; //
var getPwdStr = ''.obs;
final effectiveDateTime = DateTime.now().obs;

View File

@ -59,18 +59,24 @@ class CommonItem extends StatelessWidget {
children: [
isHaveRightWidget!
? rightWidget!
: Text(rightTitle ?? "", textAlign: TextAlign.end,
: Text(
rightTitle ?? "",
textAlign: TextAlign.right,
overflow: TextOverflow.ellipsis,
maxLines: 1,
maxLines: 2,
style: TextStyle(
fontSize: 22.sp,
color: AppColors.darkGrayTextColor),
)
),
],
),
isHaveDirection! ? SizedBox(width: 3.w) : Container(),
isHaveDirection!
? Image.asset('images/icon_right_grey.png', width: 12.w, height: 21.w,)
? Image.asset(
'images/icon_right_grey.png',
width: 12.w,
height: 21.w,
)
: SizedBox(width: 10.w),
isHaveDirection! ? SizedBox(width: 5.w) : Container(),
],