Merge pull request #446 from esteemapp/feature/share

Feature/share
This commit is contained in:
uğur erdal 2019-01-19 22:15:56 +03:00 committed by GitHub
commit 37b295018d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { withNavigation } from 'react-navigation'; import { withNavigation } from 'react-navigation';
import { Alert } from 'react-native'; import { Alert, Share } from 'react-native';
import ActionSheet from 'react-native-actionsheet'; import ActionSheet from 'react-native-actionsheet';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
@ -16,6 +16,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
// Utilities // Utilities
import { writeToClipboard } from '../../../utils/clipboard'; import { writeToClipboard } from '../../../utils/clipboard';
import { getPostUrl } from '../../../utils/post';
// Component // Component
import PostDropdownView from '../view/postDropdownView'; import PostDropdownView from '../view/postDropdownView';
@ -40,7 +41,7 @@ class PostDropdownContainer extends PureComponent {
switch (index) { switch (index) {
case '0': case '0':
writeToClipboard(`https://steemit.com${content.url}`); writeToClipboard(getPostUrl(content.url));
break; break;
case '1': case '1':
@ -52,12 +53,26 @@ class PostDropdownContainer extends PureComponent {
case '2': case '2':
this._replyNavigation(); this._replyNavigation();
break; break;
case '3':
setTimeout(() => {
this._share();
}, 500);
break;
default: default:
break; break;
} }
}; };
_share = () => {
const { content } = this.props;
Share.share({
message: content.title,
url: getPostUrl(content.url),
});
};
_reblog = () => { _reblog = () => {
const { const {
currentAccount, content, isLoggedIn, pinCode, intl, currentAccount, content, isLoggedIn, pinCode, intl,
@ -115,7 +130,7 @@ class PostDropdownContainer extends PureComponent {
return ( return (
<Fragment> <Fragment>
<PostDropdownView <PostDropdownView
options={OPTIONS} options={OPTIONS.map(item => intl.formatMessage({ id: `post_dropdown.${item}` }).toUpperCase())}
handleOnDropdownSelect={this._handleOnDropdownSelect} handleOnDropdownSelect={this._handleOnDropdownSelect}
{...this.props} {...this.props}
/> />

View File

@ -179,5 +179,11 @@
"author_payout": "Author Payout", "author_payout": "Author Payout",
"curation_payout": "Curation Payout", "curation_payout": "Curation Payout",
"payout_date": "Payout" "payout_date": "Payout"
},
"post_dropdown": {
"copy": "copy link",
"reblog": "reblog",
"reply": "reply",
"share": "share"
} }
} }

View File

@ -179,5 +179,11 @@
"author_payout": "Автору", "author_payout": "Автору",
"curation_payout": "Кураторам", "curation_payout": "Кураторам",
"payout_date": "Выплата" "payout_date": "Выплата"
},
"post_dropdown": {
"copy": "copy link",
"reblog": "reblog",
"reply": "reply",
"share": "share"
} }
} }

View File

@ -179,5 +179,11 @@
"author_payout": "Yazar Ödemeleri", "author_payout": "Yazar Ödemeleri",
"curation_payout": "Küratör Ödemeleri", "curation_payout": "Küratör Ödemeleri",
"payout_date": "Ödeme" "payout_date": "Ödeme"
},
"post_dropdown": {
"copy": "kopyala",
"reblog": "reblog",
"reply": "cevapla",
"share": "paylaş"
} }
} }

View File

@ -1,3 +1 @@
export default ['COPY LINK', 'REBLOG', 'REPLY']; export default ['copy', 'reblog', 'reply', 'share'];
export const VALUE = ['copy', 'reblog', 'reply'];

View File

@ -12,3 +12,9 @@ export const postSumTotal = (content) => {
? parseToken(content.total_payout_value) + parseToken(content.curator_payout_value) ? parseToken(content.total_payout_value) + parseToken(content.curator_payout_value)
: 0; : 0;
}; };
export const getPostUrl = (url) => {
const BASE_URL = 'https://steemit.com';
return BASE_URL + url;
};