Daisy 624eaf258b 1,新增面容开锁相关界面
2,新增猫眼工作模式相关界面
3,新增开门方向设置界面
4,新增电机功率设置页面
5,部分图片补充
2023-11-02 16:12:36 +08:00

205 lines
6.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 FaceUnlockPage extends StatefulWidget {
const FaceUnlockPage({Key? key}) : super(key: key);
@override
State<FaceUnlockPage> createState() => _FaceUnlockPageState();
}
class _FaceUnlockPageState extends State<FaceUnlockPage> {
bool faceOn = false; //面容开锁
bool autoBright = false; //自动亮屏
String senseDistance = '远距离'; //感应距离
String antiMisoperation = '关闭'; //防误开
List<String> senseDistanceList = ['远距离', '近距离'];
List<String> 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: [
CommonItem(
leftTitel: '面容开锁',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch(1))),
CommonItem(
leftTitel: '自动亮屏',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget:
SizedBox(width: 60.w, height: 50.h, child: _switch(2))),
_buildSubTitleItem(
'感应距离', '感应到门前约1.5米有人时,将自动启动面部识别开锁。', senseDistance, () {
_openBottomItemSheet(senseDistanceList, 0);
}),
SizedBox(
height: 30.h,
),
_buildSubTitleItem('防误开', '防误开已关闭,关门后仍可使用面容开锁', antiMisoperation,
() {
_openBottomItemSheet(antiMisoperationList, 1);
}),
Expanded(
child: SizedBox(
height: 30.h,
)),
_buildTipsView(),
SizedBox(
height: 60.h,
)
],
));
}
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<String> 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(() {});
},
);
});
}
}