Skip to content

Commit f098b71

Browse files
committed
KeyboardTrackingView - add 'bottomViewColor' prop
1 parent e05238b commit f098b71

File tree

10 files changed

+237
-108
lines changed

10 files changed

+237
-108
lines changed

demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class KeyboardTrackingViewScreen extends PureComponent {
6262
const {trackInteractive} = this.state;
6363

6464
return (
65-
<View flex bg-grey80 paddingT-page>
65+
<View flex bg-blue80 paddingT-page>
6666
<ScrollView
6767
contentContainerStyle={styles.scrollContainer}
6868
keyboardDismissMode={trackInteractive ? 'interactive' : 'none'}
@@ -88,8 +88,10 @@ export default class KeyboardTrackingViewScreen extends PureComponent {
8888
style={styles.trackingToolbarContainer}
8989
trackInteractive={trackInteractive}
9090
useSafeArea
91+
addBottomView
92+
bottomViewColor={Colors.grey80}
9193
>
92-
<View bg-white row spread centerV paddingH-s5 paddingV-s3>
94+
<View bg-grey80 row spread centerV paddingH-s5 paddingV-s3>
9395
<TextField
9496
migrate
9597
containerStyle={styles.textField}
@@ -119,7 +121,7 @@ const styles = StyleSheet.create({
119121
},
120122
textField: {
121123
flex: 1,
122-
backgroundColor: Colors.grey60,
124+
backgroundColor: Colors.grey50,
123125
paddingVertical: Spacings.s2,
124126
paddingHorizontal: Spacings.s4,
125127
borderRadius: 8

lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ export type KeyboardAccessoryViewProps = {
3030
* Content to be rendered above the keyboard
3131
*/
3232
renderContent?: () => React.ReactElement;
33-
/**
34-
* A callback for when the height is changed
35-
*/
36-
onHeightChanged?: (height: number) => void;
3733
/**
3834
* iOS only.
3935
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.).
@@ -48,6 +44,10 @@ export type KeyboardAccessoryViewProps = {
4844
* The props that will be sent to the KeyboardComponent
4945
*/
5046
kbInitialProps?: any;
47+
/**
48+
* A callback for when the height is changed
49+
*/
50+
onHeightChanged?: (height: number) => void;
5151
/**
5252
* Callback that will be called when an item on the keyboard has been pressed.
5353
*/
@@ -64,21 +64,18 @@ export type KeyboardAccessoryViewProps = {
6464
* iOS only.
6565
* The scrolling behavior, use KeyboardAccessoryView.iosScrollBehaviors.X where X is:
6666
* NONE, SCROLL_TO_BOTTOM_INVERTED_ONLY or FIXED_OFFSET
67-
*
6867
* default: FIXED_OFFSET
6968
*/
7069
iOSScrollBehavior?: number;
7170
/**
7271
* iOS only.
7372
* Show the keyboard on a negative scroll
74-
*
7573
* default: false
7674
*/
7775
revealKeyboardInteractive?: boolean;
7876
/**
7977
* iOS only.
8078
* Set to false to turn off inset management and manage it yourself
81-
*
8279
* default: true
8380
*/
8481
manageScrollView?: boolean;
@@ -88,39 +85,39 @@ export type KeyboardAccessoryViewProps = {
8885
* it means that the ScrollView found is the wrong one and you'll have
8986
* to have the KeyboardAccessoryView and the ScrollView as siblings
9087
* and set this to true
91-
*
9288
* default: false
9389
*/
9490
requiresSameParentToManageScrollView?: boolean;
9591
/**
9692
* iOS only.
97-
* Add a (white) SafeArea view beneath the KeyboardAccessoryView
98-
*
93+
* Allow hitting sub-views that are placed beyond the view bounds
9994
* default: false
10095
*/
101-
addBottomView?: boolean;
96+
allowHitsOutsideBounds?: boolean;
10297
/**
10398
* iOS only.
104-
* Allow hitting sub-views that are placed beyond the view bounds
105-
*
99+
* Add a SafeArea view beneath the KeyboardAccessoryView
106100
* default: false
107101
*/
108-
allowHitsOutsideBounds?: boolean;
109-
102+
addBottomView?: boolean;
103+
/**
104+
* iOS only.
105+
* The bottom view's color as an hex string
106+
* default: '#ffffff'
107+
*/
108+
bottomViewColor?: string;
110109
/**
111110
* iOS only.
112111
* Whether or not to handle SafeArea
113112
* default: true
114113
*/
115114
useSafeArea?: boolean;
116-
117115
/**
118116
* iOS only.
119117
* Whether or not to include bottom tab bat inset
120118
* default: false
121119
*/
122120
usesBottomTabs?: boolean;
123-
124121
children?: React.ReactChild;
125122
};
126123

@@ -130,7 +127,6 @@ export type KeyboardAccessoryViewProps = {
130127
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/KeyboardAccessoryView/KeyboardAccessoryView.gif?raw=true
131128
*/
132129
class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps> {
133-
134130
static iosScrollBehaviors = IOS_SCROLL_BEHAVIORS;
135131

136132
static defaultProps = {
@@ -274,12 +270,11 @@ class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps> {
274270
manageScrollView={manageScrollView}
275271
requiresSameParentToManageScrollView={requiresSameParentToManageScrollView}
276272
addBottomView={addBottomView}
273+
bottomViewColor={bottomViewColor}
277274
allowHitsOutsideBounds={allowHitsOutsideBounds}
278275
usesBottomTabs={usesBottomTabs}
279276
>
280-
<>
281-
{renderContent?.()}
282-
</>
277+
<>{renderContent?.()}</>
283278
<CustomKeyboardView
284279
inputRef={kbInputRef}
285280
component={kbComponent}

lib/components/Keyboard/KeyboardInput/keyboardAccessoryView.api.json

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
"type": "() => React.ReactElement",
1313
"description": "Content to be rendered above the keyboard"
1414
},
15-
{
16-
"name": "onHeightChanged",
17-
"type": "(height: number) => void",
18-
"description": "A callback for when the height is changed"
19-
},
2015
{
2116
"name": "kbInputRef",
2217
"type": "any",
@@ -29,6 +24,11 @@
2924
"description": "The keyboard ID (the componentID sent to KeyboardRegistry)"
3025
},
3126
{"name": "kbInitialProps", "type": "any", "description": "The props that will be sent to the KeyboardComponent"},
27+
{
28+
"name": "onHeightChanged",
29+
"type": "(height: number) => void",
30+
"description": "A callback for when the height is changed"
31+
},
3232
{
3333
"name": "onItemSelected",
3434
"type": "() => void",
@@ -54,42 +54,56 @@
5454
"name": "revealKeyboardInteractive",
5555
"type": "boolean",
5656
"description": "Show the keyboard on a negative scroll\niOS only.",
57+
"note": "KeyboardTrackingView prop. iOS only",
5758
"default": "false"
5859
},
5960
{
6061
"name": "manageScrollView",
6162
"type": "boolean",
6263
"description": "Set to false to turn off inset management and manage it yourself\niOS only.",
64+
"note": "KeyboardTrackingView prop. iOS only",
6365
"default": "true"
6466
},
6567
{
6668
"name": "requiresSameParentToManageScrollView",
6769
"type": "boolean",
6870
"description": "Set to true manageScrollView is set to true and still does not work,\nit means that the ScrollView found is the wrong one and you'll have\nto have the KeyboardAccessoryView and the ScrollView as siblings\nand set this to true\niOS only.",
71+
"note": "KeyboardTrackingView prop. iOS only",
6972
"default": "false"
7073
},
7174
{
72-
"name": "addBottomView",
75+
"name": "allowHitsOutsideBounds",
7376
"type": "boolean",
74-
"description": "Add a (white) SafeArea view beneath the KeyboardAccessoryView\niOS only.",
77+
"description": "Allow hitting sub-views that are placed beyond the view bounds\niOS only.",
78+
"note": "KeyboardTrackingView prop. iOS only",
7579
"default": "false"
7680
},
7781
{
78-
"name": "allowHitsOutsideBounds",
82+
"name": "addBottomView",
7983
"type": "boolean",
80-
"description": "Allow hitting sub-views that are placed beyond the view bounds\niOS only.",
84+
"description": "Add a view beneath the KeyboardAccessoryView\niOS only.",
85+
"note": "KeyboardTrackingView prop. iOS only",
8186
"default": "false"
8287
},
88+
{
89+
"name": "bottomViewColor",
90+
"type": "string",
91+
"description": "The bottom view's color as an hex string\niOS only.",
92+
"note": "KeyboardTrackingView prop. iOS only",
93+
"default": "#ffffff"
94+
},
8395
{
8496
"name": "useSafeArea",
8597
"type": "boolean",
8698
"description": "Whether or not to handle SafeArea\niOS only.",
99+
"note": "KeyboardTrackingView prop. iOS only",
87100
"default": "true"
88101
},
89102
{
90103
"name": "usesBottomTabs",
91104
"type": "boolean",
92105
"description": "Whether or not to include bottom tab bar inset\niOS only.",
106+
"note": "KeyboardTrackingView prop. iOS only",
93107
"default": "false"
94108
}
95109
],

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

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,73 @@ const isAndroid = Platform.OS === 'android';
77

88
export type KeyboardTrackingViewProps = ViewProps & {
99
/**
10-
* Enables tracking of the keyboard when it's dismissed interactively (false by default).
11-
* Why? When using an external keyboard (BT),
12-
* you still get the keyboard events and the view just hovers when you focus the input.
13-
* Also, if you're not using interactive style of dismissing the keyboard
14-
* (or if you don't have an input inside this view) it doesn't make sense to track it anyway.
15-
* (This is caused because of the usage of inputAccessory to be able to track the
16-
* keyboard interactive change and it introduces this bug)
17-
*/
18-
trackInteractive?: boolean;
19-
/**
20-
* Allow control safe area
21-
*/
22-
useSafeArea?: boolean;
23-
/**
24-
* Whether or not to include bottom tab bar inset
25-
*/
26-
usesBottomTabs?: boolean;
27-
28-
scrollToFocusedInput?: boolean;
29-
scrollBehavior?: number;
30-
revealKeyboardInteractive?: boolean;
31-
manageScrollView?: boolean;
32-
requiresSameParentToManageScrollView?: boolean;
33-
addBottomView?: boolean;
34-
allowHitsOutsideBounds?: boolean;
35-
36-
// Can't figure out what it's supposed to be
37-
ref?: any;
38-
39-
children?: React.ReactChild | React.ReactChild[];
40-
41-
style?: ViewStyle;
42-
}
10+
* Enables tracking of the keyboard when it's dismissed interactively (false by default).
11+
* Why? When using an external keyboard (BT),
12+
* you still get the keyboard events and the view just hovers when you focus the input.
13+
* Also, if you're not using interactive style of dismissing the keyboard
14+
* (or if you don't have an input inside this view) it doesn't make sense to track it anyway.
15+
* (This is caused because of the usage of inputAccessory to be able to track the
16+
* keyboard interactive change and it introduces this bug)
17+
*/
18+
trackInteractive?: boolean;
19+
/**
20+
* iOS only.
21+
* Show the keyboard on a negative scroll
22+
* default: false
23+
*/
24+
revealKeyboardInteractive?: boolean;
25+
/**
26+
* iOS only.
27+
* Set to false to turn off inset management and manage it yourself
28+
* default: true
29+
*/
30+
manageScrollView?: boolean;
31+
/**
32+
* iOS only.
33+
* Set to true manageScrollView is set to true and still does not work,
34+
* it means that the ScrollView found is the wrong one and you'll have
35+
* to have the KeyboardAccessoryView and the ScrollView as siblings
36+
* and set this to true
37+
*
38+
* default: false
39+
*/
40+
requiresSameParentToManageScrollView?: boolean;
41+
/**
42+
* iOS only.
43+
* Allow hitting sub-views that are placed beyond the view bounds
44+
*
45+
* default: false
46+
*/
47+
allowHitsOutsideBounds?: boolean;
48+
scrollToFocusedInput?: boolean;
49+
scrollBehavior?: number;
50+
/**
51+
* iOS only.
52+
* Add a SafeArea view beneath the KeyboardAccessoryView
53+
* default: false
54+
*/
55+
addBottomView?: boolean;
56+
/**
57+
* iOS only.
58+
* The bottom view's color as an hex string
59+
* default: '#ffffff'
60+
*/
61+
bottomViewColor?: string;
62+
/**
63+
* Allow control safe area
64+
*/
65+
useSafeArea?: boolean;
66+
/**
67+
* Whether or not to include bottom tab bar inset
68+
*/
69+
usesBottomTabs?: boolean;
70+
ref?: any;
71+
style?: ViewStyle;
72+
children?: React.ReactChild | React.ReactChild[];
73+
};
4374

4475
const KeyboardTrackingView = forwardRef(({children, ...others}: KeyboardTrackingViewProps, ref: any) => {
4576
const KeyboardTrackingViewContainer = isAndroid ? KeyboardTrackingViewAndroid : KeyboardTrackingViewIOS;
46-
4777
return (
4878
<KeyboardTrackingViewContainer {...others} ref={ref}>
4979
{children}

lib/components/Keyboard/KeyboardTracking/KeyboardTrackingView/keyboardTracking.api.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)