From 9157b18f4564bcc7b16a60a1a884da672341daa6 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 25 Oct 2019 15:24:57 +0100 Subject: [PATCH] add share button to channel page --- src/constants.js | 2 ++ src/page/channel/view.js | 17 ++++++++++++++++- src/page/file/view.js | 9 ++------- src/styles/channelPage.js | 4 ++++ src/utils/helper.js | 5 +++++ 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/constants.js b/src/constants.js index 26659e3..6cbd629 100644 --- a/src/constants.js +++ b/src/constants.js @@ -140,6 +140,8 @@ const Constants = { TRUE_STRING: 'true', MINIMUM_TRANSACTION_BALANCE: 0.1, + + SHARE_BASE_URL: 'https://open.lbry.com', }; export default Constants; diff --git a/src/page/channel/view.js b/src/page/channel/view.js index 2a787be..4432c72 100644 --- a/src/page/channel/view.js +++ b/src/page/channel/view.js @@ -13,7 +13,7 @@ import { } from 'react-native'; import { TabView, SceneMap } from 'react-native-tab-view'; import { normalizeURI } from 'lbry-redux'; -import { navigateBack, getOrderBy } from 'utils/helper'; +import { navigateBack, getOrderBy, formatLbryUrlForWeb } from 'utils/helper'; import ChannelIconItem from 'component/channelIconItem'; import ClaimList from 'component/claimList'; import Colors from 'styles/colors'; @@ -172,6 +172,15 @@ class ChannelPage extends React.PureComponent { } }; + onSharePressed = () => { + const { claim } = this.props; + if (claim) { + const { canonical_url: canonicalUrl, short_url: shortUrl, permanent_url: permanentUrl } = claim; + const url = Constants.SHARE_BASE_URL + formatLbryUrlForWeb(canonicalUrl || shortUrl || permanentUrl); + NativeModules.UtilityModule.shareUrl(url); + } + }; + onDeletePressed = () => { const { abandonClaim, claim, navigation } = this.props; if (claim) { @@ -274,6 +283,12 @@ class ChannelPage extends React.PureComponent { onPress={this.onDeletePressed} /> )} +