From 6ab5ecdf936475aed7ce7dbec75df9e8eeeb34a6 Mon Sep 17 00:00:00 2001 From: IlarionHalushka Date: Thu, 8 Aug 2019 21:28:51 +0300 Subject: [PATCH] [FEATURE] Share app (#1109) --- app/constants/links.js | 3 +++ app/views/SettingsView/index.js | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 app/constants/links.js diff --git a/app/constants/links.js b/app/constants/links.js new file mode 100644 index 000000000..15c045a7c --- /dev/null +++ b/app/constants/links.js @@ -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'; diff --git a/app/views/SettingsView/index.js b/app/views/SettingsView/index.js index 3f77e3c2d..c1c49da00 100644 --- a/app/views/SettingsView/index.js +++ b/app/views/SettingsView/index.js @@ -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(() => ); 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 = () => @@ -104,6 +108,13 @@ class SettingsView extends React.Component { right={this.renderDisclosure} /> + + -