122 lines
3.3 KiB
Dart
Executable File
122 lines
3.3 KiB
Dart
Executable File
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/card/addICCard/addICCard_state.dart';
|
|
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../tools/appRouteObserver.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
import 'addICCard_logic.dart';
|
|
|
|
class AddICCardPage extends StatefulWidget {
|
|
const AddICCardPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<AddICCardPage> createState() => _AddICCardPageState();
|
|
}
|
|
|
|
class _AddICCardPageState extends State<AddICCardPage> with RouteAware {
|
|
final AddICCardLogic logic = Get.put(AddICCardLogic());
|
|
final AddICCardState state = Get.find<AddICCardLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '添加卡'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
),
|
|
body: ListView(
|
|
children: <Widget>[
|
|
SizedBox(height: 200.h),
|
|
Center(
|
|
child: Image.asset(
|
|
'images/main/icon_addCard.png',
|
|
width: 234.w,
|
|
height: 211.h,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
SizedBox(height: 90.h),
|
|
CupertinoActivityIndicator(
|
|
radius: 25.h,
|
|
),
|
|
SizedBox(height: 120.h),
|
|
Container(
|
|
width: 1.sw,
|
|
// height: 50.h,
|
|
padding: EdgeInsets.all(10.w),
|
|
margin: EdgeInsets.only(
|
|
left: 15.w, right: 15.w, top: 10.h, bottom: 10.h),
|
|
// color: AppColors.blackColor,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.blackColor,
|
|
borderRadius: BorderRadius.circular(10.w),
|
|
),
|
|
child: Center(
|
|
child: Obx(() => Text(
|
|
state.ifConnectScuess.value
|
|
? '已连接到锁,请将卡靠近门锁的读卡区'.tr
|
|
: '尝试连接设备...'.tr,
|
|
style: TextStyle(color: Colors.white, fontSize: 24.sp)))),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@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();
|
|
state.ifCurrentScreen.value = false;
|
|
|
|
if(state.ifAddState.value){
|
|
logic.senderCancelAddCardCommand();
|
|
}
|
|
}
|
|
|
|
/// 从下级返回 当前界面即将出现
|
|
@override
|
|
void didPopNext() {
|
|
super.didPopNext();
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 进入下级界面 当前界面即将消失
|
|
@override
|
|
void didPushNext() {
|
|
super.didPushNext();
|
|
logic.cancelBlueConnetctToastTimer();
|
|
|
|
state.ifCurrentScreen.value = false;
|
|
}
|
|
}
|