添加开锁动画,修改添加锁地图功能,地址信息非必填

This commit is contained in:
魏少阳 2023-10-20 11:58:40 +08:00
parent 1136402428
commit 08e6815d4a
23 changed files with 703 additions and 172 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -98,6 +98,7 @@ import 'main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dar
import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart';
import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart'; import 'main/lockDetail/passwordKey/passwordKeyManage/passwordKeyManage_page.dart';
import 'main/lockMian/lockMain/lockMain_page.dart'; import 'main/lockMian/lockMain/lockMain_page.dart';
import 'mine/addLock/addLockSeletCountry/addLockSeletCountry_page.dart';
import 'mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart'; import 'mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart';
import 'mine/addLock/lockAddress/lockAddress/lockAddress_page.dart'; import 'mine/addLock/lockAddress/lockAddress/lockAddress_page.dart';
import 'mine/addLock/nearbyLock/nearbyLock_page.dart'; import 'mine/addLock/nearbyLock/nearbyLock_page.dart';
@ -335,6 +336,7 @@ abstract class Routers {
static const webviewShowPage = '/webviewShowPage'; // static const webviewShowPage = '/webviewShowPage'; //
static const demoModeLockDetailPage = '/DemoModeLockDetailPage'; // static const demoModeLockDetailPage = '/DemoModeLockDetailPage'; //
static const demoModeLockSetPage = '/DemoModeLockSetPage'; // static const demoModeLockSetPage = '/DemoModeLockSetPage'; //
static const addLockSeletCountryPage = '/AddLockSeletCountryPage'; //
} }
abstract class AppRouters { abstract class AppRouters {
@ -830,5 +832,6 @@ abstract class AppRouters {
GetPage(name: Routers.webviewShowPage, page: () => const WebviewShowPage()), GetPage(name: Routers.webviewShowPage, page: () => const WebviewShowPage()),
GetPage(name: Routers.demoModeLockSetPage, page: () => const DemoModeLockSetPage()), GetPage(name: Routers.demoModeLockSetPage, page: () => const DemoModeLockSetPage()),
GetPage(name: Routers.demoModeLockDetailPage, page: () => const DemoModeLockDetailPage()), GetPage(name: Routers.demoModeLockDetailPage, page: () => const DemoModeLockDetailPage()),
GetPage(name: Routers.addLockSeletCountryPage, page: () => const AddLockSeletCountryPage()),
]; ];
} }

View File

@ -72,7 +72,7 @@ class SenderAddFingerprintCommand extends SenderProtocol {
subData.add(fingerNo!); subData.add(fingerNo!);
// UseCountLimit // UseCountLimit
subData.add(0xff); subData.add(useCountLimit!);
// token // token
subData.addAll(token!); subData.addAll(token!);

View File

@ -73,7 +73,7 @@ class SenderAddICCardCommand extends SenderProtocol {
subData.add(cardNo!); subData.add(cardNo!);
// UseCountLimit // UseCountLimit
subData.add(0xff); subData.add(useCountLimit!);
// token // token
subData.addAll(token!); subData.addAll(token!);

View File

@ -21,8 +21,8 @@ import 'CheckingInInfoDataEntity.dart';
import 'lockSet_state.dart'; import 'lockSet_state.dart';
typedef BlockSetStateCallback = void Function(); typedef BlockSetStateCallback = void Function();
typedef BlockSetCheckInCallback = void Function( typedef BlockSetCheckInCallback = void Function(CheckingInInfoDataEntity checkingInInfoDataEntity);
CheckingInInfoDataEntity checkingInInfoDataEntity); typedef BlockDeletNumberCheckPasswordCallback = void Function();
class LockSetLogic extends BaseGetXController { class LockSetLogic extends BaseGetXController {
final LockSetState state = LockSetState(); final LockSetState state = LockSetState();
@ -231,15 +231,34 @@ class LockSetLogic extends BaseGetXController {
} }
// //
void checkLoginPassword() async { void checkLoginPassword(BlockDeletNumberCheckPasswordCallback blockDeletNumberCheckPasswordCallback) async {
var entity = await ApiRepository.to.checkLoginPassword( var entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text, password: state.passwordTF.text,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
if(state.getKeyInfosData.value.isLockOwner == 1){ blockDeletNumberCheckPasswordCallback();
factoryDataResetAction(); if(state.currentDeviceUUid.value.isEmpty){
}else{ Toast.show(msg: "未扫描到当前设备,请确保您在设备旁边、设备已开启、设备未被其他人连接");
deletKeyData(); return;
}
if(state.currentDeviceUUid.value[31] == "1"){
//
if(state.getKeyInfosData.value.isLockOwner == 1){
//
factoryDataResetAction();
}else{
//
deletUserAction();
}
}else if(state.currentDeviceUUid.value[31] == "0"){
//
if(state.getKeyInfosData.value.isLockOwner == 1){
//
deletLockInfoData();
}else{
//
deletKeyData();
}
} }
} }
} }
@ -296,13 +315,21 @@ class LockSetLogic extends BaseGetXController {
StreamSubscription? _passCurrentLockInformationEvent; StreamSubscription? _passCurrentLockInformationEvent;
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
// eventBus // eventBus
_passCurrentLockInformationEvent = _passCurrentLockInformationEvent = eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
state.getKeyInfosData.value = event.keyInfo; state.getKeyInfosData.value = event.keyInfo;
blockSetStateCallback(); blockSetStateCallback();
}); });
} }
// Uuid删除当前锁时 APP的时候扫描如果未被连接就传uuid过去
StreamSubscription? _scanAllDeviceFindCurrentDeviceConnectedEvent;
void initLoadDataScanAllDeviceFindCurrentDeviceAction() {
// eventBus
_scanAllDeviceFindCurrentDeviceConnectedEvent = eventBus.on<ScanAllDeviceFindCurrentDeviceConnectedEvent>().listen((event) {
state.currentDeviceUUid.value = event.uuid;
});
}
@override @override
void onReady() { void onReady() {
// TODO: implement onReady // TODO: implement onReady
@ -310,6 +337,7 @@ class LockSetLogic extends BaseGetXController {
print("onReady()"); print("onReady()");
_initReplySubscription(); _initReplySubscription();
initLoadDataScanAllDeviceFindCurrentDeviceAction();
} }
@override @override
@ -324,5 +352,6 @@ class LockSetLogic extends BaseGetXController {
// TODO: implement onClose // TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
_passCurrentLockInformationEvent!.cancel(); _passCurrentLockInformationEvent!.cancel();
_scanAllDeviceFindCurrentDeviceConnectedEvent!.cancel();
} }
} }

View File

@ -630,7 +630,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
Toast.show(msg: "请输入登录密码"); Toast.show(msg: "请输入登录密码");
return; return;
} }
logic.checkLoginPassword(); logic.checkLoginPassword((){
Navigator.pop(context);
});
}, },
cancelClick: () { cancelClick: () {
Navigator.pop(context); Navigator.pop(context);

View File

@ -8,6 +8,7 @@ class LockSetState {
final getKeyInfosData = KeyInfos().obs; final getKeyInfosData = KeyInfos().obs;
var isAttendance = 1.obs;// var isAttendance = 1.obs;//
var currentDeviceUUid = "".obs;// uuid
var isLockPickingReminder = 1.obs;// var isLockPickingReminder = 1.obs;//
var passwordTF = TextEditingController(); var passwordTF = TextEditingController();

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/blue/io_protocol/io_editUser.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart';
@ -23,6 +24,7 @@ import '../../../login/login/entity/LoginData.dart';
import '../../../login/login/entity/LoginEntity.dart'; import '../../../login/login/entity/LoginEntity.dart';
import '../../../network/api_repository.dart'; import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart'; import '../../../tools/baseGetXController.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart'; import '../../../tools/storage.dart';
import 'lockDetail_state.dart'; import 'lockDetail_state.dart';
@ -78,7 +80,10 @@ class LockDetailLogic extends BaseGetXController{
case 0x00: case 0x00:
// //
print("${reply.commandType}数据解析成功"); print("${reply.commandType}数据解析成功");
state.lockState.value = 2;
state.animationController.reset();
state.animationController.forward();
// state.animationController.isCompleted;
break; break;
case 0x06: case 0x06:
// //
@ -434,11 +439,33 @@ class LockDetailLogic extends BaseGetXController{
if (knownDeviceIndex >= 0) { if (knownDeviceIndex >= 0) {
BlueManage().connectDeviceMacAddress = v[knownDeviceIndex].id; BlueManage().connectDeviceMacAddress = v[knownDeviceIndex].id;
connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!); connectBlue(v[knownDeviceIndex].id, state.keyInfos.value.bluetooth!.bluetoothDeviceName!);
BlueManage().stopScan(); eventBus.fire(ScanAllDeviceFindCurrentDeviceConnectedEvent(v[knownDeviceIndex].serviceUuids[0].toString()));
// BlueManage().stopScan();
} }
}); });
} }
//
startConnect() {
state.lockState.value = 1;
state.animationController.forward();
openDoorAction();
Future.delayed(const Duration(seconds: 10), () {
if(state.lockState.value == 1){
stopConnect();
state.lockState.value = 4;
state.animationController.reset();
state.animationController.forward();
}
});
}
//
stopConnect() {
}
@override @override
void onReady() { void onReady() {
// TODO: implement onReady // TODO: implement onReady
@ -473,6 +500,7 @@ class LockDetailLogic extends BaseGetXController{
// factoryDataResetAction(); // factoryDataResetAction();
} }
@override @override
void onClose() { void onClose() {
// TODO: implement onClose // TODO: implement onClose

View File

@ -31,7 +31,7 @@ class LockDetailPage extends StatefulWidget {
State<LockDetailPage> createState() => _LockDetailPageState(); State<LockDetailPage> createState() => _LockDetailPageState();
} }
class _LockDetailPageState extends State<LockDetailPage> with RouteAware { class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin { // with RouteAware
final logic = Get.put(LockDetailLogic()); final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state; final state = Get.find<LockDetailLogic>().state;
@ -68,6 +68,8 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
// print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList"); // print("publicKeyData:$publicKeyData saveStrList:$saveStrList privateKeyData:$privateKeyData savePrivateKeyList:$savePrivateKeyList");
// logic.startScanAction(); // logic.startScanAction();
listeningAnimations();
} }
@override @override
@ -124,29 +126,31 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
child: Stack( child: Stack(
children: [ children: [
Center( Center(
child: GestureDetector( child:GestureDetector(
onTap: () { child: Obx(() => Stack(
// logic.transferPermissionsAction(); children: [
logic.openDoorAction(); Image.asset(
// logic.editLockUserAction(); state.lockState.value == 4
// logic.factoryDataResetAction(); ? 'images/main/icon_main_openLockBtn_grey.png'
}, : 'images/main/icon_main_openLockBtn_center.png',
child: Image.asset( width: 330.w,
'images/main/icon_main_openLockBtn.png', height: 330.w,
width: 330.w, ),
height: 330.w, (state.lockState.value == 1 || state.lockState.value == 3)
), ? buildRotationTransition()
)), : Positioned(
// Visibility( child: Image.asset(
// visible: 'images/main/icon_main_openLockBtn_circle.png',
// state.keyInfos.value.remoteEnable == 1 ? true : false, width: 330.w,
// child: Align( height: 330.w,
// alignment: const Alignment(0.6, 1), )),
// child: Image.asset( ],
// 'images/main/icon_main_remoteUnlocking.png', )),
// width: 50.w, onTap: () {
// height: 52.w, logic.startConnect();
// ))), },
)
),
], ],
), ),
), ),
@ -196,7 +200,7 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
width: 6.w, width: 6.w,
), ),
Text( Text(
'超级管理员', state.keyInfos.value.isLockOwner == 1 ? '超级管理员' : (state.keyInfos.value.keyRight == 1 ? "授权管理员" : "普通用户"),
style: TextStyle( style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor), fontSize: 20.sp, color: AppColors.darkGrayTextColor),
), ),
@ -219,7 +223,7 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
Text( Text(
'网关设备', '网关设备',
style: style:
TextStyle(fontSize: 20.sp, color: AppColors.btnDisableColor), TextStyle(fontSize: 20.sp, color: state.keyInfos.value.remoteEnable == 1 ? AppColors.mainColor : AppColors.btnDisableColor),
), ),
], ],
), ),
@ -236,6 +240,24 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
); );
} }
//
Widget buildRotationTransition() {
return Positioned(
child: RotationTransition(
//
alignment: Alignment.center,
//
turns: state.animationController,
//view
child: Image.asset(
'images/main/icon_main_openLockBtn_circle.png',
width: 330.w,
height: 330.w,
),
),
);
}
Widget bottomWidget() { Widget bottomWidget() {
return Container( return Container(
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 40.h), margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 40.h),
@ -345,7 +367,7 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
bottomItem( bottomItem(
'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, 'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr,
() { () {
BlueManage().stopScan(); // BlueManage().stopScan();
Get.toNamed(Routers.lockSetPage, arguments: widget.keyInfo); Get.toNamed(Routers.lockSetPage, arguments: widget.keyInfo);
}), }),
]; ];
@ -381,20 +403,37 @@ class _LockDetailPageState extends State<LockDetailPage> with RouteAware {
); );
} }
listeningAnimations(){
Future.delayed(Duration.zero, () {
state.animationController = AnimationController(
duration: const Duration(seconds: 30), vsync: this);
state.animationController.repeat();
//StatusListener
state.animationController.addStatusListener((status) {
print("AnimationStatus:$status");
if (status == AnimationStatus.completed) {
state.animationController.forward();
} else if (status == AnimationStatus.dismissed) {
state.animationController.forward();
}
});
});
}
@override @override
void didChangeDependencies() { void didChangeDependencies() {
// TODO: implement didChangeDependencies // TODO: implement didChangeDependencies
super.didChangeDependencies(); super.didChangeDependencies();
/// ///
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); // AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
} }
@override @override
void dispose() { void dispose() {
// TODO: implement dispose // TODO: implement dispose
/// ///
AppRouteObserver().routeObserver.unsubscribe(this); // AppRouteObserver().routeObserver.unsubscribe(this);
super.dispose(); super.dispose();
} }

View File

@ -1,10 +1,23 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../lockMian/entity/lockInfoEntity.dart'; import '../../lockMian/entity/lockInfoEntity.dart';
// enum RKConnectState {
// NULL,
// STOPPED, // 0
// CONNECTING, //1
// CONNECTED, //2
// CHECKING, // 3
// CONNECTFAIL, // 4
// }
class LockDetailState { class LockDetailState {
Rx<KeyInfos> keyInfos = KeyInfos().obs; Rx<KeyInfos> keyInfos = KeyInfos().obs;
//
late AnimationController animationController;
var lockState = 0.obs;// 0 1() 2 3 4
} }

View File

@ -208,7 +208,7 @@ class AddICCardLogic extends BaseGetXController{
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:await Storage.getUid(),
cardNo:1, cardNo:1,
useCountLimit:1, useCountLimit:0xff,
startTime:0x11223344, startTime:0x11223344,
endTime:0x11223344, endTime:0x11223344,
needAuthor:1, needAuthor:1,

View File

@ -2,6 +2,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/blue/io_type.dart';
import '../../../../blue/blue_manage.dart'; import '../../../../blue/blue_manage.dart';
@ -33,6 +34,11 @@ class OtherTypeKeyListLogic extends BaseGetXController{
_replyAddFingerprintBegin(reply); _replyAddFingerprintBegin(reply);
} }
// ()
if((reply is SenderAddICCardReply) && (state.isDeletICCardData.value == true)) {
_replyAddICCardBegin(reply);
}
if(reply is SenderQueryingFingerprintStatusReply) { if(reply is SenderQueryingFingerprintStatusReply) {
// //
_replyQueryingFingerprintStatus(reply); _replyQueryingFingerprintStatus(reply);
@ -48,12 +54,62 @@ class OtherTypeKeyListLogic extends BaseGetXController{
}); });
} }
Future<void> _replyAddICCardBegin(Reply reply) async {
int status = reply.data[2];
print("_replyAddFingerprintStatus:$status");
switch(status){
case 0x00:
//
print("${reply.commandType!.typeValue} 数据解析成功");
state.isDeletFingerprintData.value = false;
deletICCardData();
break;
case 0x06:
//
print("${reply.commandType!.typeValue} 需要鉴权");
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderAddICCardCommand(
keyID:"1",
userID:"DeleteAll!@#",
cardNo:255,
useCountLimit:0,
startTime:0x11223344,
endTime:0x11223344,
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
token: getTokenList,
);
break;
case 0x07:
//
print("${reply.commandType!.typeValue} 用户无权限");
break;
case 0x09:
//
print("${reply.commandType!.typeValue} 权限校验错误");
break;
default:
//
print("${reply.commandType!.typeValue} 失败");
break;
}
}
// //
Future<void> _replyAddFingerprintBegin(Reply reply) async { Future<void> _replyAddFingerprintBegin(Reply reply) async {
// var token = reply.data.sublist(2, 6);
// var saveStrList = changeIntListToStringList(token);
// print("_replyAddFingerprintReplyToken:$token");
// Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[2]; int status = reply.data[2];
print("status:$status"); print("status:$status");
@ -79,13 +135,11 @@ class OtherTypeKeyListLogic extends BaseGetXController{
IoSenderManage.senderAddFingerprintCommand( IoSenderManage.senderAddFingerprintCommand(
keyID:"1", keyID:"1",
userID:await Storage.getUid(), userID:"DeleteAll!@#",
fingerNo:1, fingerNo:255,
useCountLimit:0, useCountLimit:0,
startTime:0x11223344, startTime:0x11223344,
endTime:0x11223344, endTime:0x11223344,
// startTime:int.parse(state.startDate.value)~/1000,
// endTime:int.parse(state.endDate.value)~/1000,
needAuthor:1, needAuthor:1,
publicKey:publicKeyDataList, publicKey:publicKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,
@ -352,8 +406,36 @@ class OtherTypeKeyListLogic extends BaseGetXController{
useCountLimit:0, useCountLimit:0,
startTime:0x11223344, startTime:0x11223344,
endTime:0x11223344, endTime:0x11223344,
// startTime:int.parse(state.startDate.value)~/1000, needAuthor:1,
// endTime:int.parse(state.endDate.value)~/1000, publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
token: getTokenList,
);
}
});
}
//
Future<void> senderAddICCard() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected){
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
print("openDoorTokenPubToken:$getTokenList");
IoSenderManage.senderAddICCardCommand(
keyID:"1",
userID:"DeleteAll!@#",
cardNo:255,
useCountLimit:0,
startTime:0x11223344,
endTime:0x11223344,
needAuthor:1, needAuthor:1,
publicKey:publicKeyDataList, publicKey:publicKeyDataList,
privateKey:getPrivateKeyList, privateKey:getPrivateKeyList,

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
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';
@ -42,25 +43,7 @@ class _OtherTypeKeyListPageState extends State<OtherTypeKeyListPage> {
onPressed: () async { onPressed: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if(isDemoMode == false){ if(isDemoMode == false){
switch (state.fromType.value) { showDeletAlertDialog(context);
case 0:
//
state.isDeletICCardData.value = true;
logic.deletICCardData();
break;
case 1:
//
// logic.deletAllFingerprintsData();
state.isDeletFingerprintData.value = true;
logic.senderAddFingerprint();
break;
case 2:
//
break;
default:
break;
}
}else{ }else{
// Get.toNamed(Routers.seletLockTypePage); // Get.toNamed(Routers.seletLockTypePage);
Toast.show(msg: "演示模式"); Toast.show(msg: "演示模式");
@ -291,4 +274,51 @@ class _OtherTypeKeyListPageState extends State<OtherTypeKeyListPage> {
), ),
); );
} }
void showDeletAlertDialog(
BuildContext context,
) {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: const Text("提示"),
content: const Text('重置后信息都会清除哦,确认要重置吗?'),
actions: [
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
onPressed: () {
Navigator.pop(context);
},
),
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Navigator.pop(context);
switch (state.fromType.value) {
case 0:
//
state.isDeletICCardData.value = true;
logic.senderAddICCard();
break;
case 1:
//
// logic.deletAllFingerprintsData();
state.isDeletFingerprintData.value = true;
logic.senderAddFingerprint();
break;
case 2:
//
break;
default:
break;
}
},
),
],
);
},
);
}
} }

View File

@ -1,6 +1,8 @@
import 'package:star_lock/mine/addLock/addLock/addLock_state.dart'; import 'package:star_lock/mine/addLock/addLock/addLock_state.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../blue/blue_manage.dart';
class AddLockLogic extends BaseGetXController { class AddLockLogic extends BaseGetXController {
final AddLockState state = AddLockState(); final AddLockState state = AddLockState();
@ -8,6 +10,8 @@ class AddLockLogic extends BaseGetXController {
void onReady() { void onReady() {
// TODO: implement onReady // TODO: implement onReady
super.onReady(); super.onReady();
BlueManage().stopScan();
} }
@override @override

View File

@ -0,0 +1,8 @@
import '../../../tools/baseGetXController.dart';
import 'addLockSeletCountry_state.dart';
class AddLockSeletCountryLogic extends BaseGetXController {
AddLockSeletCountryState state = AddLockSeletCountryState();
}

View File

@ -0,0 +1,182 @@
import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../login/seletCountryRegion/common/countryRegionEntity.dart';
import '../../../login/seletCountryRegion/common/utils.dart';
import '../../../network/api_repository.dart';
import '../../../tools/commonItem.dart';
import '../../../tools/titleAppBar.dart';
import '../../../translations/trans_lib.dart';
import 'addLockSeletCountry_logic.dart';
class AddLockSeletCountryPage extends StatefulWidget {
const AddLockSeletCountryPage({Key? key}) : super(key: key);
@override
State<AddLockSeletCountryPage> createState() => _AddLockSeletCountryPageState();
}
class _AddLockSeletCountryPageState extends State<AddLockSeletCountryPage> {
final logic = Get.put(AddLockSeletCountryLogic());
final state = Get.find<AddLockSeletCountryLogic>().state;
List<CountryRegionModel> countriesList = [];
int seletindex = 10000;
@override
void initState() {
super.initState();
SuspensionUtil.setShowSuspensionStatus(
countriesList.cast<ISuspensionBean>());
Future.delayed(const Duration(milliseconds: 20), () {
getCountriesListRequest();
});
}
///json文件
Future<void> getCountriesListRequest() async {
CountryRegionEntity entity = await ApiRepository.to.getCountryRegion('1');
countriesList.clear();
if (entity.errorCode!.codeIsSuccessful) {
countriesList.addAll(entity.dataList!);
_handleList(countriesList);
}
}
Future<String> loadJsonFromAssets(String assetsPath) async {
return await rootBundle.loadString(assetsPath);
}
void _handleList(List<CountryRegionModel> list) {
if (list.isEmpty) return;
for (int i = 0, length = list.length; i < length; i++) {
CountryRegionModel countryModel = list[i];
String tag = countryModel.group!;
if (RegExp('[A-Z]').hasMatch(tag)) {
list[i].tagIndex = tag;
} else {
list[i].tagIndex = '#';
}
}
// A-Z sort.
SuspensionUtil.sortListBySuspensionTag(list);
// show sus tag.
SuspensionUtil.setShowSuspensionStatus(countriesList);
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFFFFFFF),
appBar: TitleAppBar(
barTitle:
"请选择您的位置",
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Column(
children: [
Expanded(
child: ListView.builder(
itemCount: countriesList.length,
itemBuilder: (c, index) {
CountryRegionModel model = countriesList[index];
return CommonItem(
leftTitel: model.name,
rightTitle: "",
allHeight: 60.h,
isHaveLine: true,
isHaveRightWidget: true,
action: (){
setState(() {
seletindex = index;
});
},
rightWidget: Row(
children: [
Image.asset((seletindex == index) ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w,),
],
)
);
}
),
),
Container(
margin: EdgeInsets.only(top: 30.h, bottom: 30.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton(
child: Text(
"跳过",
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
Get.toNamed(Routers.saveLockPage, arguments: {
"addressInfo": {},
"pwdTimestamp": state.pwdTimestamp.value,
});
},
),
TextButton(
child: Text(
TranslationLoader.lanKeys!.next!.tr,
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
if(seletindex == 10000){
Toast.show(msg: "请选择国家");
return;
}
CountryRegionModel model = countriesList[seletindex];
Get.toNamed(Routers.saveLockPage, arguments: {
"addressInfo": {"country":model.name},
"pwdTimestamp": state.pwdTimestamp.value,
});
// Navigator.pushNamed(context, Routers.saveLockPage);
},
),
],
),
)
],
),
// body: AzListView(
// data: countriesList,
// itemCount: countriesList.length,
// itemBuilder: (BuildContext context, int index) {
// CountryRegionModel model = countriesList[index];
// model.code = " ";
// return Utils.getListItem(context, model, () {
// Map<String, dynamic> resultMap = {};
// resultMap['code'] = model.code;
// resultMap['countryId'] = model.countryId.toString();
// resultMap['countryName'] = model.name;
// Navigator.pop(context, resultMap);
// });
// },
// padding: EdgeInsets.zero,
// susItemBuilder: (BuildContext context, int index) {
// CountryRegionModel model = countriesList[index];
// String tag = model.getSuspensionTag();
// return Utils.getSusItem(context, tag);
// },
// // indexBarData: const ['', ...kIndexBarData],
// ),
);
}
}

View File

@ -0,0 +1,11 @@
import 'package:get/get.dart';
class AddLockSeletCountryState{
var pwdTimestamp= 0.obs;
AddLockSeletCountryState() {
Map map = Get.arguments;
pwdTimestamp.value = map["pwdTimestamp"];
}
}

View File

@ -99,111 +99,199 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: AppColors.mainBackgroundColor, backgroundColor: Colors.white,
appBar: TitleAppBar( appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.lockAddress!.tr, barTitle: TranslationLoader.lanKeys!.lockAddress!.tr,
haveBack: true, haveBack: true,
backgroundColor: AppColors.mainColor, backgroundColor: AppColors.mainColor,
actionsList: [ // actionsList: [
TextButton( // TextButton(
child: Text( // child: Text(
TranslationLoader.lanKeys!.next!.tr, // TranslationLoader.lanKeys!.next!.tr,
style: TextStyle(color: Colors.white, fontSize: 24.sp), // style: TextStyle(color: Colors.white, fontSize: 24.sp),
), // ),
onPressed: () { // onPressed: () {
if(addressInfo!.isEmpty){ // if(addressInfo!.isEmpty){
Toast.show(msg:"还未获取到位置信息哦,请耐心等待一下!"); // Toast.show(msg:"还未获取到位置信息哦,请耐心等待一下!");
return; // return;
} // }
Get.toNamed(Routers.saveLockPage, arguments: { // Get.toNamed(Routers.saveLockPage, arguments: {
"addressInfo": addressInfo, // "addressInfo": addressInfo,
"pwdTimestamp": state.pwdTimestamp.value, // "pwdTimestamp": state.pwdTimestamp.value,
}); // });
// Navigator.pushNamed(context, Routers.saveLockPage); // // Navigator.pushNamed(context, Routers.saveLockPage);
}, // },
), // ),
], // ],
), ),
body: body:
addressInfo != null ? addressInfo != null ?
Container( ListView(
width: 1.sw, children: [
// height: 1.sh, Container(
child: Stack( margin: EdgeInsets.only(left: 25.w, top: 40.h, bottom: 40.w),
children: [ child: Row(
SizedBox( mainAxisAlignment: MainAxisAlignment.start,
// height: 1.sh - 40.h, children: [
// width: 1.sw, Text("地理位置", style: TextStyle(fontSize: 50.sp)),
child: ],
(addressInfo!["address"].toString().isNotEmpty) ?
AMapWidget(
apiKey: amapApiKeys,
//
initialCameraPosition: (
CameraPosition(
target: LatLng(double.parse(addressInfo!['latitude'].toString()), double.parse(addressInfo!['longitude'].toString())),
zoom: 10.0,
)
),
//
myLocationStyleOptions: MyLocationStyleOptions(
true,
),
// normal,satellite,night, navi,bus,
mapType: MapType.normal,
//
minMaxZoomPreference: const MinMaxZoomPreference(3, 20),
//
privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true),
// AMapController
onMapCreated: (AMapController controller) {
mapController = controller;
},
)
: Container(),
), ),
Positioned( ),
left: 20.w, right: 20.w, bottom: 100.h, SizedBox(
child: Container( height: 1.sw/5*4,
// height: h(106), width: 1.sw,
decoration: BoxDecoration( child:
color: AppColors.mainColor, (addressInfo!["address"].toString().isNotEmpty) ?
borderRadius: BorderRadius.circular(15.w), AMapWidget(
), apiKey: amapApiKeys,
child:Column( //
children: [ initialCameraPosition: (
Container( CameraPosition(
// height: h(53), target: LatLng(double.parse(addressInfo!['latitude'].toString()), double.parse(addressInfo!['longitude'].toString())),
padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w), zoom: 10.0,
child: Row(
children: [
Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
SizedBox(width: 10.w),
Expanded(
child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
),
],
),
),
// Container(height: 1.h, color: const Color(0xFF021732),),
// Container(
// // height: h(52),
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
// child: Row(
// children: [
// Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
// SizedBox(width: 10.w,),
// Expanded(
// child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
// ),
// ],
// ),
// ),
],
) )
),), ),
], //
), myLocationStyleOptions: MyLocationStyleOptions(
true,
),
// normal,satellite,night, navi,bus,
mapType: MapType.normal,
//
minMaxZoomPreference: const MinMaxZoomPreference(3, 20),
//
privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true),
// AMapController
onMapCreated: (AMapController controller) {
mapController = controller;
},
) : Container(),
),
Container(
margin: EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text("检查以确保以下地址是正确的", style: TextStyle(fontSize: 24.sp)),
],
),
),
// SizedBox(height: 20.h),
Container(
margin: EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w),
// decoration: BoxDecoration(
// color: AppColors.mainColor,
// borderRadius: BorderRadius.circular(15.w),
// ),
child:Column(
children: [
Container(
// height: h(53),
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
child: Row(
children: [
// Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
// SizedBox(width: 10.w),
Expanded(
child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.grey, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
),
],
),
),
SizedBox(height: 5.h),
Container(height: 1.h, color: AppColors.mainColor,),
// Container(
// // height: h(52),
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
// child: Row(
// children: [
// Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
// SizedBox(width: 10.w,),
// Expanded(
// child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
// ),
// ],
// ),
// ),
],
)
),
SizedBox(height:200.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextButton(
child: Text(
"跳过",
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
Get.toNamed(Routers.addLockSeletCountryPage, arguments: {
"addressInfo": {},
"pwdTimestamp": state.pwdTimestamp.value,
});
},
),
TextButton(
child: Text(
TranslationLoader.lanKeys!.next!.tr,
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
if(addressInfo!.isEmpty){
Toast.show(msg:"还未获取到位置信息哦,请耐心等待一下!");
return;
}
Get.toNamed(Routers.saveLockPage, arguments: {
"addressInfo": addressInfo,
"pwdTimestamp": state.pwdTimestamp.value,
});
// Navigator.pushNamed(context, Routers.saveLockPage);
},
),
],
)
// Positioned(
// left: 20.w, right: 20.w, bottom: 100.h,
// child: Container(
// // height: h(106),
// decoration: BoxDecoration(
// color: AppColors.mainColor,
// borderRadius: BorderRadius.circular(15.w),
// ),
// child:Column(
// children: [
// Container(
// // height: h(53),
// padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
// child: Row(
// children: [
// Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w),
// SizedBox(width: 10.w),
// Expanded(
// child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip))
// ),
// ],
// ),
// ),
// // Container(height: 1.h, color: const Color(0xFF021732),),
// // Container(
// // // height: h(52),
// // padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w),
// // child: Row(
// // children: [
// // Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w),
// // SizedBox(width: 10.w,),
// // Expanded(
// // child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),)
// // ),
// // ],
// // ),
// // ),
// ],
// )
// ),),
],
) )
: const Center(child: Text('地图加载中,请稍候。。。')), : const Center(child: Text('地图加载中,请稍候。。。')),
); );

View File

@ -29,7 +29,10 @@ class NearbyLockLogic extends BaseGetXController{
// //
void connect(String lockId, String deviceName){ void connect(String lockId, String deviceName){
// BlueManage().stopScan(); // BlueManage().stopScan();
BlueManage().connect(lockId, deviceName, isFrist: true, isShowLoading: true); BlueManage().judgeReconnect(lockId, deviceName, (DeviceConnectionState state) async {
IoSenderManage.getPublicKey(lockId: deviceName);
}, isShowLoading: true);
// BlueManage().connect(lockId, deviceName, isFrist: true, isShowLoading: true);
} }
// //
@ -157,7 +160,7 @@ class NearbyLockLogic extends BaseGetXController{
// TODO: implement onClose // TODO: implement onClose
super.onClose(); super.onClose();
_replySubscription.cancel(); _replySubscription.cancel();
BlueManage().stopScan(); // BlueManage().stopScan();
} }
} }

View File

@ -95,7 +95,7 @@ class _NearbyLockPageState extends State<NearbyLockPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// 333400 01 // 323300 01
Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)), Text(discoveredDevice.name, style: TextStyle(fontSize: 20.sp, color: ((discoveredDevice.serviceUuids.isNotEmpty ? discoveredDevice.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)),
], ],
), ),

View File

@ -1,5 +1,6 @@
import 'package:event_bus/event_bus.dart'; import 'package:event_bus/event_bus.dart';
import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart';
import 'package:uuid/uuid.dart';
/// EventBus /// EventBus
EventBus eventBus = EventBus(); EventBus eventBus = EventBus();
@ -30,3 +31,10 @@ class ChickInAddStaffCardAndFingerprintBlockNumberEvent{
String number; String number;
ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number); ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number);
} }
/// Uuid删除当前锁时 APP的时候扫描如果未被连接就传uuid过去
class ScanAllDeviceFindCurrentDeviceConnectedEvent{
String uuid;
ScanAllDeviceFindCurrentDeviceConnectedEvent(this.uuid);
}