[FEATURE] Share app (#1109)

This commit is contained in:
IlarionHalushka 2019-08-08 21:28:51 +03:00 committed by Diego Mello
parent 7b2185d361
commit 6ab5ecdf93
2 changed files with 17 additions and 9 deletions

3
app/constants/links.js Normal file
View File

@ -0,0 +1,3 @@
export const PLAY_MARKET_LINK = 'https://play.google.com/store/apps/details?id=chat.rocket.reactnative';
export const APP_STORE_LINK = 'https://itunes.apple.com/app/rocket-chat-experimental/id1272915472?ls=1&mt=8';
export const LICENSE_LINK = 'https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/LICENSE';

View File

@ -1,6 +1,6 @@
import React from 'react';
import {
View, Linking, ScrollView, AsyncStorage, SafeAreaView, Switch
View, Linking, ScrollView, AsyncStorage, SafeAreaView, Switch, Share
} from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
@ -14,14 +14,14 @@ import { DisclosureImage } from '../../containers/DisclosureIndicator';
import Separator from '../../containers/Separator';
import I18n from '../../i18n';
import { MARKDOWN_KEY } from '../../lib/rocketchat';
import { getReadableVersion, getDeviceModel } from '../../utils/deviceInfo';
import { getReadableVersion, getDeviceModel, isAndroid } from '../../utils/deviceInfo';
import openLink from '../../utils/openLink';
import scrollPersistTaps from '../../utils/scrollPersistTaps';
import { showErrorAlert } from '../../utils/info';
import styles from './styles';
import sharedStyles from '../Styles';
import { PLAY_MARKET_LINK, APP_STORE_LINK, LICENSE_LINK } from '../../constants/links';
const LICENSE_LINK = 'https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/LICENSE';
const SectionSeparator = React.memo(() => <View style={styles.sectionSeparatorBorder} />);
class SettingsView extends React.Component {
@ -62,6 +62,10 @@ class SettingsView extends React.Component {
}
}
shareApp = () => {
Share.share({ message: isAndroid ? PLAY_MARKET_LINK : APP_STORE_LINK });
}
onPressLicense = () => openLink(LICENSE_LINK)
renderDisclosure = () => <DisclosureImage />
@ -104,6 +108,13 @@ class SettingsView extends React.Component {
right={this.renderDisclosure}
/>
<Separator />
<ListItem
title={I18n.t('Share_this_app')}
onPress={this.shareApp}
showActionIndicator
testID='settings-view-share-app'
/>
<Separator />
<ListItem
title={I18n.t('Theme')}
showActionIndicator
@ -111,12 +122,6 @@ class SettingsView extends React.Component {
testID='settings-view-theme'
/>
<Separator />
<ListItem
title={I18n.t('Share_this_app')}
showActionIndicator
disabled
testID='settings-view-share-app'
/>
<SectionSeparator />