158 lines
5.3 KiB
Dart
Executable File
158 lines
5.3 KiB
Dart
Executable File
|
||
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/resetButton/resetButton_state.dart';
|
||
|
||
import '../../../../app_settings/app_colors.dart';
|
||
import '../../../../flavors.dart';
|
||
import '../../../../tools/appRouteObserver.dart';
|
||
import '../../../../tools/showTipView.dart';
|
||
import '../../../../tools/submitBtn.dart';
|
||
import '../../../../tools/titleAppBar.dart';
|
||
import 'resetButton_logic.dart';
|
||
|
||
class ResetButtonPage extends StatefulWidget {
|
||
const ResetButtonPage({Key? key}) : super(key: key);
|
||
|
||
@override
|
||
State<ResetButtonPage> createState() => _ResetButtonPageState();
|
||
}
|
||
|
||
class _ResetButtonPageState extends State<ResetButtonPage> with RouteAware {
|
||
final ResetButtonLogic logic = Get.put(ResetButtonLogic());
|
||
final ResetButtonState state = Get.find<ResetButtonLogic>().state;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
backgroundColor: Colors.white,
|
||
appBar: TitleAppBar(
|
||
barTitle: '重置键'.tr,
|
||
haveBack: true,
|
||
backgroundColor: AppColors.mainColor),
|
||
body: Container(
|
||
padding: EdgeInsets.all(30.w),
|
||
child: Column(
|
||
children: <Widget>[
|
||
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(() => Row(
|
||
mainAxisAlignment: MainAxisAlignment.start,
|
||
children: <Widget>[
|
||
Expanded(
|
||
child: Text(
|
||
"${"当前模式".tr} : ${state.resetButtonEnable.value == 1 ? '已开启'.tr : '已关闭'.tr}",
|
||
style: TextStyle(
|
||
fontWeight: FontWeight.w600, fontSize: 20.sp),
|
||
)),
|
||
],
|
||
)),
|
||
SizedBox(
|
||
height: 30.h,
|
||
),
|
||
Obx(() => SubmitBtn(
|
||
btnName: state.resetButtonEnable.value == 1
|
||
? '关闭'.tr
|
||
: '开启'.tr,
|
||
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),
|
||
onClick: () {
|
||
// showDeletAlertTipDialog(context);
|
||
ShowTipView().showIosTipWithContentDialog(
|
||
state.resetButtonEnable.value == 1 ? '确定要关闭重置键?'.tr : '确定要开启重置键?'.tr,
|
||
// '确定要${state.resetButtonEnable.value == 1 ? '关闭'.tr : '开启'.tr}重置键?',
|
||
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;
|
||
}
|
||
}
|