Commit d6d0370a authored by Marek Kotewicz's avatar Marek Kotewicz Committed by GitHub
Browse files

Merge pull request #76 from paritytech/apple_fixes

Apple fixes
parents 886cb496 c436ec30
......@@ -70,6 +70,10 @@ function findAccountWithAddress (getState, address) {
})
}
function hasAccounts (getState) {
return getState().accounts.all.length !== 0
}
export function scannerDispatch (data) {
return async function (dispatch, getState) {
if (!getState().scanner.scannerEnabled) {
......@@ -78,10 +82,15 @@ export function scannerDispatch (data) {
dispatch(disableScanner())
try {
if (!hasAccounts(getState)) {
dispatch(displayScannerWarning('No accounts found'))
return
}
let txRequest = JSON.parse(data)
let account = findAccountWithAddress(getState, txRequest.data.account)
if (!account) {
dispatch(displayScannerWarning('Invalid sender address ' + txRequest.data.account))
dispatch(displayScannerWarning('You are not able to sign transaction X from ' + txRequest.data.account))
return
}
......
......@@ -17,7 +17,7 @@
'use strict'
import React, { Component } from 'react'
import { StyleSheet, AppState } from 'react-native'
import { StyleSheet, AppState, Alert } from 'react-native'
import { Provider, connect } from 'react-redux'
import { Actions, Router, Scene } from 'react-native-router-flux'
import TabIcon from './TabIcon'
......@@ -52,7 +52,60 @@ const styles = StyleSheet.create({
}
})
const scenes = Actions.create(
const accountScenes =
<Scene>
<Scene key='accountList' title='Accounts' component={AccountList}
onRight={() => Actions.iconChooser()}
rightTitle='Add'
rightButtonTextStyle={styles.navibarTitle}
/>
<Scene key='accountNew' component={AccountNew} title='New Account' hideTabBar
onBack={() => Alert.alert('Do you want to cancel account creation?', undefined, [{
text: 'Yes',
onPress: () => {
Actions.popTo('right')
}
}, {
text: 'No',
onPress: () => {}
}])}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountChangePin' title='Current PIN' component={AccountChangePin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountSetPin' title='Set Account PIN' component={AccountSetPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountConfirmPin' title='Confirm PIN' component={AccountConfirmPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountDetails' title='Account Details' component={AccountDetails}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='qrViewAddress' title='Address QR' component={QrViewAddress}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='iconChooser' title='Choose an Icon' component={IconChooser}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
</Scene>
const scenes =
<Scene key='root'>
<Scene key='tabs' tabs style={styles.tabbar}>
<Scene key='left' title='Scan Transaction QR' initial icon={TabIcon} navigationBarStyle={styles.navibar} titleStyle={styles.navibarTitle}>
......@@ -85,56 +138,17 @@ const scenes = Actions.create(
/>
</Scene>
<Scene key='right' title='Accounts' icon={TabIcon} navigationBarStyle={styles.navibar} titleStyle={styles.navibarTitle}>
<Scene key='accountList' title='Accounts' component={AccountList}
onRight={() => Actions.iconChooser()}
rightTitle='Add'
rightButtonTextStyle={styles.navibarTitle}
/>
<Scene key='accountNew' component={AccountNew} title='New Account'
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountChangePin' title='Current PIN' component={AccountChangePin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountSetPin' title='Set Account PIN' component={AccountSetPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountConfirmPin' title='Confirm PIN' component={AccountConfirmPin}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='accountDetails' title='Account Details' component={AccountDetails}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='qrViewAddress' title='Address QR' component={QrViewAddress}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
<Scene key='iconChooser' title='Choose an Icon' component={IconChooser}
backTitle='Back'
backButtonTextStyle={styles.navibarTitle}
hideBackImage
/>
{accountScenes.props.children}
</Scene>
</Scene>
</Scene>
)
export default class App extends Component {
render () {
let actions = Actions.create(scenes)
return (
<Provider store={store}>
<ConnectedRouter scenes={scenes} />
<ConnectedRouter scenes={actions} />
</Provider>
)
}
......
......@@ -91,7 +91,7 @@ export class AccountNew extends Component {
render () {
return (
<ScrollView style={AppStyles.view}>
<ScrollView style={AppStyles.fullscreenView}>
<AccountIcon style={AppStyles.icon} seed={'0x' + this.state.address} />
<Text style={AppStyles.hintText}>Account Name</Text>
<TextInput
......
......@@ -25,6 +25,11 @@ export default StyleSheet.create({
marginBottom: 50,
padding: 20
},
fullscreenView: {
flex: 1,
marginTop: (Platform.OS === 'ios') ? 64 : 54,
padding: 20
},
listView: {
flex: 1,
marginTop: (Platform.OS === 'ios') ? 64 : 54,
......
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