feat: 添加锁前增加重置锁流程及提示

This commit is contained in:
wuyaxi 2025-07-14 15:19:44 +08:00
parent 2ffbc72d09
commit fa270b77e0
7 changed files with 274 additions and 47 deletions

View File

@ -41,6 +41,7 @@ import 'package:star_lock/main/lockDetail/palm/palmList/palmList_page.dart';
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart';
import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart'; import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart';
import 'package:star_lock/mine/about/webviewShow_page.dart'; import 'package:star_lock/mine/about/webviewShow_page.dart';
import 'package:star_lock/mine/addLock/lockResetConfirm/lockResetConfirm_page.dart';
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart'; import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
@ -514,6 +515,7 @@ abstract class Routers {
static const String starChartPage = '/starChartPage'; // static const String starChartPage = '/starChartPage'; //
static const String starChartTalkView = '/starChartTalkView'; // static const String starChartTalkView = '/starChartTalkView'; //
static const String h264WebView = '/h264WebView'; // static const String h264WebView = '/h264WebView'; //
static const String lockResetConfirmPage = '/LockResetConfirmPage'; //
} }
abstract class AppRouters { abstract class AppRouters {
@ -1185,5 +1187,9 @@ abstract class AppRouters {
GetPage<dynamic>( GetPage<dynamic>(
name: Routers.starChartTalkView, page: () => const TalkViewPage()), name: Routers.starChartTalkView, page: () => const TalkViewPage()),
GetPage<dynamic>(name: Routers.h264WebView, page: () => H264WebView()), GetPage<dynamic>(name: Routers.h264WebView, page: () => H264WebView()),
GetPage<dynamic>(
name: Routers.lockResetConfirmPage,
page: () => const LockResetConfirmPage(),
),
]; ];
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -40,12 +39,8 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
), ),
), ),
body: ListView( body: ListView(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(height: 100.h),
height: 100.h,
),
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -57,17 +52,13 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
), ),
], ],
), ),
SizedBox( SizedBox(height: 120.h),
height: 120.h,
),
Obx(() => Image.asset( Obx(() => Image.asset(
logic.state.lockTypeImg.value, logic.state.lockTypeImg.value,
width: 278.w, width: 278.w,
height: 278.w, height: 278.w,
)), )),
SizedBox( SizedBox(height: 120.h),
height: 120.h,
),
Container( Container(
width: 1.sw, width: 1.sw,
padding: EdgeInsets.only(left: 20.w, right: 20.w), padding: EdgeInsets.only(left: 20.w, right: 20.w),
@ -78,14 +69,12 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
'摸亮触摸屏,锁进入可添加状态,点击下一步'.tr, '摸亮触摸屏,锁进入可添加状态,点击下一步'.tr,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 20.sp,fontWeight: FontWeight.w500), fontSize: 20.sp, fontWeight: FontWeight.w500),
), ),
], ],
), ),
), ),
SizedBox( SizedBox(height: 120.h),
height: 120.h,
),
Container( Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w), margin: EdgeInsets.only(left: 20.w, right: 20.w),
child: SubmitBtn( child: SubmitBtn(

View File

@ -0,0 +1,16 @@
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/mine/addLock/lockResetConfirm/lockResetConfirm_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
class LockResetConfirmLogic extends BaseGetXController {
final LockResetConfirmState state = LockResetConfirmState();
//
void confirmLockReset() {
//
Get.toNamed(Routers.addLockPage, arguments: {
'getLockType': state.getLockType.value,
});
}
}

View File

@ -0,0 +1,207 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/addLock/lockResetConfirm/lockResetConfirm_logic.dart';
import '../../../app_settings/app_colors.dart';
import '../../../baseWidget.dart';
import '../../../tools/submitBtn.dart';
import '../../../tools/titleAppBar.dart';
class LockResetConfirmPage extends StatefulWidget {
const LockResetConfirmPage({Key? key}) : super(key: key);
@override
State<LockResetConfirmPage> createState() => _LockResetConfirmPageState();
}
class _LockResetConfirmPageState extends State<LockResetConfirmPage>
with BaseWidget {
@override
Widget build(BuildContext context) {
return GetBuilder<LockResetConfirmLogic>(
init: LockResetConfirmLogic(),
builder: (LockResetConfirmLogic logic) {
return Scaffold(
backgroundColor: Colors.white,
appBar: F.sw(
skyCall: () => TitleAppBar(
barTitle: '重置锁确认'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
xhjCall: () => TitleAppBar(
barTitle: '重置锁确认'.tr,
haveBack: true,
backgroundColor: Colors.white,
iconColor: AppColors.blackColor,
titleColor: AppColors.blackColor,
),
),
body: ListView(
children: [
SizedBox(height: 60.h),
//
Container(
width: 120.w,
height: 120.w,
margin: EdgeInsets.symmetric(horizontal: 1.sw / 2 - 60.w),
decoration: BoxDecoration(
color: AppColors.mainColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(60.w),
),
child: Icon(
Icons.refresh,
size: 60.w,
color: AppColors.mainColor,
),
),
SizedBox(height: 40.h),
//
Container(
width: 1.sw,
padding: EdgeInsets.symmetric(horizontal: 40.w),
child: Text(
'请确认锁已重置'.tr,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 26.sp,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
),
SizedBox(height: 30.h),
//
Container(
width: 1.sw,
padding: EdgeInsets.symmetric(horizontal: 40.w),
child: Text(
'添加锁前,请确保锁已重置为出厂状态。重置后的锁将清除所有用户数据,包括指纹、密码、卡片等信息。'.tr,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.sp,
color: Colors.black54,
height: 1.5,
),
),
),
SizedBox(height: 50.h),
//
Container(
margin: EdgeInsets.symmetric(horizontal: 30.w),
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12.w),
border: Border.all(
color: Colors.grey[200]!,
width: 1,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'重置锁步骤:'.tr,
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
SizedBox(height: 15.h),
_buildStepItem('1', '找到锁上的重置按钮或重置孔'.tr),
_buildStepItem('2', '使用重置工具(如针或牙签)长按重置按钮'.tr),
_buildStepItem('3', '听到"滴"声或看到指示灯闪烁'.tr),
_buildStepItem('4', '等待锁完成重置,指示灯常亮或熄灭'.tr),
],
),
),
SizedBox(height: 60.h),
//
Container(
margin: EdgeInsets.symmetric(horizontal: 40.w),
child: SubmitBtn(
btnName: '我已重置锁,继续添加'.tr,
borderRadius: 25.w,
onClick: () {
logic.confirmLockReset();
},
),
),
SizedBox(height: 20.h),
//
Container(
margin: EdgeInsets.symmetric(horizontal: 40.w),
child: TextButton(
onPressed: Get.back,
child: Text(
'取消'.tr,
style: TextStyle(
fontSize: 20.sp,
color: Colors.grey[600],
),
),
),
),
SizedBox(height: 40.h),
],
),
);
});
}
Widget _buildStepItem(String number, String text) {
return Padding(
padding: EdgeInsets.only(bottom: 12.h),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: AppColors.mainColor,
borderRadius: BorderRadius.circular(12.w),
),
child: Center(
child: Text(
number,
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w600,
),
),
),
),
SizedBox(width: 12.w),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: 16.sp,
color: Colors.black87,
height: 1.4,
),
),
),
],
),
);
}
}

View File

@ -0,0 +1,15 @@
import 'package:get/get.dart';
class LockResetConfirmState {
LockResetConfirmState() {
//
final Map? map = Get.arguments;
if (map is Map && map.isNotEmpty) {
if (map['getLockType'] != null) {
getLockType.value = map['getLockType'];
}
}
}
RxInt getLockType = 1.obs; //
}

View File

@ -1,4 +1,3 @@
import 'dart:io'; import 'dart:io';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -13,16 +12,25 @@ import 'selectLockType_state.dart';
class SelectLockTypeLogic extends BaseGetXController { class SelectLockTypeLogic extends BaseGetXController {
SelectLockTypeState state = SelectLockTypeState(); SelectLockTypeState state = SelectLockTypeState();
void getServerDatetime() async{ void getServerDatetime() async {
var entity = await ApiRepository.to.getServerDatetimeData(isUnShowLoading:true); var entity =
if(entity.errorCode!.codeIsSuccessful){ await ApiRepository.to.getServerDatetimeData(isUnShowLoading: true);
} if (entity.errorCode!.codeIsSuccessful) {}
}
//
void goToLockResetConfirm(int lockType) {
CommonDataManage().seletLockType = lockType;
Get.toNamed(Routers.lockResetConfirmPage, arguments: {
'getLockType': lockType,
});
} }
// //
Future<void> getNearByLimits() async { Future<void> getNearByLimits() async {
if (!Platform.isIOS) { if (!Platform.isIOS) {
final bool locationRequest = await PermissionDialog.request(Permission.location); final bool locationRequest =
await PermissionDialog.request(Permission.location);
final bool bluetoothRequest = await PermissionDialog.requestBluetooth(); final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
if (!bluetoothRequest || !locationRequest) { if (!bluetoothRequest || !locationRequest) {
return; return;
@ -35,7 +43,6 @@ class SelectLockTypeLogic extends BaseGetXController {
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
getServerDatetime(); getServerDatetime();
} }
@ -43,4 +50,4 @@ class SelectLockTypeLogic extends BaseGetXController {
void onClose() { void onClose() {
super.onClose(); super.onClose();
} }
} }

View File

@ -79,37 +79,25 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
List<Widget> getLockTypeList() { List<Widget> getLockTypeList() {
return <Widget>[ return <Widget>[
lockTypeItem('images/lockType/lockType_doorLock.png', '门锁'.tr, () { lockTypeItem('images/lockType/lockType_doorLock.png', '门锁'.tr, () {
CommonDataManage().seletLockType = 1; logic.goToLockResetConfirm(1);
Get.toNamed(Routers.addLockPage,
arguments: <String, int>{'getLockType': 1});
}), }),
// if (!F.isLite) // if (!F.isLite)
lockTypeItem('images/lockType/lockType_NFCLock.png', 'NFC无源锁'.tr, () { lockTypeItem('images/lockType/lockType_NFCLock.png', 'NFC无源锁'.tr, () {
CommonDataManage().seletLockType = 2; logic.goToLockResetConfirm(2);
// Navigator.pushNamed(context, Routers.addLockPage); }),
logic.getNearByLimits();
}),
// if (!F.isLite) // if (!F.isLite)
lockTypeItem('images/lockType/lockType_padlock.png', '挂锁'.tr, () { lockTypeItem('images/lockType/lockType_padlock.png', '挂锁'.tr, () {
CommonDataManage().seletLockType = 3; logic.goToLockResetConfirm(3);
// Navigator.pushNamed(context, Routers.addLockPage); }),
logic.getNearByLimits();
}),
lockTypeItem('images/lockType/lockType_safeLock.png', '保险箱锁'.tr, () { lockTypeItem('images/lockType/lockType_safeLock.png', '保险箱锁'.tr, () {
CommonDataManage().seletLockType = 4; logic.goToLockResetConfirm(4);
Navigator.pushNamed(context, Routers.addLockPage,
arguments: <String, int>{'getLockType': 4});
}), }),
lockTypeItem('images/lockType/lockType_parkingLock.png', '车位锁'.tr, () { lockTypeItem('images/lockType/lockType_parkingLock.png', '车位锁'.tr, () {
CommonDataManage().seletLockType = 5; logic.goToLockResetConfirm(5);
Navigator.pushNamed(context, Routers.addLockPage,
arguments: <String, int>{'getLockType': 5});
}), }),
lockTypeItem('images/lockType/lockType_entranceGuardLock.png', '智能门禁'.tr, lockTypeItem('images/lockType/lockType_entranceGuardLock.png', '智能门禁'.tr,
() { () {
CommonDataManage().seletLockType = 6; logic.goToLockResetConfirm(6);
Navigator.pushNamed(context, Routers.addLockPage,
arguments: <String, int>{'getLockType': 6});
}), }),
// lockTypeItem('images/lockType/lockType_bicycleLock.png', // lockTypeItem('images/lockType/lockType_bicycleLock.png',
@ -124,7 +112,6 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
// if (!F.isLite) // if (!F.isLite)
lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr, () { lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr, () {
CommonDataManage().seletLockType = 8; CommonDataManage().seletLockType = 8;
// Navigator.pushNamed(context, Routers.gatewayListPage);
logic.getNearByLimits(); logic.getNearByLimits();
}), }),
]; ];