2018-08-10 17:26:36 +00:00
|
|
|
import React from 'react';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2020-03-30 19:20:50 +00:00
|
|
|
View, Text, Image, BackHandler, Linking
|
2018-09-25 19:28:42 +00:00
|
|
|
} from 'react-native';
|
2018-08-10 17:26:36 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-01-31 16:08:38 +00:00
|
|
|
import { connect } from 'react-redux';
|
2019-03-12 16:23:06 +00:00
|
|
|
import Orientation from 'react-native-orientation-locker';
|
2018-08-10 17:26:36 +00:00
|
|
|
|
2018-11-27 19:40:53 +00:00
|
|
|
import { appStart as appStartAction } from '../../actions';
|
2018-08-10 17:26:36 +00:00
|
|
|
import I18n from '../../i18n';
|
2020-03-30 19:20:50 +00:00
|
|
|
import Button from '../../containers/Button';
|
2018-08-10 17:26:36 +00:00
|
|
|
import styles from './styles';
|
2020-03-30 19:20:50 +00:00
|
|
|
import { isTablet } from '../../utils/deviceInfo';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import { withTheme } from '../../theme';
|
2020-03-30 19:20:50 +00:00
|
|
|
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
|
2018-08-10 17:26:36 +00:00
|
|
|
|
2019-08-07 13:51:34 +00:00
|
|
|
class OnboardingView extends React.Component {
|
2019-03-12 16:23:06 +00:00
|
|
|
static navigationOptions = () => ({
|
|
|
|
header: null
|
|
|
|
})
|
2018-10-23 21:39:48 +00:00
|
|
|
|
2018-08-10 17:26:36 +00:00
|
|
|
static propTypes = {
|
2019-03-12 16:23:06 +00:00
|
|
|
navigation: PropTypes.object,
|
2019-12-04 16:39:53 +00:00
|
|
|
appStart: PropTypes.func,
|
|
|
|
theme: PropTypes.string
|
2018-08-10 17:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
2019-05-28 13:03:08 +00:00
|
|
|
super(props);
|
2018-11-27 19:40:53 +00:00
|
|
|
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
|
2019-11-25 20:01:17 +00:00
|
|
|
if (!isTablet) {
|
|
|
|
Orientation.lockToPortrait();
|
|
|
|
}
|
2018-08-10 17:26:36 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
const { theme } = this.props;
|
|
|
|
if (theme !== nextProps.theme) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-21 10:55:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-19 14:18:32 +00:00
|
|
|
componentWillUnmount() {
|
2018-11-27 19:40:53 +00:00
|
|
|
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleBackPress = () => {
|
|
|
|
const { appStart } = this.props;
|
|
|
|
appStart('background');
|
|
|
|
return false;
|
2018-09-19 14:18:32 +00:00
|
|
|
}
|
|
|
|
|
2018-10-23 21:39:48 +00:00
|
|
|
connectServer = () => {
|
2020-03-30 19:20:50 +00:00
|
|
|
const { navigation } = this.props;
|
|
|
|
navigation.navigate('NewServerView');
|
2018-08-10 17:26:36 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 14:13:36 +00:00
|
|
|
createWorkspace = async() => {
|
|
|
|
try {
|
|
|
|
await Linking.openURL('https://cloud.rocket.chat/trial');
|
|
|
|
} catch {
|
|
|
|
// do nothing
|
|
|
|
}
|
2018-08-10 17:26:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-12-04 16:39:53 +00:00
|
|
|
const { theme } = this.props;
|
2018-08-10 17:26:36 +00:00
|
|
|
return (
|
2020-05-20 16:33:40 +00:00
|
|
|
<FormContainer theme={theme} testID='onboarding-view'>
|
2020-03-30 19:20:50 +00:00
|
|
|
<FormContainerInner>
|
|
|
|
<Image style={styles.onboarding} source={{ uri: 'logo' }} fadeDuration={0} />
|
|
|
|
<Text style={[styles.title, { color: themes[theme].titleText }]}>{I18n.t('Onboarding_title')}</Text>
|
|
|
|
<Text style={[styles.subtitle, { color: themes[theme].controlText }]}>{I18n.t('Onboarding_subtitle')}</Text>
|
|
|
|
<Text style={[styles.description, { color: themes[theme].auxiliaryText }]}>{I18n.t('Onboarding_description')}</Text>
|
|
|
|
<View style={styles.buttonsContainer}>
|
|
|
|
<Button
|
|
|
|
title={I18n.t('Onboarding_join_workspace')}
|
|
|
|
type='primary'
|
|
|
|
onPress={this.connectServer}
|
|
|
|
theme={theme}
|
2020-05-20 16:33:40 +00:00
|
|
|
testID='join-workspace'
|
2020-03-30 19:20:50 +00:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
title={I18n.t('Create_a_new_workspace')}
|
|
|
|
type='secondary'
|
|
|
|
backgroundColor={themes[theme].chatComponentBackground}
|
|
|
|
onPress={this.createWorkspace}
|
|
|
|
theme={theme}
|
2020-05-20 16:33:40 +00:00
|
|
|
testID='create-workspace-button'
|
2020-03-30 19:20:50 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</FormContainerInner>
|
|
|
|
</FormContainer>
|
2018-08-10 17:26:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
appStart: root => dispatch(appStartAction(root))
|
|
|
|
});
|
|
|
|
|
2020-03-30 19:20:50 +00:00
|
|
|
export default connect(null, mapDispatchToProps)(withTheme(OnboardingView));
|