136 lines
4.4 KiB
Dart
Raw Normal View History

2024-04-17 10:27:51 +08:00
2023-07-10 17:50:31 +08:00
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
2023-07-10 17:50:31 +08:00
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
2024-01-23 17:34:37 +08:00
import 'package:star_lock/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart';
2024-07-26 14:12:26 +08:00
import 'package:star_lock/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_state.dart';
2023-07-10 17:50:31 +08:00
import '../../../../app_settings/app_colors.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../tools/appRouteObserver.dart';
2023-07-10 17:50:31 +08:00
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
class RemoteUnlockingPage extends StatefulWidget {
2023-07-15 15:11:28 +08:00
const RemoteUnlockingPage({Key? key}) : super(key: key);
2023-07-10 17:50:31 +08:00
@override
State<RemoteUnlockingPage> createState() => _RemoteUnlockingPageState();
}
2024-07-26 14:12:26 +08:00
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage> with RouteAware {
final RemoteUnlockingLogic logic = Get.put(RemoteUnlockingLogic());
final RemoteUnlockingState state = Get.find<RemoteUnlockingLogic>().state;
2023-09-07 18:36:16 +08:00
2023-07-10 17:50:31 +08:00
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
2024-07-31 17:24:30 +08:00
barTitle: '远程开锁'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Container(
2023-07-10 17:50:31 +08:00
padding: EdgeInsets.all(30.w),
child: Column(
2024-07-26 14:12:26 +08:00
children: <Widget>[
2023-07-10 17:50:31 +08:00
Row(
mainAxisAlignment: MainAxisAlignment.start,
2024-07-26 14:12:26 +08:00
children: <Widget>[
Expanded(
child: Text(
2024-07-26 14:12:26 +08:00
'功能开启后,你将可以通过网关远程开锁。此功能的开启和关闭只能在锁附近通过手机蓝牙进行。'.tr,
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
)),
2023-07-10 17:50:31 +08:00
],
),
SizedBox(
height: 20.h,
),
Obx(() {
2023-09-07 18:36:16 +08:00
return Row(
mainAxisAlignment: MainAxisAlignment.start,
2024-07-26 14:12:26 +08:00
children: <Widget>[
2023-09-07 18:36:16 +08:00
Expanded(
child: Text(
2024-08-01 18:54:32 +08:00
"${"当前模式".tr} : ${state.remoteEnable.value == 1 ? '已开启'.tr : '已关闭'.tr}",
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 22.sp),
)),
2023-09-07 18:36:16 +08:00
],
);
}),
SizedBox(
height: 40.h,
2023-07-10 17:50:31 +08:00
),
2023-09-07 18:36:16 +08:00
Obx(() => SubmitBtn(
btnName: state.remoteEnable.value == 1
2024-08-01 18:54:32 +08:00
? '关闭'.tr
: '开启'.tr,
2023-09-07 18:36:16 +08:00
onClick: () {
//全自动锁只判断是否开启远程开锁
bool isContains = BlueManage().connectDeviceName.contains('T9A');
if (isContains) {
logic.remoteUnlockingOpenOrClose();
} else {
logic.sendBurglarAlarm();
}
2023-09-07 18:36:16 +08:00
})),
2023-07-10 17:50:31 +08:00
],
),
));
2023-07-10 17:50:31 +08:00
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
2024-04-17 10:27:51 +08:00
// 路由订阅
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
}
@override
void dispose() {
2024-04-17 10:27:51 +08:00
// 取消路由订阅
AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose();
}
2024-04-17 10:27:51 +08:00
///从上级界面进入 当前界面即将出现
@override
void didPush() {
super.didPush();
state.ifCurrentScreen.value = true;
}
/// 返回上一个界面 当前界面即将消失
@override
void didPop() {
super.didPop();
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
/// 从下级返回 当前界面即将出现
@override
void didPopNext() {
super.didPopNext();
state.ifCurrentScreen.value = true;
}
/// 进入下级界面 当前界面即将消失
@override
void didPushNext() {
super.didPushNext();
2024-04-17 10:27:51 +08:00
logic.cancelBlueConnetctToastTimer();
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
2023-07-10 17:50:31 +08:00
}