Skip to content

Commit

Permalink
WOAUILIB-804 -fixed. now supports prop, to enable control the bottom …
Browse files Browse the repository at this point in the history
…space the keyboard-accessory-view
  • Loading branch information
mendyEdri committed Jun 23, 2020
1 parent 8d6ce0d commit bea0ea2
Show file tree
Hide file tree
Showing 9 changed files with 1,503 additions and 1,840 deletions.
1 change: 1 addition & 0 deletions demo/demoScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class KeyboardInput extends Component {
onItemSelected={this.onKeyboardItemSelected}
onKeyboardResigned={this.onKeyboardResigned}
revealKeyboardInteractive
useSafeArea={false}
/>
</View>
);
Expand Down
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ PODS:
- React-cxxreact (= 0.61.4)
- React-jsi (= 0.61.4)
- ReactCommon/jscallinvoker (= 0.61.4)
- ReactNativeKeyboardInput (5.4.0):
- ReactNativeKeyboardInput (6.0.1):
- React
- ReactNativeKeyboardTrackingView (5.6.1):
- React
Expand Down Expand Up @@ -346,11 +346,11 @@ SPEC CHECKSUMS:
React-RCTText: 21934e0a51d522abcd0a275407e80af45d6fd9ec
React-RCTVibration: 0f76400ee3cec6edb9c125da49fed279340d145a
ReactCommon: a6a294e7028ed67b926d29551aa9394fd989c24c
ReactNativeKeyboardInput: a7e007a56d2f3c831341eec14e632ab5615f12ac
ReactNativeKeyboardInput: 266ba27a2e9921f5bdc0b4cc30289b2a2f46b157
ReactNativeKeyboardTrackingView: a240a6a0dba852bb107109a7ec7e98b884055977
ReactNativeNavigation: 3fad99b3843e8840affd70577aaa30bf14b272d5
Yoga: ba3d99dbee6c15ea6bbe3783d1f0cb1ffb79af0f

PODFILE CHECKSUM: db72c512534d095b2d49d5dbe372d7ea041b7645

COCOAPODS: 1.8.4
COCOAPODS: 1.9.3
7 changes: 3 additions & 4 deletions lib/ios/RCTCustomInputController/RCTCustomInputController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ @interface RCTCustomInputController () <_WXInputHelperViewDelegate> {
BOOL _performingExpandTransition;
}

@property(nonatomic) BOOL customInputComponentPresented;

@property (nonatomic) BOOL customInputComponentPresented;
@end

@implementation RCTCustomInputController
Expand Down Expand Up @@ -114,7 +113,7 @@ -(UIView*)getFirstResponder:(UIView*)view
return nil;
}

RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag params:(nonnull NSDictionary*)params)
RCT_EXPORT_METHOD(presentCustomInputComponent:(nonnull NSNumber*)inputFieldTag params:(nonnull NSDictionary*)params useSafeArea:(BOOL)useSafeArea)
{
RCTBridge* bridge = [self.bridge valueForKey:@"parentBridge"];
if(bridge == nil)
Expand All @@ -136,7 +135,7 @@ -(UIView*)getFirstResponder:(UIView*)view

self.customInputComponentPresented = NO;

RCTCustomKeyboardViewController* customKeyboardController = [[RCTCustomKeyboardViewController alloc] init];
RCTCustomKeyboardViewController* customKeyboardController = [[RCTCustomKeyboardViewController alloc] initWithUsingSafeArea:useSafeArea];
customKeyboardController.rootView = rv;

_WXInputHelperView* helperView = [[_WXInputHelperView alloc] initWithFrame:CGRectZero];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

@interface RCTCustomKeyboardViewController : UIInputViewController

- (instancetype)initWithUsingSafeArea:(BOOL)useSafeArea;
- (void) setAllowsSelfSizing:(BOOL)allowsSelfSizing;

@property (nonatomic, strong) NSLayoutConstraint *heightConstraint;
Expand Down
33 changes: 27 additions & 6 deletions lib/ios/RCTCustomInputController/RCTCustomKeyboardViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
#define ObservingInputAccessoryView_IsAvailable true
#endif

@interface RCTCustomKeyboardViewController ()
@property (nonatomic, assign, getter=isUseingSafeArea) BOOL useSafeArea;
@end

@implementation RCTCustomKeyboardViewController

- (instancetype)init
- (instancetype)initWithUsingSafeArea:(BOOL)useSafeArea
{
self = [super init];

Expand All @@ -23,6 +27,7 @@ - (instancetype)init
self.inputView = [[UIInputView alloc] initWithFrame:CGRectZero inputViewStyle:UIInputViewStyleKeyboard];

self.heightConstraint = [self.inputView.heightAnchor constraintEqualToConstant:0];
self.useSafeArea = useSafeArea;

#ifdef ObservingInputAccessoryView_IsAvailable
ObservingInputAccessoryView *activeObservingInputAccessoryView = [ObservingInputAccessoryViewManager sharedInstance].activeObservingInputAccessoryView;
Expand Down Expand Up @@ -63,17 +68,33 @@ -(void)setRootView:(RCTRootView*)rootView
_rootView.translatesAutoresizingMaskIntoConstraints = NO;
[self.inputView addSubview:_rootView];

[self updateRootViewConstraints];
[self.inputView setNeedsLayout];
}

- (void)updateRootViewConstraints {
_rootView.translatesAutoresizingMaskIntoConstraints = NO;
[_rootView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES;
[_rootView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES;
[_rootView.topAnchor constraintEqualToAnchor:self.view.topAnchor].active = YES;

NSLayoutYAxisAnchor *yAxisAnchor = [self bottomLayoutAnchorUsingSafeArea:self.isUseingSafeArea];
[_rootView.bottomAnchor constraintEqualToAnchor:yAxisAnchor].active = YES;
}

- (NSLayoutYAxisAnchor *)bottomLayoutAnchorUsingSafeArea:(BOOL)useSafeArea {
NSLayoutYAxisAnchor *yAxisAnchor = self.view.bottomAnchor;
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
if (@available(iOS 11.0, *)) {
yAxisAnchor = self.view.safeAreaLayoutGuide.bottomAnchor;
if (!useSafeArea) {
return yAxisAnchor;
}
#endif
[_rootView.bottomAnchor constraintEqualToAnchor:yAxisAnchor].active = YES;

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
if (@available(iOS 11.0, *)) {
yAxisAnchor = self.view.safeAreaLayoutGuide.bottomAnchor;
}
#endif
return yAxisAnchor;
}

@end
Loading

0 comments on commit bea0ea2

Please sign in to comment.