145 lines
4.9 KiB
Dart
Executable File
145 lines
4.9 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/common/XSConstantMacro/XSConstantMacro.dart';
|
|
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_logic.dart';
|
|
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_state.dart';
|
|
import 'package:star_lock/tools/commonItem.dart';
|
|
import 'package:star_lock/tools/custom_bottom_sheet.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
|
|
class CatEyeSetPage extends StatefulWidget {
|
|
const CatEyeSetPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<CatEyeSetPage> createState() => _CatEyeSetPageState();
|
|
}
|
|
|
|
class _CatEyeSetPageState extends State<CatEyeSetPage> {
|
|
final CatEyeSetLogic logic = Get.put(CatEyeSetLogic());
|
|
final CatEyeSetState state = Get.find<CatEyeSetLogic>().state;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '猫眼设置'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Column(
|
|
children: <Widget>[
|
|
Obx(() => CommonItem(
|
|
leftTitel: '猫眼工作模式'.tr,
|
|
rightTitle: state.selectCatEyeWorkMode.value,
|
|
allHeight: 70.h,
|
|
isHaveLine: true,
|
|
isHaveDirection: true,
|
|
action: () {
|
|
Navigator.pushNamed(
|
|
context,
|
|
Routers.catEyeWorkModePage,
|
|
arguments: <String, Object?>{
|
|
'lockSetInfoData': state.lockSetInfoData.value,
|
|
'catEyeConfigData': state.lockSetInfoData.value
|
|
.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
|
? state.lockSetInfoData.value.lockSettingInfo!
|
|
.catEyeConfig![0]
|
|
: null
|
|
},
|
|
);
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '自动亮屏'.tr,
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
isHaveRightWidget: true,
|
|
rightWidget: _otherToDoSwitch(1))),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '亮屏持续时间'.tr,
|
|
rightTitle: state.selectBrightDuration.value,
|
|
isHaveLine: true,
|
|
isHaveDirection: true,
|
|
action: () {
|
|
_openBottomItemSheet();
|
|
})),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '逗留警告'.tr,
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveRightWidget: true,
|
|
rightWidget: _otherToDoSwitch(2),
|
|
)),
|
|
Obx(() => CommonItem(
|
|
leftTitel: '异常警告'.tr,
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveRightWidget: true,
|
|
rightWidget: _otherToDoSwitch(3))),
|
|
//ToDo 需增加国际化
|
|
CommonItem(
|
|
leftTitel: '呼叫目标'.tr,
|
|
rightTitle: '管理员APP'.tr,
|
|
allHeight: 70.h,
|
|
isHaveLine: true,
|
|
isHaveDirection: true,
|
|
action: () {}),
|
|
],
|
|
));
|
|
}
|
|
|
|
CupertinoSwitch _otherToDoSwitch(int clickIndex) {
|
|
bool isCheck = false;
|
|
switch (clickIndex) {
|
|
case 1: //自动亮屏
|
|
isCheck = state.isAutoBright.value;
|
|
break;
|
|
case 2: //逗留警告
|
|
isCheck = state.isStayWarning.value;
|
|
break;
|
|
case 3: //异常警告
|
|
isCheck = state.isExceptionWarning.value;
|
|
break;
|
|
default:
|
|
}
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: isCheck,
|
|
onChanged: (bool value) {
|
|
logic.updateSettingOptions(clickIndex, value);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future _openBottomItemSheet() async {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadiusDirectional.circular(10)),
|
|
builder: (BuildContext context) {
|
|
return AlertBottomWidget(
|
|
topTitle: '',
|
|
items: state.brightDurationTimeList,
|
|
chooseCallback: (int value) {
|
|
state.selectBrightDuration.value =
|
|
state.brightDurationTimeList[value];
|
|
logic.updateSettingOptions(4, value);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|