2025-04-22 19:02:42 +08:00

986 lines
33 KiB
Dart
Executable File

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_state.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/EasyRefreshTool.dart';
import '../../../../tools/appRouteObserver.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/showTipView.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import 'lockSetInfo_entity.dart';
import 'lockSet_logic.dart';
class LockSetPage extends StatefulWidget {
const LockSetPage({Key? key}) : super(key: key);
@override
State<LockSetPage> createState() => _LockSetPageState();
}
class _LockSetPageState extends State<LockSetPage>
with WidgetsBindingObserver, RouteAware {
final LockSetLogic logic = Get.put(LockSetLogic());
final LockSetState state = Get.find<LockSetLogic>().state;
Future<void> getHttpData() async {
logic.getLockSettingInfoData().then((LockSetInfoEntity value) {
if (mounted) {
setState(() {});
}
});
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
logic.initLoadDataAction(() {
setState(() {});
});
getHttpData();
}
@override
Widget build(BuildContext context) {
return GetBuilder<LockSetLogic>(builder: (LockSetLogic logic) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '设置'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: EasyRefreshTool(
onRefresh: () {
getHttpData();
},
child: Column(
children: <Widget>[
Expanded(
child: Obx(() => ListView(
children: getListWidget(),
)),
),
],
),
));
});
}
// 根据权限显示不同的列表
List<Widget> getListWidget() {
if (state.lockBasicInfo.value.isLockOwner == 1 ||
state.lockBasicInfo.value.keyRight == 1) {
// 超级管理员、授权管理员
return getAllWidget();
} else {
return getNormalWidget();
}
}
// 普通用户
List<Widget> getNormalWidget() {
final List<Widget> showWidgetArr = <Widget>[
// 基本信息
CommonItem(
leftTitel: '基本信息'.tr,
rightTitle: '',
isHaveLine: false,
isHaveDirection: true,
action: () {
if (!state.lockSetInfoData.value.isValid()) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr);
return;
}
Get.toNamed(Routers.basicInformationPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}),
SizedBox(height: 10.h),
// 自动闭锁
Obx(() => Visibility(
visible: state.lockFeature.value.autoLock == 1,
child: CommonItem(
leftTitel: '自动闭锁'.tr,
rightTitle: (state.lockSettingInfo.value.autoLock ?? 0) > 0
? '${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s'
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
// isHaveRightWidget: true,
// rightWidget: rightText((state.lockSetInfoData.value.lockSetting!.autoLock ?? 0) > 0
// ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s"
// : TranslationLoader.lanKeys!.closed!.tr),
action: () {
Get.toNamed(Routers.automaticBlockingPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value,
// 'lockBasicInfo': state.lockBasicInfo.value
});
}))),
// 常开模式
Obx(() => Visibility(
visible: state.lockFeature.value.passageMode == 1,
child: CommonItem(
leftTitel: '常开模式'.tr,
rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1
? '已开启'.tr
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.normallyOpenModePage,
arguments: <String, Object>{
'lockSetInfoData': state.lockSetInfoData.value,
'lockBasicInfo': state.lockBasicInfo.value
});
}))),
Visibility(
visible: true,
child: CommonItem(
leftTitel: '锁时间'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
if (!state.lockSetInfoData.value.isValid()) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr);
return;
}
Get.toNamed(Routers.lockTimePage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
})),
SizedBox(height: 30.h),
Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.h),
child: SubmitBtn(
btnName: '删除'.tr,
isDelete: true,
onClick: () async {
if (!state.lockSetInfoData.value.isValid()) {
EasyLoading.showToast('网络访问失败,请检查网络是否正常'.tr);
return;
}
// logic.deletUserAction();
// logic.deletLockInfoData();
// showDeletAlertDialog(context);
// showDeletPasswordAlertDialog(context);
final bool isNetWork =
await LockMainLogic.to()?.judgeTheNetwork() ?? false;
if (!isNetWork) {
return;
}
logic.deleyLockLogicOfRoles();
}),
),
];
return showWidgetArr;
}
// 授权管理员、超级管理员字段
List<Widget> getAllWidget() {
final List<Widget> showWidgetArr = <Widget>[
// 基本信息
CommonItem(
leftTitel: '基本信息'.tr,
rightTitle: '',
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.basicInformationPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}),
SizedBox(height: 10.h),
//by DaisyWu 田总:移至锁详情配件区
// 门磁
// Obx(() => Visibility(
// visible: state.lockFeature.value.doorStatus == 1 ? true : false,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.doorMagneticPage);
// // Toast.show(msg: "功能暂未开放");
// }))),
// // 无线键盘
// Obx(() => Visibility(
// visible: state.lockFeature.value.wirelessKeyboard == 1 ? true : false,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.wirelessKeyboard!.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.wirelessKeyboardPage);
// // Toast.show(msg: "功能暂未开放");
// }))),
// // 照明
// Obx(() => Visibility(
// visible: state.lockFeature.value.lightingTime == 1 ? true : false,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.illumination!.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// logic.showToast("功能暂未开放");
// }))),
// 开门器
// Visibility(
// visible: state.lockFeature.value.doorStatus == 1 ? true : false,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.doorOpener!.tr,
// rightTitle: "",
// isHaveLine: false,
// isHaveDirection: true,
// action: () {
// logic.showToast("功能暂未开放");
// })),
// SizedBox(height: 10.h),
// 自动闭锁
Obx(() => Visibility(
visible: state.lockFeature.value.autoLock == 1,
child: CommonItem(
leftTitel: '自动闭锁'.tr,
rightTitle: state.lockSettingInfo.value.autoLock! > 0
? '${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond}s'
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
// isHaveRightWidget: true,
// rightWidget: rightText((state.lockSetInfoData.value.lockSetting!.autoLock ?? 0) > 0
// ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s"
// : TranslationLoader.lanKeys!.closed!.tr),
action: () {
Get.toNamed(Routers.automaticBlockingPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
// 锁声音
Obx(() {
String titleStr = '';
if ((state.lockSettingInfo.value.lockSound ?? 0) == 1) {
switch (state.lockSettingInfo.value.lockSoundVolume ?? 0) {
case 1:
titleStr = ''.tr;
break;
case 2:
titleStr = '较低'.tr;
break;
case 3:
titleStr = ''.tr;
break;
case 4:
titleStr = '较高'.tr;
break;
case 5:
titleStr = ''.tr;
break;
}
} else {
titleStr = '已关闭'.tr;
}
return Visibility(
visible: state.lockFeature.value.lockSound == 1,
child: CommonItem(
leftTitel: '锁声音'.tr,
rightTitle: titleStr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockSoundSetPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}));
}),
// 防撬报警
Obx(() => Visibility(
visible: state.lockFeature.value.antiPrySwitch == 1,
child: CommonItem(
leftTitel: '防撬报警'.tr,
rightTitle: (state.lockSettingInfo.value.antiPrySwitch ?? 0) == 1
? '已开启'.tr
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.burglarAlarmPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
//todo 电子反锁、可视门铃码国际化
// 电子反锁
Obx(() => Visibility(
visible: state.lockFeature.value.isElectronicAntiLock == 1,
child: CommonItem(
leftTitel: '电子反锁'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _elecAntiLockSwitch()),
)),
// 可视门铃码
Obx(() => Visibility(
visible: state.lockFeature.value.isVisualDoorBellCode == 1,
child: CommonItem(
leftTitel: '可视门铃码'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _visualDoorbellCodeSwitch()),
)),
SizedBox(height: 10.h),
// 常开模式
Obx(() => Visibility(
visible: state.lockFeature.value.passageMode == 1,
// visible: true,
child: CommonItem(
leftTitel: '常开模式'.tr,
rightTitle: (state.lockSettingInfo.value.passageMode ?? 0) == 1
? '已开启'.tr
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.normallyOpenModePage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
//todo: 双重认证、双锁联动国际化、API接口
//双重认证
Obx(() => Visibility(
//state.lockFeature.value.doubleAuthentication == 1,
visible: false,
child: CommonItem(
leftTitel: '双重认证'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _dualAuthSwitch()))),
// 双锁联动
Visibility(
visible: state.lockFeature.value.isDoubleLockLinkage == 1,
child: CommonItem(
leftTitel: '双锁联动'.tr,
rightTitle: '未关联'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.doubleLockLinkPage);
}),
),
// 远程开锁
Obx(() => Visibility(
visible: state.lockFeature.value.remoteUnlock == 1,
child: CommonItem(
leftTitel: '远程开锁'.tr,
rightTitle: (state.lockSettingInfo.value.remoteUnlock ?? 0) == 1
? '已开启'.tr
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.remoteUnlockingPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
// 重置键
Obx(() => Visibility(
visible: state.lockBasicInfo.value.isLockOwner == 1 &&
state.lockFeature.value.resetSwitch == 1,
child: CommonItem(
leftTitel: '重置键'.tr,
rightTitle: (state.lockSettingInfo.value.resetSwitch ?? 0) == 1
? '已开启'.tr
: '已关闭'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.resetButtonPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
SizedBox(height: 10.h),
//---田总新增展示
// Obx(() =>
// 面容开锁
Visibility(
visible: state.lockFeature.value.d3Face == 1,
child: CommonItem(
leftTitel: '面容开锁'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.faceUnlockPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
})),
// ),
// 消息提醒
Visibility(
visible: true,
child: CommonItem(
leftTitel: '消息提醒'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.msgNotificationPage,
arguments: <String, int?>{
'lockId': state.lockSetInfoData.value.lockId
});
})),
//猫眼设置
Obx(() => Visibility(
visible: state.lockFeature.value.isSupportCatEye == 1,
child: CommonItem(
leftTitel: '猫眼设置'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.catEyeSetPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
// Obx(() =>
//自动亮屏已包括至面容开锁模块
// Visibility(
// visible: true,
// child: CommonItem(
// leftTitel: '自动亮屏',
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {})),
// ),
// Obx(() =>
//感应距离已包括至面容开锁模块
// Visibility(
// visible: true,
// child: CommonItem(
// leftTitel: '感应距离',
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Toast.show(msg: "功能暂未开放");
// })),
// ),
// Obx(() =>
// 开门方向设置
Visibility(
visible: state.lockFeature.value.openDirection == 1,
child: CommonItem(
leftTitel: '开门方向设置'.tr,
rightTitle: '',
isHaveDirection: true,
isHaveLine: true,
action: () {
Get.toNamed(Routers.openDoorDirectionPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
})),
// 电机功率设置
Visibility(
visible: state.lockFeature.value.motorTorsion == 1,
child: CommonItem(
leftTitel: '电机功率设置'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.motorPowerPage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
})),
// 蓝牙广播(关闭则不能使用蓝牙主动开锁)
/* 2024-01-12 会议确定去掉“蓝牙广播” by DaisyWu
Obx(() => Visibility(
visible: true,
child: CommonItem(
leftTitel: TranslationLoader.lanKeys!.bluetoothBroadcast!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _lockBlueBroadcastSwitch()))),
SizedBox(height: 10.h),
*/
//-----新增至此
SizedBox(height: 10.h),
// 标记房态
// Obx(() {
// var title = "";
// if (state.lockStatus.value.roomStatus == 1) {
// title = TranslationLoader.lanKeys!.checkedIn!.tr;
// } else if (state.lockStatus.value.roomStatus == 0) {
// title = TranslationLoader.lanKeys!.leisure!.tr;
// }
// return Visibility(
// visible: state.lockStatus.value.roomStatus == 1 ? true : false,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.markedHouseState!.tr,
// rightTitle: title,
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.markedHouseStatePage, arguments: {
// 'lockSetInfoData': state.lockSetInfoData.value
// });
// }));
// }),
// 考勤
// Obx(
// () => Visibility(
// visible: state.lockBasicInfo.value.isLockOwner == 1 &&
// state.lockFeature.value.attendance == 1,
// child: CommonItem(
// leftTitel: '考勤'.tr,
// rightTitle: '',
// isHaveLine: true,
// isHaveRightWidget: true,
// rightWidget: _openCheckInSwitch())),
// ),
// 开锁提醒
Obx(
() => Visibility(
visible: state.lockBasicInfo.value.isLockOwner == 1 &&
state.lockFeature.value.unlockReminder == 1,
child: CommonItem(
leftTitel: '开锁提醒'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _lockRemindSwitch())),
),
// APP开锁时是否需联网
Obx(
() => Visibility(
visible: state.lockBasicInfo.value.isLockOwner == 1 &&
state.lockFeature.value.appUnlockOnline == 1,
child: otherItem(
leftTitle: '开锁时是否需联网'.tr,
isHaveLine: false,
rightWidget: _openLockNeedOnlineSwitch()),
),
),
SizedBox(height: 10.h),
// wifi配网
Obx(
() => Visibility(
visible: state.lockFeature.value.wifi == 1,
child: CommonItem(
leftTitel: 'WiFi配网'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.wifiListPage, arguments: {
'lockSetInfoData': state.lockSetInfoData.value,
'pageName': 'lockSet'
});
// Get.toNamed(Routers.configuringWifiPage, arguments: {
// 'lockSetInfoData': state.lockSetInfoData.value
// });
})),
),
// Obx(() =>
// 锁时间
Visibility(
visible: true,
child: CommonItem(
leftTitel: '锁时间'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockTimePage,
arguments: <String, LockSetInfoData>{
'lockSetInfoData': state.lockSetInfoData.value
});
})),
// ),
// Obx(() =>
// 诊断
// Visibility(
// visible: true,
// child: CommonItem(
// leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.diagnosePage, arguments: {
// 'lockSetInfoData': state.lockSetInfoData.value
// });
// })),
// ),
// Obx(() =>
// 上传数据
Visibility(
visible: true,
child: CommonItem(
leftTitel: '上传数据'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.uploadDataPage);
})),
// ),
// Obx(() =>
// Visibility(
// visible: true,
// child: CommonItem(
// leftTitel: TranslationLoader
// .lanKeys!.importOtherLockData!.tr,
// rightTitle: "",
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.importOtherLockDataPage);
// })),
// ),
// Obx(() =>
// 锁升级
Visibility(
visible: true,
child: CommonItem(
leftTitel: '锁升级'.tr,
rightTitle: '',
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockEscalationPage);
})),
// ),
SizedBox(height: 30.h),
Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.h),
child: SubmitBtn(
btnName: '删除'.tr,
isDelete: true,
onClick: () {
// logic.deletUserAction();
// logic.deletLockInfoData();
// showDeletAlertDialog(context);
// showDeleteAdministratorIsHaveAllDataDialog(context);
logic.deleyLockLogicOfRoles();
}),
),
];
return showWidgetArr;
}
Widget rightText(String rightTitle) {
return Text(rightTitle,
textAlign: TextAlign.end,
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor));
}
Widget otherItem({String? leftTitle, bool? isHaveLine, Widget? rightWidget}) {
return Container(
width: 1.sw,
padding:
EdgeInsets.only(left: 20.w, top: 7.5.h, bottom: 7.5.h, right: 10.w),
decoration: BoxDecoration(
color: Colors.white,
border: isHaveLine!
? Border(
bottom: BorderSide(
color: AppColors.greyLineColor, // 设置边框颜色
width: 2.0.h, // 设置边框宽度
),
)
: null,
),
child: Row(
children: <Widget>[
Expanded(child: Text(leftTitle!, style: TextStyle(fontSize: 22.sp))),
SizedBox(width: 10.w),
rightWidget ?? Container(),
SizedBox(width: 5.w),
],
),
);
}
// 开启考勤
// CupertinoSwitch _openCheckInSwitch() {
// return CupertinoSwitch(
// activeColor: CupertinoColors.activeBlue,
// trackColor: CupertinoColors.systemGrey5,
// thumbColor: CupertinoColors.white,
// value: state.isAttendance.value == 1,
// onChanged: (bool value) {
// logic.openCheckingInData(
// (CheckingInInfoDataEntity checkingInInfoDataEntity) {
// if (checkingInInfoDataEntity.data!.companyId == 0) {
// // logic.showCupertinoAlertDialog(context);
// ShowTipView().showIosTipWithContentDialog('创建公司后,考勤功能才能使用'.tr, () {
// // 删除锁
// Get.toNamed(Routers.checkInCreatCompanyPage,
// arguments: <String, LockSetInfoData>{
// 'lockSetInfoData': state.lockSetInfoData.value
// });
// });
// } else {
// logic.setLockSetGeneralSetting();
// }
// });
// },
// );
// }
// 开锁提醒
CupertinoSwitch _lockRemindSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isUnlockReminder.value == 1,
onChanged: (bool value) {
logic.setLockPickingReminder();
},
);
}
// APP开锁时是否需联网
CupertinoSwitch _openLockNeedOnlineSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isOpenLockNeedOnline.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
logic.sendBurglarAlarm(55);
});
},
);
}
// 电子反锁
CupertinoSwitch _elecAntiLockSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isElecAntiLock.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isElecAntiLock.value = value ? 1 : 0;
});
},
);
}
// 可视门铃码
CupertinoSwitch _visualDoorbellCodeSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isVisualDoorbellCode.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isVisualDoorbellCode.value = value ? 1 : 0;
if (state.isVisualDoorbellCode.value == 1) {
ShowCupertinoAlertView().showVisualDoorbellCodeAlert(
widgetContext: context,
qrCodeUrl: BlueManage().connectDeviceName,
qrCodeText: '请扫描可视门铃码二维码'.tr,
);
} else {}
});
},
);
}
// 双重认证
CupertinoSwitch _dualAuthSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isDualAuth.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isDualAuth.value = value ? 1 : 0;
});
},
);
}
// 异常警告
// CupertinoSwitch _lockExceptionWarningsSwitch() {
// return CupertinoSwitch(
// activeColor: CupertinoColors.activeBlue,
// trackColor: CupertinoColors.systemGrey5,
// thumbColor: CupertinoColors.white,
// value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
// onChanged: (value) {
// setState(() {
// logic.sendBurglarAlarm(62);
// });
// },
// );
// }
// 逗留警告
// CupertinoSwitch _lockStayWarnSwitch() {
// return CupertinoSwitch(
// activeColor: CupertinoColors.activeBlue,
// trackColor: CupertinoColors.systemGrey5,
// thumbColor: CupertinoColors.white,
// value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
// onChanged: (value) {
// setState(() {
// logic.sendBurglarAlarm(61);
// });
// },
// );
// }
// 支持蓝牙广播
// CupertinoSwitch _lockBlueBroadcastSwitch() {
// return CupertinoSwitch(
// activeColor: CupertinoColors.activeBlue,
// trackColor: CupertinoColors.systemGrey5,
// thumbColor: CupertinoColors.white,
// value: state.isOpenBlueBroadcast.value == 1,
// onChanged: (bool value) {
// setState(() {
// logic.sendBurglarAlarm(56);
// });
// },
// );
// }
//
// CupertinoSwitch _otherUnHaveDoneSwitch() {
// return CupertinoSwitch(
// activeColor: CupertinoColors.activeBlue,
// trackColor: CupertinoColors.systemGrey5,
// thumbColor: CupertinoColors.white,
// value: false,
// onChanged: (bool value) {
// logic.showToast('功能暂未开放');
// },
// );
// }
@override
void didChangeDependencies() {
super.didChangeDependencies();
/// 路由订阅
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.paused) {
// 应用程序推入后台时清空输入框内容
logic.state.passwordTF.clear();
}
}
@override
void dispose() {
/// 取消路由订阅
AppRouteObserver().routeObserver.unsubscribe(this);
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
/// 从上级界面进入 当前界面即将出现
@override
void didPush() {
super.didPush();
state.ifCurrentScreen.value = true;
}
/// 返回上一个界面 当前界面即将消失
@override
void didPop() {
super.didPop();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) {
EasyLoading.dismiss(animation: true);
}
// if (state.deletWaitScanTimer != null) {
// state.deletWaitScanTimer!.cancel();
// }
// if (state.deletWaitScanCompleter != null &&
// !state.deletWaitScanCompleter!.isCompleted) {
// state.deletWaitScanCompleter!.complete();
// }
state.ifCurrentScreen.value = false;
}
/// 从下级返回 当前界面即将出现
@override
void didPopNext() {
super.didPopNext();
state.ifCurrentScreen.value = true;
}
/// 进入下级界面 当前界面即将消失
@override
void didPushNext() {
super.didPushNext();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) {
EasyLoading.dismiss(animation: true);
}
state.ifCurrentScreen.value = false;
}
}