mattermost-mobile/app/scenes/navigationSceneConnect.js
2017-04-10 11:33:35 -03:00

69 lines
2.3 KiB
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
/* eslint-disable */
import {connect} from 'react-redux';
import React, {PropTypes} from 'react';
import {
Platform,
TouchableOpacity,
View
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import FormattedText from 'app/components/formatted_text';
const defaults = {
renderBackButton: (props, emitter, theme) => {
return (
<TouchableOpacity
style={{flexDirection: 'row', flex: 1, paddingHorizontal: 15, alignItems: 'center'}}
onPress={props.onNavigateBack}
>
<Icon
style={{fontWeight: 'bold'}}
name='angle-left'
size={35}
color={theme.sidebarHeaderTextColor}
/>
</TouchableOpacity>
);
},
renderTitleComponent: (props, emitter, theme) => {
const navProps = props.scene.route.navigationProps || {};
const title = navProps.title;
if (title) {
return (
<View style={{alignItems: 'center', justifyContent: 'center', flex: 1, marginHorizontal: 50}}>
<FormattedText
id={title.id}
defaultMessage={title.defaultMessage}
ellipsizeMode='tail'
numberOfLines={1}
style={{
textAlign: 'center',
color: theme.sidebarHeaderTextColor,
fontSize: 15,
fontWeight: 'bold'
}}
/>
</View>
);
}
},
headerStyle: {
flexDirection: 'row',
alignItems: 'center'
},
allowSceneSwipe: true,
allowMenuSwipe: false
};
export default (stateProps, dispatchProps) => (WrappedComponent) => {
const componentNavigationProps = WrappedComponent.WrappedComponent ? WrappedComponent.WrappedComponent.navigationProps : WrappedComponent.navigationProps;
WrappedComponent.navigationProps = Object.assign({}, defaults, componentNavigationProps);
return connect(stateProps, dispatchProps)(WrappedComponent);
};