Skip to content

Commit 7efa595

Browse files
committed
Add prepareForPresentation
1 parent 6adc9bd commit 7efa595

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

ios/gamma/modals/form-sheet/RNSFormSheetContentController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
1818

1919
@property (nonatomic, readonly, nonnull) RNSFormSheetContentView *contentView;
2020

21+
- (void)prepareForPresentation;
22+
2123
@end
2224

2325
NS_ASSUME_NONNULL_END

ios/gamma/modals/form-sheet/RNSFormSheetContentController.mm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,13 @@ - (void)loadView
3030
self.view = [RNSFormSheetContentView new];
3131
}
3232

33-
- (void)viewWillAppear:(BOOL)animated
34-
{
35-
[super viewWillAppear:animated];
36-
// Recreate that delegate on each dismiss/present cycle, because
37-
// UIKit isn't triggering presentationControllerDidDismiss many times for
38-
// a single initialization.
39-
self.presentationController.delegate = self;
40-
}
33+
#pragma mark - Presentation Setup
4134

42-
- (void)viewDidDisappear:(BOOL)animated
35+
- (void)prepareForPresentation
4336
{
44-
[super viewDidDisappear:animated];
45-
self.presentationController.delegate = nil;
37+
// The presentation controller is recreated by UIKit on every present/dismiss cycle.
38+
// We must assign this delegate before actual presentation
39+
self.presentationController.delegate = self;
4640
}
4741

4842
- (void)viewDidLayoutSubviews

ios/gamma/modals/form-sheet/RNSFormSheetHostComponentView.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ - (void)updatePresentationState
101101
return;
102102
}
103103

104+
// TODO: @t0maboro - this log definitely requires refactor now and it should be removed outside Host in a followup
105+
// PR
106+
[_controller prepareForPresentation];
104107
[presentationSourceViewController presentViewController:_controller animated:YES completion:nil];
105108
} else if (!_isOpen && isPresented) {
106109
[_controller dismissViewControllerAnimated:YES completion:nil];

0 commit comments

Comments
 (0)