Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle large fonts with twelve word seed phrases #5187

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions src/backup/BackupPhraseContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Clipboard from '@react-native-clipboard/clipboard'
import * as React from 'react'
import { WithTranslation } from 'react-i18next'
import { StyleSheet, Text, TextInput, View, ViewStyle } from 'react-native'
import { StyleSheet, Text, TextInput, View, ViewStyle, useWindowDimensions } from 'react-native'
import { isValidBackupPhrase } from 'src/backup/utils'
import Touchable from 'src/components/Touchable'
import withTextInputPasteAware from 'src/components/WithTextInputPasteAware'
import { withTranslation } from 'src/i18n'
import colors from 'src/styles/colors'
import fontStyles from 'src/styles/fonts'
import { vibrateInformative } from 'src/styles/hapticFeedback'
import { Spacing } from 'src/styles/styles'
import Logger from 'src/utils/Logger'

const PhraseInput = withTextInputPasteAware(TextInput, { top: undefined, right: 12, bottom: 12 })
Expand All @@ -18,17 +19,23 @@ type TwelveWordTableProps = {
}

function TwelveWordTable({ words }: TwelveWordTableProps) {
const { fontScale } = useWindowDimensions()
return (
<>
<View style={styles.twelveWordTable}>
{words.map((word, index) => (
<View key={index} style={styles.indexWordContainer}>
<Text style={styles.indexText}>{index + 1}</Text>
<Text key={index} style={styles.wordText}>
<View
key={index}
style={[styles.wordContainer, fontScale > 1.5 ? { width: '50%' } : { width: '33%' }]}
>
<Text adjustsFontSizeToFit={true} style={styles.indexText}>
{index + 1}
</Text>
<Text numberOfLines={1} adjustsFontSizeToFit={true} style={styles.wordText} key={index}>
{word}
</Text>
</View>
))}
</>
</View>
)
}

Expand Down Expand Up @@ -153,20 +160,20 @@ const styles = StyleSheet.create({
indexText: {
...fontStyles.regular,
color: colors.gray4,
marginRight: 8,
lineHeight: 24,
},
wordText: {
...fontStyles.regular,
lineHeight: 24,
twelveWordTable: {
flexDirection: 'row',
flexWrap: 'wrap',
marginHorizontal: Spacing.Small12,
},
indexWordContainer: {
flexGrow: 1,
flexShrink: 1,
flexBasis: '30%',
wordContainer: {
flexDirection: 'row',
gap: Spacing.Smallest8,
alignItems: 'center',
marginVertical: 11,
marginLeft: '3%',
},
wordText: {
...fontStyles.regular,
},
phraseContainer: {
flexWrap: 'wrap',
Expand Down
Loading
Loading