142 lines
4.7 KiB
Dart
Executable File
142 lines
4.7 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:star_lock/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_logic.dart';
|
|
import 'package:star_lock/main/lockDetail/lockSet/remoteUnlocking/remoteUnlocking_state.dart';
|
|
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../blue/blue_manage.dart';
|
|
import '../../../../tools/appRouteObserver.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
|
|
class RemoteUnlockingPage extends StatefulWidget {
|
|
const RemoteUnlockingPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<RemoteUnlockingPage> createState() => _RemoteUnlockingPageState();
|
|
}
|
|
|
|
class _RemoteUnlockingPageState extends State<RemoteUnlockingPage>
|
|
with RouteAware {
|
|
final RemoteUnlockingLogic logic = Get.put(RemoteUnlockingLogic());
|
|
final RemoteUnlockingState state = Get.find<RemoteUnlockingLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '远程开锁'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: Container(
|
|
padding: EdgeInsets.all(30.w),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(
|
|
'功能开启后,你将可以通过网关远程开锁。'.tr + '此功能的开启和关闭只能在锁附近通过手机蓝牙进行'.tr,
|
|
style: TextStyle(
|
|
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
|
|
)),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Obx(() {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(
|
|
"${"当前模式".tr} : ${state.remoteEnable.value == 1 ? '已开启'.tr : '已关闭'.tr}",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w600, fontSize: 22.sp),
|
|
)),
|
|
],
|
|
);
|
|
}),
|
|
// Padding(
|
|
// padding: EdgeInsets.only(top: 20.h),
|
|
// child: Text('此功能的开启和关闭只能在锁附近通过手机蓝牙进行'.tr,
|
|
// style: TextStyle(fontSize: 20.sp)),
|
|
// ),
|
|
SizedBox(
|
|
height: 40.h,
|
|
),
|
|
Obx(() => SubmitBtn(
|
|
btnName: state.remoteEnable.value == 1 ? '关闭'.tr : '开启'.tr,
|
|
onClick: () {
|
|
//全自动锁只判断是否开启远程开锁
|
|
bool isContains =
|
|
BlueManage().connectDeviceName.contains('T9A');
|
|
if (isContains) {
|
|
logic.remoteUnlockingOpenOrClose();
|
|
} else {
|
|
logic.sendBurglarAlarm();
|
|
}
|
|
})),
|
|
],
|
|
),
|
|
));
|
|
}
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
|
|
// 路由订阅
|
|
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// 取消路由订阅
|
|
AppRouteObserver().routeObserver.unsubscribe(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);
|
|
state.ifCurrentScreen.value = false;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
|
|
/// 从下级返回 当前界面即将出现
|
|
@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;
|
|
state.sureBtnState.value = 0;
|
|
}
|
|
}
|