Commit 1d3adc87 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

new account view in progress

parent 7816ae81
......@@ -13,8 +13,7 @@
"react-native-router-flux": "^3.37.0",
"react-native-tabs": "^1.0.9",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"sjcl": "^1.0.6"
"redux": "^3.6.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
......
import dictionary from '../../res/words.json'
// TODO: make it secure!
export function words() {
let buf = (new Uint16Array(11)).map(_ => Math.random() * dictionary.length)
return Array.from(buf).map(n => dictionary[n]).join(' ')
}
// this should be later replaced with random keypair
export function address() {
return '0xb794f5ea0ba39494ce839613fffba74279579268'
}
import { random } from './words'
import { words } from './random'
describe('words', () => {
it('should create a list of 10 random words', () => {
let randomWords = random()
let randomWords = words()
let count = randomWords.split(' ').length
expect(count).toEqual(11)
})
......
import sjcl from 'sjcl'
import words from '../../res/words.json'
export function random() {
let count = 11
let paranoia = 10
let buf = sjcl.random.randomWords(count, paranoia)
return buf.map(n => words[Math.abs(n) % words.length]).join(' ')
}
......@@ -7,6 +7,7 @@ import reducers from '../reducers'
import TabIcon from './TabIcon'
import QrScanner from '../containers/QrScanner'
import Accounts from '../containers/Accounts'
import NewAccount from '../containers/NewAccount'
const ConnectedRouter = connect()(Router)
const store = createStore(reducers)
......@@ -30,7 +31,7 @@ const scenes = Actions.create(
/>
<Scene
key='add'
component={View}
component={NewAccount}
title='Add Account'
/>
</Scene>
......
import React, { Component, PropTypes } from 'react'
import { TextInput, StyleSheet } from 'react-native'
export default class NewAccountInput extends Component {
static propTypes = {
seed: PropTypes.string.isRequired,
onChangeText: PropTypes.func.isRequired,
}
constructor(props) {
super(props)
this.state = {
text: this.props.seed
}
}
render() {
return (
<TextInput
style={styles.input}
editable={true}
multiline={true}
autoFocus={true}
returnKeyType="default"
numberOfLines={6}
fontSize={16}
onChangeText={(text) => {
this.setState({
text: text
})
this.props.onChangeText(text)
}}
value={this.state.text}
maxLength={100}
/>
)
}
}
const styles = StyleSheet.create({
input: {
borderColor: 'gray',
borderWidth: 1,
height: 200,
fontWeight: 'bold'
},
})
import React, { Component } from 'react'
import { View, Text, StyleSheet } from 'react-native'
import NewAccountInput from '../components/NewAccountInput'
import { words } from '../actions/random'
export default class NewAccount extends Component {
constructor(props) {
super(props)
}
render() {
return (
<View style={styles.view}>
<NewAccountInput seed={words()} onChangeText={() => {}}/>
</View>
)
}
}
const styles = StyleSheet.create({
view: {
flex: 1,
marginTop: 60,
marginBottom: 50,
padding: 10
},
})
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