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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ import 'dart:ffi';
import 'package:flutter_easyloading/flutter_easyloading.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/network/api_repository.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_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../blue/blue_manage.dart';
@ -23,26 +22,44 @@ import '../../../translations/trans_lib.dart';
import '../entity/lockListInfo_entity.dart';
import 'lockList_state.dart';
class LockListLogic extends BaseGetXController{
class LockListLogic extends BaseGetXController {
LockListLogic(this.entity){
}
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;
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);
}
});
}
Future<void> _replyFactoryDataResetKey(Reply reply) async {
var token = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(token);
final List<int> token = reply.data.sublist(2, 6);
final List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6];
final int status = reply.data[6];
switch (status) {
case 0x00:
//
@ -52,22 +69,24 @@ class LockListLogic extends BaseGetXController{
break;
case 0x06:
//
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
final List<String>? token = await Storage.getStringList(saveBlueToken);
final List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
keyID: "1",
keyID: '1',
needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
publicKey:
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey:
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: getTokenList);
break;
case 0x07:
//
dismissEasyLoading();
showToast("用户无权限");
showToast('用户无权限');
break;
case 0x09:
//
@ -82,62 +101,63 @@ class LockListLogic extends BaseGetXController{
}
}
String showElectricIcon (int electricnumber){
if(electricnumber >= 100){
String showElectricIcon(int electricnumber) {
if (electricnumber >= 100) {
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';
}else if((electricnumber > 25) && (electricnumber <= 50)){
} else if ((electricnumber > 25) && (electricnumber <= 50)) {
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';
}else if(electricnumber <= 5){
} else if (electricnumber <= 5) {
return 'images/main/icon_lockElectricLevel_1.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}";
} else {
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
}
}
return "";
return '';
}
///
deleyLockLogicOfRoles(){
///
void deleyLockLogicOfRoles() {
if (state.lockListInfoItemEntity.isLockOwner == 1) {
//
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr,
() {
//
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
checkLoginPassword();
});
ShowTipView().showTFViewAlertDialog(
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;
deletKeyData();
});
} else{
} else {
//
ShowTipView().showIosTipWithContentDialog("是否删除钥匙?".tr, (){
deletKeyData();
});
ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, deletKeyData);
}
}
//
void checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword(
Future<void> checkLoginPassword() async {
final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text,
);
if (entity.errorCode!.codeIsSuccessful) {
@ -147,12 +167,12 @@ class LockListLogic extends BaseGetXController{
}
//
void deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData(
Future<void> deletLockInfoData() async {
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockListInfoItemEntity.lockId!,
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
@ -160,14 +180,14 @@ class LockListLogic extends BaseGetXController{
}
//
void deletKeyData() async {
var entity = await ApiRepository.to.deletOwnerKeyData(
Future<void> deletKeyData() async {
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.lockListInfoItemEntity.lockId.toString(),
keyId: state.lockListInfoItemEntity.keyId.toString(),
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0
);
includeUnderlings:
state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
@ -177,62 +197,74 @@ class LockListLogic extends BaseGetXController{
//
Future<void> factoryDataResetAction() async {
showEasyLoading();
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
dismissEasyLoading();
showDeletAlertTipDialog();
});
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
showBlueConnetctToastTimer(
isShowBlueConnetctToast: false,
action: () {
dismissEasyLoading();
showDeletAlertTipDialog();
});
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
final List<int> publicKeyData =
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
final List<String> saveStrList =
changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
final List<int> privateKeyData =
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
final List<String> savePrivateKeyList =
changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
List<int> signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
var saveSignKeyList = changeIntListToStringList(signKeyData);
final List<int> signKeyData =
state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
final List<String> saveSignKeyList =
changeIntListToStringList(signKeyData);
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);
IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
keyID: "1",
keyID: '1',
needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: [0,0,0,0]);
publicKey:
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
privateKey:
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
token: <int>[0, 0, 0, 0]);
} else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();
cancelBlueConnetctToastTimer();
if(state.ifCurrentScreen.value == true){
if (state.ifCurrentScreen.value == true) {
showDeletAlertTipDialog();
}
}
});
}
void showDeletAlertTipDialog({String? showContent = ""}) {
void showDeletAlertTipDialog({String? showContent = ''}) {
// 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(
context: Get.context!,
builder: (context) {
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text("提示".tr),
title: Text('提示'.tr),
content: Text(content),
actions: [
actions: <Widget>[
CupertinoDialogAction(
child: Text(TranslationLoader.lanKeys!.sure!.tr),
onPressed: () {
Get.back();
},
onPressed: Get.back,
),
],
);
@ -242,23 +274,18 @@ class LockListLogic extends BaseGetXController{
@override
void onReady() {
// TODO: implement onReady
super.onReady();
_initReplySubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
setLockListInfoGroupEntity(entity!);
}
@override
void onClose() {
// TODO: implement onClose
_replySubscription.cancel();
}
}
}

View File

@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.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 '../../../app_settings/app_colors.dart';
@ -14,50 +15,53 @@ import 'lockListGroup_view.dart';
import 'lockList_logic.dart';
class LockListPage extends StatefulWidget {
final LockListInfoGroupEntity lockListInfoGroupEntity;
const LockListPage({Key? key, required this.lockListInfoGroupEntity})
const LockListPage({required this.lockListInfoGroupEntity, Key? key})
: super(key: key);
final LockListInfoGroupEntity lockListInfoGroupEntity;
@override
State<LockListPage> createState() => _LockListPageState();
}
class _LockListPageState extends State<LockListPage> with RouteAware {
final logic = Get.put(LockListLogic());
final state = Get.find<LockListLogic>().state;
late LockListLogic logic;
late LockListState state;
var groupDataList = <GroupList>[];
@override
void initState() {
super.initState();
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
state = Get.find<LockListLogic>().state;
}
@override
Widget build(BuildContext context) {
if (widget.lockListInfoGroupEntity.pageNo == 1) {
groupDataList = <GroupList>[];
}
groupDataList.addAll(
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
return Scaffold(
body: ListView.separated(
itemCount: groupDataList.length,
itemBuilder: (context, index) {
GroupList itemData = groupDataList[index];
return _buildLockExpandedList(context, index, itemData);
},
shrinkWrap: true,
physics: const AlwaysScrollableScrollPhysics(),
separatorBuilder: (context, index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
}),
);
return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
return Scaffold(
body: ListView.separated(
itemCount: logic.groupDataList.length,
itemBuilder: (BuildContext context, int index) {
final GroupList itemData = logic.groupDataList[index];
return _buildLockExpandedList(context, index, itemData);
},
shrinkWrap: true,
physics: const AlwaysScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
}),
);
});
}
//
Widget _buildLockExpandedList(context, index, GroupList itemData) {
List lockItemList = itemData.lockList ?? [];
Widget _buildLockExpandedList(
BuildContext context, int index, GroupList itemData) {
final List<LockListInfoItemEntity> lockItemList =
itemData.lockList ?? <LockListInfoItemEntity>[];
return LockListGroupView(
onTap: () {
//
@ -65,28 +69,28 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
} else {}
setState(() {});
},
typeImgList: const [],
typeImgList: const <dynamic>[],
groupItem: itemData,
child: ListView.separated(
itemCount: lockItemList.length,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) {
separatorBuilder: (BuildContext context, int index) {
return const Divider(height: 1, color: AppColors.greyLineColor);
},
itemBuilder: (c, index) {
LockListInfoItemEntity keyInfo = lockItemList[index];
itemBuilder: (BuildContext c, int index) {
final LockListInfoItemEntity keyInfo = lockItemList[index];
bool isLast = false;
if (lockItemList.length == index + 1) {
isLast = true;
}
return Slidable(
key: ValueKey(keyInfo.keyId),
key: ValueKey<int?>(keyInfo.keyId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
children: <Widget>[
SlidableAction(
onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo;
@ -104,26 +108,27 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective)) {
logic.showToast("您的钥匙未生效".tr);
logic.showToast('您的钥匙未生效'.tr);
return;
}
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) {
logic.showToast("您的钥匙已冻结".tr);
logic.showToast('您的钥匙已冻结'.tr);
return;
}
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) {
logic.showToast("您的钥匙已过期".tr);
logic.showToast('您的钥匙已过期'.tr);
return;
}
Get.toNamed(Routers.lockDetailMainPage, arguments: {
// "lockMainEntity": widget.lockMainEntity,
"keyInfo": keyInfo,
"isOnlyOneData": false,
});
Get.toNamed(Routers.lockDetailMainPage,
arguments: <String, Object>{
// "lockMainEntity": widget.lockMainEntity,
'keyInfo': keyInfo,
'isOnlyOneData': false,
});
}),
);
}),
@ -152,18 +157,18 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
),
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
children: <Widget>[
SizedBox(
height: 20.h,
),
Row(
children: [
children: <Widget>[
SizedBox(width: 30.w),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
Text(
keyInfo.lockAlias!,
style: TextStyle(
@ -184,7 +189,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
),
SizedBox(width: 2.w),
Text(
"${keyInfo.electricQuantity!}%",
'${keyInfo.electricQuantity!}%',
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
@ -193,9 +198,9 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
),
SizedBox(height: 5.h),
Visibility(
visible: keyInfo.passageMode == 1 ? true : false,
visible: keyInfo.passageMode == 1,
child: Row(
children: [
children: <Widget>[
SizedBox(width: 30.w),
Container(
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),
color: AppColors.openPassageModeColor,
),
child: Text("常开模式开启".tr,
child: Text('常开模式开启'.tr,
style: TextStyle(
fontSize: 18.sp,
color: AppColors.appBarIconColor)),
@ -212,12 +217,12 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)),
SizedBox(height: 5.h),
Visibility(
visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false,
visible: keyInfo.lockSetting!.remoteUnlock == 1,
child: Row(
children: [
children: <Widget>[
SizedBox(width: 30.w),
Text(
"远程开锁".tr,
'远程开锁'.tr,
style: TextStyle(
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
),
@ -225,19 +230,15 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)),
SizedBox(height: 20.h),
Visibility(
visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus ==
XSConstantMacro.keyStatusExpired))
? true
: false,
visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
(keyInfo.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective ||
keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen ||
keyInfo.keyStatus == XSConstantMacro.keyStatusExpired),
// visible: true,
child: Row(
children: [
children: <Widget>[
SizedBox(width: 30.w),
Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w),
@ -257,7 +258,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
)),
SizedBox(height: 5.h),
Row(
children: [
children: <Widget>[
SizedBox(width: 30.w),
Text(
"${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_slidable/flutter_slidable.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 '../../../app_settings/app_colors.dart';
@ -14,87 +14,90 @@ import 'lockListGroup_view.dart';
import 'lockList_logic.dart';
class LockListXHJPage extends StatefulWidget {
final LockListInfoGroupEntity lockListInfoGroupEntity;
const LockListXHJPage({Key? key, required this.lockListInfoGroupEntity})
const LockListXHJPage({required this.lockListInfoGroupEntity, Key? key})
: super(key: key);
final LockListInfoGroupEntity lockListInfoGroupEntity;
@override
State<LockListXHJPage> createState() => _LockListXHJPageState();
}
class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
final logic = Get.put(LockListLogic());
final state = Get.find<LockListLogic>().state;
late LockListLogic logic;
late LockListState state;
var groupDataList = <GroupList>[];
@override
void initState() {
super.initState();
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
state = Get.find<LockListLogic>().state;
}
@override
Widget build(BuildContext context) {
if (widget.lockListInfoGroupEntity.pageNo == 1) {
groupDataList = <GroupList>[];
}
groupDataList.addAll(
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
return SafeArea(
bottom: false,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align(
alignment: Alignment.topRight,
child: IconButton(
onPressed: () {
Get.toNamed(Routers.selectLockTypePage);
},
icon: Icon(
Icons.add_circle,
size: 48.w,
color: AppColors.mainColor,
)),
),
Padding(
padding: EdgeInsets.only(left: 45.w),
child: Text(
'常用程序'.tr,
style: TextStyle(
fontSize: 32.sp,
color: AppColors.blackColor,
fontWeight: FontWeight.w600,
return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
return SafeArea(
bottom: false,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topRight,
child: IconButton(
onPressed: () {
Get.toNamed(Routers.selectLockTypePage);
},
icon: Icon(
Icons.add_circle,
size: 48.w,
color: AppColors.mainColor,
)),
),
Padding(
padding: EdgeInsets.only(left: 45.w),
child: Text(
'常用程序'.tr,
style: TextStyle(
fontSize: 32.sp,
color: AppColors.blackColor,
fontWeight: FontWeight.w600,
),
),
),
),
Expanded(
child: ListView.separated(
itemCount: groupDataList.length,
itemBuilder: (context, index) {
GroupList itemData = groupDataList[index];
return _buildLockExpandedList(context, index, itemData);
},
shrinkWrap: true,
physics: const AlwaysScrollableScrollPhysics(),
separatorBuilder: (context, index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
}),
),
],
),
);
Expanded(
child: ListView.separated(
itemCount: logic.groupDataList.length,
itemBuilder: (BuildContext context, int index) {
final GroupList itemData = logic.groupDataList[index];
return _buildLockExpandedList(context, index, itemData);
},
shrinkWrap: true,
physics: const AlwaysScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
}),
),
],
),
);
});
}
//
Widget _buildLockExpandedList(context, index, GroupList itemData) {
List lockItemList = itemData.lockList ?? [];
final List<LockListInfoItemEntity> lockItemList =
itemData.lockList ?? <LockListInfoItemEntity>[];
return LockListGroupView(
onTap: () {
setState(() {});
},
textStyle: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600),
backgroundColor: Colors.transparent,
typeImgList: const [],
typeImgList: const <dynamic>[],
groupItem: itemData,
child: GridView.extent(
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> list = [];
final List<Widget> list = <Widget>[];
for (int i = 0, j = 0; i < lockItemList.length; i++, j++) {
LockListInfoItemEntity keyInfo = lockItemList[i];
final LockListInfoItemEntity keyInfo = lockItemList[i];
bool isLast = false;
if (lockItemList.length == i + 1) {
isLast = true;
@ -121,7 +124,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
children: [
children: <Widget>[
SlidableAction(
onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo;
@ -153,7 +156,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
logic.showToast("您的钥匙已过期".tr);
return;
}
Get.toNamed(Routers.lockDetailMainPage, arguments: {
Get.toNamed(Routers.lockDetailMainPage, arguments: <String, Object>{
"keyInfo": keyInfo,
"isOnlyOneData": false,
});
@ -189,9 +192,9 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
children: <Widget>[
Row(
children: [
children: <Widget>[
Image.asset(
'images/icon_lock_circle.png',
width: 32.r,
@ -218,7 +221,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding(
padding: EdgeInsets.only(top: 5.h),
child: Row(
children: [
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w),
decoration: BoxDecoration(
@ -239,7 +242,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding(
padding: EdgeInsets.only(top: 5.h),
child: Row(
children: [
children: <Widget>[
Text(
"远程开锁".tr,
style: TextStyle(
@ -263,7 +266,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
child: Padding(
padding: EdgeInsets.only(top: 20.h),
child: Row(
children: [
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 5.w, left: 5.w),
decoration: BoxDecoration(
@ -284,7 +287,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
)),
SizedBox(height: 5.h),
Row(
children: [
children: <Widget>[
Expanded(
child: Text(
keyInfo.isLockOwner == 1

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import 'package:get/get.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/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/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.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 '../app_settings/app_settings.dart';
///
class NativeInteractionConfig{
class NativeInteractionConfig {
static String methodSendChannel = 'starLockFlutterSend';
static String receiveEventChannel = 'starLockFlutterReceive';
}
///flutter向原生发送消息
typedef BlockBlueStatus = void Function(String status);
class NativeInteractionTool{
var sendChannel = MethodChannel(NativeInteractionConfig.methodSendChannel);
var receiveChannel = MethodChannel(NativeInteractionConfig.receiveEventChannel);
class NativeInteractionTool {
MethodChannel sendChannel =
MethodChannel(NativeInteractionConfig.methodSendChannel);
MethodChannel receiveChannel =
MethodChannel(NativeInteractionConfig.receiveEventChannel);
///
loadNativeShare({required String shareText}){
sendChannel.invokeMethod('loadNativeShare', {'shareText':shareText});
void loadNativeShare({required String shareText}) {
sendChannel.invokeMethod(
'loadNativeShare', <String, String>{'shareText': shareText});
}
///
sendGetBlueStatus(){
void sendGetBlueStatus() {
sendChannel.invokeMethod('sendGetBlueStatus');
}
///
receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus){
void receiveChannelBlueIsOnEvent(BlockBlueStatus blockBlueStatus) {
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) {
case 'getBlueStatus':
// /
@ -42,5 +46,3 @@ class NativeInteractionTool{
});
}
}