394 lines
15 KiB
Dart
Executable File
394 lines
15 KiB
Dart
Executable File
|
|
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/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart';
|
|
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart';
|
|
|
|
import '../../../../../appRouters.dart';
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../common/XSConstantMacro/XSConstantMacro.dart';
|
|
import '../../../../../tools/commonDataManage.dart';
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/dateTool.dart';
|
|
import '../../../../../tools/showTFView.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import '../../../../lockMian/lockMain/lockMain_logic.dart';
|
|
|
|
enum ShowAlertEnum { name, realName, idCardNumber }
|
|
|
|
class ElectronicKeyDetailPage extends StatefulWidget {
|
|
const ElectronicKeyDetailPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ElectronicKeyDetailPage> createState() =>
|
|
_ElectronicKeyDetailPageState();
|
|
}
|
|
|
|
class _ElectronicKeyDetailPageState extends State<ElectronicKeyDetailPage> {
|
|
final ElectronicKeyDetailLogic logic = Get.put(ElectronicKeyDetailLogic());
|
|
final ElectronicKeyDetailState state = Get.find<ElectronicKeyDetailLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '钥匙详情'.tr,
|
|
haveBack: true,
|
|
actionsList: (state.keyType.value != 3)
|
|
? <Widget>[
|
|
IconButton(
|
|
icon: Image.asset(
|
|
'images/icon_bar_more.png',
|
|
height: 30.h,
|
|
width: 10.w,
|
|
),
|
|
onPressed: () {
|
|
logic.openModalBottomSheet(context);
|
|
},
|
|
),
|
|
]
|
|
: null,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: ListView(
|
|
children: <Widget>[
|
|
Obx(() => lockDataListItem('姓名'.tr, state.keyName.value, () {
|
|
showCupertinoAlertDialog(
|
|
tipsTitle: '修改姓名'.tr, alertEnum: ShowAlertEnum.name);
|
|
})),
|
|
Obx(() => Visibility(
|
|
visible: state.isRealNameAuth.value,
|
|
child: CommonItem(
|
|
leftTitel: '真实姓名'.tr,
|
|
rightTitle: state.getRealName.value,
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () {
|
|
showCupertinoAlertDialog(
|
|
tipsTitle: '修改真实姓名'.tr,
|
|
alertEnum: ShowAlertEnum.realName);
|
|
}))),
|
|
Obx(() => Visibility(
|
|
visible: state.isRealNameAuth.value,
|
|
child: CommonItem(
|
|
leftTitel: '身份证'.tr,
|
|
rightTitle: state.getIDCardNumber.value,
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () {
|
|
showCupertinoAlertDialog(
|
|
tipsTitle: '修改身份证号'.tr,
|
|
alertEnum: ShowAlertEnum.idCardNumber);
|
|
}))),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '有效期'.tr,
|
|
allHeight: 70.h,
|
|
// rightTitle:"2023.09.19 11:27\n2023.09.25 11:27",
|
|
rightTitle: logic.getKeyTypeShowDateTime(),
|
|
isHaveDirection: state.itemData.value.keyStatus! ==
|
|
XSConstantMacro.keyStatusExpired
|
|
? false
|
|
: state.keyType.value != 3,
|
|
isHaveLine: true,
|
|
action: state.itemData.value.keyStatus! ==
|
|
XSConstantMacro.keyStatusExpired
|
|
? null
|
|
: () async {
|
|
if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){
|
|
logic.showToast('冻结状态下不允许修改钥匙权限'.tr);
|
|
return;
|
|
}
|
|
|
|
if (state.keyType.value == 2 || state.keyType.value == 1) {
|
|
// 限时/永久
|
|
var data = await Get.toNamed(
|
|
Routers.electronicKeyDetailChangeDate,
|
|
arguments: <String, Object>{
|
|
'pushType': 0,
|
|
'itemData': state.itemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.starDate.value = data['beginTimeTimestamp'].toString();
|
|
state.endDate.value = data['endTimeTimestamp'].toString();
|
|
state.keyType.value = 2;
|
|
});
|
|
}
|
|
} else if (state.keyType.value == 4) {
|
|
// 循环
|
|
var data = await Get.toNamed(
|
|
Routers.electronicKeyPeriodValidityPage,
|
|
arguments: <String, Object>{
|
|
'pushType': 0,
|
|
'itemData': state.itemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.starDate.value = data['starDate'];
|
|
state.endDate.value = data['endDate'];
|
|
state.starTime.value = data['starTime'];
|
|
state.endTime.value = data['endTime'];
|
|
state.weekDay.value = data['validityValue'];
|
|
});
|
|
}
|
|
}
|
|
})),
|
|
Obx(() => Visibility(
|
|
visible: state.keyType.value == 4 ,
|
|
child: Obx(() => CommonItem(
|
|
leftTitel: '有效日'.tr,
|
|
rightTitle: logic.weekDayStr.join(','),
|
|
isHaveDirection: true,
|
|
isHaveLine: true,
|
|
action: () async {
|
|
if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){
|
|
logic.showToast('冻结状态下不允许修改钥匙权限'.tr);
|
|
return;
|
|
}
|
|
|
|
var data = await Get.toNamed(
|
|
Routers.electronicKeyPeriodValidityPage,
|
|
arguments: <String, Object>{
|
|
'pushType': 0,
|
|
'itemData': state.itemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.starDate.value = data['starDate'];
|
|
state.endDate.value = data['endDate'];
|
|
state.starTime.value = data['starTime'];
|
|
state.endTime.value = data['endTime'];
|
|
state.weekDay.value = data['validityValue'];
|
|
});
|
|
}
|
|
})))),
|
|
Obx(() => Visibility(
|
|
visible: state.keyType.value == 4 ? true : false,
|
|
child: Obx(() => CommonItem(
|
|
leftTitel: '有效时间'.tr,
|
|
rightTitle:
|
|
'${DateTool().dateToHNString(state.starTime.value)}-${DateTool().dateToHNString(state.endTime.value)}',
|
|
isHaveDirection: true,
|
|
action: () async {
|
|
if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){
|
|
logic.showToast('冻结状态下不允许修改钥匙权限'.tr);
|
|
return;
|
|
}
|
|
|
|
var data = await Get.toNamed(
|
|
Routers.electronicKeyPeriodValidityPage,
|
|
arguments: <String, Object>{
|
|
'pushType': 0,
|
|
'itemData': state.itemData.value,
|
|
});
|
|
if (data != null) {
|
|
setState(() {
|
|
state.starDate.value = data['starDate'];
|
|
state.endDate.value = data['endDate'];
|
|
state.starTime.value = data['starTime'];
|
|
state.endTime.value = data['endTime'];
|
|
state.weekDay.value = data['validityValue'];
|
|
});
|
|
}
|
|
})))),
|
|
Container(height: 10.h),
|
|
CommonItem(
|
|
leftTitel: '接收者'.tr,
|
|
rightTitle: state.itemData.value.username ?? ''),
|
|
const SizedBox(height: 1),
|
|
CommonItem(
|
|
leftTitel: '发送人'.tr,
|
|
rightTitle: state.itemData.value.senderUsername ?? ''),
|
|
const SizedBox(height: 1),
|
|
CommonItem(
|
|
leftTitel: '发送时间'.tr,
|
|
rightTitle: DateTool()
|
|
.dateToYMDHNString(state.itemData.value.sendDate.toString())),
|
|
Container(height: 10.h),
|
|
Obx(() => Visibility(
|
|
visible: state.itemData.value.keyRight == 1 ? true : false,
|
|
child: CommonItem(
|
|
leftTitel: '仅管理自己创建的用户'.tr,
|
|
rightTitle: '',
|
|
isHaveRightWidget: true,
|
|
isHaveLine: true,
|
|
rightWidget: SizedBox(
|
|
width: 60.w, child: Obx(_onlyManageYouCreatesUserSwitch))),
|
|
)),
|
|
Obx(
|
|
() => Visibility(
|
|
// (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false
|
|
// visible: CommonDataManage()
|
|
// .currentKeyInfo
|
|
// .lockSetting!
|
|
// .remoteUnlock ==
|
|
// 1
|
|
// ? true
|
|
// : false,
|
|
visible: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1 && state.itemData.value.keyRight != 1)
|
|
? true
|
|
: false,
|
|
child: CommonItem(
|
|
leftTitel: '远程开锁'.tr,
|
|
rightTitle: '',
|
|
isHaveRightWidget: true,
|
|
isHaveLine: true,
|
|
rightWidget: SizedBox(
|
|
width: 60.w, child: _remoteUnlockingSwitch()))),
|
|
),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '实名认证'.tr,
|
|
rightTitle: '',
|
|
isHaveRightWidget: true,
|
|
rightWidget:
|
|
SizedBox(width: 60.w, child: _realNameAuthSwitch()))),
|
|
Container(height: 10.h),
|
|
CommonItem(
|
|
leftTitel: '操作记录'.tr,
|
|
rightTitle: '',
|
|
isHaveDirection: true,
|
|
action: () {
|
|
Get.toNamed(Routers.lockOperatingRecordPage, arguments: <String, Object?>{
|
|
'type': 5,
|
|
'id': state.itemData.value.keyId.toString(),
|
|
'recordName': state.itemData.value.keyName
|
|
});
|
|
}),
|
|
Container(height: 40.h),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 20.w, right: 20.w),
|
|
child: SubmitBtn(
|
|
btnName: '删除'.tr,
|
|
borderRadius: 20.w,
|
|
isDelete: true,
|
|
margin: EdgeInsets.only(
|
|
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
|
|
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
|
onClick: () {
|
|
logic.deletKeyLogic();
|
|
}),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget lockDataListItem(String leftTitle, String conentStr, Function()? action){
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
// height: 70.h,
|
|
padding: EdgeInsets.only(left: 20.w, right: 10.w, top: 15.h, bottom: 15.h),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border(
|
|
bottom: BorderSide(
|
|
color: AppColors.greyLineColor, // 设置边框颜色
|
|
width: 2.0.h, // 设置边框宽度
|
|
),
|
|
)
|
|
),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(leftTitle, style: TextStyle(fontSize: 22.sp)),
|
|
SizedBox(width: 10.w),
|
|
Expanded(
|
|
child: Text(conentStr, textAlign:TextAlign.end, style: TextStyle(fontSize: 22.sp, ))
|
|
),
|
|
SizedBox(width: 10.w),
|
|
Image.asset(
|
|
'images/icon_right_grey.png',
|
|
width: 12.w,
|
|
height: 21.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
CupertinoSwitch _realNameAuthSwitch() {
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: state.isRealNameAuth.value,
|
|
onChanged: (bool value) {
|
|
if (!state.isRealNameAuth.value) {
|
|
logic.checkRealNameStatus(1);
|
|
} else {
|
|
logic.checkRealNameStatus(2);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
CupertinoSwitch _remoteUnlockingSwitch() {
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: state.isRemoteUnlock.value,
|
|
onChanged: (bool value) async {
|
|
final bool isNetWork = await LockMainLogic.to()?.judgeTheNetwork() ?? false;
|
|
if (!isNetWork) {
|
|
return;
|
|
}
|
|
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
|
|
logic.updateKeyDateRequest(2);
|
|
},
|
|
);
|
|
}
|
|
|
|
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: state.onlyManageYouCreatesUser.value,
|
|
onChanged: (bool value) async {
|
|
final bool isNetWork = await LockMainLogic.to()?.judgeTheNetwork() ?? false;
|
|
if (!isNetWork) {
|
|
return;
|
|
}
|
|
state.onlyManageYouCreatesUser.value = !state.onlyManageYouCreatesUser.value;
|
|
logic.updateKeyDateRequest(1);
|
|
},
|
|
);
|
|
}
|
|
|
|
void showCupertinoAlertDialog(
|
|
{required String tipsTitle, required ShowAlertEnum alertEnum}) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowTFView(
|
|
title: tipsTitle,
|
|
tipTitle: '请输入'.tr,
|
|
controller: logic.getCurrentController(alertEnum),
|
|
inputFormatters: <TextInputFormatter>[
|
|
FilteringTextInputFormatter.deny('\n'),
|
|
LengthLimitingTextInputFormatter(50),
|
|
],
|
|
sureClick: () {
|
|
if (alertEnum == ShowAlertEnum.name) {
|
|
logic.modifyKeyNameRequest();
|
|
} else {
|
|
Get.back();
|
|
logic.updateRealNameInfoRequest(alertEnum);
|
|
}
|
|
},
|
|
cancelClick: () {
|
|
Get.back();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|