Commit 731fa479 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

display qr code for address && alert before deleting an account

parent 9d87defc
'use strict'
import React, { Component, PropTypes } from 'react'
import { StyleSheet, View, Text, Button } from 'react-native'
import { StyleSheet, View, ScrollView, Text, Button } from 'react-native'
import AppStyles from '../styles'
export default class AccountDetails extends Component {
......@@ -9,25 +9,25 @@ export default class AccountDetails extends Component {
account: PropTypes.shape({
address: PropTypes.string.isRequired,
}).isRequired,
onSendTransactionPressed: PropTypes.func.isRequired,
onDisplayAddressPressed: PropTypes.func.isRequired,
onDeleteAccountPressed: PropTypes.func.isRequired,
}
render() {
return (
<View style={AppStyles.view}>
<ScrollView style={AppStyles.view}>
<Text style={AppStyles.hintText}>Name</Text>
<Text style={AppStyles.valueText}>{this.props.account.name ? this.props.account.name : 'no name'}</Text>
<Text style={AppStyles.hintText}>Address</Text>
<Text style={AppStyles.valueText}>{this.props.account.address}</Text>
<View style={styles.buttonContainer}>
{/*<Button
<Button
style={styles.button}
onPress={this.props.onSendTransactionPressed}
title='Send Transaction'
onPress={this.props.onDisplayAddressPressed}
title='Display Address QR Code'
color='green'
accessibilityLabel='Press to send new transaction'
/>*/}
accessibilityLabel='Press to address QR Code'
/>
<Button
style={styles.button}
onPress={() => this.props.onDeleteAccountPressed(this.props.account)}
......@@ -36,7 +36,7 @@ export default class AccountDetails extends Component {
accessibilityLabel='Press to delete account'
/>
</View>
</View>
</ScrollView>
)
}
}
......
......@@ -15,7 +15,7 @@ import Send from '../components/Send'
import Account from '../containers/Account'
import ConfirmTransaction from '../containers/ConfirmTransaction'
import { EnterPin, SetPin, ConfirmPin } from '../containers/Pin'
import QrDisplay from '../containers/QrDisplay'
import { QrViewTransaction, QrViewAddress }from '../containers/QrView'
const ConnectedRouter = connect()(Router)
const store = createStore(reducers)
......@@ -40,7 +40,7 @@ const scenes = Actions.create(
component={QrScanner}
title='Scan QR'
/>
<Scene key='confirm' component={ConfirmTransaction} title='Sign Tx'
<Scene key='confirm' component={ConfirmTransaction} title='Transaction Details'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
......@@ -55,7 +55,7 @@ const scenes = Actions.create(
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='display' title='QR Code' component={QrDisplay} rightTitle='Done'
<Scene key='displayTransaction' title='QR Code' component={QrViewTransaction} rightTitle='Done'
onRight={() => Actions.popTo('left')}
rightButtonTextStyle={styles.navibarTitle}
backTitle='Back'
......@@ -91,6 +91,13 @@ const scenes = Actions.create(
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
<Scene key='displayAddress' title='QR Code' component={QrViewAddress} rightTitle='Done'
onRight={() => Actions.popTo('right')}
rightButtonTextStyle={styles.navibarTitle}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage={true}
/>
</Scene>
</Scene>
</Scene>
......
'use strict'
import React from 'react'
import { Alert } from 'react-native'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import AccountDetails from '../components/AccountDetails'
import { deleteAccount } from '../actions/accounts'
const mapDispatchToProps = (dispatch, ownProps) => ({
onSendTransactionPressed: () => {
Actions.send()
onDisplayAddressPressed: () => {
Actions.displayAddress()
},
onDeleteAccountPressed: (account) => {
dispatch(deleteAccount(account))
Actions.pop()
Alert.alert('Do you want to delete the account?', undefined, [
{ text: 'Yes', onPress: () => {
dispatch(deleteAccount(account))
Actions.pop()
}},
{ text: 'No' }
])
},
})
......
'use strict'
import React, { Component } from 'react'
import { View, Text, TextInput, Button, StyleSheet } from 'react-native'
import { View, ScrollView, Text, TextInput, Button, StyleSheet } from 'react-native'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import debounce from 'debounce'
......@@ -53,7 +53,7 @@ export class NewAccount extends Component {
render() {
var self = this;
return (
<View style={AppStyles.view}>
<ScrollView style={AppStyles.view}>
<Text style={AppStyles.hintText}>name</Text>
<TextInput
placeholder='My Account'
......@@ -82,7 +82,7 @@ export class NewAccount extends Component {
color="green"
accessibilityLabel="Press to add new account"
/>
</View>
</ScrollView>
)
}
}
......
......@@ -19,7 +19,7 @@ async function signTransaction(dispatch, account, rlp) {
let hash = await keccak(rlp)
let signature = await brainWalletSign(account.seed, hash)
dispatch(signedTx(signature))
Actions.display()
Actions.displayTransaction()
} catch (e) {
console.log(e)
}
......
......@@ -4,10 +4,14 @@ import React from 'react'
import { connect } from 'react-redux'
import QrView from '../components/QrView'
const mapStateToProps = (state, ownProps) => ({
const mapStateToPropsTransaction = (state, ownProps) => ({
text: state.transactions.signedTx,
})
const QrDisplay = connect(mapStateToProps)(QrView)
export const QrViewTransaction = connect(mapStateToPropsTransaction)(QrView)
export default QrDisplay
const mapStateToPropsAddress = (state, ownProps) => ({
text: state.accounts.selected.address
})
export const QrViewAddress = connect(mapStateToPropsAddress)(QrView)
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