import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/pickers/pickers.dart'; import 'package:star_lock/tools/pickers/style/default_style.dart'; import 'package:star_lock/tools/storage.dart'; import 'package:star_lock/tools/submitBtn.dart'; import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/titleAppBar.dart'; import 'nDaysUnopened_logic.dart'; class NDaysUnopenedPage extends StatefulWidget { const NDaysUnopenedPage({Key? key}) : super(key: key); @override State createState() => _NDaysUnopenedPageState(); } class _NDaysUnopenedPageState extends State { final logic = Get.put(NDaysUnopenedLogic()); final state = Get.find().state; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: 'N天未开门'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: ListView( padding: EdgeInsets.all(30.w), children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Text( "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网".tr, style: TextStyle( fontSize: 20.sp, color: AppColors.darkGrayTextColor), )), ], ), SizedBox( height: 20.h, ), CommonItem( leftTitel: 'N天未开门提醒'.tr, rightTitle: '', isHaveLine: true, isHaveDirection: false, isHaveRightWidget: true, rightWidget: _unOpenDoorSwitch(), action: () {}), _buildOpenNoticeWidget(), Expanded( child: SizedBox( height: 20.h, )), SubmitBtn( btnName: '保存'.tr, onClick: () async { var isVip = await Storage.getBool(saveIsVip); if (isVip == false) { ShowCupertinoAlertView().advancedFeatureAlert(); } else { logic.lockNoticeSettingAccountList(); } }, ), SizedBox( height: 60.h, ) ], ), ); } Widget _buildOpenNoticeWidget() { return Visibility( visible: state.isUnOpenNotice.value, child: Column( children: [ Obx(() => CommonItem( leftTitel: '门未开时间'.tr, rightTitle: '${state.unOpenDoorTime.value}${'天'.tr}', isHaveLine: true, isHaveRightWidget: false, isHaveDirection: true, action: () { _openBottomItemSheet(context, state.unopenDoorTimeList); }, )), SizedBox( height: 20.h, ), GestureDetector( onTap: () { Get.toNamed(Routers.notificationModePage, arguments: {'msgNoticeInfo': state.msgNoticeInfo.value}) ?.then((val) { if (val != null) { state.emailListStr.value = logic.getEmailListStr(val); state.phontListStr.value = logic.getPhoneListStr(val); } }); }, child: Container( color: Colors.white, margin: EdgeInsets.only(bottom: 10.h), child: Column( children: [ CommonItem( leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, isHaveDirection: true, ), _buildNotifyContain('APP推送'.tr, '管理员'.tr), Obx(() => state.emailListStr.value.isNotEmpty ? _buildNotifyContain( '邮件提醒'.tr, state.emailListStr.value) : Container()), Obx(() => state.phontListStr.value.isNotEmpty ? _buildNotifyContain( '短信提醒'.tr, state.phontListStr.value) : Container()), ], ), ), ), ], )); } Widget _buildNotifyContain(String notifyTitle, String notifyContent) { return Container( padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), decoration: BoxDecoration( color: AppColors.mainBackgroundColor, borderRadius: BorderRadius.circular(6.0.w), ), child: Row( children: [ Text( notifyTitle, style: TextStyle(color: Colors.black, fontSize: 20.sp), ), Expanded( child: SizedBox( width: 20.w, )), Text(notifyContent, textAlign: TextAlign.end, style: TextStyle( color: AppColors.placeholderTextColor, fontSize: 20.sp)), ], ), ); } CupertinoSwitch _unOpenDoorSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: state.isUnOpenNotice.value, onChanged: (value) { setState(() { state.isUnOpenNotice.value = value; if (!state.isUnOpenNotice.value) { state.msgNoticeInfo.value = MsgNoticeData(); } }); }, ); } //底部选择pickerView _openBottomItemSheet(BuildContext context, List dataList) { Pickers.showSinglePicker(context, data: dataList, pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) { state.unOpenDoorTime.value = p; }, onChanged: (p, position) {}); } }