From af22df9d104c6dba393c74ff4b19c39720e2cce9 Mon Sep 17 00:00:00 2001 From: paufau Date: Wed, 2 Sep 2026 18:14:52 +0400 Subject: [PATCH] iOS: wait for dismissal animation to finish before hiding the window --- example/demo-components/src/DemoScreen.tsx | 7 ------- .../RNTModalMountingHelper/RNTModalMountingHelper.m | 6 ++++-- .../RNTModalViewController/RNTModalViewController.h | 2 +- .../RNTModalViewController/RNTModalViewController.m | 8 +++++++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/example/demo-components/src/DemoScreen.tsx b/example/demo-components/src/DemoScreen.tsx index 34dd2a4..21efac5 100644 --- a/example/demo-components/src/DemoScreen.tsx +++ b/example/demo-components/src/DemoScreen.tsx @@ -31,7 +31,6 @@ type DemoCase = { export const DemoScreen = () => { const { colors } = useTheme(); - const { colors } = useTheme(); const [activeCases, setActiveCases] = useState([]); @@ -180,22 +179,16 @@ export const DemoScreen = () => { return ( - style={[styles.safeArea, { backgroundColor: colors.background }]} > - - contentContainerStyle={styles.scrollContent} > Current Architecture: {IS_FABRIC ? 'Fabric 🚀' : 'Paper ✈️'} - {demoCases.map(({ title, description, id }) => ( {demoCases.map(({ title, description, id }) => ( - (void)presentOn:(UIViewController *)parentVC onView:(UIView *)parentView; -- (void)dismiss; +- (void)dismissWithCompletion:(void (^ _Nullable)(void))completion; - (void)addReactSubview:(UIView *)view; - (void)setupReactSubview:(UIView *)subview; - (void)setAnimationType:(NSString *)type; diff --git a/ios/Library/RNTModalViewController/RNTModalViewController.m b/ios/Library/RNTModalViewController/RNTModalViewController.m index a0a9c33..9b2dd83 100644 --- a/ios/Library/RNTModalViewController/RNTModalViewController.m +++ b/ios/Library/RNTModalViewController/RNTModalViewController.m @@ -67,7 +67,7 @@ - (void)presentOn:(UIViewController *)parentVC onView:(UIView *)parentView { [self didMoveToParentViewController:parentVC]; } -- (void)dismiss { +- (void)dismissWithCompletion:(void (^ _Nullable)(void))completion { UIView *prevReactSubviewContainer = self.reactSubviewContainer; UIView *snapshot = [self.reactSubviewContainer snapshotViewAfterScreenUpdates:NO]; @@ -81,11 +81,17 @@ - (void)dismiss { [self willMoveToParentViewController:nil]; [self.view removeFromSuperview]; [self removeFromParentViewController]; + if (completion) { + completion(); + } }]; } else { [self willMoveToParentViewController:nil]; [self.view removeFromSuperview]; [self removeFromParentViewController]; + if (completion) { + completion(); + } } }