245 lines
7.8 KiB
Dart
Executable File
245 lines
7.8 KiB
Dart
Executable File
|
||
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_logic.dart';
|
||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_state.dart';
|
||
|
||
import '../../../../../app_settings/app_colors.dart';
|
||
import '../../../../../tools/commonItem.dart';
|
||
import '../../../../../tools/titleAppBar.dart';
|
||
|
||
class MsgNotificationPage extends StatefulWidget {
|
||
const MsgNotificationPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<MsgNotificationPage> createState() => _MsgNotificationPageState();
|
||
}
|
||
|
||
class _MsgNotificationPageState extends State<MsgNotificationPage> {
|
||
final MsgNotificationLogic logic = Get.put(MsgNotificationLogic());
|
||
final MsgNotificationState state = Get.find<MsgNotificationLogic>().state;
|
||
|
||
//高亮样式
|
||
final TextStyle titleStyle = TextStyle(color: Colors.black, fontSize: 24.sp, fontWeight: FontWeight.w500);
|
||
//默认样式
|
||
final TextStyle subTipsStyle = TextStyle(color: AppColors.placeholderTextColor, fontSize: 22.sp);
|
||
|
||
// late InlineSpan tipsPreviewSpan = TextSpan(children: <InlineSpan>[
|
||
// TextSpan(text: '${'添加和使用面容开锁时:'.tr}\n', style: titleStyle),
|
||
// TextSpan(
|
||
// text:
|
||
// '\n1、请尽量保持单人在门前操作;\n2、请站立在门锁正前方约0.5~0.8米,面向门锁;\n3、请保持脸部无遮挡,露出五官;\n4、面容识别异常时,可触摸数字键盘任意按键,手动重启人脸识别。',
|
||
// style: subTipsStyle),
|
||
// ]);
|
||
|
||
@override
|
||
initState() {
|
||
super.initState();
|
||
logic.getLockNoticeSetting();
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
backgroundColor: AppColors.mainBackgroundColor,
|
||
appBar: TitleAppBar(
|
||
barTitle: '消息提醒'.tr,
|
||
haveBack: true,
|
||
backgroundColor: AppColors.mainColor),
|
||
body: SingleChildScrollView(
|
||
child: _buildMainItem(),
|
||
));
|
||
}
|
||
|
||
Widget _buildMainItem() {
|
||
return Column(
|
||
children: <Widget>[
|
||
CommonItem(
|
||
leftTitel: '开门通知'.tr,
|
||
rightTitle: '',
|
||
isHaveLine: true,
|
||
isHaveDirection: true,
|
||
action: () {
|
||
Get.toNamed(Routers.openDoorNotifyPage, arguments: <String, Object>{
|
||
'lockSetInfoData': state.msgNoticeInfo.value,
|
||
'lockId': state.getLockId.value
|
||
});
|
||
},
|
||
),
|
||
Obx(() => CommonItem(
|
||
leftTitel: 'N天未开门'.tr,
|
||
rightTitle: state.nDaysNotOpenDoor.value,
|
||
isHaveLine: true,
|
||
isHaveDirection: true,
|
||
action: () {
|
||
Get.toNamed(Routers.nDaysUnopenedPage, arguments: <String, Object>{
|
||
'lockSetInfoData': state.msgNoticeInfo.value,
|
||
'lockId': state.getLockId.value
|
||
})?.then((value) {
|
||
if (value != null) {
|
||
logic.getLockNoticeSetting();
|
||
}
|
||
});
|
||
},
|
||
)),
|
||
Obx(() => CommonItem(
|
||
leftTitel: '门未关好'.tr,
|
||
rightTitle: '',
|
||
isHaveLine: true,
|
||
isHaveRightWidget: true,
|
||
rightWidget:
|
||
SizedBox(width: 60.w, height: 50.h, child: _switch(2)))),
|
||
Obx(() => CommonItem(
|
||
leftTitel: '防拆报警'.tr,
|
||
rightTitle: '',
|
||
isHaveLine: true,
|
||
isHaveRightWidget: true,
|
||
rightWidget: SizedBox(
|
||
width: 60.w,
|
||
height: 50.h,
|
||
child: _switch(5),
|
||
))),
|
||
Obx(() => CommonItem(
|
||
leftTitel: '低电量提醒'.tr,
|
||
rightTitle: state.isLowBattery.value,
|
||
isHaveLine: true,
|
||
isHaveDirection: true,
|
||
action: () {
|
||
Get.toNamed(Routers.lowBatteryReminderPage, arguments: <String, Object>{
|
||
'lockSetInfoData': state.msgNoticeInfo.value,
|
||
'lockId': state.getLockId.value
|
||
})?.then((value) {
|
||
if (value != null) {
|
||
logic.getLockNoticeSetting();
|
||
}
|
||
});
|
||
},
|
||
)),
|
||
CommonItem(
|
||
leftTitel: '胁迫开门'.tr,
|
||
rightTitle: '',
|
||
isHaveLine: true,
|
||
isHaveDirection: true,
|
||
action: () {
|
||
Get.toNamed(Routers.coerceOpenDoorPage, arguments: <String, Object>{
|
||
'lockSetInfoData': state.msgNoticeInfo.value,
|
||
'lockId': state.getLockId.value
|
||
});
|
||
},
|
||
),
|
||
SizedBox(
|
||
height: 10.h,
|
||
),
|
||
// Obx(() => CommonItem(
|
||
// leftTitel: '有人按门铃'.tr,
|
||
// rightTitle: "",
|
||
// isHaveLine: true,
|
||
// isHaveRightWidget: true,
|
||
// rightWidget:
|
||
// SizedBox(width: 60.w, height: 50.h, child: _switch(3)))),
|
||
SizedBox(
|
||
height: 10.h,
|
||
),
|
||
Obx(() => Visibility(
|
||
visible: state.isSupportCatEye.value,
|
||
child: CommonItem(
|
||
leftTitel: '有人出现在门口'.tr,
|
||
rightTitle: '',
|
||
isHaveLine: true,
|
||
isHaveRightWidget: true,
|
||
rightWidget:
|
||
SizedBox(width: 60.w, height: 50.h, child: _switch(4))))),
|
||
SizedBox(
|
||
height: 60.h,
|
||
),
|
||
Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 30.w),
|
||
child: Text(
|
||
'此模块功能需要锁联网后设置方可生效'.tr,
|
||
style: TextStyle(fontSize: 20.sp),
|
||
textAlign: TextAlign.center, // 文本居中对齐
|
||
softWrap: true, // 允许文本换行
|
||
overflow: TextOverflow.visible, // 文本溢出时显示
|
||
),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
|
||
CupertinoSwitch _switch(int getIndex) {
|
||
bool isCheck = false;
|
||
switch (getIndex) {
|
||
//离家开门
|
||
case 1:
|
||
isCheck = state.isLeaveHomeOpenDoor.value;
|
||
break;
|
||
//门未关好
|
||
case 2:
|
||
isCheck = state.isDoorNotShut.value;
|
||
break;
|
||
//有人按门铃
|
||
case 3:
|
||
isCheck = state.isSomeoneRing.value;
|
||
break;
|
||
//有人出现在门口
|
||
case 4:
|
||
isCheck = state.isSomeoneAppeared.value;
|
||
break;
|
||
//防拆报警
|
||
case 5:
|
||
isCheck = state.isTamperAlarm.value;
|
||
break;
|
||
//低电量提醒
|
||
|
||
default:
|
||
}
|
||
return CupertinoSwitch(
|
||
activeColor: CupertinoColors.activeBlue,
|
||
trackColor: CupertinoColors.systemGrey5,
|
||
thumbColor: CupertinoColors.white,
|
||
value: isCheck,
|
||
onChanged: (bool value) {
|
||
switch (getIndex) {
|
||
//离家开门
|
||
case 1:
|
||
state.isLeaveHomeOpenDoor.value = value;
|
||
break;
|
||
//门未关好
|
||
case 2:
|
||
{
|
||
state.isDoorNotShut.value = value;
|
||
logic.updateDoorNotCloseSetting();
|
||
}
|
||
break;
|
||
//有人按门铃
|
||
case 3:
|
||
{
|
||
state.isSomeoneRing.value = value;
|
||
logic.updateDoorbellNoticeStateSetting();
|
||
}
|
||
break;
|
||
//有人出现在门口
|
||
case 4:
|
||
{
|
||
state.isSomeoneAppeared.value = value;
|
||
logic.updateSomeoneAtDoorNoticeStateSetting();
|
||
}
|
||
break;
|
||
//防拆报警
|
||
case 5:
|
||
{
|
||
state.isTamperAlarm.value = value;
|
||
logic.updateTamperAlarmStateSetting();
|
||
}
|
||
break;
|
||
|
||
default:
|
||
}
|
||
},
|
||
);
|
||
}
|
||
}
|