mattermost-mobile/app/components/layout/keyboard_layout.js
Harrison Healey 1319f1fcf8 Added KeyboardLayout to automatically use a KeyboardAvoidingView as necessary (#263)
* Renamed layouts/root_layout to components/root

* Added KeyboardLayout to automatically use a KeyboardAvoidingView when necessary
2017-02-16 09:19:48 -05:00

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>
);
}
}