From eca6af122bdd4bf08160ec06dee9fb5f9b242b1f Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Tue, 15 Oct 2019 17:56:22 +0100 Subject: [PATCH] improve ux for insufficient balance for channel creation and publish (#58) --- src/component/fileRewardsDriver/view.js | 2 +- src/constants.js | 2 ++ src/page/channelCreator/view.js | 31 ++++++++++++++++--------- src/page/publish/view.js | 23 +++++++++++++----- src/styles/colors.js | 1 + src/styles/filePage.js | 6 ++++- src/styles/publish.js | 2 +- src/styles/wallet.js | 2 +- 8 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/component/fileRewardsDriver/view.js b/src/component/fileRewardsDriver/view.js index 5e96a8a..e46a90f 100644 --- a/src/component/fileRewardsDriver/view.js +++ b/src/component/fileRewardsDriver/view.js @@ -9,7 +9,7 @@ class FileRewardsDriver extends React.PureComponent { return ( navigation.navigate('Rewards')}> - + Earn some credits to access this content. ); diff --git a/src/constants.js b/src/constants.js index be0d4f5..d1e2eba 100644 --- a/src/constants.js +++ b/src/constants.js @@ -138,6 +138,8 @@ const Constants = { MORE_PLACEHOLDER: '_more', TRUE_STRING: 'true', + + MINIMUM_TRANSACTION_BALANCE: 0.1, }; export default Constants; diff --git a/src/page/channelCreator/view.js b/src/page/channelCreator/view.js index 17a90d7..6a7c399 100644 --- a/src/page/channelCreator/view.js +++ b/src/page/channelCreator/view.js @@ -32,9 +32,11 @@ import channelIconStyle from 'styles/channelIcon'; import seedrandom from 'seedrandom'; export default class ChannelCreator extends React.PureComponent { + scrollView = null; + state = { autoStyle: null, - canSave: false, + canSave: true, claimId: null, currentSelectedValue: Constants.ITEM_ANONYMOUS, currentPhase: null, @@ -161,9 +163,6 @@ export default class ChannelCreator extends React.PureComponent { if (!fetchingChannels) { fetchChannelListMine(); } - if (balance >= 0.1) { - this.setState({ canSave: true }); - } DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked); DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled); @@ -392,6 +391,16 @@ export default class ChannelCreator extends React.PureComponent { website, } = this.state; + if (balance < Constants.MINIMUM_TRANSACTION_BALANCE) { + notify({ + message: 'Creating a channel requires credits. Press the blue bar to get some for free.', + }); + if (this.scrollView) { + this.scrollView.scrollTo({ x: 0, y: 0, animated: true }); + } + return; + } + if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) { notify({ message: 'Your channel name contains invalid characters.' }); return; @@ -528,9 +537,9 @@ export default class ChannelCreator extends React.PureComponent { }; handleNewChannelPress = () => { - const { balance, pushDrawerStack } = this.props; + const { pushDrawerStack } = this.props; pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM); - this.setState({ canSave: balance >= 0.1, currentPhase: Constants.PHASE_CREATE }); + this.setState({ currentPhase: Constants.PHASE_CREATE }); }; handleCreateCancel = () => { @@ -548,7 +557,7 @@ export default class ChannelCreator extends React.PureComponent { resetChannelCreator = () => { this.setState({ - canSave: false, + canSave: true, claimId: null, editMode: false, displayName: null, @@ -610,7 +619,7 @@ export default class ChannelCreator extends React.PureComponent { pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM); this.setState({ - canSave: balance >= 0.1, + canSave: true, claimId: channel.claim_id, currentPhase: Constants.PHASE_CREATE, displayName: value && value.title ? value.title : channel.name.substring(1), @@ -841,7 +850,7 @@ export default class ChannelCreator extends React.PureComponent { )} {currentPhase === Constants.PHASE_CREATE && ( - + (this.scrollView = ref)} style={channelCreatorStyle.createChannelContainer}> - {balance < 0.1 && } + {balance < Constants.MINIMUM_TRANSACTION_BALANCE && } @@ -1046,7 +1055,7 @@ export default class ChannelCreator extends React.PureComponent {