import React from 'react'; import { View, Text, Image, SafeAreaView, TouchableOpacity } from 'react-native'; import PropTypes from 'prop-types'; import Icon from 'react-native-vector-icons/MaterialIcons'; import { connect, Provider } from 'react-redux'; import { Navigation } from 'react-native-navigation'; import { selectServerRequest, serverInitAdd, serverFinishAdd } from '../../actions/server'; import I18n from '../../i18n'; import openLink from '../../utils/openLink'; import Button from './Button'; import styles from './styles'; import LoggedView from '../View'; import DeviceInfo from '../../utils/deviceInfo'; import store from '../../lib/createStore'; let NewServerView = null; @connect(state => ({ currentServer: state.server.server, adding: state.server.adding }), dispatch => ({ initAdd: () => dispatch(serverInitAdd()), finishAdd: () => dispatch(serverFinishAdd()), selectServer: server => dispatch(selectServerRequest(server)) })) /** @extends React.Component */ export default class OnboardingView extends LoggedView { static propTypes = { navigator: PropTypes.object, previousServer: PropTypes.string, adding: PropTypes.bool, selectServer: PropTypes.func.isRequired, currentServer: PropTypes.string, initAdd: PropTypes.func, finishAdd: PropTypes.func } constructor(props) { super('CreateChannelView', props); } componentDidMount() { const { previousServer, initAdd } = this.props; if (previousServer) { initAdd(); } } componentWillUnmount() { const { selectServer, previousServer, currentServer, adding, finishAdd } = this.props; if (adding) { if (previousServer !== currentServer) { selectServer(previousServer); } finishAdd(); } } close = () => { const { navigator } = this.props; navigator.dismissModal(); } connectServer = () => { if (NewServerView == null) { NewServerView = require('../NewServerView').default; Navigation.registerComponent('NewServerView', () => NewServerView, store, Provider); } const { navigator } = this.props; navigator.push({ screen: 'NewServerView', backButtonTitle: '', navigatorStyle: { navBarHidden: true } }); } joinCommunity = () => { if (NewServerView == null) { NewServerView = require('../NewServerView').default; Navigation.registerComponent('NewServerView', () => NewServerView, store, Provider); } const { navigator } = this.props; navigator.push({ screen: 'NewServerView', backButtonTitle: '', passProps: { server: 'https://open.rocket.chat' }, navigatorStyle: { navBarHidden: true } }); } createWorkspace = () => { openLink('https://cloud.rocket.chat/trial'); } renderClose = () => { const { previousServer } = this.props; if (previousServer) { let top = 15; if (DeviceInfo.getBrand() === 'Apple') { top = DeviceInfo.isNotch() ? 45 : 30; } return ( ); } return null; } render() { return ( {I18n.t('Welcome_to_RocketChat')} {I18n.t('Open_Source_Communication')}