2023-09-07 18:36:16 +08:00

303 lines
13 KiB
Dart

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../tools/toast.dart';
import '../../../../translations/trans_lib.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> {
final logic = Get.put(LockSetLogic());
final state = Get.find<LockSetLogic>().state;
StreamSubscription? _passCurrentLockInformationEvent;
@override
void initState() {
// TODO: implement initState
super.initState();
logic.initLoadDataAction(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.set!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
Expanded(
child: ListView(
children: [
CommonItem(
leftTitel:
TranslationLoader.lanKeys!.basicInformation!.tr,
rightTitle: "",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.basicInformationPage);
}),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel:
TranslationLoader.lanKeys!.wirelessKeyboard!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
// Get.toNamed(Routers.wirelessKeyboardPage);
Toast.show(msg: "功能暂未开放");
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr,
rightTitle: "",
isHaveLine: false,
isHaveDirection: true,
action: () {
// Get.toNamed(Routers.doorMagneticPage);
Toast.show(msg: "功能暂未开放");
}),
SizedBox(
height: 10.h,
),
Obx(()=> CommonItem(
leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr,
rightTitle: state.getKeyInfosData.value.remoteEnable == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.remoteUnlockingPage, arguments: state.getKeyInfosData.value);
})),
Obx(() => CommonItem(
leftTitel:
TranslationLoader.lanKeys!.automaticBlocking!.tr,
rightTitle: state.getKeyInfosData.value.autoLockTime! > -1 ? "${state.getKeyInfosData.value.autoLockTime!.toString()}s" : TranslationLoader.lanKeys!.closed!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.automaticBlockingPage, arguments: state.getKeyInfosData.value);
})),
Obx(() => CommonItem(
leftTitel:
TranslationLoader.lanKeys!.normallyOpenMode!.tr,
rightTitle: state.getKeyInfosData.value.passageMode == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.normallyOpenModePage, arguments: state.getKeyInfosData.value);
}),),
Obx(() {
var titleStr = "";
if(state.getKeyInfosData.value.lockSound == 1){
switch(state.getKeyInfosData.value.volume){
case 1:
titleStr = TranslationLoader.lanKeys!.low!.tr;
break;
case 2:
titleStr = TranslationLoader.lanKeys!.lower!.tr;
break;
case 3:
titleStr = TranslationLoader.lanKeys!.medium!.tr;
break;
case 4:
titleStr = TranslationLoader.lanKeys!.high!.tr;
break;
case 5:
titleStr = TranslationLoader.lanKeys!.higher!.tr;
break;
}
}else{
titleStr = TranslationLoader.lanKeys!.closed!.tr;
}
return CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockSound!.tr,
rightTitle: titleStr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockSoundSetPage, arguments: state.getKeyInfosData.value);
});
}),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr,
rightTitle: state.getKeyInfosData.value.tamperAlert == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.burglarAlarmPage, arguments: state.getKeyInfosData.value);
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.resetButton!.tr,
rightTitle: state.getKeyInfosData.value.resetButton == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.resetButtonPage, arguments: state.getKeyInfosData.value);
})),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.unlockQRCode!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.unlockQRCodePage);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr,
rightTitle: "",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.configuringWifiPage);
}),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockTime!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockTimePage, arguments: state.getKeyInfosData.value);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.diagnose!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.diagnosePage);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.uploadData!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.uploadDataPage);
}),
CommonItem(
leftTitel:
TranslationLoader.lanKeys!.importOtherLockData!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.importOtherLockDataPage);
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr,
rightTitle: "",
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockEscalationPage);
}),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: "Amazon Alexa",
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {}),
CommonItem(
leftTitel: "Google Home",
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
action: () {}),
SizedBox(
height: 10.h,
),
Obx((){
var title = "";
if(state.getKeyInfosData.value.roomStatus == 1){
title = TranslationLoader.lanKeys!.checkedIn!.tr;
}else if(state.getKeyInfosData.value.roomStatus == 2){
title = TranslationLoader.lanKeys!.leisure!.tr;
}
return CommonItem(
leftTitel:
TranslationLoader.lanKeys!.markedHouseState!.tr,
rightTitle: title,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.markedHouseStatePage, arguments: state.getKeyInfosData.value);
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(width: 60.w, child: _switch())),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
rightTitle: "",
isHaveLine: false,
isHaveRightWidget: true,
rightWidget: SizedBox(width: 60.w, child: _switch())),
SizedBox(
height: 30.h,
),
Container(
padding: EdgeInsets.only(left: 20.w, right: 20.w),
child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.delete!.tr,
isDelete: true,
onClick: () {
logic.deletUserAction();
// logic.deletLockInfoData();
}),
),
],
),
),
],
));
}
CupertinoSwitch _switch() {
bool _isOn = false;
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: _isOn,
onChanged: (value) {
setState(() {
_isOn = value;
});
},
);
}
}