diff --git a/app/components/layout/keyboard_layout.js b/app/components/layout/keyboard_layout.js new file mode 100644 index 000000000..4dd697577 --- /dev/null +++ b/app/components/layout/keyboard_layout.js @@ -0,0 +1,35 @@ +// 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 ( + + {children} + + ); + } + + return ( + + {children} + + ); + } +} diff --git a/app/components/root/index.js b/app/components/root/index.js new file mode 100644 index 000000000..f09929aa4 --- /dev/null +++ b/app/components/root/index.js @@ -0,0 +1,6 @@ +// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import RootContainer from './root_container'; + +export default RootContainer; diff --git a/app/layouts/root_layout/root_layout.js b/app/components/root/root.js similarity index 95% rename from app/layouts/root_layout/root_layout.js rename to app/components/root/root.js index 2e520ab52..d389eb369 100644 --- a/app/layouts/root_layout/root_layout.js +++ b/app/components/root/root.js @@ -6,7 +6,7 @@ import {AppState} from 'react-native'; import {getTranslations} from 'service/i18n'; import {IntlProvider} from 'react-intl'; -export default class RootLayout extends React.Component { +export default class Root extends React.Component { static propTypes = { children: React.PropTypes.node, locale: React.PropTypes.string.isRequired, diff --git a/app/layouts/root_layout/root_layout_container.js b/app/components/root/root_container.js similarity index 94% rename from app/layouts/root_layout/root_layout_container.js rename to app/components/root/root_container.js index 1bed3cbf6..8ab3c33bc 100644 --- a/app/layouts/root_layout/root_layout_container.js +++ b/app/components/root/root_container.js @@ -8,7 +8,7 @@ import Config from 'assets/config.json'; import {setAppState} from 'service/actions/general'; -import RootLayout from './root_layout'; +import Root from './root'; function mapStateToProps(state, ownProps) { const users = state.entities.users; @@ -33,4 +33,4 @@ function mapDispatchToProps(dispatch) { }; } -export default connect(mapStateToProps, mapDispatchToProps)(RootLayout); +export default connect(mapStateToProps, mapDispatchToProps)(Root); diff --git a/app/mattermost.js b/app/mattermost.js index debabbd91..3c361fccb 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -5,10 +5,10 @@ import 'harmony-reflect'; import React from 'react'; import {Provider} from 'react-redux'; -import configureStore from 'app/store'; +import Root from 'app/components/root'; import initialState from 'app/initial_state'; import Router from 'app/navigation/router'; -import RootLayout from 'app/layouts/root_layout/root_layout_container'; +import configureStore from 'app/store'; const store = configureStore(initialState); @@ -16,9 +16,9 @@ export default class Mattermost extends React.Component { render() { return ( - + - + ); } diff --git a/app/scenes/channel/channel.js b/app/scenes/channel/channel.js index 98eab9652..d827dce02 100644 --- a/app/scenes/channel/channel.js +++ b/app/scenes/channel/channel.js @@ -3,15 +3,14 @@ import React from 'react'; import { - KeyboardAvoidingView, - Platform, StatusBar, - Text, - View + Text } from 'react-native'; -import {Constants} from 'service/constants'; +import KeyboardLayout from 'app/components/layout/keyboard_layout'; import PostTextbox from 'app/components/post_textbox'; + +import {Constants} from 'service/constants'; import EventEmitter from 'service/utils/event_emitter'; import ChannelDrawerButton from './channel_drawer_button'; @@ -106,15 +105,6 @@ export default class Channel extends React.PureComponent { this.props.actions.selectFirstAvailableTeam(); }; - renderAndroid = (children) => { - const {theme} = this.props; - return ( - - {children} - - ); - }; - render() { const { currentTeam, @@ -133,43 +123,22 @@ export default class Channel extends React.PureComponent { teamId = currentTeam.id; } - const status = ( - - ); - const postList = ( - - ); - const postTextBox = ( - - ); - - if (Platform.OS === 'android') { - return this.renderAndroid([status, postList, postTextBox]); - } - return ( - - {status} - {postList} - {postTextBox} - + + + + ); } } diff --git a/app/scenes/login/login.js b/app/scenes/login/login.js index 1b29a7286..4bab9c63b 100644 --- a/app/scenes/login/login.js +++ b/app/scenes/login/login.js @@ -6,17 +6,16 @@ import {injectIntl, intlShape} from 'react-intl'; import { Image, Keyboard, - KeyboardAvoidingView, - Platform, Text, TextInput, TouchableWithoutFeedback, View } from 'react-native'; - import Button from 'react-native-button'; -import FormattedText from 'app/components/formatted_text'; + import ErrorText from 'app/components/error_text'; +import FormattedText from 'app/components/formatted_text'; +import KeyboardLayout from 'app/components/layout/keyboard_layout'; import Loading from 'app/components/loading'; import {GlobalStyles} from 'app/styles'; @@ -176,73 +175,65 @@ class Login extends Component { return ; } - const scene = ( - - - - - {this.props.config.SiteName} - - - - - - - - - ); - - if (Platform.OS === 'android') { - return scene; - } - return ( - - {scene} - + + + + + {this.props.config.SiteName} + + + + + + + + + ); } } diff --git a/app/scenes/mfa/mfa.js b/app/scenes/mfa/mfa.js index 561e683ad..7fe8258cf 100644 --- a/app/scenes/mfa/mfa.js +++ b/app/scenes/mfa/mfa.js @@ -5,15 +5,14 @@ import React, {Component} from 'react'; import { Image, Keyboard, - KeyboardAvoidingView, - Platform, TouchableWithoutFeedback, View } from 'react-native'; - import Button from 'react-native-button'; + import ErrorText from 'app/components/error_text'; import FormattedText from 'app/components/formatted_text'; +import KeyboardLayout from 'app/components/layout/keyboard_layout'; import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_localized_placeholder'; import {GlobalStyles} from 'app/styles'; @@ -80,58 +79,50 @@ export default class Mfa extends Component { }; render() { - const scene = ( - - - - - - - - - - ); - - if (Platform.OS === 'android') { - return scene; - } - return ( - - {scene} - + + + + + + + + + + ); } } diff --git a/app/scenes/select_server/select_server.js b/app/scenes/select_server/select_server.js index 651f81c58..c9b54e4c0 100644 --- a/app/scenes/select_server/select_server.js +++ b/app/scenes/select_server/select_server.js @@ -5,8 +5,6 @@ import React, {Component} from 'react'; import { Image, Keyboard, - KeyboardAvoidingView, - Platform, TouchableWithoutFeedback, View } from 'react-native'; @@ -14,6 +12,7 @@ import { import Button from 'react-native-button'; import ErrorText from 'app/components/error_text'; import FormattedText from 'app/components/formatted_text'; +import KeyboardLayout from 'app/components/layout/keyboard_layout'; import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_localized_placeholder'; import {GlobalStyles} from 'app/styles'; @@ -49,58 +48,50 @@ export default class SelectServer extends Component { }; render() { - const scene = ( - - - - - - - - - - ); - - if (Platform.OS === 'android') { - return scene; - } - return ( - - {scene} - + + + + + + + + + + ); } } diff --git a/app/scenes/thread/thread.js b/app/scenes/thread/thread.js index 59d828d42..671a1c221 100644 --- a/app/scenes/thread/thread.js +++ b/app/scenes/thread/thread.js @@ -2,14 +2,9 @@ // See License.txt for license information. import React from 'react'; -import { - KeyboardAvoidingView, - Platform, - StatusBar, - StyleSheet, - View -} from 'react-native'; +import {StatusBar, StyleSheet} from 'react-native'; +import KeyboardLayout from 'app/components/layout/keyboard_layout'; import PostList from 'app/components/post_list'; import PostTextbox from 'app/components/post_textbox'; import {makeStyleSheetFromTheme} from 'app/utils/theme'; @@ -40,57 +35,25 @@ export default class Thread extends React.Component { this.props.actions.handleCommentDraftChanged(this.props.rootId, value); }; - renderAndroid = (children) => { - const style = getStyle(this.props.theme); - - return ( - - {children} - - ); - }; - render() { const style = getStyle(this.props.theme); - const status = ( - - ); - const postList = ( - - ); - - const postTextBox = ( - - ); - - if (Platform.OS === 'android') { - return this.renderAndroid([status, postList, postTextBox]); - } - return ( - - {status} - {postList} - {postTextBox} - + + + + ); } }