// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import PropTypes from 'prop-types';
import React, {PureComponent} from 'react';
import {intlShape} from 'react-intl';
import {
Alert,
ScrollView,
Text,
TouchableOpacity,
View,
} from 'react-native';
import DeviceInfo from 'react-native-device-info';
import {SafeAreaView} from 'react-native-safe-area-context';
import Config from '@assets/config';
import CompassIcon from '@components/compass_icon';
import FormattedText from '@components/formatted_text';
import StatusBar from '@components/status_bar';
import AboutLinks from '@constants/about_links';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
import {tryOpenURL} from '@utils/url';
const MATTERMOST_BUNDLE_IDS = ['com.mattermost.rnbeta', 'com.mattermost.rn'];
export default class About extends PureComponent {
static propTypes = {
config: PropTypes.object.isRequired,
license: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
};
static contextTypes = {
intl: intlShape.isRequired,
};
openURL = (url) => {
const {intl} = this.context;
const onError = () => {
Alert.alert(
intl.formatMessage({
id: 'mobile.link.error.title',
defaultMessage: 'Error',
}),
intl.formatMessage({
id: 'mobile.link.error.text',
defaultMessage: 'Unable to open the link.',
}),
);
};
tryOpenURL(url, onError);
};
handleAboutTeam = () => {
this.openURL(Config.AboutTeamURL);
};
handleAboutEnterprise = () => {
this.openURL(Config.AboutEnterpriseURL);
};
handlePlatformNotice = () => {
this.openURL(Config.PlatformNoticeURL);
};
handleMobileNotice = () => {
this.openURL(Config.MobileNoticeURL);
};
handleTermsOfService = () => {
this.openURL(AboutLinks.TERMS_OF_SERVICE);
};
handlePrivacyPolicy = () => {
this.openURL(AboutLinks.PRIVACY_POLICY);
}
render() {
const {theme, config, license} = this.props;
const style = getStyleSheet(theme);
let title = (
);
let subTitle = (
);
let learnMore = (
{Config.TeamEditionLearnURL}
);
let licensee;
if (config.BuildEnterpriseReady === 'true') {
title = (
);
subTitle = (
);
learnMore = (
{Config.EELearnURL}
);
if (license.IsLicensed === 'true') {
title = (
);
licensee = (
);
}
}
let serverVersion;
if (config.BuildNumber === config.Version) {
serverVersion = (
);
} else {
serverVersion = (
);
}
let termsOfService;
if (config.TermsOfServiceLink) {
termsOfService = (
);
}
let privacyPolicy;
if (config.PrivacyPolicyLink) {
privacyPolicy = (
);
}
let tosPrivacyHyphen;
if (termsOfService && privacyPolicy) {
tosPrivacyHyphen = (
{' - '}
);
}
return (
{`${config.SiteName} `}
{title}
{subTitle}
{serverVersion}
{licensee}
{learnMore}
{!MATTERMOST_BUNDLE_IDS.includes(DeviceInfo.getBundleId()) &&
}
{termsOfService}
{tosPrivacyHyphen}
{privacyPolicy}
),
mobile: (
),
}}
testID='about.notice_text'
/>
{config.BuildHash}
{config.BuildHashEnterprise}
{config.BuildDate}
);
}
}
const getStyleSheet = makeStyleSheetFromTheme((theme) => {
return {
container: {
flex: 1,
},
scrollView: {
flex: 1,
backgroundColor: changeOpacity(theme.centerChannelColor, 0.06),
},
scrollViewContent: {
paddingBottom: 30,
},
logoContainer: {
alignItems: 'center',
flex: 1,
height: 200,
paddingVertical: 40,
},
infoContainer: {
flex: 1,
flexDirection: 'column',
paddingHorizontal: 20,
},
titleContainer: {
flex: 1,
marginBottom: 20,
},
title: {
fontSize: 22,
color: theme.centerChannelColor,
},
subtitle: {
color: changeOpacity(theme.centerChannelColor, 0.5),
fontSize: 19,
marginBottom: 15,
},
learnContainer: {
flex: 1,
flexDirection: 'column',
marginVertical: 20,
},
learn: {
color: theme.centerChannelColor,
fontSize: 16,
},
learnLink: {
color: theme.linkColor,
fontSize: 16,
},
info: {
color: theme.centerChannelColor,
fontSize: 16,
lineHeight: 19,
},
licenseContainer: {
flex: 1,
flexDirection: 'row',
marginTop: 20,
},
noticeContainer: {
flex: 1,
flexDirection: 'column',
},
noticeLink: {
color: theme.linkColor,
fontSize: 11,
lineHeight: 13,
},
hashContainer: {
flex: 1,
flexDirection: 'column',
},
footerGroup: {
flex: 1,
},
footerTitleText: {
color: changeOpacity(theme.centerChannelColor, 0.5),
fontSize: 11,
fontWeight: '600',
lineHeight: 13,
},
footerText: {
color: changeOpacity(theme.centerChannelColor, 0.5),
fontSize: 11,
lineHeight: 13,
marginBottom: 10,
},
copyrightText: {
marginBottom: 0,
},
hyphenText: {
marginBottom: 0,
},
tosPrivacyContainer: {
flex: 1,
flexDirection: 'row',
marginBottom: 10,
},
};
});