From 65b307a95103f17a4ffd7e2847cc535c5c1795d8 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Sun, 29 Sep 2024 11:31:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix:=20`RNIModalSheetView.onModa?= =?UTF-8?q?lSheetStateDidChange`=20Event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift | 9 ++++++--- ios/Temp/ModalSheetPresentationStateMachine.swift | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index abb1ee44..85bd8945 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -326,13 +326,16 @@ extension RNIModalSheetViewDelegate: ModalSheetPresentationStateEventsNotifiable prevState: ModalSheetState?, currentState: ModalSheetState ) { - let payload: Dictionary = [ - "prevState": currentState.asDictionary, + var payload: Dictionary = [ "currentState": currentState.asDictionary ]; + payload.unwrapAndMerge(withOther: [ + "prevState": prevState?.asDictionary + ]); + self.dispatchEvent( - for: .onModalSheetStateWillChange, + for: .onModalSheetStateDidChange, withPayload: payload ); }; diff --git a/ios/Temp/ModalSheetPresentationStateMachine.swift b/ios/Temp/ModalSheetPresentationStateMachine.swift index 3560be8d..caae4603 100644 --- a/ios/Temp/ModalSheetPresentationStateMachine.swift +++ b/ios/Temp/ModalSheetPresentationStateMachine.swift @@ -24,6 +24,10 @@ public class ModalSheetPresentationStateMachine { // --------------- public func setStateExplicit(nextState: ModalSheetState){ + guard self.currentState != nextState else { + return; + }; + let prevState = self.prevState; let currentState = self.currentState;