From f37b1450f75ee81c7c4e28e8c7825bed828933d4 Mon Sep 17 00:00:00 2001 From: u-e Date: Fri, 12 Jul 2019 14:33:07 +0300 Subject: [PATCH] added sc modal --- package.json | 1 + src/screens/promote/screen/promoteScreen.js | 50 +++++++++++++++------ yarn.lock | 5 +++ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index fd58123dd..60b407ef3 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "dependencies": { "@babel/runtime": "^7.1.2", "@esteemapp/esteem-render-helpers": "^1.0.9", + "@ptomasroos/react-native-multi-slider": "^1.0.0", "appcenter": "^1.10.0", "appcenter-analytics": "^1.10.0", "appcenter-crashes": "^1.10.0", diff --git a/src/screens/promote/screen/promoteScreen.js b/src/screens/promote/screen/promoteScreen.js index e1685c6f6..90944339e 100644 --- a/src/screens/promote/screen/promoteScreen.js +++ b/src/screens/promote/screen/promoteScreen.js @@ -7,6 +7,7 @@ import { Text, View, WebView, ScrollView } from 'react-native'; import get from 'lodash/get'; import ActionSheet from 'react-native-actionsheet'; import { ScaleSlider } from '../../../components'; +import { steemConnectOptions } from '../../../constants/steemConnectOptions'; // Container import { PointsContainer } from '../../../containers'; @@ -20,7 +21,7 @@ import { TextInput } from '../../../components/textInput'; import { TransferFormItem } from '../../../components/transferFormItem'; import { MainButton } from '../../../components/mainButton'; import { DropdownButton } from '../../../components/dropdownButton'; -// import { Modal } from '../../../components/modal'; +import { Modal } from '../../../components/modal'; import { PROMOTE_PRICING, PROMOTE_DAYS } from '../../../constants/options/points'; @@ -40,6 +41,8 @@ class PointsScreen extends PureComponent { selectedUser: '', balance: '', day: 1, + isSCModalOpen: false, + SCPath: '', }; } @@ -91,15 +94,33 @@ class PointsScreen extends PureComponent { }); }; - _promote = promote => { + _promote = (promote, currentAccount) => { const { day, permlink, author } = this.state; // @u-e/esteem-mobile-v2-guide - if (promote) promote(day, permlink, 'u-e'); + if (get(currentAccount, 'local.authType') === 'steemConnect') { + const user = get(currentAccount, 'name'); + + const json = JSON.stringify({ + user, + author, + permlink, + duration: day, + }); + + const uri = `sign/custom-json?authority=active&required_auths=%5B%22${user}%22%5D&required_posting_auths=%5B%5D&id=esteem_promote&json=${encodeURIComponent( + json, + )}`; + + this.setState({ + isSCModalOpen: true, + SCPath: uri, + }); + } else if (promote) promote(day, permlink, 'u-e'); }; render() { const { intl } = this.props; - const { selectedUser, balance, day } = this.state; + const { selectedUser, balance, day, SCPath, isSCModalOpen } = this.state; return ( @@ -113,6 +134,7 @@ class PointsScreen extends PureComponent { currentAccountName, balance: _balance, promote, + currentAccount, }) => ( @@ -176,18 +198,18 @@ class PointsScreen extends PureComponent { cancelButtonIndex={1} destructiveButtonIndex={0} onPress={index => { - index === 0 ? this._promote(promote) : null; + index === 0 ? this._promote(promote, currentAccount) : null; }} /> - {/* - - */} + this.setState({ openSCModal: false })} + title={intl.formatMessage({ id: 'transfer.steemconnect_title' })} + > + + )} diff --git a/yarn.lock b/yarn.lock index e8f8cff18..96ac916eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1256,6 +1256,11 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^12.0.9" +"@ptomasroos/react-native-multi-slider@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@ptomasroos/react-native-multi-slider/-/react-native-multi-slider-1.0.0.tgz#a4ea27b1320b93a1db9f696c24789695df6c9f30" + integrity sha512-NpX22rQLArg9widwMzGf7XsInTDf6mfY/D1XaDVjglNkVphj3NSN37+nF6MofArCxC++1P+jHv0SGWbmJQwy4g== + "@react-native-community/cli@^1.2.1": version "1.9.11" resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-1.9.11.tgz#b868b17201057b9cd16a3a20c30561176071f21a"