feat:修改电子钥匙页面滑动,子页面不变的问题

This commit is contained in:
anfe 2024-05-04 17:28:39 +08:00
parent 421a978ab5
commit c2cb7218ee
6 changed files with 861 additions and 916 deletions

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/commonDataManage.dart';
@ -12,220 +12,4 @@ import '../../../../../tools/showTipView.dart';
class SendElectronicKeyLogic extends BaseGetXController {
final SendElectronicKeyState state = SendElectronicKeyState();
//
Future<void> sendElectronicKeyRequest() async {
if (state.emailOrPhoneController.text.isEmpty) {
showToast("请输入接收者账号".tr);
return;
}
//
// if(state.keyNameController.text.isEmpty){
// showToast("请输入接收者姓名");
// return;
// }
//
var startDate = "0";
var endDate = "0";
var startTime = "0";
var endTime = "0";
int typeValue = state.seletType.value;
switch (typeValue) {
case 0:
{
//
if (state.timeLimitBeginTime.value.isEmpty) {
showToast("请选择开始时间".tr);
return;
}
if (state.timeLimitEndTime.value.isEmpty) {
showToast("请选择结束时间".tr);
return;
}
typeValue = XSConstantMacro.keyTypeTime;
startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString();
startTime = "0";
endTime = "0";
// if(DateTime.now().millisecondsSinceEpoch > int.parse(state.beginTimeTimestamp.value)){
// Toast.show(msg: "生效时间要大于当前时间");
// return;
// }
if (int.parse(startDate) >= int.parse(endDate)) {
showToast("失效时间要大于生效时间".tr);
return;
}
}
break;
case 1:
typeValue = XSConstantMacro.keyTypeLong;
break;
case 2:
typeValue = XSConstantMacro.keyTypeOnce;
break;
case 3:
typeValue = XSConstantMacro.keyTypeLoop;
if (state.cycleBeginTime.value.isEmpty) {
showToast("请选择有效期".tr);
return;
}
startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString();
endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
break;
default:
typeValue = XSConstantMacro.keyTypeTime;
break;
}
String getKeyType = typeValue.toString();
var entity = await ApiRepository.to.sendElectronicKey(
createUser: state.isCreateUser.value == true ? "1" : "0",
countryCode: state.countryCode.value,
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
? '1'
: '2',
endDate: int.parse(endDate),
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
isCameraEnable: '2',
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
keyNameForAdmin: state.keyNameController.text,
keyRight: '0',
keyType: getKeyType,
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
operatorUid: '',
receiverUsername: state.emailOrPhoneController.text,
remarks: '',
startDate: int.parse(startDate),
weekDays: state.weekdaysList.value,
startTime: int.parse(startTime),
endTime: int.parse(endTime),
isOnlyManageSelf: 0);
if (entity.errorCode!.codeIsSuccessful) {
state.isSendSuccess.value = true;
state.sendSucceedType.value = state.seletType.value;
resetData();
eventBus.fire(ElectronicKeyListRefreshUI());
} else {
if (entity.errorCode == 425) {
//
state.isCreateUser.value = true;
ShowTipView().showIosTipWithContentDialog('${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}', (){
sendElectronicKeyRequest();
});
// if (isPhoneNumber(state.emailOrPhoneController.text) == true) {
// _showEmailDialog();
// } else {
// _showEmailDialog();
// }
}
}
}
bool isPhoneNumber(String input) {
// 11
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
return phoneRegExp.hasMatch(input);
}
bool isEmail(String input) {
//
final RegExp emailRegExp =
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
return emailRegExp.hasMatch(input);
}
// //
// void _showPhoneDialog(widgetContext, String errMsg) {
// showCupertinoDialog(
// context: widgetContext,
// builder: (context) {
// return CupertinoAlertDialog(
// title: Text('接收者号码未注册,请重新发送'.tr),
// actions: [
// CupertinoDialogAction(
// child: Text(
// TranslationLoader.lanKeys!.cancel!.tr,
// style: TextStyle(color: AppColors.mainColor),
// ),
// onPressed: () {
// Get.back();
// },
// ),
// CupertinoDialogAction(
// child: Text(
// TranslationLoader.lanKeys!.sure!.tr,
// style: TextStyle(color: AppColors.mainColor),
// ),
// onPressed: () async {
// //
// Get.back();
//
// // var result = await Get.toNamed(Routers.selectCountryRegionPage);
// // if (result != null) {
// // result as Map<String, dynamic>;
// // state.countryCode.value = result['code'];
// // state.countryName.value = result['countryName'];
// // }
// sendElectronicKeyRequest();
// },
// ),
// ],
// );
// },
// );
// }
//---
// void _showEmailDialog() {
// showCupertinoDialog(
// context: Get.context!,
// builder: (context) {
// return CupertinoAlertDialog(
// title: Text('${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}'),
// actions: [
// CupertinoDialogAction(
// child: Text(
// TranslationLoader.lanKeys!.cancel!.tr,
// style: TextStyle(color: AppColors.mainColor),
// ),
// onPressed: () {
// Get.back();
// },
// ),
// CupertinoDialogAction(
// child: Text(
// TranslationLoader.lanKeys!.sure!.tr,
// style: TextStyle(color: AppColors.mainColor),
// ),
// onPressed: () {
// Get.back();
//
// sendElectronicKeyRequest();
// },
// ),
// ],
// );
// },
// );
// }
void resetData() {
state.emailOrPhoneController.text = "";
state.keyNameController.text = "";
state.timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
state.timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
state.cycleBeginTime = "".obs;//
state.cycleEndTime = "".obs;//
state.effectiveDateTime = "".obs;//
state.failureDateTime = "".obs;//
state.weekdaysList = [].obs;
}
}

View File

@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_page.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
@ -37,28 +38,11 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
final logic = Get.put(SendElectronicKeyLogic());
final state = Get.find<SendElectronicKeyLogic>().state;
Future<void> getDemoMode() async {
state.isDemoMode = (await Storage.getBool(ifIsDemoModeOrNot))!;
}
@override
void initState() {
// TODO: implement initState
super.initState();
getDemoMode();
state.tabController =
TabController(vsync: this, length: _itemTabs.length, initialIndex: 0);
state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
state.seletType.value = state.tabController.index;
});
if (state.tabController.animation!.value == state.tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
}
});
}
@override
@ -78,587 +62,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
);
}
Widget indexChangeWidget(ItemView item) {
if (state.isSendSuccess.value == true &&
state.sendSucceedType.value.toString() == item.type) {
return sendElectronicKeySucceed();
} else {
switch (item.type) {
case '0':
{
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(),
keyTimeWidget(),
remoteUnlockingWidget(),
keyRealNameWidget(),
keyBottomWidget(state.timeLimitTips)
],
),
);
}
case '1':
{
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(),
remoteUnlockingWidget(),
keyRealNameWidget(),
keyBottomWidget(state.permanentTips)
],
),
);
}
case '2':
{
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(),
remoteUnlockingWidget(),
keyRealNameWidget(),
keyBottomWidget(state.onceLimitTips)
],
),
);
}
case '3':
{
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(),
keyPeriodValidityWidget(),
remoteUnlockingWidget(),
keyRealNameWidget(),
keyBottomWidget(state.cycleLimitTips)
],
),
);
}
default:
return Container();
}
}
}
// widget
Widget keyInfoWidget() {
return Column(
children: [
// Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
rightWidget: Text(
'${state.countryName.value} +${state.countryCode.value}',
textAlign: TextAlign.end,
style:
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
action: () async {
var result = await Navigator.pushNamed(
context, Routers.selectCountryRegionPage);
if (result != null) {
result as Map<String, dynamic>;
state.countryCode.value = result['code'];
state.countryName.value = result['countryName'];
}
},
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: getTFWidget(
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)),
Container(height: 10.h),
],
);
}
//
Widget keyTimeWidget() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.timeLimitBeginTime.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
PDuration selectDate = PDuration.parse(
DateTime.parse(state.timeLimitBeginTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true,
action: () {
PDuration selectDate = PDuration.parse(
DateTime.tryParse(state.timeLimitEndTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
],
);
}
//
Widget keyRealNameWidget() {
return Column(
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
rightTitle: "",
isTipsImg: true,
tipsImgAction: () {
ShowTipView().showSureAlertDialog(
"人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。".tr);
},
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _remoteSwitch(false)),
),
],
);
}
//
Widget keyPeriodValidityWidget() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:
"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
})),
Obx(() => Visibility(
visible: state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日".tr,
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.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.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.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
}))),
],
);
}
Widget keyBottomWidget(String sendElectronicKeyTips) {
return Column(
children: [
Container(
padding: EdgeInsets.all(20.w),
child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
sendElectronicKeyTips,
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
)),
],
),
),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.send!.tr,
onClick: () {
if (state.isDemoMode == false) {
logic.sendElectronicKeyRequest();
setState(() {});
} else {
//
logic.showToast("演示模式".tr);
}
}),
Container(
padding: EdgeInsets.only(right: 30.w),
// color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () {
//
if (state.isDemoMode == false) {
Navigator.pushNamed(
context, Routers.massSendElectronicKeyManagePage);
} else {
logic.showToast("演示模式".tr);
}
},
child: Text(
TranslationLoader.lanKeys!.sendGroupKey!.tr,
style:
TextStyle(color: AppColors.mainColor, fontSize: 22.sp),
)),
],
),
),
],
);
}
//
Widget sendElectronicKeySucceed() {
return Column(
children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30.h,
),
Image.asset(
'images/icon_send_success.png',
width: 100.w,
height: 100.w,
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"发送成功".tr,
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
],
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '完成'.tr,
onClick: () {
state.isSendSuccess.value = false;
logic.resetData();
}),
SizedBox(
height: 10.h,
),
OutLineBtn(
btnName: '分享'.tr,
onClick: () {
// Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
_openModalBottomSheet();
},
),
SizedBox(
height: 10.h,
),
// OutLineBtn(
// btnName: '微信通知',
// onClick: () {},
// ),
// SizedBox(
// height: 10.h,
// ),
//
// OutLineBtn(
// btnName: '标记为已入住',
// onClick: () {
// updateRoomCheckIn();
// },
// ),
],
);
}
// isOn:: 1 2
Future<void> updateRoomCheckIn() async {
// var entity = await ApiRepository.to
// .updateSetting(state.keyInfo.value.lockId.toString(), '1', '13');
// if (entity.errorCode!.codeIsSuccessful) {
// Toast.show(msg: "标记成功");
// } else {
// Toast.show(msg: '操作失败');
// }
var entity = await ApiRepository.to.setRoomStatusData(
lockId: CommonDataManage().currentKeyInfo.lockId!,
roomStatus: 1,
);
if (entity.errorCode!.codeIsSuccessful) {
logic.showToast("标记成功".tr);
}
}
//
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) {
return SizedBox(
height: 65.h,
width: 320.w,
child: Row(
children: [
Expanded(
child: TextField(
controller: lineIndex == 1
? state.emailOrPhoneController
: state.keyNameController,
//
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(30),
],
// controller: _controller,
autofocus: false,
textAlign: TextAlign.end,
// decoration: InputDecoration(
// //
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
// hintText: tfStr,
// hintStyle: TextStyle(fontSize: 22.sp),
// //线
// border: InputBorder.none,
// ),
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),
),
style: TextStyle(
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
),
),
SizedBox(
width: 10.w,
),
isHaveBtn
? Container(
width: 32.w,
height: 32.w,
decoration: const BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage('images/icon_addressBook.png'),
fit: BoxFit.fill),
),
alignment: Alignment.center,
child: InkWell(
onTap: () async {
Contact? currentContact =
await state.contactPicker.selectContact();
state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
}
if (currentContact.fullName!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!;
}
},
),
)
: Container()
],
),
);
}
//
Widget remoteUnlockingWidget() {
return Visibility(
visible: state.isDemoMode
? false
: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1
? true
: false),
child: Column(
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
rightTitle: "",
// isTipsImg: true,
// tipsImgAction: () {
// ShowTipView().showSureAlertDialog("人脸实名认证指的是用户在使用手机APP或小程序开锁时需要先进行本人人脸验证验证通过才能开锁。");
// },
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _remoteSwitch(true)),
action: () {}),
Container(height: 10.h),
],
),
);
}
//isRemote true: false:
CupertinoSwitch _remoteSwitch(bool isRemote) {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value:
isRemote ? state.isRemoteUnlock.value : state.isAuthentication.value,
onChanged: (value) {
if (isRemote) {
state.isRemoteUnlock.value = !state.isRemoteUnlock.value;
} else {
state.isAuthentication.value = !state.isAuthentication.value;
if (state.isAuthentication.value) {
ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () {
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': false});
});
}
}
},
);
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) {
return Column(
children: [
SizedBox(
width: ScreenUtil().screenWidth,
height: 180.h,
child: ListView(
scrollDirection: Axis.horizontal, //
children: initBottomSheetList()),
),
Container(
height: 8.h,
color: AppColors.greyBackgroundColor,
),
TextButton(
style: ButtonStyle(
overlayColor:
MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
'取消'.tr,
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
),
onPressed: () {
Navigator.pop(context);
},
)
],
);
});
}
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
@ -688,11 +91,8 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
Tab _tab(ItemView item) {
return Tab(
// text: item.title,
child: Container(
// width: 1.sw / 8,
margin: EdgeInsets.all(10.w),
// color: Colors.red,
child: Text(
item.title,
textAlign: TextAlign.center,
@ -706,7 +106,9 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
child: TabBarView(
controller: state.tabController,
children: _itemTabs
.map((ItemView item) => Obx(() => indexChangeWidget(item)))
.map((ItemView item) => SendElectronicKeyView(
type: item.type,
))
.toList()),
);
}
@ -718,81 +120,6 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage>
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "3"),
];
List<Widget> initBottomSheetList() {
List<Widget> widgetList = [];
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2));
widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3));
return widgetList;
}
GestureDetector buildCenter3(
String imageName, String titleStr, int itemIndex) {
return GestureDetector(
child: Container(
width: 120.w,
// height: 64.h,
margin:
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
imageName,
width: 50.w,
height: 50.h,
),
SizedBox(
height: 16.w,
),
Text(
titleStr,
style: TextStyle(
fontSize: ScreenUtil().setSp(20), color: Colors.black),
),
],
),
),
onTap: () => _jumpSmartDeviceRoute(itemIndex),
);
}
_jumpSmartDeviceRoute(int itemIndex) {
Get.back();
switch (itemIndex) {
case 0:
//
{
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
}
break;
case 1:
//
{
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
}
break;
case 2:
//
{
Get.toNamed(Routers.sendEmailNotificationPage);
}
break;
case 3:
//
{
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
}
break;
default:
}
}
}
class ItemView {

View File

@ -6,34 +6,12 @@ import '../../../../../tools/dateTool.dart';
import '../../../../lockMian/entity/lockListInfo_entity.dart';
class SendElectronicKeyState {
TextEditingController emailOrPhoneController = TextEditingController(); ///
TextEditingController keyNameController = TextEditingController(); //
late TabController tabController;
final FlutterContactPicker contactPicker = FlutterContactPicker();
late Contact contact;
// final keyInfo = LockListInfoItemEntity().obs;
final isRemoteUnlock = false.obs; //
final isAuthentication = false.obs; //
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var cycleBeginTime = "".obs;//
var cycleEndTime = "".obs;//
var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;//
var weekdaysList = [].obs;
var seletType = 0.obs;//
var isSendSuccess = false.obs;
var countryName = '中国'.tr.obs;
var countryCode = '86'.obs;
var isCreateUser = false.obs; //1 0
var isDemoMode = false;
final sendSucceedType = 0.obs;
final timeLimitTips = '接收者在有效期内可以不限次数使用'; //
final permanentTips = '接收者可以使用此App开关锁'; //

View File

@ -0,0 +1,164 @@
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/showTipView.dart';
import 'package:star_lock/tools/storage.dart';
class SendElectronicKeyViewLogic extends BaseGetXController {
String type;
final SendElectronicKeyViewState state = SendElectronicKeyViewState();
SendElectronicKeyViewLogic(this.type);
@override
void onInit() {
super.onInit();
Storage.getBool(ifIsDemoModeOrNot)
.then((value) => state.isDemoMode = value ?? false);
}
//
Future<void> sendElectronicKeyRequest() async {
if (state.emailOrPhoneController.text.isEmpty) {
showToast("请输入接收者账号".tr);
return;
}
//
var startDate = "0";
var endDate = "0";
var startTime = "0";
var endTime = "0";
int typeValue;
switch (type) {
case '0':
//
if (state.timeLimitBeginTime.value.isEmpty) {
showToast("请选择开始时间".tr);
return;
}
if (state.timeLimitEndTime.value.isEmpty) {
showToast("请选择结束时间".tr);
return;
}
typeValue = XSConstantMacro.keyTypeTime;
startDate = DateTool()
.dateToTimestamp(state.timeLimitBeginTime.value, 1)
.toString();
endDate = DateTool()
.dateToTimestamp(state.timeLimitEndTime.value, 1)
.toString();
startTime = "0";
endTime = "0";
if (int.parse(startDate) >= int.parse(endDate)) {
showToast("失效时间要大于生效时间".tr);
return;
}
break;
case '1':
typeValue = XSConstantMacro.keyTypeLong;
break;
case '2':
typeValue = XSConstantMacro.keyTypeOnce;
break;
case '3':
typeValue = XSConstantMacro.keyTypeLoop;
if (state.cycleBeginTime.value.isEmpty) {
showToast("请选择有效期".tr);
return;
}
startDate = DateTool()
.dateToTimestamp(state.cycleBeginTime.value, 1)
.toString();
endDate =
DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
startTime = DateTool()
.dateToTimestamp(state.effectiveDateTime.value, 0)
.toString();
endTime = DateTool()
.dateToTimestamp(state.failureDateTime.value, 0)
.toString();
break;
default:
typeValue = XSConstantMacro.keyTypeTime;
break;
}
String getKeyType = typeValue.toString();
var entity = await ApiRepository.to.sendElectronicKey(
createUser: state.isCreateUser.value == true ? "1" : "0",
countryCode: state.countryCode.value,
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
? '1'
: '2',
endDate: int.parse(endDate),
faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
isCameraEnable: '2',
isRemoteUnlock: state.isRemoteUnlock.value == true ? '1' : '2',
keyNameForAdmin: state.keyNameController.text,
keyRight: '0',
keyType: getKeyType,
lockId: CommonDataManage().currentKeyInfo.lockId.toString(),
operatorUid: '',
receiverUsername: state.emailOrPhoneController.text,
remarks: '',
startDate: int.parse(startDate),
weekDays: state.weekdaysList,
startTime: int.parse(startTime),
endTime: int.parse(endTime),
isOnlyManageSelf: 0);
if (entity.errorCode!.codeIsSuccessful) {
state.isSendSuccess.value = true;
resetData();
eventBus.fire(ElectronicKeyListRefreshUI());
} else {
if (entity.errorCode == 425) {
//
state.isCreateUser.value = true;
ShowTipView().showIosTipWithContentDialog(
'${"是否发送电子钥匙给未注册账号".tr}\n${state.emailOrPhoneController.text}', () {
sendElectronicKeyRequest();
});
}
}
}
bool isPhoneNumber(String input) {
// 11
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
return phoneRegExp.hasMatch(input);
}
bool isEmail(String input) {
//
final RegExp emailRegExp =
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
return emailRegExp.hasMatch(input);
}
void resetData() {
state.emailOrPhoneController.text = "";
state.keyNameController.text = "";
state.timeLimitBeginTime = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; //
state.timeLimitEndTime = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; //
state.cycleBeginTime = "".obs; //
state.cycleEndTime = "".obs; //
state.effectiveDateTime = "".obs; //
state.failureDateTime = "".obs; //
state.weekdaysList = [].obs;
}
}

View File

@ -0,0 +1,656 @@
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/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_logic.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/NativeInteractionTool.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/commonItem.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 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import 'package:star_lock/tools/showTipView.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/submitBtn.dart';
import 'package:star_lock/translations/trans_lib.dart';
class SendElectronicKeyView extends StatefulWidget {
String type;
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
@override
State<SendElectronicKeyView> createState() => _SendElectronicKeyViewState();
}
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
return GetBuilder<SendElectronicKeyViewLogic>(
tag: widget.type,
init: SendElectronicKeyViewLogic(widget.type),
builder: (SendElectronicKeyViewLogic logic) {
return Obx(() {
if (logic.state.isSendSuccess.value == true) {
return sendElectronicKeySucceed(logic);
} else {
switch (widget.type) {
case '0':
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(logic),
keyTimeWidget(logic),
remoteUnlockingWidget(logic),
keyRealNameWidget(logic),
keyBottomWidget(logic.state.timeLimitTips, logic)
],
),
);
case '1':
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(logic),
remoteUnlockingWidget(logic),
keyRealNameWidget(logic),
keyBottomWidget(logic.state.permanentTips, logic)
],
),
);
case '2':
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(logic),
remoteUnlockingWidget(logic),
keyRealNameWidget(logic),
keyBottomWidget(logic.state.onceLimitTips, logic)
],
),
);
case '3':
//
return SingleChildScrollView(
child: Column(
children: [
keyInfoWidget(logic),
keyPeriodValidityWidget(logic),
remoteUnlockingWidget(logic),
keyRealNameWidget(logic),
keyBottomWidget(logic.state.cycleLimitTips, logic)
],
),
);
default:
return Container();
}
}
});
});
}
// widget
Widget keyInfoWidget(SendElectronicKeyViewLogic logic) {
return Column(
children: [
// Container(height: 10.h),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
1,
logic)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
rightWidget: Text(
'${logic.state.countryName.value} +${logic.state.countryCode.value}',
textAlign: TextAlign.end,
style:
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
action: () async {
var result = await Navigator.pushNamed(
context, Routers.selectCountryRegionPage);
if (result != null) {
result as Map<String, dynamic>;
logic.state.countryCode.value = result['code'];
logic.state.countryName.value = result['countryName'];
}
},
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: getTFWidget(
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2, logic)),
Container(height: 10.h),
],
);
}
//
Widget keyTimeWidget(SendElectronicKeyViewLogic logic) {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: logic.state.timeLimitBeginTime.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
PDuration selectDate = PDuration.parse(
DateTime.parse(logic.state.timeLimitBeginTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
logic.state.timeLimitBeginTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: logic.state.timeLimitEndTime.value,
isHaveDirection: true,
action: () {
PDuration selectDate = PDuration.parse(
DateTime.tryParse(logic.state.timeLimitEndTime.value));
Pickers.showDatePicker(context,
selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
logic.state.timeLimitEndTime.value =
DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
],
);
}
//
Widget keyRealNameWidget(SendElectronicKeyViewLogic logic) {
return Column(
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
rightTitle: "",
isTipsImg: true,
tipsImgAction: () {
ShowTipView().showSureAlertDialog(
"人脸实名认证指的是用户在使用手机APP开锁时需要先进行本人人脸验证验证通过才能开锁。".tr);
},
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _remoteSwitch(false, logic)),
),
],
);
}
//
Widget keyPeriodValidityWidget(SendElectronicKeyViewLogic logic) {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:
"${logic.state.cycleBeginTime.value}\n${logic.state.cycleEndTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result =
await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': logic.state.weekdaysList,
'starDate': logic.state.cycleBeginTime.value,
'endDate': logic.state.cycleEndTime.value,
'starTime': logic.state.effectiveDateTime.value,
'endTime': logic.state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
logic.state.weekdaysList.value = result['validityValue'];
logic.state.cycleBeginTime.value = result['starDate'];
logic.state.cycleEndTime.value = result['endDate'];
logic.state.effectiveDateTime.value = result['starTime'];
logic.state.failureDateTime.value = result['endTime'];
}
})),
Obx(() => Visibility(
visible: logic.state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日".tr,
rightTitle: logic.state.weekdaysList.join(",").toString(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': logic.state.weekdaysList,
'starDate': logic.state.cycleBeginTime.value,
'endDate': logic.state.cycleEndTime.value,
'starTime': logic.state.effectiveDateTime.value,
'endTime': logic.state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
logic.state.weekdaysList.value = result['validityValue'];
logic.state.cycleBeginTime.value = result['starDate'];
logic.state.cycleEndTime.value = result['endDate'];
logic.state.effectiveDateTime.value = result['starTime'];
logic.state.failureDateTime.value = result['endTime'];
}
}))),
Obx(() => Visibility(
visible: logic.state.effectiveDateTime.value.isNotEmpty,
child: CommonItem(
leftTitel: "有效时间".tr,
rightTitle:
"${logic.state.effectiveDateTime.value}-${logic.state.failureDateTime.value}",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': logic.state.weekdaysList,
'starDate': logic.state.cycleBeginTime.value,
'endDate': logic.state.cycleEndTime.value,
'starTime': logic.state.effectiveDateTime.value,
'endTime': logic.state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
logic.state.weekdaysList.value = result['validityValue'];
logic.state.cycleBeginTime.value = result['starDate'];
logic.state.cycleEndTime.value = result['endDate'];
logic.state.effectiveDateTime.value = result['starTime'];
logic.state.failureDateTime.value = result['endTime'];
}
}))),
],
);
}
Widget keyBottomWidget(
String sendElectronicKeyTips, SendElectronicKeyViewLogic logic) {
return Column(
children: [
Container(
padding: EdgeInsets.all(20.w),
child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
sendElectronicKeyTips,
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
)),
],
),
),
SubmitBtn(
btnName: TranslationLoader.lanKeys!.send!.tr,
onClick: () {
if (logic.state.isDemoMode == false) {
logic.sendElectronicKeyRequest();
setState(() {});
} else {
//
logic.showToast("演示模式".tr);
}
}),
Container(
padding: EdgeInsets.only(right: 30.w),
// color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () {
//
if (logic.state.isDemoMode == false) {
Navigator.pushNamed(
context, Routers.massSendElectronicKeyManagePage);
} else {
logic.showToast("演示模式".tr);
}
},
child: Text(
TranslationLoader.lanKeys!.sendGroupKey!.tr,
style:
TextStyle(color: AppColors.mainColor, fontSize: 22.sp),
)),
],
),
),
],
);
}
//
Widget sendElectronicKeySucceed(SendElectronicKeyViewLogic logic) {
return Column(
children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
children: [
SizedBox(
height: 30.h,
),
Image.asset(
'images/icon_send_success.png',
width: 100.w,
height: 100.w,
),
SizedBox(
height: 20.h,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"发送成功".tr,
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
],
),
],
),
),
SizedBox(
height: 20.h,
),
SubmitBtn(
btnName: '完成'.tr,
onClick: () {
logic.state.isSendSuccess.value = false;
logic.resetData();
}),
SizedBox(
height: 10.h,
),
OutLineBtn(
btnName: '分享'.tr,
onClick: () {
_openModalBottomSheet();
},
),
SizedBox(
height: 10.h,
),
],
);
}
// isOn:: 1 2
Future<void> updateRoomCheckIn(SendElectronicKeyViewLogic logic) async {
var entity = await ApiRepository.to.setRoomStatusData(
lockId: CommonDataManage().currentKeyInfo.lockId!,
roomStatus: 1,
);
if (entity.errorCode!.codeIsSuccessful) {
logic.showToast("标记成功".tr);
}
}
//
Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex,
SendElectronicKeyViewLogic logic) {
return SizedBox(
height: 65.h,
width: 320.w,
child: Row(
children: [
Expanded(
child: TextField(
controller: lineIndex == 1
? logic.state.emailOrPhoneController
: logic.state.keyNameController,
//
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(30),
],
// controller: _controller,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//
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),
),
style: TextStyle(
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
),
),
SizedBox(
width: 10.w,
),
isHaveBtn
? Container(
width: 32.w,
height: 32.w,
decoration: const BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage('images/icon_addressBook.png'),
fit: BoxFit.fill),
),
alignment: Alignment.center,
child: InkWell(
onTap: () async {
Contact? currentContact =
await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
logic.state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
}
if (currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
}
},
),
)
: Container()
],
),
);
}
//
Widget remoteUnlockingWidget(SendElectronicKeyViewLogic logic) {
return Visibility(
visible: logic.state.isDemoMode
? false
: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1
? true
: false),
child: Column(
children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, height: 50.h, child: _remoteSwitch(true, logic)),
action: () {}),
Container(height: 10.h),
],
),
);
}
//isRemote true: false:
CupertinoSwitch _remoteSwitch(
bool isRemote, SendElectronicKeyViewLogic logic) {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: isRemote
? logic.state.isRemoteUnlock.value
: logic.state.isAuthentication.value,
onChanged: (value) {
if (isRemote) {
logic.state.isRemoteUnlock.value = !logic.state.isRemoteUnlock.value;
} else {
logic.state.isAuthentication.value =
!logic.state.isAuthentication.value;
if (logic.state.isAuthentication.value) {
ShowTipView().showBuyTipWithContentAlert(
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () {
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': false});
});
}
}
},
);
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) {
return Column(
children: [
SizedBox(
width: ScreenUtil().screenWidth,
height: 180.h,
child: ListView(
scrollDirection: Axis.horizontal, //
children: initBottomSheetList()),
),
Container(
height: 8.h,
color: AppColors.greyBackgroundColor,
),
TextButton(
style: ButtonStyle(
overlayColor:
MaterialStateProperty.all<Color>(Colors.white)),
child: Text(
'取消'.tr,
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
),
onPressed: () {
Navigator.pop(context);
},
)
],
);
});
}
List<Widget> initBottomSheetList() {
List<Widget> widgetList = [];
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友'.tr, 0));
widgetList.add(buildCenter3('images/icon_message.png', '短信'.tr, 1));
widgetList.add(buildCenter3('images/icon_email.png', '邮件'.tr, 2));
widgetList.add(buildCenter3('images/icon_more.png', '更多'.tr, 3));
return widgetList;
}
GestureDetector buildCenter3(
String imageName, String titleStr, int itemIndex) {
return GestureDetector(
child: Container(
width: 120.w,
// height: 64.h,
margin:
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
imageName,
width: 50.w,
height: 50.h,
),
SizedBox(
height: 16.w,
),
Text(
titleStr,
style: TextStyle(
fontSize: ScreenUtil().setSp(20), color: Colors.black),
),
],
),
),
onTap: () => _jumpSmartDeviceRoute(itemIndex),
);
}
_jumpSmartDeviceRoute(int itemIndex) {
Get.back();
switch (itemIndex) {
case 0:
//
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
break;
case 1:
//
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
break;
case 2:
//
Get.toNamed(Routers.sendEmailNotificationPage);
break;
case 3:
//
String pwdShareStr = '您好,您的电子钥匙生成成功'.tr;
NativeInteractionTool().loadNativeShare(shareText: pwdShareStr);
break;
default:
}
}
@override
bool get wantKeepAlive => true;
}

View File

@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/dateTool.dart';
class SendElectronicKeyViewState {
TextEditingController emailOrPhoneController = TextEditingController(); ///
TextEditingController keyNameController = TextEditingController(); //
final FlutterContactPicker contactPicker = FlutterContactPicker();
late Contact contact;
final isRemoteUnlock = false.obs; //
final isAuthentication = false.obs; //
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var cycleBeginTime = "".obs;//
var cycleEndTime = "".obs;//
var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;//
var weekdaysList = [].obs;
var isSendSuccess = false.obs;
var countryName = '中国'.tr.obs;
var countryCode = '86'.obs;
var isCreateUser = false.obs; //1 0
var isDemoMode = false;
final timeLimitTips = '接收者在有效期内可以不限次数使用'; //
final permanentTips = '接收者可以使用此App开关锁'; //
final onceLimitTips = '单次钥匙有效期为1小时只能使用一次'; //
final cycleLimitTips = '接收者可以在有效期内的固定时间段里,不限次数使用'; //
}