From f3c5c2c48997a1b69a597be94f778149a27d03a9 Mon Sep 17 00:00:00 2001 From: ashrafzarkanisala Date: Tue, 27 Aug 2024 00:27:41 +0300 Subject: [PATCH] pushdoor lock animation --- .../door_lock/bloc/door_lock_bloc.dart | 19 ++----------------- .../door_lock/widget/door_button.dart | 5 ++++- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart b/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart index 98af2b5a..8ad2a05c 100644 --- a/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart +++ b/lib/pages/device_managment/door_lock/bloc/door_lock_bloc.dart @@ -15,7 +15,7 @@ class DoorLockBloc extends Bloc { DoorLockBloc({required this.deviceId}) : super(DoorLockInitial()) { on(_onFetchDeviceStatus); - on(_onDoorLockControl); + //on(_onDoorLockControl); on(_updateLock); } @@ -33,25 +33,10 @@ class DoorLockBloc extends Bloc { } } - FutureOr _onDoorLockControl( - DoorLockControl event, Emitter emit) async { - final oldValue = _getValueByCode(event.code); - _updateLocalValue(event.code, event.value); - emit(DoorLockStatusLoaded(deviceStatus)); - - await _runDebounce( - deviceId: event.deviceId, - code: event.code, - value: event.value, - oldValue: oldValue, - emit: emit, - ); - } - FutureOr _updateLock( UpdateLockEvent event, Emitter emit) async { final oldValue = deviceStatus.normalOpenSwitch; - deviceStatus = deviceStatus.copyWith(normalOpenSwitch: event.value); + deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue); emit(DoorLockStatusLoaded(deviceStatus)); try { diff --git a/lib/pages/device_managment/door_lock/widget/door_button.dart b/lib/pages/device_managment/door_lock/widget/door_button.dart index 83ac4fa7..e8e3066e 100644 --- a/lib/pages/device_managment/door_lock/widget/door_button.dart +++ b/lib/pages/device_managment/door_lock/widget/door_button.dart @@ -44,7 +44,7 @@ class _DoorLockButtonState extends State }); if (smartDoorModel.unlockRequest > 0) { - _animationController.forward(); + _animationController.reverse(from: 1); } } @@ -56,8 +56,11 @@ class _DoorLockButtonState extends State setState(() { smartDoorModel = widget.smartDoorModel; }); + if (smartDoorModel.unlockRequest > 0) { _animationController.forward(from: 0); + } else { + _animationController.reverse(from: 1); } } }