Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 0c8b010

Browse files
Add RestorePassword view for password entry during restore.
1 parent 2ae3fa1 commit 0c8b010

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

src/action/nav.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class NavAction {
2727

2828
goRestoreWallet() {
2929
// this._store.route = 'RestoreWallet';
30+
31+
goRestorePassword() {
32+
this._store.route = 'RestorePassword';
3033
}
3134

3235
goSeedSuccess() {

src/view/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Seed from './seed';
99
import SeedVerify from './seed-verify';
1010
import SeedSuccess from './seed-success';
1111
import SetPassword from './set-password';
12+
import RestorePassword from './restore-password';
1213
import Password from './password';
1314
import NewAddress from './new-address';
1415
import LoaderSyncing from './loader-syncing';
@@ -68,6 +69,9 @@ class MainView extends Component {
6869
{route === 'SetPassword' && (
6970
<SetPassword store={store} wallet={wallet} />
7071
)}
72+
{route === 'RestorePassword' && (
73+
<RestorePassword store={store} wallet={wallet} nav={nav} />
74+
)}
7175
{route === 'Password' && <Password store={store} wallet={wallet} />}
7276
{route === 'NewAddress' && (
7377
<NewAddress store={store} invoice={invoice} info={info} />

src/view/restore-password.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React from 'react';
2+
import { StyleSheet, View } from 'react-native';
3+
import { observer } from 'mobx-react';
4+
import PropTypes from 'prop-types';
5+
import Background from '../component/background';
6+
import MainContent from '../component/main-content';
7+
import { H1Text } from '../component/text';
8+
import { Header } from '../component/header';
9+
import { Button, BackButton, GlasButton } from '../component/button';
10+
import { InputField } from '../component/field';
11+
import Card from '../component/card';
12+
import { FormSubText, FormStretcher } from '../component/form';
13+
14+
//
15+
// Restore Wallet Password View
16+
//
17+
18+
const styles = StyleSheet.create({
19+
content: {
20+
justifyContent: 'flex-end',
21+
},
22+
title: {
23+
textAlign: 'center',
24+
marginBottom: 20,
25+
},
26+
card: {
27+
maxHeight: 350,
28+
maxWidth: 680,
29+
paddingLeft: 45,
30+
paddingRight: 45,
31+
paddingBottom: 50,
32+
},
33+
});
34+
35+
const RestorePasswordView = ({ store, wallet, nav }) => (
36+
<Background image="purple-gradient-bg">
37+
<Header>
38+
<BackButton onPress={() => nav.goSelectSeed()} />
39+
<Button disabled onPress={() => {}} />
40+
</Header>
41+
<MainContent style={styles.content}>
42+
<View>
43+
<H1Text style={styles.title}>Restore wallet</H1Text>
44+
</View>
45+
<Card style={styles.card}>
46+
<FormSubText>Please enter your password.</FormSubText>
47+
<FormStretcher>
48+
<InputField
49+
style={styles.input}
50+
placeholder="Password"
51+
secureTextEntry={true}
52+
autoFocus={true}
53+
value={store.wallet.password}
54+
onChangeText={password => wallet.setPassword({ password })}
55+
onSubmitEditing={() => wallet.restoreWallet()}
56+
/>
57+
</FormStretcher>
58+
</Card>
59+
<GlasButton onPress={() => wallet.restoreWallet()}>Restore</GlasButton>
60+
</MainContent>
61+
</Background>
62+
);
63+
64+
RestorePasswordView.propTypes = {
65+
store: PropTypes.object.isRequired,
66+
wallet: PropTypes.object.isRequired,
67+
nav: PropTypes.object.isRequired,
68+
};
69+
70+
export default observer(RestorePasswordView);

stories/screen-story.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import Seed from '../src/view/seed';
4747
import SeedVerify from '../src/view/seed-verify';
4848
import SetPassword from '../src/view/set-password';
4949
import Password from '../src/view/password';
50+
import RestorePassword from '../src/view/restore-password';
5051
import NewAddress from '../src/view/new-address';
5152
import Wait from '../src/view/wait';
5253
import RestoreWallet from '../src/view/restore-wallet';
@@ -95,6 +96,9 @@ storiesOf('Screens', module)
9596
.add('Seed Success', () => <SeedSuccess wallet={wallet} />)
9697
.add('Set Password', () => <SetPassword store={store} wallet={wallet} />)
9798
.add('Password', () => <Password store={store} wallet={wallet} />)
99+
.add('Restore Wallet: Password', () => (
100+
<RestorePassword store={store} wallet={wallet} nav={nav} />
101+
))
98102
.add('New Address', () => (
99103
<NewAddress store={store} invoice={invoice} info={info} />
100104
))

test/unit/action/nav.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ describe('Action Nav Unit Tests', () => {
7474
});
7575
});
7676

77+
describe('goRestorePassword()', () => {
78+
it('should set correct route', () => {
79+
nav.goRestorePassword();
80+
expect(store.route, 'to equal', 'RestorePassword');
81+
});
82+
});
83+
7784
describe('goNewAddress()', () => {
7885
it('should set correct route', () => {
7986
nav.goNewAddress();

0 commit comments

Comments
 (0)