Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 42 additions & 25 deletions src/components/ScreenWrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ class ScreenWrapper extends React.Component {
onPanResponderRelease: toggleTestToolsModal,
});

this.keyboardDissmissPanResponder = PanResponder.create({
onMoveShouldSetPanResponderCapture: (e, gestureState) => {
const isHorizontalSwipe = Math.abs(gestureState.dx) > Math.abs(gestureState.dy);
if (isHorizontalSwipe && this.props.shouldDismissKeyboardBeforeClose) {
return true;
}
return false;
},
onPanResponderGrant: Keyboard.dismiss,
});

this.state = {
didScreenTransitionEnd: false,
};
Expand Down Expand Up @@ -96,35 +107,41 @@ class ScreenWrapper extends React.Component {

return (
<View
style={[...this.props.style, styles.flex1, paddingStyle]}
style={styles.flex1}
// eslint-disable-next-line react/jsx-props-no-spreading
{...(this.props.environment === CONST.ENVIRONMENT.DEV ? this.panResponder.panHandlers : {})}
{...(this.props.environment === CONST.ENVIRONMENT.DEV ? {...this.panResponder.panHandlers} : undefined)}
>
<KeyboardAvoidingView
style={[styles.w100, styles.h100, {maxHeight}]}
behavior={this.props.keyboardAvoidingViewBehavior}
enabled={this.props.shouldEnableKeyboardAvoidingView}
<View
style={[...this.props.style, styles.flex1, paddingStyle]}
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...this.keyboardDissmissPanResponder.panHandlers}
>
<PickerAvoidingView
style={styles.flex1}
enabled={this.props.shouldEnablePickerAvoiding}
<KeyboardAvoidingView
style={[styles.w100, styles.h100, {maxHeight}]}
behavior={this.props.keyboardAvoidingViewBehavior}
enabled={this.props.shouldEnableKeyboardAvoidingView}
>
<HeaderGap />
{this.props.environment === CONST.ENVIRONMENT.DEV && <TestToolsModal />}
{this.props.environment === CONST.ENVIRONMENT.DEV && <CustomDevMenu />}
{
// If props.children is a function, call it to provide the insets to the children.
_.isFunction(this.props.children)
? this.props.children({
insets,
safeAreaPaddingBottomStyle,
didScreenTransitionEnd: this.state.didScreenTransitionEnd,
})
: this.props.children
}
{this.props.isSmallScreenWidth && this.props.shouldShowOfflineIndicator && <OfflineIndicator />}
</PickerAvoidingView>
</KeyboardAvoidingView>
<PickerAvoidingView
style={styles.flex1}
enabled={this.props.shouldEnablePickerAvoiding}
>
<HeaderGap />
{this.props.environment === CONST.ENVIRONMENT.DEV && <TestToolsModal />}
{this.props.environment === CONST.ENVIRONMENT.DEV && <CustomDevMenu />}
{
// If props.children is a function, call it to provide the insets to the children.
_.isFunction(this.props.children)
? this.props.children({
insets,
safeAreaPaddingBottomStyle,
didScreenTransitionEnd: this.state.didScreenTransitionEnd,
})
: this.props.children
}
{this.props.isSmallScreenWidth && this.props.shouldShowOfflineIndicator && <OfflineIndicator />}
</PickerAvoidingView>
</KeyboardAvoidingView>
</View>
</View>
);
}}
Expand Down