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

Commit f3575b8

Browse files
valentinewallacetanx
authored andcommitted
Implement Restore Wallet: Seed view for mobile and hook it up.
1 parent d8f3340 commit f3575b8

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

src/view/main-mobile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import SeedVerifyView from './seed-verify-mobile';
1616
import SetPinView from './set-pin-mobile';
1717
import SetPinConfirmView from './set-pin-confirm-mobile';
1818
import SeedSuccessView from './seed-success-mobile';
19+
import RestoreSeedView from './restore-seed-mobile';
1920
import NewAddressView from './new-address-mobile';
2021

2122
import PinView from './pin-mobile';
@@ -84,6 +85,8 @@ const SetPasswordConfirm = () => (
8485

8586
const SeedSuccess = () => <SeedSuccessView wallet={wallet} />;
8687

88+
const RestoreSeed = () => <RestoreSeedView store={store} wallet={wallet} />;
89+
8790
const NewAddress = () => (
8891
<NewAddressView store={store} invoice={invoice} info={info} />
8992
);
@@ -190,6 +193,7 @@ const MainStack = createStackNavigator(
190193
SetPassword,
191194
SetPasswordConfirm,
192195
SeedSuccess,
196+
RestoreSeed,
193197
NewAddress,
194198
Password,
195199
LoaderSyncing,

src/view/restore-seed-mobile.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import React, { Component } from 'react';
2+
import { observer } from 'mobx-react';
3+
import PropTypes from 'prop-types';
4+
import SeedEntry from '../component/seed-entry';
5+
import { Button, BackButton, SmallGlasButton } from '../component/button';
6+
import { FormSubText } from '../component/form';
7+
import Background from '../component/background';
8+
import MainContent from '../component/main-content';
9+
import { CopyOnboardText } from '../component/text';
10+
import { Header } from '../component/header';
11+
import Card from '../component/card';
12+
import { createStyles, maxWidth } from '../component/media-query';
13+
import { smallBreakWidth } from '../component/style';
14+
15+
//
16+
// Restore Seed View (Mobile)
17+
//
18+
19+
const baseStyles = {
20+
content: {
21+
justifyContent: 'flex-end',
22+
},
23+
title: {
24+
textAlign: 'center',
25+
marginBottom: 20,
26+
},
27+
subText: {
28+
maxWidth: 235,
29+
},
30+
};
31+
32+
const styles = createStyles(
33+
baseStyles,
34+
35+
maxWidth(smallBreakWidth, {
36+
title: {
37+
fontSize: 30,
38+
lineHeight: 40,
39+
},
40+
})
41+
);
42+
43+
class RestoreSeedView extends Component {
44+
constructor(props) {
45+
super(props);
46+
this.state = {
47+
focusedInput: 0,
48+
};
49+
}
50+
51+
render() {
52+
const { store, wallet } = this.props;
53+
return (
54+
<Background image="purple-gradient-bg">
55+
<Header>
56+
<BackButton onPress={() => wallet.initPrevRestorePage()} />
57+
<Button disabled onPress={() => {}} />
58+
</Header>
59+
<MainContent style={styles.content}>
60+
<CopyOnboardText style={styles.title}>
61+
{'Restore your wallet'}
62+
</CopyOnboardText>
63+
<Card>
64+
<FormSubText style={styles.subText}>
65+
{store.restoreVerifyCopy}
66+
</FormSubText>
67+
{store.restoreVerifyIndexes.map((seedIndex, i) => (
68+
<SeedEntry
69+
seedIndex={seedIndex}
70+
value={store.wallet.restoreSeed[seedIndex - 1]}
71+
onChangeText={word =>
72+
wallet.setRestoreSeed({ word, index: seedIndex - 1 })
73+
}
74+
key={i}
75+
autoFocus={seedIndex - 1 === store.wallet.focusedRestoreInd}
76+
onSubmitEditing={() =>
77+
i === 2
78+
? wallet.initNextRestorePage()
79+
: wallet.setFocusedRestoreInd({ index: seedIndex })
80+
}
81+
onClick={() =>
82+
wallet.setFocusedRestoreInd({ index: seedIndex - 1 })
83+
}
84+
/>
85+
))}
86+
</Card>
87+
<SmallGlasButton onPress={() => wallet.initNextRestorePage()}>
88+
Next
89+
</SmallGlasButton>
90+
</MainContent>
91+
</Background>
92+
);
93+
}
94+
}
95+
96+
RestoreSeedView.propTypes = {
97+
store: PropTypes.object.isRequired,
98+
wallet: PropTypes.object.isRequired,
99+
};
100+
101+
export default observer(RestoreSeedView);

stories/screen-story.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import NewAddressMobile from '../src/view/new-address-mobile';
8282
import Wait from '../src/view/wait';
8383
import WaitMobile from '../src/view/wait-mobile';
8484
import RestoreSeed from '../src/view/restore-seed';
85+
import RestoreSeedMobile from '../src/view/restore-seed-mobile';
8586

8687
const store = new Store();
8788
store.init();
@@ -138,6 +139,9 @@ storiesOf('Screens', module)
138139
.add('Restore Wallet: Seed', () => (
139140
<RestoreSeed store={store} wallet={wallet} />
140141
))
142+
.add('Restore Wallet: Seed (Mobile)', () => (
143+
<RestoreSeedMobile store={store} wallet={wallet} />
144+
))
141145
.add('Seed Success', () => <SeedSuccess wallet={wallet} />)
142146
.add('Seed Success (Mobile)', () => <SeedSuccessMobile wallet={wallet} />)
143147
.add('Set Password', () => (

0 commit comments

Comments
 (0)