# Conflicts: # star_lock/lib/main/lockDetail/card/addCardType/addCardManage/addCardTypeManage_tabbar.dart # star_lock/lib/network/api.dart
326 lines
11 KiB
Dart
326 lines
11 KiB
Dart
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/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';
|
|
import 'addRemoteControl_logic.dart';
|
|
|
|
class AddRemoteControlPage extends StatefulWidget {
|
|
final String selectType;
|
|
|
|
const AddRemoteControlPage({Key? key, required this.selectType})
|
|
: super(key: key);
|
|
|
|
@override
|
|
State<AddRemoteControlPage> createState() => _AddRemoteControlPageState();
|
|
}
|
|
|
|
class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
|
|
final logic = Get.put(AddRemoteControlLoigc());
|
|
final state = Get.find<AddRemoteControlLoigc>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return indexChangeWidget();
|
|
}
|
|
|
|
Widget indexChangeWidget() {
|
|
switch (int.parse(widget.selectType)) {
|
|
case 0:
|
|
{
|
|
// 永久
|
|
// return sendElectronicKeySucceed();
|
|
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(),
|
|
SizedBox(height: 10.h),
|
|
keyBottomWidget()
|
|
],
|
|
);
|
|
}
|
|
case 2:
|
|
{
|
|
// 循环
|
|
return Column(
|
|
children: [
|
|
perpetualKeyWidget(
|
|
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}');
|
|
}),
|
|
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) {
|
|
setState(() {
|
|
setState(() {
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
|
rightTitle: state.endTime.value,
|
|
isHaveDirection: true,
|
|
action: () {
|
|
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
|
|
onConfirm: (p) {
|
|
setState(() {
|
|
setState(() {
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
})),
|
|
Container(height: 10.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget keyBottomWidget() {
|
|
return Column(
|
|
children: [
|
|
// CommonItem(
|
|
// leftTitel: TranslationLoader.lanKeys!.remoteControl!.tr,
|
|
// rightTitle: "",
|
|
// isTipsImg: false,
|
|
// isHaveRightWidget: true,
|
|
// rightWidget: SizedBox(
|
|
// width: 60.w, height: 50.h, child: _isStressFingerprint())),
|
|
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.showToast("请确保在设备附近");
|
|
// logic.addFingerprintsData();
|
|
} else {
|
|
// Get.toNamed(Routers.selectLockTypePage);
|
|
logic.showToast("演示模式");
|
|
}
|
|
}),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 发送电子钥匙成功
|
|
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(
|
|
// 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,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
//isStressFingerprint false:不是胁迫指纹 ture:胁迫指纹
|
|
CupertinoSwitch _isStressFingerprint() {
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: true,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
// state.isStressFingerprint.value = value;
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|