200 lines
6.0 KiB
Dart
Executable File
200 lines
6.0 KiB
Dart
Executable File
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
import '../../../../tools/appRouteObserver.dart';
|
|
import 'addFingerprint_logic.dart';
|
|
|
|
class AddFingerprintPage extends StatefulWidget {
|
|
const AddFingerprintPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<AddFingerprintPage> createState() => _AddFingerprintPageState();
|
|
}
|
|
|
|
class _AddFingerprintPageState extends State<AddFingerprintPage> with RouteAware {
|
|
final AddFingerprintLogic logic = Get.put(AddFingerprintLogic());
|
|
final AddFingerprintState state = Get.find<AddFingerprintLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: TitleAppBar(
|
|
barTitle: '添加指纹'.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: ListView(
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 50.h,
|
|
),
|
|
Obx(() => Visibility(
|
|
visible: state.ifConnectScuess.value,
|
|
child: Container(
|
|
padding: EdgeInsets.only(left: 20.w, right: 20.w),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(
|
|
'请将您的手指按下'.tr,
|
|
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
|
textAlign: TextAlign.center,
|
|
maxLines: null,
|
|
style: TextStyle(
|
|
fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 10.h),
|
|
Text(
|
|
'(${state.regIndex.value}/${state.maxRegCount.value})',
|
|
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
|
textAlign: TextAlign.center,
|
|
maxLines: null,
|
|
style: TextStyle(fontSize: 24.sp),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
Obx(() => Visibility(
|
|
visible: !state.ifConnectScuess.value,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(
|
|
'尝试连接设备...'.tr,
|
|
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
|
textAlign: TextAlign.center,
|
|
maxLines: null,
|
|
style: TextStyle(
|
|
fontSize: 24.sp, fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
SizedBox(
|
|
height: 100.h,
|
|
),
|
|
Obx(
|
|
() => Image.asset(
|
|
getIconNumber(state.regIndex.value),
|
|
width: 185.w,
|
|
height: 295.h,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 120.h,
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.all(10.w),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Text(
|
|
'根据提示,抬起手指后再进行下一次指纹采集'.tr,
|
|
// TranslationLoader.lanKeys!.lightTouchScreenTip!.tr,
|
|
textAlign: TextAlign.center,
|
|
maxLines: null,
|
|
style: TextStyle(fontSize: 24.sp),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String getIconNumber(int number) {
|
|
String iconPath = '';
|
|
switch (number) {
|
|
case 1:
|
|
iconPath = 'images/main/addFingerprint/1.jpg';
|
|
break;
|
|
case 2:
|
|
iconPath = 'images/main/addFingerprint/2.jpg';
|
|
break;
|
|
case 3:
|
|
iconPath = 'images/main/addFingerprint/3.jpg';
|
|
break;
|
|
case 4:
|
|
iconPath = 'images/main/addFingerprint/4.jpg';
|
|
break;
|
|
case 5:
|
|
iconPath = 'images/main/addFingerprint/5.jpg';
|
|
break;
|
|
case 6:
|
|
iconPath = 'images/main/addFingerprint/6.jpg';
|
|
break;
|
|
default:
|
|
iconPath = 'images/main/addFingerprint/0.jpg';
|
|
break;
|
|
}
|
|
return iconPath;
|
|
}
|
|
|
|
@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.senderCancelAddFingerprintCommand();
|
|
}
|
|
}
|
|
|
|
/// 从下级返回 当前界面即将出现
|
|
@override
|
|
void didPopNext() {
|
|
super.didPopNext();
|
|
state.ifCurrentScreen.value = true;
|
|
}
|
|
|
|
/// 进入下级界面 当前界面即将消失
|
|
@override
|
|
void didPushNext() {
|
|
super.didPushNext();
|
|
logic.cancelBlueConnetctToastTimer();
|
|
|
|
state.ifCurrentScreen.value = false;
|
|
}
|
|
}
|