164 lines
5.7 KiB
Dart
Raw Permalink Normal View History

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-07-26 14:12:26 +08:00
import 'package:star_lock/main/lockDetail/lockSet/resetButton/resetButton_state.dart';
2023-07-10 17:50:31 +08:00
import '../../../../app_settings/app_colors.dart';
2024-07-26 14:12:26 +08:00
import '../../../../flavors.dart';
import '../../../../tools/appRouteObserver.dart';
2024-04-17 10:27:51 +08:00
import '../../../../tools/showTipView.dart';
2023-07-10 17:50:31 +08:00
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
2023-09-07 18:36:16 +08:00
import 'resetButton_logic.dart';
2023-07-10 17:50:31 +08:00
class ResetButtonPage extends StatefulWidget {
2023-07-15 15:11:28 +08:00
const ResetButtonPage({Key? key}) : super(key: key);
2023-07-10 17:50:31 +08:00
@override
State<ResetButtonPage> createState() => _ResetButtonPageState();
}
class _ResetButtonPageState extends State<ResetButtonPage> with RouteAware {
2024-07-26 14:12:26 +08:00
final ResetButtonLogic logic = Get.put(ResetButtonLogic());
final ResetButtonState state = Get.find<ResetButtonLogic>().state;
2023-07-10 17:50:31 +08:00
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
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>[
2025-12-23 09:27:18 +08:00
// Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: <Widget>[
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// if (F.isSKY)
// Text(
// '开启后,锁被撬动时,会发出报警声'.tr,
// style: TextStyle(fontSize: 20.sp),
// )
// else
// Text(
// '开启后可通过长按锁上的设置键重新上电用APP重新添加'.tr,
// style: TextStyle(fontSize: 20.sp),
// ),
// SizedBox(
// height: 10.h,
// ),
// Text(
// '关闭后重置键无效锁要通过app删除后才能重新添加'.tr,
// style: TextStyle(fontSize: 20.sp),
// )
// ],
// )),
// ],
// ),
// SizedBox(
// height: 30.h,
// ),
Obx(()=> state.resetButtonEnable.value == 1 ? Container(
alignment: Alignment.centerLeft, margin: EdgeInsets.only(bottom: 20.h),
child: Text(
'关闭后,重置键无效'.tr,
style: TextStyle(fontSize: 20.sp),
)) : SizedBox.shrink()),
2023-09-07 18:36:16 +08:00
Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.start,
2024-07-26 14:12:26 +08:00
children: <Widget>[
Expanded(
child: Text(
2024-08-01 18:54:32 +08:00
"${"当前模式".tr} : ${state.resetButtonEnable.value == 1 ? '已开启'.tr : '已关闭'.tr}",
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 20.sp),
2023-09-07 18:36:16 +08:00
)),
],
)),
SizedBox(
height: 30.h,
),
2023-09-07 18:36:16 +08:00
Obx(() => SubmitBtn(
btnName: state.resetButtonEnable.value == 1
2024-08-01 18:54:32 +08:00
? '关闭'.tr
: '开启'.tr,
2023-07-10 17:50:31 +08:00
borderRadius: 20.w,
fontSize: 32.sp,
// margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w),
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
2023-09-07 18:36:16 +08:00
onClick: () {
2024-04-17 10:27:51 +08:00
// showDeletAlertTipDialog(context);
ShowTipView().showIosTipWithContentDialog(
2024-08-01 18:54:32 +08:00
state.resetButtonEnable.value == 1 ? '确定要关闭重置键?'.tr : '确定要开启重置键?'.tr,
// '确定要${state.resetButtonEnable.value == 1 ? '关闭'.tr : '开启'.tr}重置键?',
2024-07-26 14:12:26 +08:00
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();
/// 路由订阅
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();
2024-07-26 14:12:26 +08:00
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();
2024-07-26 14:12:26 +08:00
if (EasyLoading.isShow) {
EasyLoading.dismiss(animation: true);
}
state.ifCurrentScreen.value = false;
state.sureBtnState.value = 0;
}
2023-07-10 17:50:31 +08:00
}