fix: 调整列表左滑无法删除的问题

This commit is contained in:
liyi 2025-10-23 09:49:21 +08:00
parent a4892633a3
commit 5ed7e4013e
4 changed files with 20 additions and 20 deletions

View File

@ -96,8 +96,8 @@ class LockListLogic extends BaseGetXController {
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: '1', keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(), publicKey: state.lockListInfoItemEntity.value.bluetooth!.publicKey!.cast<int>(),
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(), privateKey: state.lockListInfoItemEntity.value.bluetooth!.privateKey!.cast<int>(),
token: getTokenList); token: getTokenList);
break; break;
case 0x07: case 0x07:
@ -173,7 +173,7 @@ class LockListLogic extends BaseGetXController {
/// ///
void deleyLockLogicOfRoles() { void deleyLockLogicOfRoles() {
if (state.lockListInfoItemEntity.isLockOwner == 1) { if (state.lockListInfoItemEntity.value.isLockOwner == 1) {
// //
showTipView.showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () { showTipView.showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr, () {
// //
@ -181,7 +181,7 @@ class LockListLogic extends BaseGetXController {
showTipView.resetGetController(); showTipView.resetGetController();
showTipView.showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword); showTipView.showTFViewAlertDialog(state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
}); });
} else if (state.lockListInfoItemEntity.keyRight == 1) { } else if (state.lockListInfoItemEntity.value.keyRight == 1) {
// //
showTipView.showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) { showTipView.showDeleteAdministratorIsHaveAllDataDialog('同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
// //
@ -208,7 +208,7 @@ class LockListLogic extends BaseGetXController {
// //
Future<void> deletLockInfoData() async { Future<void> deletLockInfoData() async {
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData( final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockListInfoItemEntity.lockId!, lockId: state.lockListInfoItemEntity.value.lockId!,
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ''; BlueManage().connectDeviceMacAddress = '';
@ -221,8 +221,8 @@ class LockListLogic extends BaseGetXController {
// //
Future<void> deletKeyData() async { Future<void> deletKeyData() async {
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData( final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.lockListInfoItemEntity.lockId.toString(), lockId: state.lockListInfoItemEntity.value.lockId.toString(),
keyId: state.lockListInfoItemEntity.keyId.toString(), keyId: state.lockListInfoItemEntity.value.keyId.toString(),
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0); includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ''; BlueManage().connectDeviceMacAddress = '';
@ -241,38 +241,35 @@ class LockListLogic extends BaseGetXController {
dismissEasyLoading(); dismissEasyLoading();
showDeletAlertTipDialog(); showDeletAlertTipDialog();
}); });
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async { BlueManage().blueSendData(state.lockListInfoItemEntity.value.lockName!, (BluetoothConnectionState connectionState)
async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
final List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(); final List<int> publicKeyData = state.lockListInfoItemEntity.value.bluetooth!.publicKey!.cast<int>();
final List<String> saveStrList = changeIntListToStringList(publicKeyData); final List<String> saveStrList = changeIntListToStringList(publicKeyData);
await Storage.setStringList(saveBluePublicKey, saveStrList); await Storage.setStringList(saveBluePublicKey, saveStrList);
// //
final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey); final List<String>? privateKey = await Storage.getStringList(saveBluePrivateKey);
final List<int> privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(); final List<int> privateKeyData = state.lockListInfoItemEntity.value.bluetooth!.privateKey!.cast<int>();
final List<String> savePrivateKeyList = changeIntListToStringList(privateKeyData); final List<String> savePrivateKeyList = changeIntListToStringList(privateKeyData);
await Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); await Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey // signKey
final List<int> signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>(); final List<int> signKeyData = state.lockListInfoItemEntity.value.bluetooth!.signKey!.cast<int>();
final List<String> saveSignKeyList = changeIntListToStringList(signKeyData); final List<String> saveSignKeyList = changeIntListToStringList(signKeyData);
await Storage.setStringList(saveBlueSignKey, saveSignKeyList); await Storage.setStringList(saveBlueSignKey, saveSignKeyList);
final List<String> saveTokenList = changeIntListToStringList(<int>[0, 0, 0, 0]); final List<String> saveTokenList = changeIntListToStringList(<int>[0, 0, 0, 0]);
await Storage.setStringList(saveBlueToken, saveTokenList); await Storage.setStringList(saveBlueToken, saveTokenList);
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
final List<String>? publicKey = await Storage.getStringList(saveBluePublicKey);
final List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
IoSenderManage.senderFactoryDataReset( IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName, lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
keyID: '1', keyID: '1',
needAuthor: 1, needAuthor: 1,
publicKey: publicKeyDataList, publicKey: publicKeyData,
privateKey: getPrivateKeyList, privateKey: privateKeyData,
token: <int>[0, 0, 0, 0]); token: <int>[0, 0, 0, 0]);
} else if (connectionState == BluetoothConnectionState.disconnected) { } else if (connectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading(); dismissEasyLoading();

View File

@ -91,7 +91,8 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
children: <Widget>[ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context) { onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo; state.lockListInfoItemEntity.value = keyInfo;
state.lockListInfoItemEntity.refresh();
logic.deleyLockLogicOfRoles(); logic.deleyLockLogicOfRoles();
}, },
backgroundColor: Colors.red, backgroundColor: Colors.red,

View File

@ -7,7 +7,8 @@ import '../entity/lockListInfo_entity.dart';
class LockListState{ class LockListState{
RxBool itemStatusIsEable = false.obs; // item是否能点击 RxBool itemStatusIsEable = false.obs; // item是否能点击
LockListInfoItemEntity lockListInfoItemEntity = LockListInfoItemEntity(); // item //
Rx<LockListInfoItemEntity> lockListInfoItemEntity = LockListInfoItemEntity().obs; // item
TextEditingController passwordTF = TextEditingController(); TextEditingController passwordTF = TextEditingController();
RxBool deleteAdministratorIsHaveAllData = false.obs; // RxBool deleteAdministratorIsHaveAllData = false.obs; //
RxBool ifCurrentScreen = true.obs; // , RxBool ifCurrentScreen = true.obs; // ,

View File

@ -192,7 +192,8 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
children: <Widget>[ children: <Widget>[
SlidableAction( SlidableAction(
onPressed: (BuildContext context) { onPressed: (BuildContext context) {
state.lockListInfoItemEntity = keyInfo; state.lockListInfoItemEntity.value = keyInfo;
state.lockListInfoItemEntity.refresh();
logic.deleyLockLogicOfRoles(); logic.deleyLockLogicOfRoles();
}, },
backgroundColor: Colors.red, backgroundColor: Colors.red,