Merge branch 'release' of gitee.com:starlock-cn/app-starlock into release

This commit is contained in:
Daisy 2024-05-22 17:49:40 +08:00
commit 204cd370d8
13 changed files with 455 additions and 377 deletions

View File

@ -5,7 +5,11 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart'; import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart';
import 'package:star_lock/tools/NativeInteractionTool.dart';
import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart';
@ -26,18 +30,21 @@ import 'authorizedAdmin_state.dart';
class AuthorizedAdminLogic extends BaseGetXController { class AuthorizedAdminLogic extends BaseGetXController {
final AuthorizedAdminState state = AuthorizedAdminState(); final AuthorizedAdminState state = AuthorizedAdminState();
int? keyId;
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async { EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if (reply is TransferPermissionsReply) { if (reply is TransferPermissionsReply) {
var token = reply.data.sublist(2, 6); final List<int> token = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6]; final int status = reply.data[6];
switch (status) { switch (status) {
case 0x00: case 0x00:
@ -45,20 +52,24 @@ class AuthorizedAdminLogic extends BaseGetXController {
break; break;
case 0x06: case 0x06:
// //
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
List<int> getPrivateKeyList = await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!); changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList =
changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token =
List<int> getTokenList = changeStringListToIntList(token!); await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: "1", keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: publicKeyDataList, publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
@ -76,21 +87,25 @@ class AuthorizedAdminLogic extends BaseGetXController {
BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey =
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); await Storage.getStringList(saveBluePrivateKey);
final List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey); final List<String>? publicKey =
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList =
changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderTransferPermissions( IoSenderManage.senderTransferPermissions(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
authUserID: await Storage.getUid(), authUserID: await Storage.getUid(),
keyID: "1", keyID: '1',
oldUserID: await Storage.getUid(), oldUserID: await Storage.getUid(),
newUserID: "100002", newUserID: '100002',
needAuthor: 1, needAuthor: 1,
publicKey: publicKeyDataList, publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, privateKey: getPrivateKeyList,
@ -102,40 +117,40 @@ class AuthorizedAdminLogic extends BaseGetXController {
// //
Future<void> sendElectronicKeyRequest() async { Future<void> sendElectronicKeyRequest() async {
if (state.emailOrPhoneController.text.isEmpty) { if (state.emailOrPhoneController.text.isEmpty) {
showToast("请输入接收者账号"); showToast('请输入接收者账号');
return; return;
} }
if (state.keyNameController.text.isEmpty) { if (state.keyNameController.text.isEmpty) {
showToast("请输入接收者姓名"); showToast('请输入接收者姓名');
return; return;
} }
var startDate = "0"; String startDate = '0';
var endDate = "0"; String endDate = '0';
var startTime = "0"; String startTime = '0';
var endTime = "0"; String endTime = '0';
AppLog.log("state.type.value:${state.seletType.value}"); AppLog.log('state.type.value:${state.seletType.value}');
String getKeyType = "1"; String getKeyType = '1';
if (state.seletType.value == 0) { if (state.seletType.value == 0) {
getKeyType = "2"; getKeyType = '2';
startDate = startDate =
DateTool().dateToTimestamp(state.beginDate.value, 1).toString(); DateTool().dateToTimestamp(state.beginDate.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString(); endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString();
startTime = "0"; startTime = '0';
endTime = "0"; endTime = '0';
if (startDate.isEmpty) { if (startDate.isEmpty) {
showToast("请选择开始时间"); showToast('请选择开始时间');
return; return;
} }
if (endDate.isEmpty) { if (endDate.isEmpty) {
showToast("请选择结束时间"); showToast('请选择结束时间');
return; return;
} }
if (int.parse(startDate) >= int.parse(endDate)) { if (int.parse(startDate) >= int.parse(endDate)) {
showToast("失效时间要大于生效时间"); showToast('失效时间要大于生效时间');
return; return;
} }
} }
@ -143,12 +158,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
// //
if (state.isAuthentication.value == true) { if (state.isAuthentication.value == true) {
if (state.realNameController.text.isEmpty) { if (state.realNameController.text.isEmpty) {
showToast("请输入真实姓名".tr); showToast('请输入真实姓名'.tr);
return; return;
} }
if (state.idCardController.text.isEmpty) { if (state.idCardController.text.isEmpty) {
showToast("请输入身份证号".tr); showToast('请输入身份证号'.tr);
return; return;
} }
// //
@ -179,38 +194,39 @@ class AuthorizedAdminLogic extends BaseGetXController {
required String startDate, required String startDate,
required String startTime, required String startTime,
required String endTime}) async { required String endTime}) async {
var entity = await ApiRepository.to.sendElectronicKey( final AuthorizedAdminSendEntity entity = await ApiRepository.to
createUser: state.isCreateUser.value ? "1" : "0", .sendElectronicKey(
countryCode: state.countryCode.value, createUser: state.isCreateUser.value ? '1' : '0',
usernameType: '1', countryCode: state.countryCode.value,
endDate: int.parse(endDate), usernameType: '1',
faceAuthentication: state.isAuthentication.value == true ? '1' : '2', endDate: int.parse(endDate),
isCameraEnable: '2', faceAuthentication:
isRemoteUnlock: '2', state.isAuthentication.value == true ? '1' : '2',
keyNameForAdmin: state.keyNameController.text, isCameraEnable: '2',
keyRight: '1', isRemoteUnlock: '2',
keyType: getKeyType, keyNameForAdmin: state.keyNameController.text,
lockId: CommonDataManage().currentKeyInfo.lockId!.toString(), keyRight: '1',
operatorUid: '', keyType: getKeyType,
receiverUsername: state.emailOrPhoneController.text, lockId: CommonDataManage().currentKeyInfo.lockId!.toString(),
remarks: '', operatorUid: '',
startDate: int.parse(startDate), receiverUsername: state.emailOrPhoneController.text,
weekDays: state.weekdaysList, remarks: '',
startTime: int.parse(startTime), startDate: int.parse(startDate),
endTime: int.parse(endTime), weekDays: state.weekdaysList,
isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0, startTime: int.parse(startTime),
realName: state.isRequireAuth.value == true endTime: int.parse(endTime),
? state.realNameController.text isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0,
: "", realName: state.isRequireAuth.value == true
idCardNumber: state.isRequireAuth.value == true ? state.realNameController.text
? state.idCardController.text : '',
: ""); idCardNumber: state.isRequireAuth.value == true
? state.idCardController.text
: '');
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.isCreateUser.value = false; state.isCreateUser.value = false;
state.isSendSuccess.value = true; state.isSendSuccess.value = true;
// Toast.show(msg: "添加成功");
state.addUserId.value = entity.data!.receiverUser!.id.toString(); state.addUserId.value = entity.data!.receiverUser!.id.toString();
// addUserConnectBlue(state.addUserId.value); keyId = entity.data!.keyId;
eventBus.fire(AuthorizedAdminPageRefreshUI()); eventBus.fire(AuthorizedAdminPageRefreshUI());
} else { } else {
if (entity.errorCode == 425) { if (entity.errorCode == 425) {
@ -218,16 +234,15 @@ class AuthorizedAdminLogic extends BaseGetXController {
state.isCreateUser.value = true; state.isCreateUser.value = true;
ShowTipView().showIosTipWithContentDialog( ShowTipView().showIosTipWithContentDialog(
'${"是否发送授权管理员给未注册账号".tr}\n${state.emailOrPhoneController.text}', '${"是否发送授权管理员给未注册账号".tr}\n${state.emailOrPhoneController.text}',
() { sendElectronicKeyRequest);
sendElectronicKeyRequest();
});
} }
} }
} }
// //
Future<void> keyCheckFace() async { Future<void> keyCheckFace() async {
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( final AdvancedFunctionRecordEntity entity =
await ApiRepository.to.keyCheckFace(
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
@ -240,7 +255,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
titleStr: '实名认证为付费功能,请购买后再使用'.tr, titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () { sureClick: () {
Get.toNamed(Routers.advancedFeaturesWebPage, Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: {'isShop': false}); arguments: <String, bool>{'isShop': false});
}); });
} else if (entity.errorCode == 433) { } else if (entity.errorCode == 433) {
// //
@ -250,12 +265,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
// isOn:: 1 2 // isOn:: 1 2
Future<void> updateRoomCheckIn() async { Future<void> updateRoomCheckIn() async {
var entity = await ApiRepository.to.setRoomStatusData( final LoginEntity entity = await ApiRepository.to.setRoomStatusData(
lockId: CommonDataManage().currentKeyInfo.lockId!, lockId: CommonDataManage().currentKeyInfo.lockId!,
roomStatus: 1, roomStatus: 1,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
showToast("标记成功"); showToast('标记成功');
} }
} }
@ -279,6 +294,31 @@ class AuthorizedAdminLogic extends BaseGetXController {
return currentController; return currentController;
} }
//
Future<void> sendMsg({required bool isPhone}) async {
if (keyId == null) {
return;
}
final NoticeTemplateEntity entity = await ApiRepository.to
.getNoticeTemplate(
lockId: CommonDataManage().currentKeyInfo.lockId!,
keyId: keyId!,
channelType: isPhone ? 1 : 2);
if (entity.errorCode!.codeIsSuccessful) {
final List<Item?> list =
entity.data!.list!.where((Item item) => item.isUse == 0).toList();
if (list.isNotEmpty) {
final Item item = list.first!;
final String template = item.template ?? '';
NativeInteractionTool().loadNativeShare(shareText: template);
} else {
showToast('获取模板失败 0x02');
}
} else {
showToast('获取模板失败 0x01');
}
}
@override @override
void onReady() { void onReady() {
// TODO: implement onReady // TODO: implement onReady

View File

@ -362,8 +362,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
if (state.emailOrPhoneController.text.contains('@')) { if (state.emailOrPhoneController.text.contains('@')) {
Get.toNamed(Routers.sendEmailNotificationPage); Get.toNamed(Routers.sendEmailNotificationPage);
} else { } else {
NativeInteractionTool() logic.sendMsg(isPhone: true);
.loadNativeShare(shareText: state.pwdShareStr);
} }
}, },
), ),
@ -373,8 +372,8 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
OutLineBtn( OutLineBtn(
btnName: '微信通知', btnName: '微信通知',
onClick: () { onClick: () {
NativeInteractionTool() logic.sendMsg(
.loadNativeShare(shareText: state.pwdShareStr); isPhone: state.emailOrPhoneController.text.contains('@'));
}, },
), ),
SizedBox( SizedBox(

View File

@ -15,25 +15,25 @@ class AuthorizedAdminState {
final FlutterContactPicker contactPicker = FlutterContactPicker(); final FlutterContactPicker contactPicker = FlutterContactPicker();
late Contact contact; late Contact contact;
var isAuthentication = false.obs; // RxBool isAuthentication = false.obs; //
final onlyManageYouCreatesUser = false.obs; // final RxBool onlyManageYouCreatesUser = false.obs; //
var beginDate = DateTool() RxString beginDate = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; // .obs; //
var endDate = DateTool() RxString endDate = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()) .dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; // .obs; //
var isSendSuccess = false.obs; RxBool isSendSuccess = false.obs;
var countryName = '中国'.obs; RxString countryName = '中国'.obs;
var countryCode = '86'.obs; RxString countryCode = '86'.obs;
var weekdaysList = [].obs; RxList weekdaysList = [].obs;
var isCreateUser = false.obs; //1 0 RxBool isCreateUser = false.obs; //1 0
var seletType = 0.obs; RxInt seletType = 0.obs;
String pwdShareStr = '您好,您的授权管理员生成成功'; String pwdShareStr = '您好,您的授权管理员生成成功';
var addUserId = ''.obs; RxString addUserId = ''.obs;
var isRequireAuth = false.obs; // RxBool isRequireAuth = false.obs; //
} }

View File

@ -2,7 +2,7 @@ import 'dart:ffi';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';

View File

@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/baseGetXController.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
@ -23,26 +22,44 @@ import '../../../translations/trans_lib.dart';
import '../entity/lockListInfo_entity.dart'; import '../entity/lockListInfo_entity.dart';
import 'lockList_state.dart'; import 'lockList_state.dart';
class LockListLogic extends BaseGetXController{ class LockListLogic extends BaseGetXController {
LockListLogic(this.entity){
}
LockListState state = LockListState(); LockListState state = LockListState();
List<GroupList> groupDataList = <GroupList>[];
LockListInfoGroupEntity? entity;
//
void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) {
this.entity = entity;
if (entity.pageNo == 1) {
groupDataList = <GroupList>[];
}
groupDataList.addAll(entity.groupList!);
update();
}
// //
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { _replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
// //
if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) { if ((reply is FactoryDataResetReply) &&
(state.ifCurrentScreen.value == true)) {
_replyFactoryDataResetKey(reply); _replyFactoryDataResetKey(reply);
} }
}); });
} }
Future<void> _replyFactoryDataResetKey(Reply reply) async { Future<void> _replyFactoryDataResetKey(Reply reply) async {
var token = reply.data.sublist(2, 6); final List<int> token = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(token); final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList); Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6]; final int status = reply.data[6];
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
@ -52,22 +69,24 @@ class LockListLogic extends BaseGetXController{
break; break;
case 0x06: case 0x06:
// //
var token = await Storage.getStringList(saveBlueToken); final List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: "1", keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(), publicKey:
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(), state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey:
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: getTokenList); token: getTokenList);
break; break;
case 0x07: case 0x07:
// //
dismissEasyLoading(); dismissEasyLoading();
showToast("用户无权限"); showToast('用户无权限');
break; break;
case 0x09: case 0x09:
// //
@ -82,62 +101,63 @@ class LockListLogic extends BaseGetXController{
} }
} }
String showElectricIcon (int electricnumber){ String showElectricIcon(int electricnumber) {
if(electricnumber >= 100){ if (electricnumber >= 100) {
return 'images/main/icon_lockElectricLevel_5.png'; return 'images/main/icon_lockElectricLevel_5.png';
}else if((electricnumber > 50) && (electricnumber < 100)){ } else if ((electricnumber > 50) && (electricnumber < 100)) {
return 'images/main/icon_lockElectricLevel_4.png'; return 'images/main/icon_lockElectricLevel_4.png';
}else if((electricnumber > 25) && (electricnumber <= 50)){ } else if ((electricnumber > 25) && (electricnumber <= 50)) {
return 'images/main/icon_lockElectricLevel_3.png'; return 'images/main/icon_lockElectricLevel_3.png';
}else if((electricnumber > 5) && (electricnumber <= 25)){ } else if ((electricnumber > 5) && (electricnumber <= 25)) {
return 'images/main/icon_lockElectricLevel_2.png'; return 'images/main/icon_lockElectricLevel_2.png';
}else if(electricnumber <= 5){ } else if (electricnumber <= 5) {
return 'images/main/icon_lockElectricLevel_1.png'; return 'images/main/icon_lockElectricLevel_1.png';
} }
return 'images/main/icon_lockElectricLevel_5.png'; return 'images/main/icon_lockElectricLevel_5.png';
} }
String getKeyEffective(LockListInfoItemEntity keyInfo){ String getKeyEffective(LockListInfoItemEntity keyInfo) {
// //
if(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop){ if (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) {
// 使 // 使
if(keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) { if (keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse ||
keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) {
return "${"".tr}${DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!)}${"".tr}"; return "${"".tr}${DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!)}${"".tr}";
} else { } else {
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!); return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
} }
} }
return ""; return '';
} }
/// ///
deleyLockLogicOfRoles(){ void deleyLockLogicOfRoles() {
if (state.lockListInfoItemEntity.isLockOwner == 1) { if (state.lockListInfoItemEntity.isLockOwner == 1) {
// //
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){ ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr,
() {
// //
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){ ShowTipView().showTFViewAlertDialog(
checkLoginPassword(); state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
});
}); });
} else if (state.lockListInfoItemEntity.keyRight == 1){ } else if (state.lockListInfoItemEntity.keyRight == 1) {
// //
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){ ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
// //
state.deleteAdministratorIsHaveAllData.value = a; state.deleteAdministratorIsHaveAllData.value = a;
deletKeyData(); deletKeyData();
}); });
} else{ } else {
// //
ShowTipView().showIosTipWithContentDialog("是否删除钥匙?".tr, (){ ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, deletKeyData);
deletKeyData();
});
} }
} }
// //
void checkLoginPassword() async { Future<void> checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword( final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text, password: state.passwordTF.text,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
@ -147,12 +167,12 @@ class LockListLogic extends BaseGetXController{
} }
// //
void deletLockInfoData() async { Future<void> deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData( final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockListInfoItemEntity.lockId!, lockId: state.lockListInfoItemEntity.lockId!,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ""; BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
}); });
@ -160,14 +180,14 @@ class LockListLogic extends BaseGetXController{
} }
// //
void deletKeyData() async { Future<void> deletKeyData() async {
var entity = await ApiRepository.to.deletOwnerKeyData( final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.lockListInfoItemEntity.lockId.toString(), lockId: state.lockListInfoItemEntity.lockId.toString(),
keyId: state.lockListInfoItemEntity.keyId.toString(), keyId: state.lockListInfoItemEntity.keyId.toString(),
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0 includeUnderlings:
); state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ""; BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
}); });
@ -177,62 +197,74 @@ class LockListLogic extends BaseGetXController{
// //
Future<void> factoryDataResetAction() async { Future<void> factoryDataResetAction() async {
showEasyLoading(); showEasyLoading();
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){ showBlueConnetctToastTimer(
dismissEasyLoading(); isShowBlueConnetctToast: false,
showDeletAlertTipDialog(); action: () {
}); dismissEasyLoading();
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { showDeletAlertTipDialog();
});
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(); final List<int> publicKeyData =
var saveStrList = changeIntListToStringList(publicKeyData); state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
final List<String> saveStrList =
changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList); Storage.setStringList(saveBluePublicKey, saveStrList);
// //
List<int> privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(); final List<int> privateKeyData =
var savePrivateKeyList = changeIntListToStringList(privateKeyData); state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
final List<String> savePrivateKeyList =
changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey // signKey
List<int> signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>(); final List<int> signKeyData =
var saveSignKeyList = changeIntListToStringList(signKeyData); state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
final List<String> saveSignKeyList =
changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList); Storage.setStringList(saveBlueSignKey, saveSignKeyList);
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); final List<String> saveTokenList =
changeIntListToStringList(<int>[0, 0, 0, 0]);
Storage.setStringList(saveBlueToken, saveTokenList); Storage.setStringList(saveBlueToken, saveTokenList);
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: "1", keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(), publicKey:
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(), state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
token: [0,0,0,0]); privateKey:
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: <int>[0, 0, 0, 0]);
} else if (connectionState == BluetoothConnectionState.disconnected) { } else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){ if (state.ifCurrentScreen.value == true) {
showDeletAlertTipDialog(); showDeletAlertTipDialog();
} }
} }
}); });
} }
void showDeletAlertTipDialog({String? showContent = ""}) { void showDeletAlertTipDialog({String? showContent = ''}) {
// bool isContains = BlueManage().connectDeviceName!.contains("T9A"); // bool isContains = BlueManage().connectDeviceName!.contains("T9A");
var content = showContent!.isEmpty ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" : showContent; final String content = showContent!.isEmpty
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
: showContent;
showCupertinoDialog( showCupertinoDialog(
context: Get.context!, context: Get.context!,
builder: (context) { builder: (BuildContext context) {
return CupertinoAlertDialog( return CupertinoAlertDialog(
title: Text("提示".tr), title: Text('提示'.tr),
content: Text(content), content: Text(content),
actions: [ actions: <Widget>[
CupertinoDialogAction( CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr), child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () { onPressed: Get.back,
Get.back();
},
), ),
], ],
); );
@ -242,23 +274,18 @@ class LockListLogic extends BaseGetXController{
@override @override
void onReady() { void onReady() {
// TODO: implement onReady
super.onReady(); super.onReady();
_initReplySubscription(); _initReplySubscription();
} }
@override @override
void onInit() { void onInit() {
// TODO: implement onInit
super.onInit(); super.onInit();
setLockListInfoGroupEntity(entity!);
} }
@override @override
void onClose() { void onClose() {
// TODO: implement onClose
_replySubscription.cancel(); _replySubscription.cancel();
} }
}
}

View File

@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/flavors.dart';
import 'package:star_lock/main/lockMian/lockList/lockList_state.dart';
import '../../../appRouters.dart'; import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
@ -14,50 +15,53 @@ import 'lockListGroup_view.dart';
import 'lockList_logic.dart'; import 'lockList_logic.dart';
class LockListPage extends StatefulWidget { class LockListPage extends StatefulWidget {
final LockListInfoGroupEntity lockListInfoGroupEntity;
const LockListPage({Key? key, required this.lockListInfoGroupEntity}) const LockListPage({required this.lockListInfoGroupEntity, Key? key})
: super(key: key); : super(key: key);
final LockListInfoGroupEntity lockListInfoGroupEntity;
@override @override
State<LockListPage> createState() => _LockListPageState(); State<LockListPage> createState() => _LockListPageState();
} }
class _LockListPageState extends State<LockListPage> with RouteAware { class _LockListPageState extends State<LockListPage> with RouteAware {
final logic = Get.put(LockListLogic()); late LockListLogic logic;
final state = Get.find<LockListLogic>().state; late LockListState state;
var groupDataList = <GroupList>[]; @override
void initState() {
super.initState();
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
state = Get.find<LockListLogic>().state;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (widget.lockListInfoGroupEntity.pageNo == 1) { return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
groupDataList = <GroupList>[]; return Scaffold(
} body: ListView.separated(
groupDataList.addAll( itemCount: logic.groupDataList.length,
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>); itemBuilder: (BuildContext context, int index) {
final GroupList itemData = logic.groupDataList[index];
return Scaffold( return _buildLockExpandedList(context, index, itemData);
body: ListView.separated( },
itemCount: groupDataList.length, shrinkWrap: true,
itemBuilder: (context, index) { physics: const AlwaysScrollableScrollPhysics(),
GroupList itemData = groupDataList[index]; separatorBuilder: (BuildContext context, int index) {
return _buildLockExpandedList(context, index, itemData); return const Divider(
}, height: 1,
shrinkWrap: true, color: AppColors.greyLineColor,
physics: const AlwaysScrollableScrollPhysics(), );
separatorBuilder: (context, index) { }),
return const Divider( );
height: 1, });
color: AppColors.greyLineColor,
);
}),
);
} }
// //
Widget _buildLockExpandedList(context, index, GroupList itemData) { Widget _buildLockExpandedList(
List lockItemList = itemData.lockList ?? []; BuildContext context, int index, GroupList itemData) {
final List<LockListInfoItemEntity> lockItemList =
itemData.lockList ?? <LockListInfoItemEntity>[];
return LockListGroupView( return LockListGroupView(
onTap: () { onTap: () {
// //
@ -65,28 +69,28 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
} else {} } else {}
setState(() {}); setState(() {});
}, },
typeImgList: const [], typeImgList: const <dynamic>[],
groupItem: itemData, groupItem: itemData,
child: ListView.separated( child: ListView.separated(
itemCount: lockItemList.length, itemCount: lockItemList.length,
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) { separatorBuilder: (BuildContext context, int index) {
return const Divider(height: 1, color: AppColors.greyLineColor); return const Divider(height: 1, color: AppColors.greyLineColor);
}, },
itemBuilder: (c, index) { itemBuilder: (BuildContext c, int index) {
LockListInfoItemEntity keyInfo = lockItemList[index]; final LockListInfoItemEntity keyInfo = lockItemList[index];
bool isLast = false; bool isLast = false;
if (lockItemList.length == index + 1) { if (lockItemList.length == index + 1) {
isLast = true; isLast = true;
} }
return Slidable( return Slidable(
key: ValueKey(keyInfo.keyId), key: ValueKey<int?>(keyInfo.keyId),
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context) { onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo; state.lockListInfoItemEntity = keyInfo;
@ -104,26 +108,27 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
keyInfo.keyType == XSConstantMacro.keyTypeLoop) && keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == (keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective)) { XSConstantMacro.keyStatusWaitIneffective)) {
logic.showToast("您的钥匙未生效".tr); logic.showToast('您的钥匙未生效'.tr);
return; return;
} }
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) && keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) { (keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) {
logic.showToast("您的钥匙已冻结".tr); logic.showToast('您的钥匙已冻结'.tr);
return; return;
} }
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime || if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) && keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) { (keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) {
logic.showToast("您的钥匙已过期".tr); logic.showToast('您的钥匙已过期'.tr);
return; return;
} }
Get.toNamed(Routers.lockDetailMainPage, arguments: { Get.toNamed(Routers.lockDetailMainPage,
// "lockMainEntity": widget.lockMainEntity, arguments: <String, Object>{
"keyInfo": keyInfo, // "lockMainEntity": widget.lockMainEntity,
"isOnlyOneData": false, 'keyInfo': keyInfo,
}); 'isOnlyOneData': false,
});
}), }),
); );
}), }),
@ -152,18 +157,18 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
), ),
child: Column( child: Column(
// mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: [ children: <Widget>[
SizedBox( SizedBox(
height: 20.h, height: 20.h,
), ),
Row( Row(
children: [ children: <Widget>[
SizedBox(width: 30.w), SizedBox(width: 30.w),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: <Widget>[
Text( Text(
keyInfo.lockAlias!, keyInfo.lockAlias!,
style: TextStyle( style: TextStyle(
@ -184,7 +189,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
), ),
SizedBox(width: 2.w), SizedBox(width: 2.w),
Text( Text(
"${keyInfo.electricQuantity!}%", '${keyInfo.electricQuantity!}%',
style: TextStyle( style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor), fontSize: 18.sp, color: AppColors.darkGrayTextColor),
), ),
@ -193,9 +198,9 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
), ),
SizedBox(height: 5.h), SizedBox(height: 5.h),
Visibility( Visibility(
visible: keyInfo.passageMode == 1 ? true : false, visible: keyInfo.passageMode == 1,
child: Row( child: Row(
children: [ children: <Widget>[
SizedBox(width: 30.w), SizedBox(width: 30.w),
Container( Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
@ -203,7 +208,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
borderRadius: BorderRadius.circular(5.w), borderRadius: BorderRadius.circular(5.w),
color: AppColors.openPassageModeColor, color: AppColors.openPassageModeColor,
), ),
child: Text("常开模式开启".tr, child: Text('常开模式开启'.tr,
style: TextStyle( style: TextStyle(
fontSize: 18.sp, fontSize: 18.sp,
color: AppColors.appBarIconColor)), color: AppColors.appBarIconColor)),
@ -212,12 +217,12 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)), )),
SizedBox(height: 5.h), SizedBox(height: 5.h),
Visibility( Visibility(
visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false, visible: keyInfo.lockSetting!.remoteUnlock == 1,
child: Row( child: Row(
children: [ children: <Widget>[
SizedBox(width: 30.w), SizedBox(width: 30.w),
Text( Text(
"远程开锁".tr, '远程开锁'.tr,
style: TextStyle( style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor), fontSize: 18.sp, color: AppColors.darkGrayTextColor),
), ),
@ -225,19 +230,15 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)), )),
SizedBox(height: 20.h), SizedBox(height: 20.h),
Visibility( Visibility(
visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) && keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == (keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective || XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus == keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen ||
XSConstantMacro.keyStatusFrozen || keyInfo.keyStatus == XSConstantMacro.keyStatusExpired),
keyInfo.keyStatus ==
XSConstantMacro.keyStatusExpired))
? true
: false,
// visible: true, // visible: true,
child: Row( child: Row(
children: [ children: <Widget>[
SizedBox(width: 30.w), SizedBox(width: 30.w),
Container( Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
@ -257,7 +258,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)), )),
SizedBox(height: 5.h), SizedBox(height: 5.h),
Row( Row(
children: [ children: <Widget>[
SizedBox(width: 30.w), SizedBox(width: 30.w),
Text( Text(
"${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员'.tr : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr)}", "${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员'.tr : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr)}",

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/flavors.dart'; import 'package:star_lock/main/lockMian/lockList/lockList_state.dart';
import '../../../appRouters.dart'; import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
@ -14,87 +14,90 @@ import 'lockListGroup_view.dart';
import 'lockList_logic.dart'; import 'lockList_logic.dart';
class LockListXHJPage extends StatefulWidget { class LockListXHJPage extends StatefulWidget {
final LockListInfoGroupEntity lockListInfoGroupEntity;
const LockListXHJPage({Key? key, required this.lockListInfoGroupEntity}) const LockListXHJPage({required this.lockListInfoGroupEntity, Key? key})
: super(key: key); : super(key: key);
final LockListInfoGroupEntity lockListInfoGroupEntity;
@override @override
State<LockListXHJPage> createState() => _LockListXHJPageState(); State<LockListXHJPage> createState() => _LockListXHJPageState();
} }
class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware { class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
final logic = Get.put(LockListLogic()); late LockListLogic logic;
final state = Get.find<LockListLogic>().state; late LockListState state;
var groupDataList = <GroupList>[]; @override
void initState() {
super.initState();
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
state = Get.find<LockListLogic>().state;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (widget.lockListInfoGroupEntity.pageNo == 1) { return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
groupDataList = <GroupList>[]; return SafeArea(
} bottom: false,
groupDataList.addAll( child: Column(
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>); crossAxisAlignment: CrossAxisAlignment.start,
return SafeArea( children: <Widget>[
bottom: false, Align(
child: Column( alignment: Alignment.topRight,
crossAxisAlignment: CrossAxisAlignment.start, child: IconButton(
children: [ onPressed: () {
Align( Get.toNamed(Routers.selectLockTypePage);
alignment: Alignment.topRight, },
child: IconButton( icon: Icon(
onPressed: () { Icons.add_circle,
Get.toNamed(Routers.selectLockTypePage); size: 48.w,
}, color: AppColors.mainColor,
icon: Icon( )),
Icons.add_circle, ),
size: 48.w, Padding(
color: AppColors.mainColor, padding: EdgeInsets.only(left: 45.w),
)), child: Text(
), '常用程序'.tr,
Padding( style: TextStyle(
padding: EdgeInsets.only(left: 45.w), fontSize: 32.sp,
child: Text( color: AppColors.blackColor,
'常用程序'.tr, fontWeight: FontWeight.w600,
style: TextStyle( ),
fontSize: 32.sp,
color: AppColors.blackColor,
fontWeight: FontWeight.w600,
), ),
), ),
), Expanded(
Expanded( child: ListView.separated(
child: ListView.separated( itemCount: logic.groupDataList.length,
itemCount: groupDataList.length, itemBuilder: (BuildContext context, int index) {
itemBuilder: (context, index) { final GroupList itemData = logic.groupDataList[index];
GroupList itemData = groupDataList[index]; return _buildLockExpandedList(context, index, itemData);
return _buildLockExpandedList(context, index, itemData); },
}, shrinkWrap: true,
shrinkWrap: true, physics: const AlwaysScrollableScrollPhysics(),
physics: const AlwaysScrollableScrollPhysics(), separatorBuilder: (BuildContext context, int index) {
separatorBuilder: (context, index) { return const Divider(
return const Divider( height: 1,
height: 1, color: AppColors.greyLineColor,
color: AppColors.greyLineColor, );
); }),
}), ),
), ],
], ),
), );
); });
} }
// //
Widget _buildLockExpandedList(context, index, GroupList itemData) { Widget _buildLockExpandedList(context, index, GroupList itemData) {
List lockItemList = itemData.lockList ?? []; final List<LockListInfoItemEntity> lockItemList =
itemData.lockList ?? <LockListInfoItemEntity>[];
return LockListGroupView( return LockListGroupView(
onTap: () { onTap: () {
setState(() {}); setState(() {});
}, },
textStyle: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600), textStyle: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600),
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
typeImgList: const [], typeImgList: const <dynamic>[],
groupItem: itemData, groupItem: itemData,
child: GridView.extent( child: GridView.extent(
padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w), padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w),
@ -109,9 +112,9 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
} }
List<Widget> forItems(List lockItemList) { List<Widget> forItems(List lockItemList) {
List<Widget> list = []; final List<Widget> list = <Widget>[];
for (int i = 0, j = 0; i < lockItemList.length; i++, j++) { for (int i = 0, j = 0; i < lockItemList.length; i++, j++) {
LockListInfoItemEntity keyInfo = lockItemList[i]; final LockListInfoItemEntity keyInfo = lockItemList[i];
bool isLast = false; bool isLast = false;
if (lockItemList.length == i + 1) { if (lockItemList.length == i + 1) {
isLast = true; isLast = true;
@ -121,7 +124,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
endActionPane: ActionPane( endActionPane: ActionPane(
extentRatio: 0.2, extentRatio: 0.2,
motion: const ScrollMotion(), motion: const ScrollMotion(),
children: [ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context) { onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo; state.lockListInfoItemEntity = keyInfo;
@ -153,7 +156,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
logic.showToast("您的钥匙已过期".tr); logic.showToast("您的钥匙已过期".tr);
return; return;
} }
Get.toNamed(Routers.lockDetailMainPage, arguments: { Get.toNamed(Routers.lockDetailMainPage, arguments: <String, Object>{
"keyInfo": keyInfo, "keyInfo": keyInfo,
"isOnlyOneData": false, "isOnlyOneData": false,
}); });
@ -189,9 +192,9 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: <Widget>[
Row( Row(
children: [ children: <Widget>[
Image.asset( Image.asset(
'images/icon_lock_circle.png', 'images/icon_lock_circle.png',
width: 32.r, width: 32.r,
@ -218,7 +221,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 5.h), padding: EdgeInsets.only(top: 5.h),
child: Row( child: Row(
children: [ children: <Widget>[
Container( Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -239,7 +242,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 5.h), padding: EdgeInsets.only(top: 5.h),
child: Row( child: Row(
children: [ children: <Widget>[
Text( Text(
"远程开锁".tr, "远程开锁".tr,
style: TextStyle( style: TextStyle(
@ -263,7 +266,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 20.h), padding: EdgeInsets.only(top: 20.h),
child: Row( child: Row(
children: [ children: <Widget>[
Container( Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w), padding: EdgeInsets.only(right: 5.w, left: 5.w),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -284,7 +287,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
)), )),
SizedBox(height: 5.h), SizedBox(height: 5.h),
Row( Row(
children: [ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
keyInfo.isLockOwner == 1 keyInfo.isLockOwner == 1

View File

@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart';
import '../../../app_settings/app_settings.dart'; import '../../../app_settings/app_settings.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
@ -15,7 +15,8 @@ import 'lockMain_state.dart';
class LockMainLogic extends BaseGetXController { class LockMainLogic extends BaseGetXController {
final LockMainState state = LockMainState(); final LockMainState state = LockMainState();
Future<LockListInfoEntity> getStarLockInfo({bool isUnShowLoading = false}) async { Future<LockListInfoEntity> getStarLockInfo(
{bool isUnShowLoading = false}) async {
LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo( LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo(
pageNo: pageNo, pageNo: pageNo,
pageSize: 50, pageSize: 50,
@ -35,11 +36,11 @@ class LockMainLogic extends BaseGetXController {
return entity; return entity;
} }
Future<void> loadMainDataLogic(LockListInfoGroupEntity entity){ void loadMainDataLogic(LockListInfoGroupEntity entity) {
if (entity.groupList!.isEmpty) { if (entity.groupList!.isEmpty) {
state.dataLength.value = 0; state.dataLength.value = 0;
} else if (entity.groupList!.length == 1) { } else if (entity.groupList!.length == 1) {
GroupList groupList = entity.groupList![0]; final GroupList groupList = entity.groupList![0];
if (groupList.lockList!.length > 1) { if (groupList.lockList!.length > 1) {
state.dataLength.value = 2; state.dataLength.value = 2;
} else { } else {
@ -49,7 +50,11 @@ class LockMainLogic extends BaseGetXController {
state.dataLength.value = 2; state.dataLength.value = 2;
} }
state.lockListInfoGroupEntity.value = entity; state.lockListInfoGroupEntity.value = entity;
return Future.value(); //
if (Get.isRegistered<LockListLogic>()) {
//
Get.find<LockListLogic>().setLockListInfoGroupEntity(entity);
}
} }
/// ///
@ -81,7 +86,8 @@ class LockMainLogic extends BaseGetXController {
connectListener() async { connectListener() async {
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
AppLog.log("设置网络切换监听:$result"); AppLog.log("设置网络切换监听:$result");
if (state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none) { if (state.networkConnectionStatus.value == 0 &&
result != ConnectivityResult.none) {
// //
state.networkConnectionStatus.value = 1; state.networkConnectionStatus.value = 1;
getStarLockInfo(); getStarLockInfo();

View File

@ -43,7 +43,7 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
await Storage.getLockMainListData(); await Storage.getLockMainListData();
if (lockListInfoGroupEntity != null) { if (lockListInfoGroupEntity != null) {
var localLockListInfoGroupEntity = lockListInfoGroupEntity; var localLockListInfoGroupEntity = lockListInfoGroupEntity;
await logic.loadMainDataLogic(localLockListInfoGroupEntity); logic.loadMainDataLogic(localLockListInfoGroupEntity);
} }
await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading); await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading);
await Future.delayed(const Duration(milliseconds: 200)); await Future.delayed(const Duration(milliseconds: 200));

View File

@ -43,7 +43,7 @@ class NearbyLockLogic extends BaseGetXController {
// //
void connect(String deviceName) { void connect(String deviceName) {
showTitleEasyLoading("获取锁信息 1/3"); showTitleEasyLoading('获取锁信息 1/3');
// if(state.sureBtnState.value == 1){ // if(state.sureBtnState.value == 1){
// return; // return;
// } // }
@ -56,9 +56,9 @@ class NearbyLockLogic extends BaseGetXController {
}); });
BlueManage().blueSendData(deviceName, BlueManage().blueSendData(deviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
AppLog.log("点击要添加的设备了"); AppLog.log('点击要添加的设备了');
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
AppLog.log("开始获取公钥"); AppLog.log('开始获取公钥');
IoSenderManage.getPublicKey(lockId: deviceName); IoSenderManage.getPublicKey(lockId: deviceName);
} else if (state == BluetoothConnectionState.disconnected) { } else if (state == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();
@ -108,18 +108,18 @@ class NearbyLockLogic extends BaseGetXController {
switch (reply.status) { switch (reply.status) {
case 0x00: case 0x00:
// //
AppLog.log("获取公钥成功"); AppLog.log('获取公钥成功');
// //
var publicKey = reply.data.sublist(3); var publicKey = reply.data.sublist(3);
var saveStrList = changeIntListToStringList(publicKey); var saveStrList = changeIntListToStringList(publicKey);
Storage.setStringList(saveBluePublicKey, saveStrList); Storage.setStringList(saveBluePublicKey, saveStrList);
// //
AppLog.log("开始获取私钥"); AppLog.log('开始获取私钥');
showTitleEasyLoading("获取锁信息 2/3"); showTitleEasyLoading('获取锁信息 2/3');
IoSenderManage.getPrivateKey( IoSenderManage.getPrivateKey(
lockId: BlueManage().connectDeviceName, lockId: BlueManage().connectDeviceName,
keyID: "1", keyID: '1',
authUserID: await Storage.getUid(), authUserID: await Storage.getUid(),
nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, nowTime: DateTime.now().millisecondsSinceEpoch ~/ 1000,
publicKeyData: publicKey, publicKeyData: publicKey,
@ -127,7 +127,7 @@ class NearbyLockLogic extends BaseGetXController {
break; break;
default: default:
// state.sureBtnState.value = 0; // state.sureBtnState.value = 0;
AppLog.log("获取公钥失败"); AppLog.log('获取公钥失败');
break; break;
} }
} }
@ -135,7 +135,7 @@ class NearbyLockLogic extends BaseGetXController {
Future<void> _replyGetPrivateKeyKey(Reply reply) async { Future<void> _replyGetPrivateKeyKey(Reply reply) async {
switch (reply.status) { switch (reply.status) {
case 0x00: case 0x00:
AppLog.log("获取私钥成功"); AppLog.log('获取私钥成功');
// //
reply.data.removeAt(0); reply.data.removeAt(0);
@ -156,7 +156,7 @@ class NearbyLockLogic extends BaseGetXController {
(0xff & timestamp[2]) << 8 | (0xff & timestamp[2]) << 8 |
(0xFF & timestamp[3])); (0xFF & timestamp[3]));
showTitleEasyLoading("获取锁信息 3/3"); showTitleEasyLoading('获取锁信息 3/3');
_getStarLockStatus(); _getStarLockStatus();
break; break;
default: default:
@ -171,83 +171,83 @@ class NearbyLockLogic extends BaseGetXController {
switch (status) { switch (status) {
case 0x00: case 0x00:
// //
AppLog.log("获取锁状态成功"); AppLog.log('获取锁状态成功');
// //
var index = 3; var index = 3;
var vendor = reply.data.sublist(index, index + 20); var vendor = reply.data.sublist(index, index + 20);
var vendorStr = utf8String(vendor); var vendorStr = utf8String(vendor);
state.lockInfo["vendor"] = vendorStr; state.lockInfo['vendor'] = vendorStr;
// state.lockInfo["vendor"] = "XL"; // state.lockInfo["vendor"] = "XL";
index = index + 20; index = index + 20;
AppLog.log("厂商名称 vendorStr:$vendorStr"); AppLog.log('厂商名称 vendorStr:$vendorStr');
// //
var product = reply.data[index]; var product = reply.data[index];
state.lockInfo["product"] = product; state.lockInfo['product'] = product;
index = index + 1; index = index + 1;
AppLog.log("锁设备类型 product:$product"); AppLog.log('锁设备类型 product:$product');
// //
var model = reply.data.sublist(index, index + 20); var model = reply.data.sublist(index, index + 20);
var modelStr = utf8String(model); var modelStr = utf8String(model);
state.lockInfo["model"] = modelStr; state.lockInfo['model'] = modelStr;
// state.lockInfo["model"] = "JL-BLE-01"; // state.lockInfo["model"] = "JL-BLE-01";
index = index + 20; index = index + 20;
AppLog.log("产品名称 mmodelStr:$modelStr"); AppLog.log('产品名称 mmodelStr:$modelStr');
// //
var fwVersion = reply.data.sublist(index, index+20); var fwVersion = reply.data.sublist(index, index+20);
var fwVersionStr = utf8String(fwVersion); var fwVersionStr = utf8String(fwVersion);
state.lockInfo["fwVersion"] = fwVersionStr; state.lockInfo['fwVersion'] = fwVersionStr;
index = index + 20; index = index + 20;
AppLog.log("软件版本 fwVersionStr:$fwVersionStr"); AppLog.log('软件版本 fwVersionStr:$fwVersionStr');
// //
var hwVersion = reply.data.sublist(index, index+20); var hwVersion = reply.data.sublist(index, index+20);
var hwVersionStr = utf8String(hwVersion); var hwVersionStr = utf8String(hwVersion);
state.lockInfo["hwVersion"] = hwVersionStr; state.lockInfo['hwVersion'] = hwVersionStr;
index = index + 20; index = index + 20;
AppLog.log("硬件版本 hwVersionStr:$hwVersionStr"); AppLog.log('硬件版本 hwVersionStr:$hwVersionStr');
// //
var serialNum0 = reply.data.sublist(index, index + 16); var serialNum0 = reply.data.sublist(index, index + 16);
var serialNum0Str = utf8String(serialNum0); var serialNum0Str = utf8String(serialNum0);
state.lockInfo["serialNum0"] = serialNum0Str; state.lockInfo['serialNum0'] = serialNum0Str;
// state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}"; // state.lockInfo["serialNum0"] = "${DateTime.now().millisecondsSinceEpoch ~/ 10}";
index = index + 16; index = index + 16;
AppLog.log("厂商序列号 serialNum0Str:${serialNum0Str.length}"); AppLog.log('厂商序列号 serialNum0Str:${serialNum0Str.length}');
// //
var serialNum1 = reply.data.sublist(index, index + 16); var serialNum1 = reply.data.sublist(index, index + 16);
var serialNum1Str = utf8String(serialNum1); var serialNum1Str = utf8String(serialNum1);
state.lockInfo["serialNum1"] = serialNum1Str; state.lockInfo['serialNum1'] = serialNum1Str;
index = index + 16; index = index + 16;
AppLog.log("成品商序列号 serialNum1Str:$serialNum1Str"); AppLog.log('成品商序列号 serialNum1Str:$serialNum1Str');
// //
var btDeviceName = reply.data.sublist(index, index + 16); var btDeviceName = reply.data.sublist(index, index + 16);
var btDeviceNameStr = utf8String(btDeviceName); var btDeviceNameStr = utf8String(btDeviceName);
state.lockInfo["btDeviceName"] = btDeviceNameStr; state.lockInfo['btDeviceName'] = btDeviceNameStr;
index = index + 16; index = index + 16;
AppLog.log("蓝牙名称 btDeviceNameStr:$btDeviceNameStr"); AppLog.log('蓝牙名称 btDeviceNameStr:$btDeviceNameStr');
// //
var battRemCap = reply.data[index]; var battRemCap = reply.data[index];
state.lockInfo["electricQuantity"] = battRemCap; state.lockInfo['electricQuantity'] = battRemCap;
index = index + 1; index = index + 1;
AppLog.log("电池剩余电量 battRemCap:$battRemCap"); AppLog.log('电池剩余电量 battRemCap:$battRemCap');
// //
var battRemCapStandby = reply.data[index]; var battRemCapStandby = reply.data[index];
state.lockInfo["electricQuantityStandby"] = battRemCapStandby; state.lockInfo['electricQuantityStandby'] = battRemCapStandby;
index = index + 1; index = index + 1;
AppLog.log("电池剩余电量 battRemCap:$battRemCap"); AppLog.log('电池剩余电量 battRemCap:$battRemCap');
// //
var restoreCounter = reply.data.sublist(index, index + 2); var restoreCounter = reply.data.sublist(index, index + 2);
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1]; state.lockInfo['restoreCount'] = restoreCounter[0] * 256 + restoreCounter[1];
index = index + 2; index = index + 2;
AppLog.log("重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}"); AppLog.log('重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}');
// //
var restoreDate = reply.data.sublist(index, index + 4); var restoreDate = reply.data.sublist(index, index + 4);
@ -256,16 +256,16 @@ class NearbyLockLogic extends BaseGetXController {
(0xff & restoreDate[2]) << 8 | (0xff & restoreDate[2]) << 8 |
(0xFF & restoreDate[3])); (0xFF & restoreDate[3]));
// String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString()); // String restoreDateStr = DateTool().dateToYMDHNSString(restoreDateValue.toString());
state.lockInfo["restoreDate"] = restoreDateValue * 1000; state.lockInfo['restoreDate'] = restoreDateValue * 1000;
index = index + 4; index = index + 4;
AppLog.log("重置时间 restoreDateValue:$restoreDateValue"); AppLog.log('重置时间 restoreDateValue:$restoreDateValue');
// //
var icPartNo = reply.data.sublist(index, index + 10); var icPartNo = reply.data.sublist(index, index + 10);
var icPartNoStr = utf8String(icPartNo); var icPartNoStr = utf8String(icPartNo);
state.lockInfo["icPartNo"] = icPartNoStr; state.lockInfo['icPartNo'] = icPartNoStr;
index = index + 10; index = index + 10;
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr"); AppLog.log('主控芯片型号 icPartNoStr:$icPartNoStr');
// //
var indate = reply.data.sublist(index, index + 4); var indate = reply.data.sublist(index, index + 4);
@ -274,27 +274,27 @@ class NearbyLockLogic extends BaseGetXController {
(0xff & indate[2]) << 8 | (0xff & indate[2]) << 8 |
(0xFF & indate[3])); (0xFF & indate[3]));
// String indateStr = DateTool().dateToYMDHNSString("$indateValue"); // String indateStr = DateTool().dateToYMDHNSString("$indateValue");
state.lockInfo["indate"] = indateValue * 1000; state.lockInfo['indate'] = indateValue * 1000;
index = index + 4; index = index + 4;
AppLog.log("有效时间 indateValue:$indateValue"); AppLog.log('有效时间 indateValue:$indateValue');
// mac地址 // mac地址
var macAddress = reply.data.sublist(index, index + 20); var macAddress = reply.data.sublist(index, index + 20);
var macAddressStr = utf8String(macAddress); var macAddressStr = utf8String(macAddress);
state.lockInfo["mac"] = macAddressStr; state.lockInfo['mac'] = macAddressStr;
index = index + 20; index = index + 20;
AppLog.log("mac地址 macAddressStr:$macAddressStr"); AppLog.log('mac地址 macAddressStr:$macAddressStr');
// //
var featureValueLength = reply.data[index]; var featureValueLength = reply.data[index];
index = index + 1; index = index + 1;
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength"); AppLog.log('锁特征值字符串长度 featureValueLength:$featureValueLength');
// () // ()
// //
var featureNetxLength = index + featureValueLength; var featureNetxLength = index + featureValueLength;
if (reply.data.length < featureNetxLength) { if (reply.data.length < featureNetxLength) {
showToast("锁数据异常,请重试"); showToast('锁数据异常,请重试');
return; return;
} }
var featureValue = reply.data.sublist(index, index + featureValueLength); var featureValue = reply.data.sublist(index, index + featureValueLength);
@ -303,17 +303,17 @@ class NearbyLockLogic extends BaseGetXController {
// List allFeatureValueTwoList = charListChangeIntList(featureValue); // List allFeatureValueTwoList = charListChangeIntList(featureValue);
// AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr"); // AppLog.log("featureValueLength:$featureValueLength featureValue:$featureValue \n featureValueStr:$featureValueStr");
index = index + featureValueLength; index = index + featureValueLength;
AppLog.log("锁特征值字符串 featureValueStr:$featureValueStr"); AppLog.log('锁特征值字符串 featureValueStr:$featureValueStr');
// 使 // 使
var featureEnValLength = reply.data[index]; var featureEnValLength = reply.data[index];
index = index + 1; index = index + 1;
AppLog.log("使能特征值字符串长度 featureEnValLength:$featureEnValLength"); AppLog.log('使能特征值字符串长度 featureEnValLength:$featureEnValLength');
// 使() // 使()
var featureEnNextLength = index + featureEnValLength; var featureEnNextLength = index + featureEnValLength;
if (reply.data.length < featureEnNextLength) { if (reply.data.length < featureEnNextLength) {
showToast("锁数据异常,请重试"); showToast('锁数据异常,请重试');
return; return;
} }
var featureEnVal = reply.data.sublist(index, index + featureEnValLength); var featureEnVal = reply.data.sublist(index, index + featureEnValLength);
@ -322,21 +322,21 @@ class NearbyLockLogic extends BaseGetXController {
// List allFeatureEnValTwoList = charListChangeIntList(featureEnVal); // List allFeatureEnValTwoList = charListChangeIntList(featureEnVal);
// AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr"); // AppLog.log("featureEnValLength:$featureEnValLength featureEnVal:$featureEnVal \n featureEnValStr:$featureEnValStr");
index = index + featureEnValLength; index = index + featureEnValLength;
AppLog.log("使能锁特征值说明 featureEnValStr:$featureEnValStr"); AppLog.log('使能锁特征值说明 featureEnValStr:$featureEnValStr');
// //
// var featureParaTotal = reply.data[index]; // var featureParaTotal = reply.data[index];
var featureParaTotalList = reply.data.sublist(index); var featureParaTotalList = reply.data.sublist(index);
state.featureSettingParams = featureParaTotalList; state.featureSettingParams = featureParaTotalList;
AppLog.log("featureParaTotalList:$featureParaTotalList"); AppLog.log('featureParaTotalList:$featureParaTotalList');
Get.toNamed(Routers.lockAddressGaoDePage, arguments: { Get.toNamed(Routers.lockAddressGaoDePage, arguments: {
"pwdTimestamp": state.timestampValue * 1000, 'pwdTimestamp': state.timestampValue * 1000,
"lockInfo": state.lockInfo, 'lockInfo': state.lockInfo,
"featureValue": state.featureValue, 'featureValue': state.featureValue,
"featureSettingValue": state.featureSettingValue, 'featureSettingValue': state.featureSettingValue,
"featureSettingParams": state.featureSettingParams, 'featureSettingParams': state.featureSettingParams,
}); });
break; break;
@ -372,7 +372,7 @@ class NearbyLockLogic extends BaseGetXController {
// if (state == BluetoothConnectionState.connected) { // if (state == BluetoothConnectionState.connected) {
// dismissEasyLoading(); // dismissEasyLoading();
AppLog.log("开始获取锁状态"); AppLog.log('开始获取锁状态');
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -397,9 +397,9 @@ class NearbyLockLogic extends BaseGetXController {
ScanResult device = list[i]; ScanResult device = list[i];
if (((device.advertisementData.serviceUuids.isNotEmpty if (((device.advertisementData.serviceUuids.isNotEmpty
? device.advertisementData.serviceUuids[0] ? device.advertisementData.serviceUuids[0]
: "") : '')
.toString()[31] != .toString()[31] !=
"1")) { '1')) {
state.devices.add(list[i]); state.devices.add(list[i]);
} }
} }
@ -413,17 +413,17 @@ class NearbyLockLogic extends BaseGetXController {
// , ota // , ota
void oTAUpgrade(String deviceName) { void oTAUpgrade(String deviceName) {
showTitleEasyLoading("连接设备中..."); showTitleEasyLoading('连接设备中...');
this.deviceName = deviceName; this.deviceName = deviceName;
BlueManage().blueSendData(deviceName, BlueManage().blueSendData(deviceName,
(BluetoothConnectionState state) async { (BluetoothConnectionState state) async {
AppLog.log("连接设备"); AppLog.log('连接设备');
if (state == BluetoothConnectionState.connected) { if (state == BluetoothConnectionState.connected) {
AppLog.log("连接成功"); AppLog.log('连接成功');
dismissEasyLoading(); dismissEasyLoading();
otaUpdate(); otaUpdate();
} else if (state == BluetoothConnectionState.disconnected) { } else if (state == BluetoothConnectionState.disconnected) {
AppLog.log("连接失败"); AppLog.log('连接失败');
dismissEasyLoading(); dismissEasyLoading();
} }
}, isAddEquipment: true); }, isAddEquipment: true);

View File

@ -1,7 +1,7 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart'; import 'package:star_lock/blue/entity/lock_user_no_list_entity.dart';
import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/login/selectCountryRegion/common/countryRegionEntity.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/notice_template_entity.dart'; import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/lockUserList/lockUserList_entity.dart';

View File

@ -1,34 +1,38 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import '../app_settings/app_settings.dart'; import '../app_settings/app_settings.dart';
/// ///
class NativeInteractionConfig{ class NativeInteractionConfig {
static String methodSendChannel = 'starLockFlutterSend'; static String methodSendChannel = 'starLockFlutterSend';
static String receiveEventChannel = 'starLockFlutterReceive'; static String receiveEventChannel = 'starLockFlutterReceive';
} }
///flutter向原生发送消息 ///flutter向原生发送消息
typedef BlockBlueStatus = void Function(String status); typedef BlockBlueStatus = void Function(String status);
class NativeInteractionTool{
var sendChannel = MethodChannel(NativeInteractionConfig.methodSendChannel); class NativeInteractionTool {
var receiveChannel = MethodChannel(NativeInteractionConfig.receiveEventChannel); MethodChannel sendChannel =
MethodChannel(NativeInteractionConfig.methodSendChannel);
MethodChannel receiveChannel =
MethodChannel(NativeInteractionConfig.receiveEventChannel);
/// ///
loadNativeShare({required String shareText}){ void loadNativeShare({required String shareText}) {
sendChannel.invokeMethod('loadNativeShare', {'shareText':shareText}); sendChannel.invokeMethod(
'loadNativeShare', <String, String>{'shareText': shareText});
} }
/// ///
sendGetBlueStatus(){ void sendGetBlueStatus() {
sendChannel.invokeMethod('sendGetBlueStatus'); sendChannel.invokeMethod('sendGetBlueStatus');
} }
/// ///
receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus){ void receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus) {
receiveChannel.setMethodCallHandler((MethodCall call) async { receiveChannel.setMethodCallHandler((MethodCall call) async {
AppLog.log('收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}'); AppLog.log(
'收到原生发送的信息call.method: ${call.method} call.arguments:${call.arguments}');
switch (call.method) { switch (call.method) {
case 'getBlueStatus': case 'getBlueStatus':
// / // /
@ -42,5 +46,3 @@ class NativeInteractionTool{
}); });
} }
} }