pushdoor lock animation

This commit is contained in:
ashrafzarkanisala
2024-08-27 00:27:41 +03:00
parent f39ce0a72b
commit f3c5c2c489
2 changed files with 6 additions and 18 deletions

View File

@ -15,7 +15,7 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
DoorLockBloc({required this.deviceId}) : super(DoorLockInitial()) {
on<DoorLockFetchStatus>(_onFetchDeviceStatus);
on<DoorLockControl>(_onDoorLockControl);
//on<DoorLockControl>(_onDoorLockControl);
on<UpdateLockEvent>(_updateLock);
}
@ -33,25 +33,10 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
}
}
FutureOr<void> _onDoorLockControl(
DoorLockControl event, Emitter<DoorLockState> 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<void> _updateLock(
UpdateLockEvent event, Emitter<DoorLockState> emit) async {
final oldValue = deviceStatus.normalOpenSwitch;
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: event.value);
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue);
emit(DoorLockStatusLoaded(deviceStatus));
try {

View File

@ -44,7 +44,7 @@ class _DoorLockButtonState extends State<DoorLockButton>
});
if (smartDoorModel.unlockRequest > 0) {
_animationController.forward();
_animationController.reverse(from: 1);
}
}
@ -56,8 +56,11 @@ class _DoorLockButtonState extends State<DoorLockButton>
setState(() {
smartDoorModel = widget.smartDoorModel;
});
if (smartDoorModel.unlockRequest > 0) {
_animationController.forward(from: 0);
} else {
_animationController.reverse(from: 1);
}
}
}