Skip to content

Commit de64105

Browse files
authored
refactor: short names for KeyboardGestureArea component props (#141)
## 📜 Description Use shorter name for `KeyboardGestureArea` props. - `allowToShowKeyboardFromHiddenStateBySwipeUp` -> `showOnSwipeUp` - `allowToDragKeyboardFromShownStateBySwipes` -> `enableSwipeToDismiss` ## 💡 Motivation and Context Short names are better. Honestly I also didn't like such big names, but at the time of the implementation I decided not to think about correct names 😅 By gathering a feedback I've decided to rename it (I've decided not to mark old props as deprecated because it would bring more confusions). I highly doubt there are any people who just started to use this new feature and already shipped it to theirs applications, so I'm going to do a small `1.5.1` release after merging this PR. ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - renamed props; ### Docs - renamed props; ### Android - renamed props and corresponding setters; ## 🤔 How Has This Been Tested? Tested on emulator. ## 📝 Checklist - [x] CI successfully passed
1 parent bcad0b5 commit de64105

File tree

8 files changed

+16
-19
lines changed

8 files changed

+16
-19
lines changed

FabricExample/src/screens/Examples/InteractiveKeyboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function InteractiveKeyboard({ navigation }: Props) {
8686
<KeyboardGestureArea
8787
style={styles.content}
8888
interpolator={interpolator}
89-
allowToShowKeyboardFromHiddenStateBySwipeUp
89+
showOnSwipeUp
9090
>
9191
<Reanimated.ScrollView
9292
showsVerticalScrollIndicator={false}

android/src/fabric/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ class KeyboardGestureAreaViewManager(mReactContext: ReactApplicationContext) :
3232
manager.setInterpolator(view as KeyboardGestureAreaReactViewGroup, value ?: "linear")
3333
}
3434

35-
@ReactProp(name = "allowToShowKeyboardFromHiddenStateBySwipeUp")
36-
override fun setAllowToShowKeyboardFromHiddenStateBySwipeUp(
37-
view: ReactViewGroup,
38-
value: Boolean,
39-
) {
35+
@ReactProp(name = "showOnSwipeUp")
36+
override fun setShowOnSwipeUp(view: ReactViewGroup, value: Boolean) {
4037
manager.setScrollKeyboardOnScreenWhenNotVisible(view as KeyboardGestureAreaReactViewGroup, value)
4138
}
4239

43-
@ReactProp(name = "allowToDragKeyboardFromShownStateBySwipes")
44-
override fun setAllowToDragKeyboardFromShownStateBySwipes(view: ReactViewGroup?, value: Boolean) {
40+
@ReactProp(name = "enableSwipeToDismiss")
41+
override fun setEnableSwipeToDismiss(view: ReactViewGroup?, value: Boolean) {
4542
manager.setScrollKeyboardOffScreenWhenVisible(view as KeyboardGestureAreaReactViewGroup, value)
4643
}
4744
}

android/src/paper/java/com/reactnativekeyboardcontroller/KeyboardGestureAreaViewManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class KeyboardGestureAreaViewManager(mReactContext: ReactApplicationContext) : R
2121
manager.setInterpolator(view, interpolator)
2222
}
2323

24-
@ReactProp(name = "allowToShowKeyboardFromHiddenStateBySwipeUp")
24+
@ReactProp(name = "showOnSwipeUp")
2525
fun setScrollKeyboardOnScreenWhenNotVisible(view: KeyboardGestureAreaReactViewGroup, value: Boolean) {
2626
manager.setScrollKeyboardOnScreenWhenNotVisible(view, value)
2727
}
2828

29-
@ReactProp(name = "allowToDragKeyboardFromShownStateBySwipes")
29+
@ReactProp(name = "enableSwipeToDismiss")
3030
fun setScrollKeyboardOffScreenWhenVisible(view: KeyboardGestureAreaReactViewGroup, value: Boolean) {
3131
manager.setScrollKeyboardOffScreenWhenVisible(view, value)
3232
}

docs/docs/api/keyboard-gesture-area.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ String with possible values `linear` and `ios`:
1919
- **ios** - interactive keyboard dismissing will work as in iOS: swipes in non-keyboard area will not affect keyboard positioning, but if your swipe touches keyboard - keyboard will follow finger position.
2020
- **linear** - gestures inside the component will linearly affect the position of the keyboard, i.e. if the user swipes down by 20 pixels, then the keyboard will also be moved down by 20 pixels, even if the gesture was not made over the keyboard area.
2121

22-
#### `allowToShowKeyboardFromHiddenStateBySwipeUp`
22+
#### `showOnSwipeUp`
2323

2424
A boolean prop which allows to customize interactive keyboard behavior. If set to `true` then it allows to show keyboard (if it's already closed) by swipe up gesture. `false` by default.
2525

26-
#### `allowToDragKeyboardFromShownStateBySwipes`
26+
#### `enableSwipeToDismiss`
2727

2828
A boolean prop which allows to customize interactive keyboard behavior. If set to `false`, then any gesture will not affect keyboard position if the keyboard is shown. `true` by default.
2929

docs/versioned_docs/version-1.5.0/api/keyboard-gesture-area.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ String with possible values `linear` and `ios`:
1919
- **ios** - interactive keyboard dismissing will work as in iOS: swipes in non-keyboard area will not affect keyboard positioning, but if your swipe touches keyboard - keyboard will follow finger position.
2020
- **linear** - gestures inside the component will linearly affect the position of the keyboard, i.e. if the user swipes down by 20 pixels, then the keyboard will also be moved down by 20 pixels, even if the gesture was not made over the keyboard area.
2121

22-
#### `allowToShowKeyboardFromHiddenStateBySwipeUp`
22+
#### `showOnSwipeUp`
2323

2424
A boolean prop which allows to customize interactive keyboard behavior. If set to `true` then it allows to show keyboard (if it's already closed) by swipe up gesture. `false` by default.
2525

26-
#### `allowToDragKeyboardFromShownStateBySwipes`
26+
#### `enableSwipeToDismiss`
2727

2828
A boolean prop which allows to customize interactive keyboard behavior. If set to `false`, then any gesture will not affect keyboard position if the keyboard is shown. `true` by default.
2929

example/src/screens/Examples/InteractiveKeyboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function InteractiveKeyboard({ navigation }: Props) {
8686
<KeyboardGestureArea
8787
style={styles.content}
8888
interpolator={interpolator}
89-
allowToShowKeyboardFromHiddenStateBySwipeUp
89+
showOnSwipeUp
9090
>
9191
<Reanimated.ScrollView
9292
showsVerticalScrollIndicator={false}

src/specs/KeyboardGestureAreaNativeComponent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNati
55

66
export interface NativeProps extends ViewProps {
77
interpolator?: WithDefault<'linear' | 'ios', 'linear'>;
8-
allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;
9-
allowToDragKeyboardFromShownStateBySwipes?: boolean;
8+
showOnSwipeUp?: boolean;
9+
enableSwipeToDismiss?: boolean;
1010
}
1111

1212
export default codegenNativeComponent<NativeProps>('KeyboardGestureArea', {

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export type KeyboardGestureAreaProps = {
3939
* Whether to allow to show a keyboard from dismissed state by swipe up.
4040
* Default to `false`.
4141
*/
42-
allowToShowKeyboardFromHiddenStateBySwipeUp?: boolean;
42+
showOnSwipeUp?: boolean;
4343
/**
4444
* Whether to allow to control a keyboard by gestures. The strategy how
4545
* it should be controlled is determined by `interpolator` property.
4646
* Defaults to `true`.
4747
*/
48-
allowToDragKeyboardFromShownStateBySwipes?: boolean;
48+
enableSwipeToDismiss?: boolean;
4949
} & ViewProps;
5050

5151
export type KeyboardControllerModule = {

0 commit comments

Comments
 (0)