Skip to content

Commit ccfbf24

Browse files
KeyboardAccessoryView - adding 'usesBottomTabs' prop (#1871)
* KeyboardAccessoryView - adding 'usesBottomTabs' prop to add bottom offset * lib - bump version * Update lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.tsx Co-authored-by: Ethan Sharabi <[email protected]> Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 9e9f83c commit ccfbf24

File tree

8 files changed

+60
-7
lines changed

8 files changed

+60
-7
lines changed

demo/src/screens/nativeComponentScreens/keyboardInput/KeyboardInputViewScreen.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ export default class KeyboardInputViewScreen extends PureComponent {
170170
};
171171

172172
render() {
173-
const {message} = this.props;
173+
const {message, isModal} = this.props;
174174
const {receivedKeyboardData, customKeyboard, useSafeArea} = this.state;
175+
175176
return (
176177
<View flex bg-grey80>
177178
<Text h2 marginT-page marginL-page>
@@ -201,6 +202,7 @@ export default class KeyboardInputViewScreen extends PureComponent {
201202
revealKeyboardInteractive
202203
onRequestShowKeyboard={this.onRequestShowKeyboard}
203204
useSafeArea={useSafeArea}
205+
usesBottomTabs={!isModal}
204206
/>
205207
</View>
206208
);

generatedTypes/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ export declare type KeyboardAccessoryViewProps = {
8787
* default: true
8888
*/
8989
useSafeArea?: boolean;
90+
/**
91+
* iOS only.
92+
* Whether or not to include bottom tab bat inset
93+
* default: true
94+
*/
95+
usesBottomTabs?: boolean;
9096
children?: React.ReactChild;
9197
};
9298
/**

generatedTypes/lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export declare type KeyboardTrackingViewProps = ViewProps & {
1515
* Allow control safe area
1616
*/
1717
useSafeArea?: boolean;
18+
/**
19+
* Whether or not to include bottom tab bat inset
20+
*/
21+
usesBottomTabs?: boolean;
1822
scrollToFocusedInput?: boolean;
1923
scrollBehavior?: number;
2024
revealKeyboardInteractive?: boolean;
@@ -41,6 +45,10 @@ declare const KeyboardTrackingView: React.ForwardRefExoticComponent<Pick<ViewPro
4145
* Allow control safe area
4246
*/
4347
useSafeArea?: boolean | undefined;
48+
/**
49+
* Whether or not to include bottom tab bat inset
50+
*/
51+
usesBottomTabs?: boolean | undefined;
4452
scrollToFocusedInput?: boolean | undefined;
4553
scrollBehavior?: number | undefined;
4654
revealKeyboardInteractive?: boolean | undefined;
@@ -51,5 +59,5 @@ declare const KeyboardTrackingView: React.ForwardRefExoticComponent<Pick<ViewPro
5159
ref?: any;
5260
children?: React.ReactChild | React.ReactChild[] | undefined;
5361
style?: ViewStyle | undefined;
54-
}, keyof ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & React.RefAttributes<unknown>>;
62+
}, keyof ViewProps | "useSafeArea" | "trackInteractive" | "usesBottomTabs" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & React.RefAttributes<unknown>>;
5563
export default KeyboardTrackingView;

generatedTypes/lib/components/Keyboard/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare const _default: {
88
KeyboardTrackingView: import("react").ForwardRefExoticComponent<Pick<import("react-native").ViewProps & {
99
trackInteractive?: boolean | undefined;
1010
useSafeArea?: boolean | undefined;
11+
usesBottomTabs?: boolean | undefined;
1112
scrollToFocusedInput?: boolean | undefined;
1213
scrollBehavior?: number | undefined;
1314
revealKeyboardInteractive?: boolean | undefined;
@@ -18,7 +19,7 @@ declare const _default: {
1819
ref?: any;
1920
children?: import("react").ReactChild | import("react").ReactChild[] | undefined;
2021
style?: import("react-native").ViewStyle | undefined;
21-
}, keyof import("react-native").ViewProps | "useSafeArea" | "trackInteractive" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & import("react").RefAttributes<unknown>>;
22+
}, keyof import("react-native").ViewProps | "useSafeArea" | "trackInteractive" | "usesBottomTabs" | "scrollToFocusedInput" | "scrollBehavior" | "revealKeyboardInteractive" | "manageScrollView" | "requiresSameParentToManageScrollView" | "addBottomView" | "allowHitsOutsideBounds"> & import("react").RefAttributes<unknown>>;
2223
KeyboardAwareInsetsView: {
2324
(props: KeyboardTrackingViewProps): JSX.Element;
2425
displayName: string;

lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ export type KeyboardAccessoryViewProps = {
113113
* default: true
114114
*/
115115
useSafeArea?: boolean;
116+
/**
117+
* iOS only.
118+
* Whether or not to include bottom tab bat inset
119+
* default: true
120+
*/
121+
usesBottomTabs?: boolean;
116122

117123
children?: React.ReactChild;
118124
};
@@ -252,7 +258,8 @@ class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps> {
252258
kbComponent,
253259
onItemSelected,
254260
onRequestShowKeyboard,
255-
useSafeArea
261+
useSafeArea,
262+
usesBottomTabs
256263
} = this.props;
257264

258265
return (
@@ -267,6 +274,7 @@ class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps> {
267274
requiresSameParentToManageScrollView={requiresSameParentToManageScrollView}
268275
addBottomView={addBottomView}
269276
allowHitsOutsideBounds={allowHitsOutsideBounds}
277+
usesBottomTabs={usesBottomTabs}
270278
>
271279
<>
272280
{renderContent?.()}

lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export type KeyboardTrackingViewProps = ViewProps & {
2020
* Allow control safe area
2121
*/
2222
useSafeArea?: boolean;
23+
/**
24+
* Whether or not to include bottom tab bar inset
25+
*/
26+
usesBottomTabs?: boolean;
2327

2428
scrollToFocusedInput?: boolean;
2529
scrollBehavior?: number;

lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ @interface KeyboardTrackingViewTemp : UIView
5151
@property (nonatomic) KeyboardTrackingScrollBehavior scrollBehavior;
5252
@property (nonatomic) BOOL addBottomView;
5353
@property (nonatomic) BOOL useSafeArea;
54+
@property (nonatomic) BOOL usesBottomTabs;
5455
@property (nonatomic) BOOL scrollToFocusedInput;
5556
@property (nonatomic) BOOL allowHitsOutsideBounds;
5657

@@ -82,6 +83,7 @@ -(instancetype)init
8283

8384
self.addBottomView = NO;
8485
self.scrollToFocusedInput = NO;
86+
self.usesBottomTabs = NO;
8587

8688
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rctContentDidAppearNotification:) name:RCTContentDidAppearNotification object:nil];
8789
}
@@ -503,14 +505,35 @@ - (void) rctContentDidAppearNotification:(NSNotification*)notification
503505
});
504506
}
505507

508+
#pragma mark - root view controller and presenting style
509+
510+
511+
- (BOOL)isModal {
512+
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
513+
UIViewController *presentedViewController = window.rootViewController.presentedViewController;
514+
515+
if (presentedViewController != nil) {
516+
if ([presentedViewController isKindOfClass:[UINavigationController class]]) {
517+
UINavigationController *presented = (UINavigationController*)presentedViewController;
518+
if (presented.visibleViewController) {
519+
return YES;
520+
}
521+
}
522+
}
523+
return NO;
524+
}
525+
526+
#pragma mark - TabBarController
527+
506528
-(CGFloat)getTabBarHeight
507529
{
508530
if (@available(iOS 11.0, *)) {
509-
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
510-
if ([window.rootViewController isKindOfClass:[UITabBarController class]])
531+
NSLog(@"INBAL usesBottomTabs: %d", self.usesBottomTabs);
532+
if (self.usesBottomTabs == YES)
511533
{
512534
UITabBarController *tabBarController = [UITabBarController new];
513535
CGFloat tabBarHeight = tabBarController.tabBar.frame.size.height;
536+
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
514537
CGFloat bottomPadding = window.safeAreaInsets.bottom;
515538
return tabBarHeight + bottomPadding;
516539
}
@@ -650,6 +673,7 @@ @implementation KeyboardTrackingViewTempManager
650673
RCT_REMAP_VIEW_PROPERTY(requiresSameParentToManageScrollView, requiresSameParentToManageScrollView, BOOL)
651674
RCT_REMAP_VIEW_PROPERTY(addBottomView, addBottomView, BOOL)
652675
RCT_REMAP_VIEW_PROPERTY(useSafeArea, useSafeArea, BOOL)
676+
RCT_REMAP_VIEW_PROPERTY(usesBottomTabs, usesBottomTabs, BOOL)
653677
RCT_REMAP_VIEW_PROPERTY(scrollToFocusedInput, scrollToFocusedInput, BOOL)
654678
RCT_REMAP_VIEW_PROPERTY(allowHitsOutsideBounds, allowHitsOutsideBounds, BOOL)
655679

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-native",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"homepage": "https://github.com/wix/react-native-ui-lib",
55
"description": "uilib native components (separated from js components)",
66
"main": "components/index.js",

0 commit comments

Comments
 (0)