Skip to content

fix: iOS modal freeze when animationType prop is set#70

Open
dawidzawada wants to merge 1 commit intopaufau:mainfrom
dawidzawada:fix/ios-animation-type-freeze
Open

fix: iOS modal freeze when animationType prop is set#70
dawidzawada wants to merge 1 commit intopaufau:mainfrom
dawidzawada:fix/ios-animation-type-freeze

Conversation

@dawidzawada
Copy link

Motivation

I've encountered an issue with modal freeze when animationType was provided, reported here: #64
I've tested the patch provided by @khanjandobariya and simplified it a little bit.
Let me know what you think!

Summary

When animationType is set to fade or slide, the modal content freezes and becomes invisible on iOS. This happens because prepareAnimation: is called in viewDidLoad, but animate: is never called to transition to the visible state.

Changes

  • Initialize default animations in initWithDelegate: ensures inAnimation/outAnimation are never nil between init and setAnimationType:
  • Add viewDidAppear: calls [self.inAnimation animate:...]: to actually run the entrance animation after the view is on screen

Testing

Tested on every modal in react-native-multiple-modals-examples using the patch below.

Simplified Patch

diff --git a/node_modules/react-native-multiple-modals/ios/Library/RNTModalViewController/RNTModalViewController.m b/node_modules/react-native-multiple-modals/ios/Library/RNTModalViewController/RNTModalViewController.m
index a695eeb..d581919 100644
--- a/node_modules/react-native-multiple-modals/ios/Library/RNTModalViewController/RNTModalViewController.m
+++ b/node_modules/react-native-multiple-modals/ios/Library/RNTModalViewController/RNTModalViewController.m
@@ -14,6 +14,9 @@ - (instancetype)initWithDelegate:(id<RNTModalViewControllerDelegate>)delegate {
     if (self) {
         self.reactSubviewContainer = [[UIView alloc] init];
         self.delegate = delegate;
+        ModalAnimation *defaultAnimation = [[ModalAnimation alloc] init];
+        self.inAnimation = defaultAnimation;
+        self.outAnimation = defaultAnimation;
     }
     return self;
 }
@@ -37,6 +40,11 @@ - (void)viewDidLoad {
     [self setupReactSubview:self.reactSubviewContainer];
 }
 
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    [self.inAnimation animate:self.reactSubviewContainer completion:nil];
+}
+
 - (void)viewDidLayoutSubviews
 {
     [super viewDidLayoutSubviews];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant