完成分组功能,调试蓝牙协议

This commit is contained in:
魏少阳 2023-11-13 11:28:42 +08:00
parent 5e920b9ada
commit 79c0b74f36
45 changed files with 1861 additions and 408 deletions

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart';
import 'package:star_lock/login/register/starLock_register_binding.dart';
@ -20,7 +19,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi
import 'package:star_lock/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart';
@ -130,7 +129,8 @@ import 'mine/mineSet/authorityManagement/authorityManagement_page.dart';
import 'mine/mineSet/authorityManagement/getDeviceList_page.dart';
import 'mine/mineSet/authorityManagement/getNameList_page.dart';
import 'mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart';
import 'mine/mineSet/lockGroup/lockItemList_page.dart';
import 'mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart';
import 'mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart';
import 'mine/mineSet/lockScreen/lockScreen_page.dart';
import 'mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart';
import 'mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart';
@ -201,6 +201,7 @@ abstract class Routers {
'/UploadElectricQuantityPage'; //
static const editLockNamePage = '/EditLockNamePage'; //
static const lockSeletGroupingPage = '/LockSeletGroupingPage'; //
static const groupEditLockPage = '/GroupEditLockPage'; //
static const adminOpenLockPasswordPage =
'/AdminOpenLockPasswordPage'; //
static const wirelessKeyboardPage = '/WirelessKeyboardPage'; //
@ -756,6 +757,8 @@ abstract class AppRouters {
page: () => const LockUserManageListPage()),
GetPage(
name: Routers.lockGroupListPage, page: () => const LockGroupListPage()),
GetPage(
name: Routers.groupEditLockPage, page: () => const GroupEditLockPage()),
GetPage(
name: Routers.lockItemListPage, page: () => const LockItemListPage()),
GetPage(

View File

@ -1,15 +1,11 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:star_lock/blue/sender_manage.dart';
import '../app_settings/app_settings.dart';
import '../tools/storage.dart';
import '../tools/toast.dart';
import 'io_tool/io_manager.dart';
import 'io_tool/io_model.dart';
import 'io_tool/io_tool.dart';
import 'io_tool/manager_event_bus.dart';
@ -218,6 +214,10 @@ class BlueManage{
//
Future<void> judgeReconnect(String deviceMAC, String deviceName, ConnectStateCallBack? connectStateCallBack, {bool isShowLoading = true}) async {
// print("11111111$deviceConnectionState");
if(deviceMAC.isEmpty){
Toast.show(msg: "未连接到设备,请确保在设备附近,设备未被连接,设备已打开");
// return;
}
if(deviceConnectionState == DeviceConnectionState.connected){
// print("2222222:$deviceConnectionState");
if(isShowLoading){
@ -369,7 +369,6 @@ class BlueManage{
}
}
Future<void> writeCharacteristicWithoutResponse(
QualifiedCharacteristic characteristic, List<int> value) async {
try {

View File

@ -0,0 +1,121 @@
import 'dart:convert';
import '../io_tool/io_tool.dart';
import '../sm4Encipher/sm4.dart';
import '../io_reply.dart';
import '../io_sender.dart';
import '../io_type.dart';
import 'package:crypto/crypto.dart' as crypto;
///TODO:
class SenderReadAdminPasswordCommand extends SenderProtocol {
String? keyID;
String? userID;
int? role;
int? pwdNum;
int? pwdNo;
List<int>? token;
int? needAuthor;
List<int>? publicKey;
List<int>? privateKey;
SenderReadAdminPasswordCommand({
this.keyID,
this.userID,
this.role,
this.pwdNum,
this.pwdNo,
this.token,
this.needAuthor,
this.publicKey,
this.privateKey,
}) : super(CommandType.generalExtendedCommond);
@override
List<int> messageDetail() {
List<int> data = [];
List<int> subData = [];
List<int> ebcData = [];
//
int type = commandType!.typeValue;
double typeDouble = type / 256;
int type1 = typeDouble.toInt();
int type2 = type % 256;
data.add(type1);
data.add(type2);
//
data.add(74);
// keyID 40
int keyIDLength = utf8.encode(keyID!).length;
// print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}");
subData.addAll(utf8.encode(keyID!));
subData = getFixedLengthList(subData, 40 - keyIDLength);
//userID 20
int userIDLength = utf8.encode(userID!).length;
// print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}");
subData.addAll(utf8.encode(userID!));
subData = getFixedLengthList(subData, 20 - userIDLength);
// Role
subData.add(role!);
// PwdNum
subData.add(pwdNum!);
// PwdNo
subData.add(pwdNo!);
if(needAuthor == 0){
//AuthCodeLen 1
subData.add(0);
} else {
List<int> authCodeData = [];
//authUserID
authCodeData.addAll(utf8.encode(userID!));
//KeyID
authCodeData.addAll(utf8.encode(keyID!));
//token 4 Token 0
authCodeData.addAll(token!);
authCodeData.addAll(publicKey!);
print("${commandType!.typeValue}-authCodeData:$authCodeData");
// KeyIDauthUserIDmd5加密之后就是authCode
var authCode = crypto.md5.convert(authCodeData);
subData.add(authCode.bytes.length);
subData.addAll(authCode.bytes);
}
data.add(subData.length);
data.addAll(subData);
if ((data.length % 16) != 0) {
int add = (16 - data.length % 16);
for (int i = 0; i < add; i++) {
data.add(0);
}
}
print("${commandType!.typeName} SM4Data:$data");
// LockId进行SM4 ECB加密 key:544d485f633335373034383064613864
ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB);
return ebcData;
}
}
class SenderReadAdminPasswordReply extends Reply {
SenderReadAdminPasswordReply.parseData(CommandType commandType, List<int> dataDetail)
: super.parseData(commandType, dataDetail) {
data = dataDetail;
}
}

View File

@ -1,5 +1,7 @@
import 'io_type.dart';
abstract class Reply{
CommandType? commandType;

View File

@ -37,7 +37,7 @@ int _hexToInt(String hex) {
// a..f
val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)));
} else {
throw new FormatException("Invalid hexadecimal value");
throw FormatException("Invalid hexadecimal value");
}
}
return val;

View File

@ -8,6 +8,7 @@ import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart';
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsWithParameters.dart';
import 'package:star_lock/blue/io_protocol/io_referEventRecordTime.dart';
@ -299,6 +300,12 @@ class CommandReciverManager {
reply = ReadSupportFunctionsWithParametersReply.parseData(commandType, data);
}
break;
case 74:
{
//
reply = SenderReadAdminPasswordReply.parseData(commandType, data);
}
break;
}
}
break;

View File

@ -3,6 +3,7 @@ import 'package:star_lock/blue/io_protocol/io_addICCard.dart';
import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart';
import 'package:star_lock/blue/io_protocol/io_deletUser.dart';
import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart';
import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart';
import 'io_protocol/io_addFingerprint.dart';
import 'io_protocol/io_addStressFingerprint.dart';
@ -714,4 +715,30 @@ class IoSenderManage {
), callBack:callBack);
}
//todo:
static void senderReadAdminPasswordCommand({
required String? keyID,
required String? userID,
required int? role,
required int? pwdNum,
required int? pwdNo,
required List<int>? token,
required int? needAuthor,
required List<int>? publicKey,
required List<int>? privateKey,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: SenderReadAdminPasswordCommand(
keyID: keyID,
userID: userID,
role: role,
pwdNum: pwdNum,
pwdNo: pwdNo,
token: token,
needAuthor: needAuthor,
publicKey: publicKey,
privateKey: privateKey,
), callBack:callBack);
}
}

View File

@ -52,6 +52,7 @@ class GroupListData {
class GroupListItem {
int? lockNum;
int? keyGroupId;
int? groupType; // 0 1
String? keyGroupName;
List<LockListItem>? lockList;
bool _isChecked = false;
@ -60,11 +61,12 @@ class GroupListItem {
set isChecked(bool value) => _isChecked = value;
GroupListItem(
{this.lockNum, this.keyGroupId, this.keyGroupName, this.lockList});
{this.lockNum, this.keyGroupId, this.groupType, this.keyGroupName, this.lockList});
GroupListItem.fromJson(Map<String, dynamic> json) {
lockNum = json['lockNum'];
keyGroupId = json['keyGroupId'];
groupType = json['groupType'];
keyGroupName = json['keyGroupName'];
if (json['lockList'] != null) {
lockList = <LockListItem>[];
@ -78,6 +80,7 @@ class GroupListItem {
final Map<String, dynamic> data = <String, dynamic>{};
data['lockNum'] = lockNum;
data['keyGroupId'] = keyGroupId;
data['groupType'] = groupType;
data['keyGroupName'] = keyGroupName;
if (lockList != null) {
data['lockList'] = lockList!.map((v) => v.toJson()).toList();

View File

@ -0,0 +1,65 @@
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import '../../../../../blue/blue_manage.dart';
import '../../../../../blue/io_tool/io_tool.dart';
import '../../../../../blue/sender_manage.dart';
import '../../../../../tools/baseGetXController.dart';
import '../../../../../tools/storage.dart';
import '../basicInformation/basicInformation_state.dart';
class AdminOpenLockPasswordLogic extends BaseGetXController{
final BasicInformationState state = BasicInformationState();
// -
Future<void> _readAdminPassword() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.senderReadAdminPasswordCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
role:0xff,
pwdNum:5,
pwdNo: 0,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList
);
}
}, isShowLoading: true);
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
_readAdminPassword();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
}
@override
void onClose() {
// TODO: implement onClose
}
}

View File

@ -0,0 +1,16 @@
import 'package:get/get.dart';
import '../../lockSet/lockSetInfo_entity.dart';
class BasicInformationState {
var lockSetInfoData = LockSetInfoData().obs;
var lockBasicInfo = LockBasicInfo().obs;
BasicInformationState() {
var map = Get.arguments;
lockSetInfoData.value = map["lockSetInfoData"];
lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!;
}
}

View File

@ -5,4 +5,55 @@ import 'basicInformation_state.dart';
class BasicInformationLogic extends BaseGetXController{
final BasicInformationState state = BasicInformationState();
// -
// Future<void> _readAdminPassword() async {
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
// if (connectionState == DeviceConnectionState.connected) {
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
// var token = await Storage.getStringList(saveBlueToken);
// List<int> getTokenList = changeStringListToIntList(token!);
//
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
//
// IoSenderManage.senderReadAdminPasswordCommand(
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
// userID: await Storage.getUid(),
// role:0xff,
// pwdNum:5,
// pwdNo: 0,
// token: getTokenList,
// needAuthor: 1,
// publicKey: getPublicKeyList,
// privateKey: getPrivateKeyList
// );
// }
// }, isShowLoading: true);
// }
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
// _readAdminPassword();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
}
@override
void onClose() {
// TODO: implement onClose
}
}

View File

@ -49,7 +49,7 @@ class _BasicInformationPageState extends State<BasicInformationPage> {
isHaveLine: true),
CommonItem(
leftTitel: "MAC/ID",
rightTitle: state.lockBasicInfo.value.lockAlias,
rightTitle: state.lockBasicInfo.value.mac,
allHeight: 70.h,
isHaveLine: false),
SizedBox(

View File

@ -313,6 +313,7 @@ class LockBasicInfo {
int? keyType;
int? startDate;
int? endDate;
String? mac;
LockBasicInfo(
{this.keyId,
@ -326,7 +327,8 @@ class LockBasicInfo {
this.adminPwd,
this.keyType,
this.startDate,
this.endDate,});
this.endDate,
this.mac});
LockBasicInfo.fromJson(Map<String, dynamic> json) {
keyId = json['keyId'];
@ -346,6 +348,7 @@ class LockBasicInfo {
keyType = json['keyType'];
startDate = json['startDate'];
endDate = json['endDate'];
mac = json['mac'];
}
Map<String, dynamic> toJson() {
@ -364,6 +367,7 @@ class LockBasicInfo {
data['keyType'] = keyType;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['mac'] = mac;
return data;
}
}
@ -410,6 +414,9 @@ class LockSettingInfo {
String? adminPwd;
int? unlockReminderPush;
String? languageSettingLangText;
int? motorTorsion;
int? stayWarn;
int? abnormalWarn;
LockSettingInfo(
{this.remoteUnlock,
@ -433,7 +440,10 @@ class LockSettingInfo {
this.bluetoothBroadcast,
this.adminPwd,
this.unlockReminderPush,
this.languageSettingLangText});
this.languageSettingLangText,
this.motorTorsion,
this.stayWarn,
this.abnormalWarn,});
LockSettingInfo.fromJson(Map<String, dynamic> json) {
remoteUnlock = json['remoteUnlock'];
@ -463,6 +473,9 @@ class LockSettingInfo {
adminPwd = json['adminPwd'];
unlockReminderPush = json['unlockReminderPush'];
languageSettingLangText = json['languageSettingLangText'];
motorTorsion = json['motorTorsion'];
stayWarn = json['stayWarn'];
abnormalWarn = json['abnormalWarn'];
}
Map<String, dynamic> toJson() {
@ -492,6 +505,9 @@ class LockSettingInfo {
data['adminPwd'] = adminPwd;
data['unlockReminderPush'] = unlockReminderPush;
data['languageSettingLangText'] = languageSettingLangText;
data['motorTorsion'] = motorTorsion;
data['stayWarn'] = stayWarn;
data['abnormalWarn'] = abnormalWarn;
return data;
}
}

View File

@ -8,6 +8,8 @@ import 'package:star_lock/blue/io_type.dart';
import '../../../../appRouters.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_factoryDataReset.dart';
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
@ -41,6 +43,16 @@ class LockSetLogic extends BaseGetXController {
if(reply is FactoryDataResetReply){
_replyFactoryDataResetKey(reply);
}
// ()
if(reply is SetSupportFunctionsNoParametersReply) {
_replySetSupportFunctionsWithParameters(reply);
}
// ()
if((reply is ReadSupportFunctionsNoParametersReply) && (state.settingUpSupportFeatures == 56)) {
_readSupportFunctionsWithParametersReply(reply);
}
});
}
@ -153,6 +165,82 @@ class LockSetLogic extends BaseGetXController {
}
}
//
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
state.isOpenBlueBroadcast.value = reply.data[6];
print("isOpenBlueBroadcast:${state.isOpenBlueBroadcast.value}");
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
// Toast.show(msg: "操作成功");featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1;
if(state.settingUpSupportFeatures == 56){
// 广
state.isOpenBlueBroadcast.value = state.isOpenBlueBroadcast.value == 1 ? 0 : 1;
state.lockSetInfoData.value.lockSettingInfo!.bluetoothBroadcast = state.isOpenBlueBroadcast.value;
}else if(state.settingUpSupportFeatures == 61){
//
state.isOpenStayWarn.value = state.isOpenStayWarn.value == 1 ? 0 : 1;
state.lockSetInfoData.value.lockSettingInfo!.stayWarn = state.isOpenStayWarn.value;
}else if(state.settingUpSupportFeatures == 62){
//
state.isOpenExceptionWarnings.value = state.isOpenExceptionWarnings.value == 1 ? 0 : 1;
state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn = state.isOpenExceptionWarnings.value;
}
print("isOpenBlueBroadcast111:${state.isOpenBlueBroadcast.value}");
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> deletUserAction() async {
BlueManage().judgeReconnect(
@ -207,6 +295,71 @@ class LockSetLogic extends BaseGetXController {
});
}
// -
// Future<void> _readSupportFunctionsNoParameters(int type) async {
// BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
// if (connectionState == DeviceConnectionState.connected) {
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
// var token = await Storage.getStringList(saveBlueToken);
// List<int> getTokenList = changeStringListToIntList(token!);
//
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
//
// IoSenderManage.readSupportFunctionsNoParametersCommand(
// keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
// userID: await Storage.getUid(),
// featureBit: type,
// token: getTokenList,
// needAuthor: 1,
// publicKey: getPublicKeyList,
// privateKey: getPrivateKeyList
// );
// }
// }, isShowLoading: true);
// }
// ()
Future<void> sendBurglarAlarm(int type) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
state.settingUpSupportFeatures = type;
var featureEnable = 0;
if(type == 56){
// 广
featureEnable = state.isOpenBlueBroadcast.value == 1 ? 0 : 1;
}else if(type == 61){
//
featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1;
}else if(type == 62){
//
featureEnable = state.isOpenExceptionWarnings.value == 1 ? 0 : 1;
}
IoSenderManage.setSupportFunctionsNoParametersCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
featureBit: type,
featureEnable: featureEnable,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList);
}
});
}
//
void getLockSettingInfoData() async {
var entity = await ApiRepository.to.getLockSettingInfoData(
@ -218,6 +371,11 @@ class LockSetLogic extends BaseGetXController {
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;
state.isAttendance.value = state.lockSettingInfo.value.attendance!;
state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!;
state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!;
// await _readSupportFunctionsNoParameters(56);
// _readSupportFunctionsNoParameters(62);
}
}

View File

@ -336,7 +336,9 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
isHaveLine: true,
action: () {
// Toast.show(msg: "功能暂未开放");
Get.toNamed(Routers.openDoorDirectionPage);
Get.toNamed(Routers.openDoorDirectionPage, arguments: {
'lockSetInfoData': state.lockSetInfoData.value
});
})),
// ),
// Obx(() =>
@ -352,18 +354,19 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
Get.toNamed(Routers.motorPowerPage);
})),
// ),
// Obx(() =>
Visibility(
visible: true,
child: CommonItem(
leftTitel: '逗留警告',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _otherToDoSwitch(0),
)),
// ),
// Obx(() =>
Obx(() =>
Visibility(
visible: true,
child: CommonItem(
leftTitel: '逗留警告',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _lockStayWarnSwitch(),
)),
),
Obx(() =>
//
Visibility(
visible: true,
child: CommonItem(
@ -371,8 +374,17 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _otherToDoSwitch(1))),
// ),
rightWidget: _lockExceptionWarningsSwitch())),
),
// 广使
Obx(() => Visibility(
visible: true,
child: CommonItem(
leftTitel: '蓝牙广播',
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _lockBlueBroadcastSwitch()))),
SizedBox(height: 10.h),
//-----
//
@ -409,23 +421,18 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, child: _openCheckInSwitch()))),
rightWidget: _openCheckInSwitch())),
),
//
Obx(
() => Visibility(
visible: state.lockFeature.value.unlockReminder == 1
? true
: false,
visible: state.lockFeature.value.unlockReminder == 1 ? true : false,
child: CommonItem(
leftTitel:
TranslationLoader.lanKeys!.unlockReminder!.tr,
leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr,
rightTitle: "",
isHaveLine: false,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w, child: _lockRemindSwitch()))),
rightWidget: _lockRemindSwitch())),
),
SizedBox(height: 10.h),
// wifi配网
@ -434,8 +441,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
visible:
state.lockFeature.value.wifi == 1 ? true : false,
child: CommonItem(
leftTitel: TranslationLoader
.lanKeys!.wifiDistributionNetwork!.tr,
leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr,
rightTitle: "",
isHaveLine: true,
isHaveDirection: true,
@ -542,7 +548,7 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
}
CupertinoSwitch _openCheckInSwitch() {
print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
// print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}");
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
@ -574,6 +580,52 @@ class _LockSetPageState extends State<LockSetPage> with RouteAware {
);
}
//
CupertinoSwitch _lockExceptionWarningsSwitch() {
print("isOpenBlueBroadcast222:${state.isOpenExceptionWarnings.value}");
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
onChanged: (value) {
setState(() {
logic.sendBurglarAlarm(62);
});
},
);
}
//
CupertinoSwitch _lockStayWarnSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: (state.isOpenExceptionWarnings.value) == 1 ? true : false,
onChanged: (value) {
setState(() {
logic.sendBurglarAlarm(61);
});
},
);
}
// 广
CupertinoSwitch _lockBlueBroadcastSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: (state.isOpenBlueBroadcast.value) == 1 ? true : false,
onChanged: (value) {
setState(() {
logic.sendBurglarAlarm(56);
});
},
);
}
CupertinoSwitch _otherUnHaveDoneSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,

View File

@ -13,9 +13,16 @@ class LockSetState {
var isAttendance = 0.obs;//
var currentDeviceUUid = "".obs;// uuid
var isLockPickingReminder = 0.obs;//
var isOpenBlueBroadcast = 0.obs;// 广
var isOpenExceptionWarnings = 0.obs;//
var isOpenStayWarn = 0.obs;//
var passwordTF = TextEditingController();
var settingUpSupportFeatures = 0;
LockSetState() {
Map map = Get.arguments;
lockId.value = map["lockId"];

View File

@ -0,0 +1,190 @@
import 'dart:async';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/toast.dart';
import 'motorPower_state.dart';
class MotorPowerLogic extends BaseGetXController {
final MotorPowerState state = MotorPowerState();
// ->
Future<void> _setLockSetGeneralSetting() async{
var entity = await ApiRepository.to.setOpenDoorDirectionData(
lockId: state.lockSetInfoData.value.lockId!,
openDirectionValue:state.motorTorsion.value, // 1-2-;
);
if(entity.errorCode!.codeIsSuccessful){
state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.motorTorsion.value;
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
Toast.show(msg: "操作成功");
}
}
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
if(reply is SetSupportFunctionsNoParametersReply) {
_replySetSupportFunctionsWithParameters(reply);
}
// ()
if(reply is ReadSupportFunctionsNoParametersReply) {
_readSupportFunctionsWithParametersReply(reply);
}
});
}
//
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
state.motorTorsion.value = reply.data[6];
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
_setLockSetGeneralSetting();
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
// -
Future<void> _readSupportFunctionsNoParameters() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.readSupportFunctionsNoParametersCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
featureBit: 58,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList
);
}
}, isShowLoading: true);
}
// ()
Future<void> sendOpenDoorDirection() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.setSupportFunctionsWithParametersCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
featureBit: 58,
featureParaLength: 1,
featureData: [state.motorTorsion.value],
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList);
}
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
_initReplySubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
_readSupportFunctionsNoParameters();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
_replySubscription.cancel();
}
}

View File

@ -0,0 +1,19 @@
import 'package:get/get.dart';
import '../lockSet/lockSetInfo_entity.dart';
class MotorPowerState {
var lockSetInfoData = LockSetInfoData().obs;
var motorTorsion = 1.obs;
MotorPowerState() {
var map = Get.arguments;
lockSetInfoData.value = map["lockSetInfoData"];
motorTorsion.value = lockSetInfoData.value.lockSettingInfo!.motorTorsion!;
}
}

View File

@ -0,0 +1,191 @@
import 'dart:async';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import '../../../../blue/blue_manage.dart';
import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart';
import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart';
import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/toast.dart';
import 'openDoorDirection_state.dart';
class OpenDoorDirectionLogic extends BaseGetXController {
final OpenDoorDirectionState state = OpenDoorDirectionState();
// ->
Future<void> _setLockSetGeneralSetting() async{
var entity = await ApiRepository.to.setOpenDoorDirectionData(
lockId: state.lockSetInfoData.value.lockId!,
openDirectionValue:state.openDirectionValue.value, // 1-2-;
);
if(entity.errorCode!.codeIsSuccessful){
// eventBus.fire(RefreshLockListInfoDataEvent());
// state.openDirectionValue.value = state.openDirectionValue.value == 1 ? 0 : 1;
state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.openDirectionValue.value;
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
Toast.show(msg: "操作成功");
}
}
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
if(reply is SetSupportFunctionsNoParametersReply) {
_replySetSupportFunctionsWithParameters(reply);
}
// ()
if(reply is ReadSupportFunctionsNoParametersReply) {
_readSupportFunctionsWithParametersReply(reply);
}
});
}
//
Future<void> _readSupportFunctionsWithParametersReply(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
state.openDirectionValue.value = reply.data[6];
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
_setLockSetGeneralSetting();
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
// -
Future<void> _readSupportFunctionsNoParameters() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.readSupportFunctionsNoParametersCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
featureBit: 41,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList
);
}
}, isShowLoading: true);
}
// ()
Future<void> sendOpenDoorDirection() async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async {
if (connectionState == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.setSupportFunctionsNoParametersCommand(
keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
userID: await Storage.getUid(),
featureBit: 41,
featureEnable: state.openDirectionValue.value,
token: getTokenList,
needAuthor: 1,
publicKey: getPublicKeyList,
privateKey: getPrivateKeyList);
}
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
print("onReady()");
_initReplySubscription();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
print("onInit()");
_readSupportFunctionsNoParameters();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
_replySubscription.cancel();
}
}

View File

@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/titleAppBar.dart';
import 'openDoorDirection_logic.dart';
class OpenDoorDirectionPage extends StatefulWidget {
const OpenDoorDirectionPage({Key? key}) : super(key: key);
@ -12,9 +14,12 @@ class OpenDoorDirectionPage extends StatefulWidget {
}
class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
bool isCheck = false;
int selectIndex = 0;
int _selectGroupValue = 1; //
final logic = Get.put(OpenDoorDirectionLogic());
final state = Get.find<OpenDoorDirectionLogic>().state;
// bool isCheck = false;
// int selectIndex = 0;
// int _selectGroupValue = 1; //
@override
Widget build(BuildContext context) {
@ -64,7 +69,7 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
SizedBox(
width: 60.w,
),
_colorfulCheckBox(1),
Obx(() => _colorfulCheckBox(1)),
Text(
"左开",
style: TextStyle(fontSize: 24.sp),
@ -72,7 +77,7 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
SizedBox(
width: 200.w,
),
_colorfulCheckBox(2),
Obx(() => _colorfulCheckBox(2)),
Text(
'右开',
style: TextStyle(fontSize: 24.sp),
@ -85,12 +90,13 @@ class _OpenDoorDirectionPageState extends State<OpenDoorDirectionPage> {
return Radio(
value: selectIndex,
onChanged: (value) {
// print(value);
_selectGroupValue = value;
setState(() {});
print("selectIndex$selectIndex valuevaluevaluevalue:$value");
// _selectGroupValue = value;
state.openDirectionValue.value = value;
print("state.openDirectionValue.value:${state.openDirectionValue.value}");
logic.sendOpenDoorDirection();
},
groupValue: _selectGroupValue,
groupValue: state.openDirectionValue.value,
activeColor: AppColors.mainColor,
);
}

View File

@ -0,0 +1,18 @@
import 'package:get/get.dart';
import '../lockSet/lockSetInfo_entity.dart';
class OpenDoorDirectionState {
var lockSetInfoData = LockSetInfoData().obs;
var openDirectionValue = 1.obs;
OpenDoorDirectionState() {
var map = Get.arguments;
lockSetInfoData.value = map["lockSetInfoData"];
openDirectionValue.value = lockSetInfoData.value.lockSettingInfo!.openDirectionValue!;
}
}

View File

@ -4,6 +4,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/blue/io_protocol/io_editUser.dart';
@ -15,6 +16,7 @@ import 'package:star_lock/tools/toast.dart';
import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
import '../../../blue/io_protocol/io_openLock.dart';
import '../../../blue/io_protocol/io_referEventRecordTime.dart';
import '../../../blue/io_reply.dart';
import '../../../blue/io_tool/io_manager.dart';
import '../../../blue/io_tool/io_tool.dart';
@ -26,6 +28,8 @@ import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart';
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart';
import 'lockDetail_state.dart';
class LockDetailLogic extends BaseGetXController{
@ -54,6 +58,11 @@ class LockDetailLogic extends BaseGetXController{
if(reply is GetStarLockStatuInfoReply){
_replyGetStarLockStatusInfo(reply);
}
//
if(reply is SenderReferEventRecordTimeReply) {
_replyReferEventRecordTime(reply);
}
});
}
@ -80,6 +89,7 @@ class LockDetailLogic extends BaseGetXController{
case 0x00:
//
print("${reply.commandType}数据解析成功");
getLockRecordLastUploadDataTime();
state.lockState.value = 2;
state.animationController.reset();
state.animationController.forward();
@ -335,6 +345,64 @@ class LockDetailLogic extends BaseGetXController{
}
}
//
Future<void> _replyReferEventRecordTime(Reply reply) async {
int status = reply.data[2];
switch(status){
case 0x00:
//
print("${reply.commandType}数据解析成功");
if(reply.data[5] > 0){
reply.data.removeRange(0, 6);
// 8
var getList = splitList(reply.data, 8);
var uploadList = [];
for(int i = 0; i<getList.length; i++){
var indexList = getList[i];
var indexMap = {};
indexMap["seq"] = indexList[0].toString();
indexMap["user"] = indexList[3].toString();
indexMap["pwd"] = indexList[2].toString();
indexMap["success"] = "1";
indexMap["type"] = indexList[1].toString();
int value = ((0xff & indexList[(4)]) << 24 |
(0xff & indexList[5]) << 16 |
(0xff & indexList[6]) << 8 |
(0xFF & indexList[7]));
// indexMap["date"] = DateTool().dateToYMDHNSString("$value");
// print("value${DateTool().dateToYMDHNSString("$value")}");
indexMap["date"] = "${value*1000}";
uploadList.add(indexMap);
}
lockRecordUploadData(uploadList);
// print("reply.data:${reply.data} getList:$getList}");
}
break;
case 0x06:
//
print("${reply.commandType}需要鉴权");
break;
case 0x07:
//
print("${reply.commandType}用户无权限");
break;
case 0x09:
//
print("${reply.commandType}权限校验错误");
break;
default:
//
print("${reply.commandType}失败");
break;
}
}
//
Future<void> openDoorAction() async {
// if(BlueManage().connectDeviceMacAddress.isEmpty){
@ -431,6 +499,34 @@ class LockDetailLogic extends BaseGetXController{
}, isShowLoading: false);
}
// ()
Future<void> senderReferEventRecordTime(int time) async {
BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async {
if (state == DeviceConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
IoSenderManage.senderReferEventRecordTimeCommand(
keyID:BlueManage().connectDeviceName,
userID:await Storage.getUid(),
logsCount:20,
// time:DateTime.now().millisecondsSinceEpoch~/1000,
time: time,
token:getTokenList,
needAuthor:1,
publicKey:getPublicKeyList,
privateKey:getPrivateKeyList,
);
}
});
}
void startScanAction(){
BlueManage().startScan(true, (v){
print("startScanAllDevice:${v}");
@ -467,6 +563,26 @@ class LockDetailLogic extends BaseGetXController{
}
//
void getLockRecordLastUploadDataTime() async {
LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) {
senderReferEventRecordTime(entity.data!.operateDate!~/1000);
}
}
//
void lockRecordUploadData(List list) async {
KeyOperationRecordEntity entity =
await ApiRepository.to.lockRecordUploadData(
lockId: state.keyInfos.value.lockId.toString(),
records: list);
if (entity.errorCode!.codeIsSuccessful) {
// mockNetworkDataRequest();
}
}
@override
void onReady() {
// TODO: implement onReady

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -5,6 +6,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyO
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/custom_bottom_sheet.dart';
import '../../../tools/jh_pop_menus.dart';
import '../../../tools/noData.dart';
import '../../../tools/storage.dart';
@ -44,19 +46,21 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
onPressed: () async {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if(isDemoMode == false){
JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
print('选中index: $index');
print('选中text: $selText');
if (index == 0) {
logic.mockNetworkDataRequest();
} else if (index == 1) {
logic.clearOperationRecordRequest();
}
}, listData: [
{'text': '读取记录'},
{'text': '清空记录'},
{'text': '导出记录'},
]);
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
// print('选中index: $index');
// print('选中text: $selText');
// if (index == 0) {
// logic.mockNetworkDataRequest();
// } else if (index == 1) {
// logic.clearOperationRecordRequest();
// }
// }, listData: [
// {'text': '读取记录'},
// {'text': '清空记录'},
// {'text': '导出记录'},
// ]);
_openModalBottomSheet();
}else{
// Get.toNamed(Routers.seletLockTypePage);
Toast.show(msg: "演示模式");
@ -77,7 +81,7 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
),
_searchWidget(),
SizedBox(
height: 10.h,
height: 10.h
),
Expanded(child: _buildMainUI()),
],
@ -128,7 +132,6 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
int? operateDate = dataItem.operateDate;
DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!);
String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} ';
return _operatingRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () {
});
@ -238,4 +241,26 @@ class _LockOperatingRecordPageState extends State<LockOperatingRecordPage> {
),
);
}
Future _openModalBottomSheet() async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
builder: (BuildContext context) {
return AlertBottomWidget(
topTitle: '',
items: const ['读取记录', '清空记录', '导出记录'],
chooseCallback: (value) {
int getSelectIndex = value;
if (getSelectIndex == 0) {
logic.mockNetworkDataRequest();
} else if (getSelectIndex == 1) {
logic.clearOperationRecordRequest();
}
},
);
});
}
}

View File

@ -29,18 +29,6 @@ class _LockListPageState extends State<LockListPage> {
}
groupDataList.addAll(widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
// return ListView.builder(
// itemCount: dataList.length,
// itemBuilder: (c, index) {
// GroupList keyInfo = dataList[index];
// return lockInfoListItem('images/icon_lock.png', keyInfo.groupName, () {
// // Get.toNamed(Routers.lockDetailMainPage, arguments: {
// // "lockMainEntity": widget.lockMainEntity,
// // "keyInfo": keyInfo
// // });
// });
// });
return ListView.separated(
itemCount: groupDataList.length,
itemBuilder: (context, index) {
@ -48,6 +36,7 @@ class _LockListPageState extends State<LockListPage> {
return _buildLockExpandedList(context, index, itemData);
},
shrinkWrap: true,
physics:const AlwaysScrollableScrollPhysics(),
separatorBuilder: (context, index) {
return const Divider(
height: 1,
@ -94,12 +83,18 @@ class _LockListPageState extends State<LockListPage> {
child: ListView.separated(
itemCount: lockItemList.length,
shrinkWrap: true,
physics:const NeverScrollableScrollPhysics(),
separatorBuilder: (context, index) {
return const Divider(height: 1, color: AppColors.greyLineColor);
},
itemBuilder: (c, index) {
LockListInfoItemEntity keyInfo = lockItemList[index];
return lockInfoListItem(keyInfo, () {
bool isLast = false;
if (lockItemList.length == index+1){
isLast = true;
}
// print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast");
return lockInfoListItem(keyInfo, isLast, () {
Get.toNamed(Routers.lockDetailMainPage, arguments: {
// "lockMainEntity": widget.lockMainEntity,
"keyInfo": keyInfo
@ -109,12 +104,12 @@ class _LockListPageState extends State<LockListPage> {
);
}
Widget lockInfoListItem(LockListInfoItemEntity keyInfo, Function() action) {
Widget lockInfoListItem(LockListInfoItemEntity keyInfo, bool isLast, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
// height: 122.h,
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.w),

View File

@ -20,7 +20,6 @@ import '../../../../translations/trans_lib.dart';
import 'lockAddressGaoDe_logic.dart';
class LockAddressGaoDePage extends StatefulWidget {
const LockAddressGaoDePage({Key? key}) : super(key: key);
@override
@ -141,7 +140,7 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>{
height: 1.sw/5*4,
width: 1.sw,
child:
(addressInfo!["address"].toString().isNotEmpty) ?
(addressInfo!["address"].toString().isNotEmpty) ?
AMapWidget(
apiKey: amapApiKeys,
//

View File

@ -1,7 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:get/get.dart';
@ -9,22 +7,18 @@ import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../blue/blue_manage.dart';
import '../../../blue/io_protocol/io_addUser.dart';
import '../../../blue/io_protocol/io_getLockStatu.dart';
import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart';
import '../../../blue/io_reply.dart';
import '../../../blue/io_tool/io_manager.dart';
import '../../../blue/io_tool/io_tool.dart';
import '../../../blue/io_tool/manager_event_bus.dart';
import '../../../blue/sender_manage.dart';
import '../../../network/api_repository.dart';
import '../../../tools/baseGetXController.dart';
import '../../../tools/dateTool.dart';
import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart';
import 'saveLock_state.dart';
class SaveLockLogic extends BaseGetXController {
final SaveLockState state = SaveLockState();
//
@ -39,7 +33,6 @@ class SaveLockLogic extends BaseGetXController {
if(reply is GetStarLockStatuInfoReply) {
_replyGetStarLockStatusInfo(reply);
}
});
}
@ -193,9 +186,15 @@ class SaveLockLogic extends BaseGetXController {
state.lockInfo["indate"] = indateValue*1000;
// print("indate:$indate indateValue:$indateValue");
var index = 153;
// mac地址
var macAddress = reply.data.sublist(153, 173);
var macAddressStr = utf8String(macAddress);
state.lockInfo["mac"] = macAddressStr;
print("macAddress:$macAddress macAddressStr:$macAddressStr");
var index = 173;
//
var featureValueLength = reply.data[153];
var featureValueLength = reply.data[173];
// ()
//
var featureValue = reply.data.sublist(index+1, index + featureValueLength+1);

View File

@ -42,7 +42,7 @@ class SafeVerifyState {
///
void initLoginData() async {
final data = await Storage.getString('userLoginData');
print("getLoginData:$data");
// print("getLoginData:$data");
if (data != null && data.isNotEmpty) {
loginData.value = LoginData.fromJson(jsonDecode(data));

View File

@ -19,7 +19,7 @@ class StarLockMineState {
///
void initLoginData() async {
final data = await Storage.getString('userLoginData');
print("getLoginData:$data");
// print("getLoginData:$data");
if (data != null && data.isNotEmpty) {
loginData.value = LoginData.fromJson(jsonDecode(data));
}

View File

@ -44,7 +44,7 @@ class PersonInfoEditAccountState {
///
void initLoginData() async {
final data = await Storage.getString('userLoginData');
print("getLoginData:$data");
// print("getLoginData:$data");
if (data != null && data.isNotEmpty) {
loginData.value = LoginData.fromJson(jsonDecode(data));
}

View File

@ -37,15 +37,15 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
barTitle: TranslationLoader
.lanKeys!.appUnlockRequiresMobilePhoneAccessToTheLock!.tr,
haveBack: true,
actionsList: [
IconButton(
onPressed: () {},
icon: Image.asset(
"images/icon_bar_search.png",
width: 30.w,
height: 30.w,
))
],
// actionsList: [
// IconButton(
// onPressed: () {},
// icon: Image.asset(
// "images/icon_bar_search.png",
// width: 30.w,
// height: 30.w,
// ))
// ],
backgroundColor: AppColors.mainColor),
body: Column(
children: [
@ -99,11 +99,11 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
itemCount: state.lockItemList.value.length,
itemBuilder: (c, index) {
LockItemData itemData = state.lockItemList.value[index];
if(state.isCheckAll.value == true){
itemData.isCheck = true;
}else{
itemData.isCheck = false;
}
// if(state.isCheckAll.value == true){
// itemData.isCheck = true;
// }else{
// itemData.isCheck = false;
// }
return _gatewatListItem(itemData);
})),
),
@ -133,6 +133,12 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State<APPUnlockNeedMob
} else {
state.selectLockIdList.remove(itemData.lockId);
}
if(state.selectLockIdList.length == state.lockItemList.length){
state.isCheckAll.value = true;
}else{
state.isCheckAll.value = false;
}
});
},
child: Container(

View File

@ -1,109 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/submitBtn.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
class GroupAddLockPage extends StatefulWidget {
const GroupAddLockPage({Key? key}) : super(key: key);
@override
State<GroupAddLockPage> createState() => _GroupAddLockPageState();
}
class _GroupAddLockPageState extends State<GroupAddLockPage> {
List<LockListItem> lockList = [];
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["lockList"] != null)) {
lockList = obj["lockList"];
}
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.lock!.tr,
haveBack: true,
actionsList: [
IconButton(
icon: Image.asset(
'images/icon_bar_more.png',
height: 30.h,
width: 10.w,
),
onPressed: () {
// -
},
),
],
backgroundColor: AppColors.mainColor),
body: lockList.isNotEmpty
? ListView.separated(
itemBuilder: (context, index) {
LockListItem itemData = lockList[index];
return _listItemView(itemData);
},
itemCount: lockList.length,
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1.h,
color: AppColors.greyLineColor,
);
},
)
: Stack(
alignment: Alignment.center,
children: [
Positioned(
bottom: 350.h,
left: (ScreenUtil().screenWidth - 200.w) / 2,
width: 200.w,
child: SubmitBtn(
btnName: '添加',
onClick: () {
//
},
)),
const NoData(),
],
));
}
Widget _listItemView(LockListItem itemData) {
return GestureDetector(
child: Container(
color: Colors.white,
height: 80.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 20.w,
),
Image.asset(
'images/icon_lockGroup_item.png',
width: 36,
height: 36,
fit: BoxFit.fill,
),
SizedBox(
width: 10.w,
),
Text(
itemData.lockAlias ?? '',
style: TextStyle(fontSize: 24.sp),
)
],
),
),
onTap: () {},
);
}
}

View File

@ -0,0 +1,37 @@
import 'package:get/get.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/toast.dart';
import 'groupEditLock_state.dart';
class GroupEditLockLogic extends BaseGetXController {
final GroupEditLockState state = GroupEditLockState();
//
Future<void> lockGroupAddLock(List lockId) async {
var entity = await ApiRepository.to.lockGroupAddLock(
lockIds: lockId,
groupId: state.seletGroupListItem.keyGroupId!);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "添加成功");
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
eventBus.fire(RefreshLockListInfoDataEvent());
Get.close(2);
}
}
//
Future<void> lockGroupDeletLock(List lockId) async {
var entity = await ApiRepository.to.lockGroupDeletLock(lockIds: lockId);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功");
eventBus.fire(LockGroupEditGroupLockRefreshEvent());
eventBus.fire(RefreshLockListInfoDataEvent());
Get.close(2);
}
}
}

View File

@ -0,0 +1,117 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import 'package:star_lock/tools/noData.dart';
import '../../../../../../app_settings/app_colors.dart';
import '../../../../../../tools/titleAppBar.dart';
import '../../../../../../translations/trans_lib.dart';
import '../../../../tools/submitBtn.dart';
import 'groupEditLock_logic.dart';
class GroupEditLockPage extends StatefulWidget {
const GroupEditLockPage({Key? key}) : super(key: key);
@override
State<GroupEditLockPage> createState() => _GroupEditLockPageState();
}
class _GroupEditLockPageState extends State<GroupEditLockPage> {
final logic = Get.put(GroupEditLockLogic());
final state = Get.find<GroupEditLockLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: state.type == 0 ? TranslationLoader.lanKeys!.add!.tr : TranslationLoader.lanKeys!.delete!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
Container(
margin: EdgeInsets.all(15.w),
child: Row(
children: [
Text("选择要加入分组的锁", style: TextStyle(fontSize: 25.sp)),
],
),
),
Expanded(child: _buildMainUI()),
SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async {
var idList = [];
for(int i = 0; i<state.lockList.length; i++){
LockListItem lockListItem = state.lockList[i];
if(lockListItem.isChecked == true){
idList.add(lockListItem.lockId);
}
}
if(state.type == 0){
//
logic.lockGroupAddLock(idList);
}else if(state.type == 1){
//
logic.lockGroupDeletLock(idList);
}
}),
SizedBox(height: 20.h)
],
));
}
Widget _buildMainUI(){
return state.lockList.isNotEmpty
? ListView.separated(
itemBuilder: (context, index) {
LockListItem itemData = state.lockList[index];
return _listItemView(itemData);
},
itemCount: state.lockList.length,
separatorBuilder: (BuildContext context, int index) {
return Divider(
height: 1.h,
color: AppColors.greyLineColor,
);
},
) : const NoData();
}
Widget _listItemView(LockListItem itemData) {
return Container(
color: Colors.white,
height: 80.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(width: 20.w,),
Image.asset('images/icon_lockGroup_item.png', width: 36, height: 36, fit: BoxFit.fill,),
SizedBox(width: 10.w,),
Text(
itemData.lockAlias ?? '',
style: TextStyle(fontSize: 24.sp),
),
Expanded(child: SizedBox(width: 10.w)),
GestureDetector(
child: Image.asset(
itemData.isChecked
? 'images/icon_round_selet.png'
: 'images/icon_round_unSelet.png',
width: 35.w,
height: 35.w,
),
onTap: (){
setState(() {
itemData.isChecked = !itemData.isChecked;
});
},
),
SizedBox(width: 30.w)
],
),
);
}
}

View File

@ -0,0 +1,26 @@
import 'package:get/get.dart';
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
class GroupEditLockState {
var lockList = <LockListItem>[];
var type = 0;// 0 1
var seletGroupListItem = GroupListItem();
var ungrouped = GroupListItem();
GroupEditLockState() {
Map map = Get.arguments;
type = map["type"];
seletGroupListItem = map["groupListItem"];
ungrouped = map["ungrouped"];
if(type == 0){
lockList = ungrouped.lockList!;
}else{
lockList = seletGroupListItem.lockList!;
}
for(int i = 0; i<lockList.length; i++){
LockListItem lockListItem = lockList[i];
lockListItem.isChecked = false;
}
}
}

View File

@ -5,9 +5,12 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/submitBtn.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
import '../../../../../../app_settings/app_colors.dart';
import '../../../../../../tools/titleAppBar.dart';
import '../../../../../../translations/trans_lib.dart';
import '../../../../appRouters.dart';
import '../../../../tools/custom_bottom_sheet.dart';
import '../../../../tools/jh_pop_menus.dart';
class LockItemListPage extends StatefulWidget {
const LockItemListPage({Key? key}) : super(key: key);
@ -18,19 +21,21 @@ class LockItemListPage extends StatefulWidget {
class _LockItemListPageState extends State<LockItemListPage> {
List<LockListItem> lockList = [];
var ungrouped = GroupListItem();
@override
Widget build(BuildContext context) {
dynamic obj = ModalRoute.of(context)?.settings.arguments;
if (obj != null && (obj["lockList"] != null)) {
lockList = obj["lockList"];
}
Map map = Get.arguments;
GroupListItem groupListItem = map["groupListItem"];
lockList = groupListItem.lockList!;
ungrouped = map["ungrouped"];
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.lock!.tr,
haveBack: true,
actionsList: [
actionsList: (lockList.isNotEmpty && groupListItem.groupType == 0) ? [
IconButton(
icon: Image.asset(
'images/icon_bar_more.png',
@ -38,10 +43,26 @@ class _LockItemListPageState extends State<LockItemListPage> {
width: 10.w,
),
onPressed: () {
// -
//
_openModalBottomSheet(groupListItem);
// JhPopMenus.showLinePop(context, clickCallback: (index, selText) {
// print('选中index: $index');
// print('选中text: $selText');
// if (index == 0) {
// Get.back();
// // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
// } else if (index == 1) {
// Get.back();
// Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
// }
// }, listData: [
// {'text': '添加'},
// {'text': '删除'},
// ]);
},
),
],
] :[],
backgroundColor: AppColors.mainColor),
body: lockList.isNotEmpty
? ListView.separated(
@ -68,6 +89,7 @@ class _LockItemListPageState extends State<LockItemListPage> {
btnName: '添加',
onClick: () {
//
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
},
)),
const NoData(),
@ -106,4 +128,26 @@ class _LockItemListPageState extends State<LockItemListPage> {
onTap: () {},
);
}
Future _openModalBottomSheet(GroupListItem groupListItem) async {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(10)),
builder: (BuildContext context) {
return AlertBottomWidget(
topTitle: '',
items: const ['添加', '删除'],
chooseCallback: (value) {
int getSelectIndex = value;
if (getSelectIndex == 0) {
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0});
} else if (getSelectIndex == 1) {
Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1});
}
},
);
});
}
}

View File

@ -0,0 +1,82 @@
import 'dart:async';
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/toast.dart';
import 'lockGroupList_state.dart';
class LockGroupListLogic extends BaseGetXController {
final LockGroupListState state = LockGroupListState();
//
void mockNetworkDataRequest() async {
var entity = await ApiRepository.to.lockGroupList('1');
if (entity.errorCode!.codeIsSuccessful) {
if (entity.data != null) {
state.lockNum = 0;
state.itemDataList.value = entity.data!.groupList!;
}
}
}
//
Future<void> addLockGroupRequest() async {
MassSendLockGroupListEntity entity =
await ApiRepository.to.addLockGroup(state.changeNameController.text, '0');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "创建成功");
mockNetworkDataRequest();
}
}
//
Future<void> editLockGroupRequest(int groupId) async {
var entity = await ApiRepository.to.editLockGroupRequest(groupId:groupId, groupName:state.changeNameController.text);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "编辑成功");
mockNetworkDataRequest();
}
}
//
Future<void> deleteLockGroupRequest(int groupId) async {
var entity = await ApiRepository.to.deleteGroup(groupId);
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "删除成功");
mockNetworkDataRequest();
}
}
//
late StreamSubscription _teamEvent;
void _initRefreshAction() {
_teamEvent = eventBus.on<LockGroupEditGroupLockRefreshEvent>().listen((event) {
mockNetworkDataRequest();
});
}
@override
void onReady() {
// TODO: implement onReady
super.onReady();
_initRefreshAction();
mockNetworkDataRequest();
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
}
@override
void onClose() {
// TODO: implement onClose
_teamEvent.cancel();
}
}

View File

@ -0,0 +1,217 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import 'package:star_lock/tools/showTFView.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../../appRouters.dart';
import '../../../../../../app_settings/app_colors.dart';
import '../../../../../../tools/commonItem.dart';
import '../../../../../../tools/titleAppBar.dart';
import '../../../../../../translations/trans_lib.dart';
import '../../../../tools/left_slide_actions.dart';
import '../../../../tools/noData.dart';
import '../../../../tools/showIosTipView.dart';
import 'lockGroupList_logic.dart';
class LockGroupListPage extends StatefulWidget {
const LockGroupListPage({Key? key}) : super(key: key);
@override
State<LockGroupListPage> createState() => _LockGroupListPageState();
}
class _LockGroupListPageState extends State<LockGroupListPage> {
final logic = Get.put(LockGroupListLogic());
final state = Get.find<LockGroupListLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
haveBack: true,
actionsList: [
IconButton(
icon: Image.asset(
'images/icon_add_white.png',
width: 36.w,
height: 36.w,
),
onPressed: () {
// -
showCupertinoAlertDialog(context, true, 0);
},
),
],
backgroundColor: AppColors.mainColor),
body: Column(
children: [
Expanded(child: Obx(() => state.itemDataList.value.isEmpty ? const NoData(): _buildMainUI())),
],
),
);
}
Widget _buildMainUI() {
for (int i = 0; i < state.itemDataList.value.length; i++) {
GroupListItem itemData = state.itemDataList.value[i];
state.lockNum += itemData.lockList!.length;
}
return ListView.separated(
itemCount: state.itemDataList.value.length + 1,
itemBuilder: (c, index) {
if (index == state.itemDataList.value.length) {
return Center(
child: Column(
children: [
SizedBox(
height: 20.h,
),
SizedBox(
height: 40.h,
child: Text(
'锁数量:${state.lockNum.toString()}',
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
),
)
],
),
);
} else {
GroupListItem itemData = state.itemDataList.value[index];
if(itemData.groupType == 0){
state.ungrouped = itemData;
}
if (index < state.itemDataList.value.length) {
return LeftSlideActions(
key: Key(itemData.keyGroupId!.toString()),
actionsWidth: itemData.groupType != 0 ? 200.w : 0,
actions: itemData.groupType != 0 ? [
_buildEditBtn(itemData),
_buildDeleteBtn(itemData),
] : [],
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(1)),
),
child: CommonItem(
leftTitel:
'${itemData.keyGroupName}(${itemData.lockList?.length})',
rightTitle: "",
allHeight: 70.h,
action: () {
Get.toNamed(Routers.lockItemListPage, arguments: {'groupListItem': itemData, "ungrouped": state.ungrouped});
}),
);
}
return const SizedBox.shrink();
}
},
separatorBuilder: (BuildContext context, int index) {
return const Divider(
height: 1,
color: AppColors.greyLineColor,
);
});
}
void showCupertinoAlertDialog(BuildContext context, bool isAdd, int groupId) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
controller: state.changeNameController,
sureClick: () {
//
if (state.changeNameController.text.isNotEmpty) {
if(isAdd == true){
logic.addLockGroupRequest();
}else{
logic.editLockGroupRequest(groupId);
}
Navigator.pop(context);
} else {
Toast.show(msg: '请输入分组名称');
}
},
cancelClick: () {
Navigator.pop(context);
},
);
},
);
}
Widget _buildDeleteBtn(GroupListItem groupListItem) {
return GestureDetector(
onTap: () {
// :
showIosTipViewDialog(context, groupListItem);
},
child: Container(
width: 100.w,
color: const Color(0xFFF20101),
alignment: Alignment.center,
child: const Text(
'删除',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
height: 1,
),
),
),
);
}
Widget _buildEditBtn(GroupListItem groupListItem) {
return GestureDetector(
onTap: () {
//
state.changeNameController.text = groupListItem.keyGroupName!;
showCupertinoAlertDialog(context, false, groupListItem.keyGroupId!);
},
child: Container(
width: 100.w,
color: AppColors.mainColor,
alignment: Alignment.center,
child: const Text(
'编辑',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
height: 1,
),
),
),
);
}
void showIosTipViewDialog(BuildContext context, GroupListItem groupListItem) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowIosTipView(
title: "提示",
tipTitle: "确定要删除吗?",
sureClick: () {
Get.back();
logic.deleteLockGroupRequest(groupListItem.keyGroupId!);
},
cancelClick: () {
Get.back();
},
);
}
);
}
}

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
class LockGroupListState {
TextEditingController changeNameController = TextEditingController();
var itemDataList = <GroupListItem>[].obs;
int lockNum = 0;
var ungrouped = GroupListItem();
}

View File

@ -1,158 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/showTFView.dart';
import 'package:star_lock/tools/toast.dart';
import '../../../../../appRouters.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart';
import '../../../../../tools/titleAppBar.dart';
import '../../../../../translations/trans_lib.dart';
class LockGroupListPage extends StatefulWidget {
const LockGroupListPage({Key? key}) : super(key: key);
@override
State<LockGroupListPage> createState() => _LockGroupListPageState();
}
class _LockGroupListPageState extends State<LockGroupListPage> {
TextEditingController _changeNameController = TextEditingController();
List<GroupListItem> itemDataList = [];
int lockNum = 0;
@override
void initState() {
super.initState();
mockNetworkDataRequest();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.lockGroup!.tr,
haveBack: true,
actionsList: [
IconButton(
icon: Image.asset(
'images/icon_add_white.png',
width: 36.w,
height: 36.w,
),
onPressed: () {
// -
showCupertinoAlertDialog(context);
},
),
],
backgroundColor: AppColors.mainColor),
body: Column(
children: [
Expanded(child: _buildMainUI()),
],
),
);
}
Widget _buildMainUI() {
for (int i = 0; i < itemDataList.length; i++) {
GroupListItem itemData = itemDataList[i];
lockNum += itemData.lockList!.length;
}
return ListView.builder(
itemCount: itemDataList.length + 1,
itemBuilder: (c, index) {
if (index == itemDataList.length) {
return Center(
child: Column(
children: [
SizedBox(
height: 20.h,
),
SizedBox(
height: 40.h,
child: Text(
'锁数量:${lockNum.toString()}',
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 20.sp),
),
)
],
),
);
} else {
GroupListItem itemData = itemDataList[index];
return CommonItem(
leftTitel:
'${itemData.keyGroupName}(${itemData.lockList?.length})',
rightTitle: "",
allHeight: 70.h,
isHaveLine: true,
action: () {
Navigator.pushNamed(context, Routers.lockItemListPage,
arguments: {'lockList': itemData.lockList});
});
}
});
}
//
Future<List<GroupListItem>> mockNetworkDataRequest() async {
MassSendLockGroupListEntity entity =
await ApiRepository.to.lockGroupList('1');
List<GroupListItem> dataList = [];
if (entity.errorCode!.codeIsSuccessful) {
if (entity.data != null) {
dataList = entity.data!.groupList!;
}
}
setState(() {
itemDataList = dataList;
});
return dataList;
}
//
Future<void> addLockGroupRequest() async {
MassSendLockGroupListEntity entity =
await ApiRepository.to.addLockGroup(_changeNameController.text, '0');
if (entity.errorCode!.codeIsSuccessful) {
Toast.show(msg: "创建成功");
mockNetworkDataRequest();
setState(() {});
}
}
void showCupertinoAlertDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return ShowTFView(
title: TranslationLoader.lanKeys!.createNewGroup!.tr,
tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr,
controller: _changeNameController,
sureClick: () {
//
if (_changeNameController.text.isNotEmpty) {
addLockGroupRequest();
Navigator.pop(context);
} else {
Toast.show(msg: '请输入分组名称');
}
},
cancelClick: () {
Navigator.pop(context);
},
);
},
);
}
}

View File

@ -47,12 +47,17 @@ abstract class Api {
final String updatePasswordKeyURL = '/keyboardPwd/update'; //
final String clearOperationRecordURL = '/lockRecords/clear'; //
final String addlockGroupURL = '/keyGroup/add'; //
final String editlockGroupURL = '/keyGroup/modifyGroupName'; //
final String setlockGroupURL = '/keyGroup/setGroup'; //
final String lockGroupListURL = '/authorizedAdmin/listGroup'; //
final String lockDeletGroupURL = '/keyGroup/delete'; //
final String lockGroupAddLockURL = '/keyGroup/addLockGroup'; //
final String lockGroupDeletLockURL = '/keyGroup/deleteLockGroup'; //
final String listLockByGroupURL = '/authorizedAdmin/listLockByGroup'; //
final String setRoomStatusURL = '/lock/updateLockStatus'; //
final String keyGroupListURL = '/keyGroup/list'; //
final String lockListByGroupURL = '/room/listByGroup'; //
// final String keyGroupListURL = '/keyGroup/list'; //
// final String lockListByGroupURL = '/room/listByGroup'; //
final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // Wifi锁服务器
final String updateLockSettingUrl = '/lockSetting/updateLockSetting'; //

View File

@ -444,6 +444,11 @@ class ApiProvider extends BaseProvider {
addlockGroupURL.toUrl,
jsonEncode({'groupName': groupName, 'operatorUid': operatorUid}));
//
Future<Response> editLockGroupRequest(int groupId, String groupName) => post(
editlockGroupURL.toUrl,
jsonEncode({'groupId': groupId, 'groupName': groupName}));
Future<Response> setLockGroup(String lockId, String groupId) => post(
setlockGroupURL.toUrl,
jsonEncode({'lockId': lockId, 'groupId': groupId}));
@ -451,6 +456,28 @@ class ApiProvider extends BaseProvider {
Future<Response> lockGroupList(String type) =>
post(lockGroupListURL.toUrl, jsonEncode({'type': type}));
//
Future<Response> deleteGroup(int groupId) => post(
lockDeletGroupURL.toUrl,
jsonEncode({
'groupId': groupId,
}));
//
Future<Response> lockGroupAddLock(List lockIds, int groupId) => post(
lockGroupAddLockURL.toUrl,
jsonEncode({
'lockId': lockIds,
'groupId': groupId,
}));
//
Future<Response> lockGroupDeletLock(List lockIds) => post(
lockGroupDeletLockURL.toUrl,
jsonEncode({
'lockId': lockIds,
}));
Future<Response> selectLockList() =>
post(selectLockListURL.toUrl, jsonEncode({}));
@ -501,12 +528,12 @@ class ApiProvider extends BaseProvider {
// post(updateSettingURL.toUrl,
// jsonEncode({'lockId': lockId, 'isOn': isOn, 'type': type}));
Future<Response> keyGroupList(String type) =>
post(keyGroupListURL.toUrl, jsonEncode({'type': type}));
Future<Response> lockListByGroup(String type, String keyGroupId) => post(
lockListByGroupURL.toUrl,
jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
// Future<Response> keyGroupList(String type) =>
// post(keyGroupListURL.toUrl, jsonEncode({'type': type}));
//
// Future<Response> lockListByGroup(String type, String keyGroupId) => post(
// lockListByGroupURL.toUrl,
// jsonEncode({'type': type, 'keyGroupId': keyGroupId}));
///
//
@ -539,6 +566,16 @@ class ApiProvider extends BaseProvider {
'antiPrySwitch': antiPrySwitch,
}));
//
Future<Response> setOpenDoorDirectionData(
int lockId, int openDirectionValue) =>
post(
updateLockSettingUrl.toUrl,
jsonEncode({
'lockId': lockId,
'openDirectionValue': openDirectionValue,
}));
//
Future<Response> remoteUnlockingOpenOrCloseLoadData(int lockId, int remoteUnlock) =>
post(

View File

@ -32,7 +32,7 @@ class BaseProvider extends GetConnect with Api {
// print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}");
if (isUnShowLoading == false) EasyLoading.show();
print('哈喽请求body体为${body}');
print('星锁请求body体为${body}');
var res = await super.post(url, body,
contentType: contentType,
headers: headers,

View File

@ -440,6 +440,15 @@ class ApiRepository {
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<MassSendLockGroupListEntity> editLockGroupRequest({
required int groupId,
required String groupName
}) async {
final res = await apiProvider.editLockGroupRequest(groupId, groupName);
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<MassSendLockGroupListEntity> setLockGroup(
String lockId, String groupId) async {
@ -453,6 +462,34 @@ class ApiRepository {
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<MassSendLockGroupListEntity> deleteGroup(int groupId) async {
final res =
await apiProvider.deleteGroup(groupId);
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<MassSendLockGroupListEntity> lockGroupAddLock(
{
required List lockIds,
required int groupId
}) async {
final res =
await apiProvider.lockGroupAddLock(lockIds, groupId);
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<MassSendLockGroupListEntity> lockGroupDeletLock(
{
required List lockIds
}) async {
final res =
await apiProvider.lockGroupDeletLock(lockIds);
return MassSendLockGroupListEntity.fromJson(res.body);
}
//
Future<SelectLockListEntity> selectLockList() async {
final res = await apiProvider.selectLockList();
@ -505,18 +542,18 @@ class ApiRepository {
return PasswordKeyEntity.fromJson(res.body);
}
//
Future<PasswordKeyEntity> keyGroupList(String type) async {
final res = await apiProvider.keyGroupList(type);
return PasswordKeyEntity.fromJson(res.body);
}
//
Future<PasswordKeyEntity> lockListByGroup(
String type, String keyGroupId) async {
final res = await apiProvider.lockListByGroup(type, keyGroupId);
return PasswordKeyEntity.fromJson(res.body);
}
// //
// Future<PasswordKeyEntity> keyGroupList111(String type) async {
// final res = await apiProvider.keyGroupList(type);
// return PasswordKeyEntity.fromJson(res.body);
// }
//
// //
// Future<PasswordKeyEntity> lockListByGroup111(
// String type, String keyGroupId) async {
// final res = await apiProvider.lockListByGroup(type, keyGroupId);
// return PasswordKeyEntity.fromJson(res.body);
// }
// Wifi锁服务器
Future<ConfiguringWifiEntity> getWifiLockServiceIpAndPort() async {
@ -585,6 +622,16 @@ class ApiRepository {
return LoginEntity.fromJson(res.body);
}
//
Future<LoginEntity> setOpenDoorDirectionData({
required int lockId,
required int openDirectionValue,
}) async {
final res =
await apiProvider.setOpenDoorDirectionData(lockId, openDirectionValue);
return LoginEntity.fromJson(res.body);
}
//
Future<LoginEntity> setRoomStatusData({
required int lockId,

View File

@ -42,4 +42,9 @@ class ScanAllDeviceFindCurrentDeviceConnectedEvent{
class ChangeLanguageBlockLastLanguageEvent{
String languageTitle;
ChangeLanguageBlockLastLanguageEvent(this.languageTitle);
}
///
class LockGroupEditGroupLockRefreshEvent{
LockGroupEditGroupLockRefreshEvent();
}

View File

@ -88,8 +88,7 @@ class _LeftSlideActionsState extends State<LeftSlideActions>
}
void _onHorizontalDragUpdate(DragUpdateDetails details) {
_translateX =
(_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0);
_translateX = (_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0);
setState(() {});
}