* Renamed layouts/root_layout to components/root * Added KeyboardLayout to automatically use a KeyboardAvoidingView when necessary
35 lines
1,001 B
JavaScript
35 lines
1,001 B
JavaScript
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {KeyboardAvoidingView, Platform, View} from 'react-native';
|
|
|
|
export default class KeyboardLayout extends React.Component {
|
|
static propTypes = {
|
|
behaviour: React.PropTypes.string,
|
|
children: React.PropTypes.node,
|
|
keyboardVerticalOffset: React.PropTypes.number
|
|
};
|
|
|
|
render() {
|
|
const {behaviour, children, keyboardVerticalOffset, ...otherProps} = this.props;
|
|
|
|
if (Platform.OS === 'android') {
|
|
return (
|
|
<View {...otherProps}>
|
|
{children}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<KeyboardAvoidingView
|
|
behaviour={behaviour}
|
|
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
{...otherProps}
|
|
>
|
|
{children}
|
|
</KeyboardAvoidingView>
|
|
);
|
|
}
|
|
}
|