Create add token button and template view

feature/default_network_editable
Dan Finlay 8 years ago
parent a80945e730
commit 0e1e0aa323
  1. 6
      ui/app/account-detail.js
  2. 11
      ui/app/actions.js
  3. 91
      ui/app/add-token.js
  4. 5
      ui/app/app.js
  5. 37
      ui/app/components/token-list.js
  6. 10
      ui/app/reducers/app.js

@ -277,7 +277,11 @@ AccountDetailScreen.prototype.tabSwitchView = function () {
switch (currentAccountTab) { switch (currentAccountTab) {
case 'tokens': case 'tokens':
return h(TokenList, { userAddress: address, network }) return h(TokenList, {
userAddress: address,
network,
addToken: () => this.props.dispatch(actions.showAddTokenPage()),
})
default: default:
return this.transactionList() return this.transactionList()
} }

@ -121,7 +121,9 @@ var actions = {
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE', SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
USE_ETHERSCAN_PROVIDER: 'USE_ETHERSCAN_PROVIDER', USE_ETHERSCAN_PROVIDER: 'USE_ETHERSCAN_PROVIDER',
useEtherscanProvider: useEtherscanProvider, useEtherscanProvider: useEtherscanProvider,
showConfigPage: showConfigPage, showConfigPage,
SHOW_ADD_TOKEN_PAGE: 'SHOW_ADD_TOKEN_PAGE',
showAddTokenPage,
setRpcTarget: setRpcTarget, setRpcTarget: setRpcTarget,
setDefaultRpcTarget: setDefaultRpcTarget, setDefaultRpcTarget: setDefaultRpcTarget,
setProviderType: setProviderType, setProviderType: setProviderType,
@ -627,6 +629,13 @@ function showConfigPage (transitionForward = true) {
} }
} }
function showAddTokenPage (transitionForward = true) {
return {
type: actions.SHOW_ADD_TOKEN_PAGE,
value: transitionForward,
}
}
function goBackToInitView () { function goBackToInitView () {
return { return {
type: actions.BACK_TO_INIT_MENU, type: actions.BACK_TO_INIT_MENU,

@ -0,0 +1,91 @@
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('./actions')
module.exports = connect(mapStateToProps)(AddTokenScreen)
function mapStateToProps (state) {
return {}
}
inherits(AddTokenScreen, Component)
function AddTokenScreen () {
this.state = { warning: null }
Component.call(this)
}
AddTokenScreen.prototype.render = function () {
const state = this.state
const { warning } = state
return (
h('.flex-column.flex-grow', [
// subtitle and nav
h('.section-title.flex-row.flex-center', [
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => {
state.dispatch(actions.goHome())
},
}),
h('h2.page-subtitle', 'Add Token'),
]),
h('.error', {
style: {
display: warning ? 'block' : 'none',
padding: '0 20px',
textAlign: 'center',
},
}, warning),
// conf view
h('.flex-column.flex-justify-center.flex-grow.select-none', [
h('.flex-space-around', {
style: {
padding: '20px',
},
}, [
h('div', [
h('span', {
style: { fontWeight: 'bold', paddingRight: '10px'},
}, 'Token Sybmol'),
]),
h('div', { style: {display: 'flex'} }, [
h('input#token_symbol', {
placeholder: `Like "ETH"`,
style: {
width: 'inherit',
flex: '1 0 auto',
height: '30px',
margin: '8px',
},
onKeyPress (event) {
if (event.key === 'Enter') {
var element = event.target
var newRpc = element.value
}
},
}),
]),
h('button', {
style: {
alignSelf: 'center',
},
onClick (event) {
event.preventDefault()
var tokenSymbolEl = document.querySelector('input#token_symbol')
var tokenSymbol = tokenSymbolEl.value
console.log(tokenSymbol)
},
}, 'Add'),
]),
]),
])
)
}

@ -19,6 +19,7 @@ const NoticeScreen = require('./components/notice')
const generateLostAccountsNotice = require('../lib/lost-accounts-notice') const generateLostAccountsNotice = require('../lib/lost-accounts-notice')
// other views // other views
const ConfigScreen = require('./config') const ConfigScreen = require('./config')
const AddTokenScreen = require('./add-token')
const Import = require('./accounts/import') const Import = require('./accounts/import')
const InfoScreen = require('./info') const InfoScreen = require('./info')
const Loading = require('./components/loading') const Loading = require('./components/loading')
@ -458,6 +459,10 @@ App.prototype.renderPrimary = function () {
log.debug('rendering confirm tx screen') log.debug('rendering confirm tx screen')
return h(ConfirmTxScreen, {key: 'confirm-tx'}) return h(ConfirmTxScreen, {key: 'confirm-tx'})
case 'add-token':
log.debug('rendering add-token screen from unlock screen.')
return h(AddTokenScreen, {key: 'add-token'})
case 'config': case 'config':
log.debug('rendering config screen') log.debug('rendering config screen')
return h(ConfigScreen, {key: 'config'}) return h(ConfigScreen, {key: 'config'})

@ -40,13 +40,16 @@ TokenList.prototype.render = function () {
return h(TokenCell, tokenData) return h(TokenCell, tokenData)
}) })
return ( return h('div', [
h('ol', { h('ol', {
style: { style: {
height: '302px', height: '260px',
overflowY: 'auto', overflowY: 'auto',
display: 'flex',
flexDirection: 'column',
}, },
}, [h('style', ` }, [
h('style', `
li.token-cell { li.token-cell {
display: flex; display: flex;
@ -64,8 +67,32 @@ TokenList.prototype.render = function () {
cursor: pointer; cursor: pointer;
} }
`)].concat(tokenViews.length ? tokenViews : this.message('No Tokens Found.'))) `),
) ...tokenViews,
tokenViews.length ? null : this.message('No Tokens Found.'),
]),
this.addTokenButtonElement(),
])
}
TokenList.prototype.addTokenButtonElement = function () {
return h('div', [
h('div.footer.hover-white.pointer', {
key: 'reveal-account-bar',
onClick: () => {
this.props.addToken()
},
style: {
display: 'flex',
height: '40px',
padding: '10px',
justifyContent: 'center',
alignItems: 'center',
},
}, [
h('i.fa.fa-plus.fa-lg'),
]),
])
} }
TokenList.prototype.message = function (body) { TokenList.prototype.message = function (body) {

@ -103,7 +103,17 @@ function reduceApp (state, action) {
transForward: action.value, transForward: action.value,
}) })
case actions.SHOW_ADD_TOKEN_PAGE:
return extend(appState, {
currentView: {
name: 'add-token',
context: appState.currentView.context,
},
transForward: action.value,
})
case actions.SHOW_IMPORT_PAGE: case actions.SHOW_IMPORT_PAGE:
return extend(appState, { return extend(appState, {
currentView: { currentView: {
name: 'import-menu', name: 'import-menu',

Loading…
Cancel
Save