2018-02-27 18:42:44 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "RCTInputAccessoryViewContent.h"
|
|
|
|
|
|
|
|
#import <React/UIView+React.h>
|
|
|
|
|
|
|
|
@implementation RCTInputAccessoryViewContent
|
2018-03-13 18:05:53 +00:00
|
|
|
{
|
|
|
|
UIView *_safeAreaContainer;
|
|
|
|
}
|
2018-02-27 18:42:44 +00:00
|
|
|
|
2018-03-13 18:05:53 +00:00
|
|
|
- (instancetype)init
|
2018-02-27 18:42:44 +00:00
|
|
|
{
|
2018-03-13 18:05:53 +00:00
|
|
|
if (self = [super init]) {
|
|
|
|
_safeAreaContainer = [UIView new];
|
|
|
|
[self addSubview:_safeAreaContainer];
|
|
|
|
}
|
|
|
|
return self;
|
2018-02-27 18:42:44 +00:00
|
|
|
}
|
|
|
|
|
2018-03-13 18:05:53 +00:00
|
|
|
- (void)didMoveToSuperview
|
2018-02-27 18:42:44 +00:00
|
|
|
{
|
|
|
|
|
2018-03-13 18:05:53 +00:00
|
|
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
2018-04-04 23:43:37 +00:00
|
|
|
// Avoid the home pill (in portrait mode)
|
|
|
|
// TODO: Support rotation, anchor to left and right without breaking frame x coordinate (T27974328).
|
2018-03-13 18:05:53 +00:00
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
|
if (self.window) {
|
|
|
|
[_safeAreaContainer.bottomAnchor
|
|
|
|
constraintLessThanOrEqualToSystemSpacingBelowAnchor:self.window.safeAreaLayoutGuide.bottomAnchor
|
2018-02-27 18:42:44 +00:00
|
|
|
multiplier:1.0f].active = YES;
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 18:05:53 +00:00
|
|
|
#endif
|
2018-02-27 18:42:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-03-13 18:05:53 +00:00
|
|
|
- (void)setFrame:(CGRect)frame
|
2018-02-27 18:42:44 +00:00
|
|
|
{
|
2018-03-13 18:05:53 +00:00
|
|
|
[super setFrame:frame];
|
|
|
|
[_safeAreaContainer setFrame:frame];
|
2018-02-27 18:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)index
|
|
|
|
{
|
|
|
|
[super insertReactSubview:subview atIndex:index];
|
2018-03-13 18:05:53 +00:00
|
|
|
[_safeAreaContainer insertSubview:subview atIndex:index];
|
2018-02-27 18:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeReactSubview:(UIView *)subview
|
|
|
|
{
|
|
|
|
[super removeReactSubview:subview];
|
|
|
|
[subview removeFromSuperview];
|
2018-03-13 18:05:53 +00:00
|
|
|
if ([[_safeAreaContainer subviews] count] == 0 && [self isFirstResponder]) {
|
2018-02-27 18:42:44 +00:00
|
|
|
[self resignFirstResponder];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|