|
| 1 | +import React from 'react'; |
| 2 | +import { View, StyleSheet } from 'react-native'; |
| 3 | +import { observer } from 'mobx-react'; |
| 4 | +import PropTypes from 'prop-types'; |
| 5 | +import MainContent from '../component/main-content'; |
| 6 | +import { Text } from '../component/text'; |
| 7 | +import { Background } from '../component/background'; |
| 8 | +import { Header } from '../component/header'; |
| 9 | +import { Button, BackButton, GlasButton } from '../component/button'; |
| 10 | +import LightningBoltIcon from '../asset/icon/lightning-bolt'; |
| 11 | +import { color, font } from '../component/style'; |
| 12 | + |
| 13 | +// |
| 14 | +// Seed (Mobile) View |
| 15 | +// |
| 16 | + |
| 17 | +const styles = StyleSheet.create({ |
| 18 | + header: { |
| 19 | + height: 150, |
| 20 | + }, |
| 21 | + title: { |
| 22 | + alignItems: 'center', |
| 23 | + }, |
| 24 | + titleTxt: { |
| 25 | + width: 200, |
| 26 | + marginTop: 10, |
| 27 | + textAlign: 'center', |
| 28 | + fontSize: 15, |
| 29 | + letterSpacing: 2, |
| 30 | + }, |
| 31 | + background: { |
| 32 | + flex: 1, |
| 33 | + justifyContent: 'space-between', |
| 34 | + backgroundColor: color.blackDark, |
| 35 | + }, |
| 36 | + seed: { |
| 37 | + flex: 1, |
| 38 | + justifyContent: 'center', |
| 39 | + alignItems: 'center', |
| 40 | + }, |
| 41 | + pagination: { |
| 42 | + paddingBottom: 10, |
| 43 | + }, |
| 44 | +}); |
| 45 | + |
| 46 | +const SeedView = ({ store, wallet }) => ( |
| 47 | + <Background image="purple-gradient-bg"> |
| 48 | + <Header separator style={styles.header}> |
| 49 | + <BackButton onPress={() => wallet.initPrevSeedPage()} /> |
| 50 | + <View style={styles.title}> |
| 51 | + <LightningBoltIcon height={35} width={29} /> |
| 52 | + <Text style={styles.titleTxt}> |
| 53 | + Write down each word and store it in a safe place. |
| 54 | + </Text> |
| 55 | + </View> |
| 56 | + <Button disabled onPress={() => {}} /> |
| 57 | + </Header> |
| 58 | + <MainContent style={styles.background}> |
| 59 | + <View style={styles.seed}> |
| 60 | + <WordList |
| 61 | + startingIndex={store.wallet.seedIndex} |
| 62 | + seedMnemonic={store.seedMnemonic.slice( |
| 63 | + store.wallet.seedIndex, |
| 64 | + store.wallet.seedIndex + 8 |
| 65 | + )} |
| 66 | + /> |
| 67 | + <Text style={styles.pagination}> |
| 68 | + {`${store.wallet.seedIndex + 8} of 24`} |
| 69 | + </Text> |
| 70 | + </View> |
| 71 | + <GlasButton onPress={() => wallet.initNextSeedPage()}>Next</GlasButton> |
| 72 | + </MainContent> |
| 73 | + </Background> |
| 74 | +); |
| 75 | + |
| 76 | +SeedView.propTypes = { |
| 77 | + store: PropTypes.object.isRequired, |
| 78 | + wallet: PropTypes.object.isRequired, |
| 79 | +}; |
| 80 | + |
| 81 | +// |
| 82 | +// Word List |
| 83 | +// |
| 84 | + |
| 85 | +const listStyles = StyleSheet.create({ |
| 86 | + wrapper: { |
| 87 | + justifyContent: 'center', |
| 88 | + margin: 20, |
| 89 | + }, |
| 90 | + words: { |
| 91 | + flexDirection: 'row', |
| 92 | + flexWrap: 'wrap', |
| 93 | + justifyContent: 'center', |
| 94 | + }, |
| 95 | +}); |
| 96 | + |
| 97 | +const WordList = ({ seedMnemonic, startingIndex }) => ( |
| 98 | + <View style={listStyles.wrapper}> |
| 99 | + <View style={listStyles.words}> |
| 100 | + {seedMnemonic.map((word, i) => ( |
| 101 | + <Word word={word} index={startingIndex + i + 1} key={i} /> |
| 102 | + ))} |
| 103 | + </View> |
| 104 | + </View> |
| 105 | +); |
| 106 | + |
| 107 | +WordList.propTypes = { |
| 108 | + seedMnemonic: PropTypes.array.isRequired, |
| 109 | + startingIndex: PropTypes.number, |
| 110 | +}; |
| 111 | + |
| 112 | +// |
| 113 | +// Word |
| 114 | +// |
| 115 | + |
| 116 | +const wordStyles = StyleSheet.create({ |
| 117 | + wrapper: { |
| 118 | + justifyContent: 'center', |
| 119 | + height: 45, |
| 120 | + width: 115, |
| 121 | + margin: 10, |
| 122 | + borderWidth: 1, |
| 123 | + borderColor: color.seedBorder, |
| 124 | + backgroundColor: color.seedBackground, |
| 125 | + }, |
| 126 | + word: { |
| 127 | + fontSize: font.sizeS * 1.2, |
| 128 | + paddingLeft: 10, |
| 129 | + }, |
| 130 | +}); |
| 131 | + |
| 132 | +const Word = ({ word, index }) => ( |
| 133 | + <View style={wordStyles.wrapper}> |
| 134 | + <Text style={wordStyles.word}> |
| 135 | + {index}. {word} |
| 136 | + </Text> |
| 137 | + </View> |
| 138 | +); |
| 139 | + |
| 140 | +Word.propTypes = { |
| 141 | + word: PropTypes.string.isRequired, |
| 142 | + index: PropTypes.number.isRequired, |
| 143 | +}; |
| 144 | + |
| 145 | +export default observer(SeedView); |
0 commit comments