239 lines
7.6 KiB
Dart
Raw Normal View History

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
2023-11-13 09:47:19 +08:00
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
2024-04-16 18:32:42 +08:00
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),
2023-11-13 09:47:19 +08:00
body: SingleChildScrollView(
child: _buildMainItem(),
));
}
2023-11-13 09:47:19 +08:00
Widget _buildMainItem() {
return Column(
children: <Widget>[
2023-11-13 09:47:19 +08:00
CommonItem(
leftTitel: '开门通知'.tr,
rightTitle: '',
isHaveLine: true,
2023-11-13 09:47:19 +08:00
isHaveDirection: true,
action: () {
Get.toNamed(Routers.openDoorNotifyPage, arguments: <String, Object>{
'lockSetInfoData': state.msgNoticeInfo.value,
'lockId': state.getLockId.value
});
2023-11-13 09:47:19 +08:00
},
),
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();
}
});
},
)),
2023-11-13 09:47:19 +08:00
Obx(() => CommonItem(
leftTitel: '门未关好'.tr,
rightTitle: '',
isHaveLine: true,
2023-11-13 09:47:19 +08:00
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();
}
});
},
)),
2023-11-13 09:47:19 +08:00
CommonItem(
leftTitel: '胁迫开门'.tr,
rightTitle: '',
2023-11-13 09:47:19 +08:00
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.coerceOpenDoorPage, arguments: <String, Object>{
'lockSetInfoData': state.msgNoticeInfo.value,
'lockId': state.getLockId.value
});
2023-11-13 09:47:19 +08:00
},
),
SizedBox(
height: 10.h,
2023-11-13 09:47:19 +08:00
),
// Obx(() => CommonItem(
// leftTitel: '有人按门铃'.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveRightWidget: true,
// rightWidget:
// SizedBox(width: 60.w, height: 50.h, child: _switch(3)))),
2023-11-13 09:47:19 +08:00
SizedBox(
height: 10.h,
2023-11-13 09:47:19 +08:00
),
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))))),
2023-11-13 09:47:19 +08:00
SizedBox(
height: 60.h,
),
Text(
'此模块功能需要锁联网后设置方可生效'.tr,
style: TextStyle(fontSize: 20.sp),
2023-11-13 09:47:19 +08:00
)
],
);
}
CupertinoSwitch _switch(int getIndex) {
2023-11-13 09:47:19 +08:00
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;
//低电量提醒
2023-11-13 09:47:19 +08:00
default:
}
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
2023-11-13 09:47:19 +08:00
value: isCheck,
onChanged: (bool value) {
2023-11-13 09:47:19 +08:00
switch (getIndex) {
//离家开门
case 1:
state.isLeaveHomeOpenDoor.value = value;
break;
//门未关好
case 2:
{
state.isDoorNotShut.value = value;
logic.updateDoorNotCloseSetting();
}
2023-11-13 09:47:19 +08:00
break;
//有人按门铃
case 3:
{
state.isSomeoneRing.value = value;
logic.updateDoorbellNoticeStateSetting();
}
2023-11-13 09:47:19 +08:00
break;
//有人出现在门口
case 4:
{
state.isSomeoneAppeared.value = value;
logic.updateSomeoneAtDoorNoticeStateSetting();
}
break;
//防拆报警
case 5:
{
state.isTamperAlarm.value = value;
logic.updateTamperAlarmStateSetting();
}
2023-11-13 09:47:19 +08:00
break;
default:
}
},
);
}
}