Commit 31b5b471 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

improved naming of components and containers

parent 9737cea6
......@@ -2,10 +2,10 @@
import React, { Component, PropTypes } from 'react'
import { Text, View, ListView, RecyclerViewBackedScrollView, StatusBar } from 'react-native'
import AccountsListRow from './AccountsListRow'
import AccountListRow from './AccountListRow'
import AppStyles from '../styles'
export default class AccountsList extends Component {
export default class AccountList extends Component {
static propTypes = {
accounts: PropTypes.arrayOf(PropTypes.shape({
address: PropTypes.string.isRequired,
......@@ -34,7 +34,7 @@ export default class AccountsList extends Component {
dataSource={this.state.dataSource}
renderRow={(rowData, sectionID: number, rowID: number, highlightRow) => {
return (
<AccountsListRow
<AccountListRow
upperText={rowData.name ? rowData.name : 'no name'}
lowerText={'0x' + rowData.address}
onPress={() => {
......
......@@ -3,7 +3,7 @@
import React, { Component, PropTypes } from 'react'
import { TouchableHighlight, StyleSheet, View, Text } from 'react-native'
export default class AccountsListRow extends Component {
export default class AccountListRow extends Component {
static propTypes = {
upperText: PropTypes.string.isRequired,
lowerText: PropTypes.string.isRequired,
......
......@@ -3,7 +3,7 @@
import React, { Component, PropTypes } from 'react'
import { Text, TextInput, View, StyleSheet } from 'react-native'
export default class Pin extends Component {
export default class AccountPin extends Component {
static propTypes = {
onNextPressed: PropTypes.func.isRequired,
}
......
......@@ -3,7 +3,7 @@
import React, { Component, PropTypes } from 'react'
import { TextInput, StyleSheet } from 'react-native'
export default class NewAccountInput extends Component {
export default class AccountSeed extends Component {
static propTypes = {
seed: PropTypes.string.isRequired,
onChangeText: PropTypes.func.isRequired,
......
......@@ -7,13 +7,11 @@ import { createStore } from 'redux'
import { Actions, ActionConst, Router, Scene } from 'react-native-router-flux'
import TabIcon from './TabIcon'
import QrScanner from '../containers/QrScanner'
import Accounts from '../containers/Accounts'
import SelectAccount from '../containers/SelectAccount'
import NewAccount from '../containers/NewAccount'
import Send from '../components/Send'
import Account from '../containers/Account'
import ConfirmTransaction from '../containers/ConfirmTransaction'
import { EnterPin, SetPin, ConfirmPin } from '../containers/Pin'
import AccountList from '../containers/AccountList'
import AccountNew from '../containers/AccountNew'
import AccountDetails from '../containers/AccountDetails'
import TxDetails from '../containers/TxDetails'
import { AccountEnterPin, AccountSetPin, AccountConfirmPin } from '../containers/AccountPin'
import { QrViewTransaction, QrViewAddress } from '../containers/QrView'
import { loadAccounts, saveAccounts } from '../util/db'
import { setAccounts } from '../actions/accounts'
......@@ -41,26 +39,21 @@ const scenes = Actions.create(
<Scene key='root'>
<Scene key='tabs' tabs style={styles.tabbar}>
<Scene key='left' title='Scan QR' initial icon={TabIcon} navigationBarStyle={styles.navibar} titleStyle={styles.navibarTitle}>
<Scene key='scan'
<Scene key='qrScan'
component={QrScanner}
title='Scan QR'
/>
<Scene key='confirm' component={ConfirmTransaction} title='Transaction Details'
<Scene key='txDetails' component={TxDetails} title='Transaction Details'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='select' title='Select Account' component={SelectAccount}
<Scene key='accountEnterPin' title='Enter Pin' component={AccountEnterPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='enterPin' title='Enter Pin' component={EnterPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='displayTransaction' title='QR Code' component={QrViewTransaction} rightTitle='Done'
<Scene key='qrViewTx' title='QR Code' component={QrViewTransaction} rightTitle='Done'
onRight={() => Actions.popTo('left')}
rightButtonTextStyle={styles.navibarTitle}
backTitle='Back'
......@@ -69,34 +62,29 @@ const scenes = Actions.create(
/>
</Scene>
<Scene key='right' title='Accounts' icon={TabIcon} navigationBarStyle={styles.navibar} titleStyle={styles.navibarTitle}>
<Scene key='accounts' title='Accounts' component={Accounts}
rightTitle="Add" onRight={() => Actions.add()} rightButtonTextStyle={styles.navibarTitle}/>
<Scene key='add' component={NewAccount} title='Add Account'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='setPin' title='Set Pin' component={SetPin}
<Scene key='accountList' title='Accounts' component={AccountList}
rightTitle="Add" onRight={() => Actions.accountNew()} rightButtonTextStyle={styles.navibarTitle}/>
<Scene key='accountNew' component={AccountNew} title='Add Account'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='confirmPin' title='Confirm Pin' component={ConfirmPin}
<Scene key='accountSetPin' title='Set Pin' component={AccountSetPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='details' component={Account} title='Account Details'
<Scene key='accountConfirmPin' title='Confirm Pin' component={AccountConfirmPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='send' component={Send} title='Send TX'
<Scene key='accountDetails' component={AccountDetails} title='Account Details'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='displayAddress' title='QR Code' component={QrViewAddress} rightTitle='Done'
<Scene key='qrViewAddress' title='QR Code' component={QrViewAddress} rightTitle='Done'
onRight={() => Actions.popTo('right')}
rightButtonTextStyle={styles.navibarTitle}
backTitle='Back'
......
......@@ -10,7 +10,7 @@ import { deleteAccount as dbDeleteAccount } from '../util/db'
const mapDispatchToProps = (dispatch, ownProps) => ({
onDisplayAddressPressed: () => {
Actions.displayAddress()
Actions.qrViewAddress()
},
onDeleteAccountPressed: (account) => {
Alert.alert('Do you want to delete the account?', undefined, [
......@@ -24,8 +24,8 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
},
})
const Account = connect(state => ({
const AccountDetailsContainer = connect(state => ({
account: state.accounts.selected,
}), mapDispatchToProps)(AccountDetails)
export default Account
export default AccountDetailsContainer
......@@ -3,18 +3,18 @@
import React from 'react'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import AccountsList from '../components/AccountsList'
import AccountList from '../components/AccountList'
import { selectAccount } from '../actions/accounts'
const mapDispatchToProps = (dispatch, ownProps) => ({
onAccountSelected: (account) => {
dispatch(selectAccount(account))
Actions.details()
Actions.accountDetails()
}
})
const Accounts = connect(state => ({
const AccountListContainer = connect(state => ({
accounts: state.accounts.all
}), mapDispatchToProps)(AccountsList)
}), mapDispatchToProps)(AccountList)
export default Accounts
export default AccountListContainer
......@@ -5,7 +5,7 @@ import { View, ScrollView, Text, TextInput, Button, StyleSheet } from 'react-nat
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import debounce from 'debounce'
import NewAccountInput from '../components/NewAccountInput'
import AccountSeed from '../components/AccountSeed'
import { words } from '../util/random'
import { brainWalletAddress } from '../util/native'
import { selectAccount } from '../actions/accounts'
......@@ -19,12 +19,12 @@ const mapDispatchToProps = (dispatch) => {
address: account.address,
name: account.name,
}))
Actions.setPin()
Actions.accountSetPin()
}
}
}
export class NewAccount extends Component {
export class AccountNew extends Component {
constructor(props) {
super(props)
......@@ -68,7 +68,7 @@ export class NewAccount extends Component {
onChangeText={(text) => {this.setState({name: text})}}
/>
<Text style={AppStyles.hintText}>brain wallet seed</Text>
<NewAccountInput seed={this.state.seed} onChangeText={
<AccountSeed seed={this.state.seed} onChangeText={
debounce((text) => { this.updateAddress(this, text) }, 100)
}/>
<Text style={AppStyles.valueText}>0x{this.state.address}</Text>
......@@ -104,5 +104,5 @@ const styles = StyleSheet.create({
export default connect(
undefined,
mapDispatchToProps
)(NewAccount)
)(AccountNew)
......@@ -4,7 +4,7 @@ import React from 'react'
import { Alert } from 'react-native'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import Pin from '../components/Pin'
import AccountPin from '../components/AccountPin'
import { addAccount, setPin } from '../actions/accounts'
import { signedTx } from '../actions/transactions'
import { keccak, brainWalletSign } from '../util/native'
......@@ -20,7 +20,7 @@ async function signTransaction(dispatch, account, rlp) {
let hash = await keccak(rlp)
let signature = await brainWalletSign(account.seed, hash)
dispatch(signedTx(signature))
Actions.displayTransaction()
Actions.txViewTx()
} catch (e) {
console.log(e)
}
......@@ -39,7 +39,7 @@ const mapDispatchToPropsEnterPin = (dispatch, ownProps) => ({
const mapDispatchToPropsSetPin = (dispatch, ownProps) => ({
onNextPressed: (pin) => {
dispatch(setPin(pin))
Actions.confirmPin()
Actions.accountConfirmPin()
}
})
......@@ -52,18 +52,18 @@ const mapDispatchToPropsConfirmPin = (dispatch, ownProps) => ({
if (pin === account.pin) {
dispatch(addAccount(account))
saveAccount(account)
Actions.popTo('accounts')
Actions.popTo('accountList')
} else {
Alert.alert('Invalid pin')
}
}
})
export const EnterPin = connect(mapStateToPropsEnterPin, mapDispatchToPropsEnterPin)(Pin)
export const AccountEnterPin = connect(mapStateToPropsEnterPin, mapDispatchToPropsEnterPin)(AccountPin)
export const SetPin = connect(undefined, mapDispatchToPropsSetPin)(Pin)
export const AccountSetPin = connect(undefined, mapDispatchToPropsSetPin)(AccountPin)
export const ConfirmPin = connect(mapStateToPropsConfirmPin, mapDispatchToPropsConfirmPin)(Pin)
export const AccountConfirmPin = connect(mapStateToPropsConfirmPin, mapDispatchToPropsConfirmPin)(AccountPin)
......@@ -4,7 +4,7 @@ import React, { Component } from 'react'
import { Vibration, Alert } from 'react-native'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import Scanner from '../components/Scanner'
import QrScanner from '../components/QrScanner'
import { selectAccount } from '../actions/accounts'
import { scannedTx } from '../actions/transactions'
import transaction from '../util/transaction'
......@@ -33,7 +33,7 @@ async function onScannedTransaction(data, dispatch) {
dispatch(selectAccount(account))
dispatch(scannedTx(data.rlp, tx))
//Vibration.vibrate()
Actions.confirm()
Actions.txDetails()
scanning = false
} catch (e) {
console.log(e)
......@@ -49,9 +49,9 @@ const mapDispatchToProps = (dispatch, ownProps) => ({
}
})
const QrScanner = connect(
const QrScannerContainer = connect(
undefined,
mapDispatchToProps
)(Scanner)
)(QrScanner)
export default QrScanner
export default QrScannerContainer
'use strict'
import React from 'react'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import AccountsList from '../components/AccountsList'
import { selectAccount } from '../actions/accounts'
const mapDispatchToProps = (dispatch, ownProps) => ({
onAccountSelected: (account) => {
dispatch(selectAccount(account))
Actions.enterPin()
}
})
const SelectAccount = connect(state => ({
accounts: state.accounts.all
}), mapDispatchToProps)(AccountsList)
export default SelectAccount
......@@ -3,7 +3,7 @@
import React from 'react'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import Send from '../components/Send'
import TxDetails from '../components/TxDetails'
const mapStateToProps = (state, ownProps) => ({
nextButtonTitle: 'Next',
......@@ -18,10 +18,10 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch, ownProps) => ({
nextButtonAction: () => {
Actions.enterPin()
Actions.accountEnterPin()
}
})
const ConfirmTransaction = connect(mapStateToProps, mapDispatchToProps)(Send)
const TxDetailsContainer = connect(mapStateToProps, mapDispatchToProps)(TxDetails)
export default ConfirmTransaction
export default TxDetailsContainer
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment