import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/tools/custom_bottom_sheet.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 createState() => _MsgNotificationPageState(); } class _MsgNotificationPageState extends State { bool faceOn = false; //面容开锁 bool autoBright = false; //自动亮屏 String senseDistance = '远距离'; //感应距离 String antiMisoperation = '关闭'; //防误开 List senseDistanceList = ['远距离', '近距离']; List antiMisoperationList = ['关闭', '5秒', '10秒', '15秒', '30秒', '60秒']; //高亮样式 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( barTitle: '消息通知', haveBack: true, backgroundColor: AppColors.mainColor), body: 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, ), SizedBox( height: 20.h, ), 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, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(2))), SizedBox( height: 20.h, ), CommonItem( leftTitel: '异常', rightTitle: "已启用", isHaveLine: true, isHaveDirection: true, ), 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), ), ), CommonItem( leftTitel: '有人按门铃', rightTitle: "", isHaveLine: false, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(2))), 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), ), ), CommonItem( leftTitel: '有人出现在门口', rightTitle: "", isHaveLine: false, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(2))), ], )); } Widget _buildSubTitleItem( String leftStr, String subTitle, String rightStr, Function()? action) { return GestureDetector( onTap: action, child: Container( margin: EdgeInsets.only(left: 20.sp, right: 20.sp, top: 20.h), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( width: 20.w, ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( alignment: Alignment.centerLeft, child: Text( leftStr, style: TextStyle(fontSize: 24.sp, color: Colors.black), ), ), SizedBox( height: 10.h, ), Container( alignment: Alignment.centerLeft, child: Text( subTitle, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 20.sp, color: AppColors.btnDisableColor), ), ) ], )), SizedBox( width: 20.w, ), Text( rightStr, style: TextStyle( fontSize: 22.sp, color: AppColors.darkGrayTextColor), ), SizedBox( width: 10.w, ), Image.asset( 'images/icon_right_grey.png', width: 12.w, height: 21.w, ) ], ), ), ); } Widget _buildTipsView() { return Container( width: ScreenUtil().screenWidth - 40.w, margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 10.h), decoration: BoxDecoration( color: AppColors.mainBackgroundColor, borderRadius: BorderRadius.circular(10.0), ), child: Padding( padding: EdgeInsets.only(left: 20.w, top: 30.h, bottom: 40.h, right: 15.w), child: RichText(text: tipsPreviewSpan)), ); } CupertinoSwitch _switch(int getIndex) { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, value: getIndex == 1 ? faceOn : autoBright, onChanged: (value) { setState(() { if (getIndex == 1) { faceOn = value; } else { autoBright = value; } }); }, ); } Future _openBottomItemSheet( List bottomItemList, int clickIndex) async { showModalBottomSheet( context: context, shape: RoundedRectangleBorder( borderRadius: BorderRadiusDirectional.circular(10)), builder: (BuildContext context) { return AlertBottomWidget( topTitle: '', items: bottomItemList, chooseCallback: (value) { if (clickIndex == 0) { //感应距离 senseDistance = senseDistanceList[value]; } else if (clickIndex == 1) { //防误开 antiMisoperation = antiMisoperationList[value]; } setState(() {}); }, ); }); } }