Skip to content

Commit

Permalink
Update safe area frame when keyboard shows/hides (#407)
Browse files Browse the repository at this point in the history
* Update safe area frame when keyboard shows/hides

Happens in pageSheet/formSheet presentation styles

* Update RNCSafeAreaProviderComponentView.mm
  • Loading branch information
jacobp100 committed Jul 4, 2023
1 parent 8c1d811 commit fd2b02f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/Fabric/RNCSafeAreaProviderComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ - (instancetype)initWithFrame:(CGRect)frame
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const RNCSafeAreaProviderProps>();
_props = defaultProps;

[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(invalidateSafeAreaInsets)
name:UIKeyboardDidShowNotification
object:nil];
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(invalidateSafeAreaInsets)
name:UIKeyboardDidHideNotification
object:nil];
}

return self;
Expand Down
15 changes: 15 additions & 0 deletions ios/RNCSafeAreaProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ @implementation RNCSafeAreaProvider {
BOOL _initialInsetsSent;
}

- (instancetype)init
{
if ((self = [super init])) {
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(invalidateSafeAreaInsets)
name:UIKeyboardDidShowNotification
object:nil];
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(invalidateSafeAreaInsets)
name:UIKeyboardDidHideNotification
object:nil];
}
return self;
}

- (void)safeAreaInsetsDidChange
{
[self invalidateSafeAreaInsets];
Expand Down

0 comments on commit fd2b02f

Please sign in to comment.