Implemented steem connect transfer

This commit is contained in:
Mustafa Buyukcelebi 2019-04-19 18:35:13 +03:00
parent f3f19e35ba
commit 94860059df
3 changed files with 45 additions and 6 deletions

View File

@ -0,0 +1,6 @@
export const steemConnectOptions = {
base_url: 'https://app.steemconnect.com/',
client_id: 'esteem-app',
redirect_uri: 'http://127.0.0.1:3415/', // http://127.0.0.1:3415
scope: 'vote,comment,delete_comment,comment_options,custom_json,claim_reward_balance,offline',
};

View File

@ -54,14 +54,21 @@ class ExampleContainer extends Component {
.catch(err => dispatch(toastNotification(err))); .catch(err => dispatch(toastNotification(err)));
}; };
_handleOnModalClose = () => {
const { navigation } = this.props;
navigation.goBack();
};
render() { render() {
const { accounts } = this.props; const { accounts, currentAccount } = this.props;
return ( return (
<TransferView <TransferView
accounts={accounts} accounts={accounts}
getAccountsWithUsername={this._getAccountsWithUsername} getAccountsWithUsername={this._getAccountsWithUsername}
transferToAccount={this._transferToAccount} transferToAccount={this._transferToAccount}
handleOnModalClose={this._handleOnModalClose}
accountType={currentAccount.local.authType}
/> />
); );
} }

View File

@ -1,9 +1,12 @@
/* eslint-disable no-restricted-globals */ /* eslint-disable no-restricted-globals */
import React, { Fragment, Component } from 'react'; import React, { Fragment, Component } from 'react';
import { Text, View } from 'react-native'; import { Text, View, WebView } 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';
import { steemConnectOptions } from '../../../constants/steemConnectOptions';
import AUTH_TYPE from '../../../constants/authType';
import { BasicHeader } from '../../../components/basicHeader'; import { BasicHeader } from '../../../components/basicHeader';
import { TextInput } from '../../../components/textInput'; import { TextInput } from '../../../components/textInput';
import { TransferFormItem } from '../../../components/transferFormItem'; import { TransferFormItem } from '../../../components/transferFormItem';
@ -11,6 +14,7 @@ import { MainButton } from '../../../components/mainButton';
import { DropdownButton } from '../../../components/dropdownButton'; import { DropdownButton } from '../../../components/dropdownButton';
import { UserAvatar } from '../../../components/userAvatar'; import { UserAvatar } from '../../../components/userAvatar';
import { Icon } from '../../../components/icon'; import { Icon } from '../../../components/icon';
import { Modal } from '../../../components/modal';
import styles from './transferStyles'; import styles from './transferStyles';
/* Props /* Props
@ -27,6 +31,7 @@ class TransferView extends Component {
amount: '', amount: '',
memo: '', memo: '',
isUsernameValid: false, isUsernameValid: false,
steemConnectTransfer: false,
}; };
} }
@ -58,12 +63,16 @@ class TransferView extends Component {
}; };
_handleTransferAction = () => { _handleTransferAction = () => {
const { transferToAccount } = this.props; const { transferToAccount, accountType } = this.props;
const { const {
from, destination, amount, memo, from, destination, amount, memo,
} = this.state; } = this.state;
if (accountType === AUTH_TYPE.STEEM_CONNECT) {
this.setState({ steemConnectTransfer: true });
} else {
transferToAccount(from, destination, amount, memo); transferToAccount(from, destination, amount, memo);
}
}; };
_renderInput = (placeholder, state) => ( _renderInput = (placeholder, state) => (
@ -91,8 +100,16 @@ class TransferView extends Component {
_renderDescription = text => <Text style={styles.description}>{text}</Text>; _renderDescription = text => <Text style={styles.description}>{text}</Text>;
render() { render() {
const { accounts, intl } = this.props; const { accounts, intl, handleOnModalClose } = this.props;
const { destination, isUsernameValid, amount } = this.state; const {
destination, isUsernameValid, amount, steemConnectTransfer, memo,
} = this.state;
const path = `sign/transfer?from=${
accounts[0].username
}&to=${destination}&amount=${encodeURIComponent(`${amount} STEEM`)}&memo=${encodeURIComponent(
memo,
)}`;
return ( return (
<Fragment> <Fragment>
@ -162,6 +179,15 @@ class TransferView extends Component {
index === 0 ? this._handleTransferAction() : null; index === 0 ? this._handleTransferAction() : null;
}} }}
/> />
<Modal
isOpen={steemConnectTransfer}
isFullScreen
isCloseButton
handleOnModalClose={handleOnModalClose}
title="Steemconnect Transfer"
>
<WebView source={{ uri: `${steemConnectOptions.base_url}${path}` }} />
</Modal>
</Fragment> </Fragment>
); );
} }