diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-04-22 00:01:51 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-04-22 00:01:51 +0800 |
commit | 40e2450022488daa5e36d4c1b866e061bba7c5d2 (patch) | |
tree | 7cb0e9d3a1d3f5a9654f8a4c5358987d567d9ea9 /ui | |
parent | 7202639b370279f90886f2e94ab77aba5b205bc3 (diff) | |
download | tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar.gz tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar.bz2 tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar.lz tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar.xz tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.tar.zst tangerine-wallet-browser-40e2450022488daa5e36d4c1b866e061bba7c5d2.zip |
Get token list looking ok
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/account-detail.js | 18 | ||||
-rw-r--r-- | ui/app/components/balance.js | 88 | ||||
-rw-r--r-- | ui/app/components/identicon.js | 8 | ||||
-rw-r--r-- | ui/app/components/token-cell.js | 11 | ||||
-rw-r--r-- | ui/app/components/token-list.js | 23 |
5 files changed, 136 insertions, 12 deletions
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 411f38e5e..5ceee4fe0 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -249,6 +249,12 @@ AccountDetailScreen.prototype.subview = function () { } AccountDetailScreen.prototype.tabSections = function () { + var subview + try { + subview = this.props.accountDetail.subview + } catch (e) { + subview = null + } return h('section.tabSection', [ @@ -257,7 +263,7 @@ AccountDetailScreen.prototype.tabSections = function () { { content: 'History', key: 'history' }, { content: 'Tokens', key: 'tokens' }, ], - defaultTab: 'history', + defaultTab: subview || 'history', tabSelected: (key) => { this.setState({ tabSelection: key }) }, @@ -268,8 +274,16 @@ AccountDetailScreen.prototype.tabSections = function () { } AccountDetailScreen.prototype.tabSwitchView = function () { - const tabSelection = this.state.tabSelection || 'history' const userAddress = this.props.address + var subview + try { + subview = this.props.accountDetail.subview + return h(TokenList, { userAddress }) + } catch (e) { + subview = null + } + + const tabSelection = this.state.tabSelection || 'history' switch (tabSelection) { case 'tokens': diff --git a/ui/app/components/balance.js b/ui/app/components/balance.js new file mode 100644 index 000000000..3c5e24b65 --- /dev/null +++ b/ui/app/components/balance.js @@ -0,0 +1,88 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const inherits = require('util').inherits +const formatBalance = require('../util').formatBalance const generateBalanceObject = require('../util').generateBalanceObject +const Tooltip = require('./tooltip.js') +const FiatValue = require('./fiat-value.js') + +module.exports = EthBalanceComponent + +inherits(EthBalanceComponent, Component) +function EthBalanceComponent () { + Component.call(this) +} + +EthBalanceComponent.prototype.render = function () { + var props = this.props + let { value } = props + var style = props.style + var needsParse = this.props.needsParse !== undefined ? this.props.needsParse : true + value = value ? formatBalance(value, 6, needsParse) : '...' + var width = props.width + + return ( + + h('.ether-balance.ether-balance-amount', { + style: style, + }, [ + h('div', { + style: { + display: 'inline', + width: width, + }, + }, this.renderBalance(value)), + ]) + + ) +} +EthBalanceComponent.prototype.renderBalance = function (value) { + var props = this.props + if (value === 'None') return value + if (value === '...') return value + var balanceObj = generateBalanceObject(value, props.shorten ? 1 : 3) + var balance + var splitBalance = value.split(' ') + var ethNumber = splitBalance[0] + var ethSuffix = splitBalance[1] + const showFiat = 'showFiat' in props ? props.showFiat : true + + if (props.shorten) { + balance = balanceObj.shortBalance + } else { + balance = balanceObj.balance + } + + var label = balanceObj.label + + return ( + h(Tooltip, { + position: 'bottom', + title: `${ethNumber} ${ethSuffix}`, + }, h('div.flex-column', [ + h('.flex-row', { + style: { + alignItems: 'flex-end', + lineHeight: '13px', + fontFamily: 'Montserrat Light', + textRendering: 'geometricPrecision', + }, + }, [ + h('div', { + style: { + width: '100%', + textAlign: 'right', + }, + }, this.props.incoming ? `+${balance}` : balance), + h('div', { + style: { + color: ' #AEAEAE', + fontSize: '12px', + marginLeft: '5px', + }, + }, label), + ]), + + showFiat ? h(FiatValue, { value: props.value }) : null, + ])) + ) +} diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 6d4871d02..1bb92301e 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -34,19 +34,19 @@ IdenticonComponent.prototype.render = function () { IdenticonComponent.prototype.componentDidMount = function () { var props = this.props - var address = props.address + const { address, network } = props if (!address) return var container = findDOMNode(this) var diameter = props.diameter || this.defaultDiameter - var img = iconFactory.iconForAddress(address, diameter, false) + var img = iconFactory.iconForAddress(address, diameter, false, network) container.appendChild(img) } IdenticonComponent.prototype.componentDidUpdate = function () { var props = this.props - var address = props.address + const { address, network } = props if (!address) return @@ -58,6 +58,6 @@ IdenticonComponent.prototype.componentDidUpdate = function () { } var diameter = props.diameter || this.defaultDiameter - var img = iconFactory.iconForAddress(address, diameter, false) + var img = iconFactory.iconForAddress(address, diameter, false, network) container.appendChild(img) } diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js index 34a12733f..81e92b301 100644 --- a/ui/app/components/token-cell.js +++ b/ui/app/components/token-cell.js @@ -1,6 +1,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits +const Identicon = require('./identicon') module.exports = TokenCell @@ -15,8 +16,14 @@ TokenCell.prototype.render = function () { log.info({ address, symbol, string }) return ( - h('li', [ - h('span', `${symbol}: ${string}`), + h('li.token-cell', [ + + h(Identicon, { + diameter: 50, + address, + }), + + h('h3', `${string || 0} ${symbol}`), ]) ) } diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 35e79401b..c6a7d3552 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -24,11 +24,26 @@ function TokenList () { TokenList.prototype.render = function () { const tokens = this.state.tokens + const tokenViews = tokens.map((tokenData) => { + console.log('rendering token with', tokenData) + return h(TokenCell, tokenData) + }) + return ( - h('ol', tokens.map((tokenData) => { - console.log('rendering token with', tokenData) - return h(TokenCell, tokenData) - })) + h('ol', [h('style', ` + + li.token-cell { + display: flex; + flex-direction: row; + align-items: center; + padding: 10px; + } + + li.token-cell > h3 { + margin-left: 12px; + } + + `)].concat(tokenViews)) ) } |