234 lines
6.8 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';
import 'package:star_lock/main/lockDetail/lcokSet/msgNotification/msgNotification_logic.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> {
2023-11-13 09:47:19 +08:00
final logic = Get.put(MsgNotificationLogic());
final 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: [
TextSpan(text: '添加和使用面容开锁时:\n', style: titleStyle),
TextSpan(
text:
'\n1、请尽量保持单人在门前操作\n2、请站立在门锁正前方约0.5~0.8米,面向门锁;\n3、请保持脸部无遮挡露出五官\n4、面容识别异常时可触摸数字键盘任意按键手动重启人脸识别。',
style: subTipsStyle),
]);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
2023-11-13 09:47:19 +08:00
barTitle: '消息提醒',
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: [
Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(left: 40.w, top: 40.h, bottom: 30.h),
child: Text(
'门锁通知',
style:
TextStyle(color: AppColors.msgNoticeTextColor, fontSize: 24.sp),
),
),
CommonItem(
leftTitel: '开门通知',
rightTitle: "已启用",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.openDoorNotifyPage);
},
),
SizedBox(
height: 20.h,
),
CommonItem(
leftTitel: 'N天未开门',
rightTitle: "已启用",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.nDaysUnopenedPage);
},
),
2023-11-18 10:38:13 +08:00
// SizedBox(
// height: 20.h,
// ),
// Obx(() => CommonItem(
// leftTitel: '离家开门',
// rightTitle: "",
// isHaveLine: false,
// isHaveRightWidget: true,
// rightWidget:
// SizedBox(width: 60.w, height: 50.h, child: _switch(1)))),
2023-11-13 09:47:19 +08:00
SizedBox(
height: 20.h,
),
Obx(() => CommonItem(
leftTitel: '门未关好',
rightTitle: "",
isHaveLine: false,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch(2)))),
SizedBox(
height: 20.h,
),
CommonItem(
leftTitel: '防拆报警',
rightTitle: "已启用",
isHaveLine: false,
isHaveDirection: true,
),
SizedBox(
height: 20.h,
),
CommonItem(
leftTitel: '低电量提醒',
rightTitle: "已启用",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lowBatteryReminderPage);
},
),
SizedBox(
height: 20.h,
),
CommonItem(
leftTitel: '胁迫开门',
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.coerceOpenDoorPage);
},
),
SizedBox(
height: 30.h,
),
Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(left: 40.w, top: 40.h, bottom: 30.h),
child: Text(
'门铃通知',
style:
TextStyle(color: AppColors.msgNoticeTextColor, fontSize: 24.sp),
),
),
Obx(() => CommonItem(
leftTitel: '有人按门铃',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch(3)))),
SizedBox(
height: 30.h,
),
Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(left: 40.w, top: 40.h, bottom: 30.h),
child: Text(
'猫眼通知',
style:
TextStyle(color: AppColors.msgNoticeTextColor, fontSize: 24.sp),
),
),
Obx(() => CommonItem(
leftTitel: '有人出现在门口',
rightTitle: "",
isHaveLine: false,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch(4)))),
SizedBox(
height: 60.h,
)
],
);
}
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;
default:
}
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
2023-11-13 09:47:19 +08:00
value: isCheck,
onChanged: (value) {
2023-11-13 09:47:19 +08:00
switch (getIndex) {
//离家开门
case 1:
state.isLeaveHomeOpenDoor.value = value;
break;
//门未关好
case 2:
state.isDoorNotShut.value = value;
break;
//有人按门铃
case 3:
state.isSomeoneRing.value = value;
break;
//有人出现在门口
case 4:
state.isSomeoneAppeared.value = value;
break;
default:
}
},
);
}
}