|
| 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); |
0 commit comments