Skip to content

Commit 409d711

Browse files
authored
Merge branch 'feature/tx-review-token-details' into feature/tx-review-collateral
2 parents 71ce377 + 22d9e30 commit 409d711

File tree

4 files changed

+51
-52
lines changed

4 files changed

+51
-52
lines changed

apps/wallet-mobile/src/features/ReviewTx/common/CopiableText.tsx

+4-45
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,19 @@
11
import {useTheme} from '@yoroi/theme'
22
import * as React from 'react'
3-
import {StyleSheet, Text, TextProps, TextStyle, TouchableOpacity, View} from 'react-native'
3+
import {StyleSheet, TouchableOpacity, View} from 'react-native'
44

55
import {Icon} from '../../../components/Icon'
6-
import {Space} from '../../../components/Space/Space'
76
import {useCopy} from '../../../hooks/useCopy'
87

9-
export const CopiableText = ({
10-
text,
11-
index,
12-
textStyle,
13-
multiline = false,
14-
addressProps,
15-
}: {
16-
text: string
17-
index?: number
18-
textStyle?: TextStyle
19-
multiline?: boolean
20-
addressProps?: TextProps
21-
}) => {
8+
export const CopiableText = ({children, textToCopy}: {children: React.ReactNode; textToCopy: string}) => {
229
const {styles, colors} = useStyles()
2310
const [, copy] = useCopy()
2411

2512
return (
2613
<View style={styles.text}>
27-
<Text
28-
style={[styles.addressText, textStyle]}
29-
numberOfLines={!multiline ? 1 : undefined}
30-
ellipsizeMode={!multiline ? 'middle' : undefined}
31-
{...addressProps}
32-
>
33-
{text}
34-
</Text>
14+
{children}
3515

36-
{index !== undefined ? (
37-
<>
38-
<Space width="sm" />
39-
40-
<Text style={styles.index}>{`#${index}`}</Text>
41-
42-
<Space width="sm" />
43-
</>
44-
) : (
45-
<Space width="xs" />
46-
)}
47-
48-
<TouchableOpacity onPress={() => copy(text)} activeOpacity={0.5}>
16+
<TouchableOpacity onPress={() => copy(textToCopy)} activeOpacity={0.5}>
4917
<Icon.Copy size={24} color={colors.copy} />
5018
</TouchableOpacity>
5119
</View>
@@ -59,15 +27,6 @@ const useStyles = () => {
5927
...atoms.flex_row,
6028
...atoms.justify_between,
6129
},
62-
addressText: {
63-
...atoms.flex_1,
64-
...atoms.body_2_md_regular,
65-
color: color.text_gray_medium,
66-
},
67-
index: {
68-
...atoms.body_2_md_medium,
69-
color: color.text_gray_medium,
70-
},
7130
})
7231

7332
const colors = {

apps/wallet-mobile/src/features/ReviewTx/common/TokenDetails.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ const PolicyId = ({policyId}: {policyId: string}) => {
174174
<Space width="lg" />
175175

176176
<View style={styles.copiableText}>
177-
<CopiableText textStyle={styles.value} text={policyId} multiline />
177+
<CopiableText textToCopy={policyId}>
178+
<Text style={styles.value}>{policyId}</Text>
179+
</CopiableText>
178180
</View>
179181
</Row>
180182
)
@@ -193,7 +195,9 @@ const Fingerprint = ({info}: {info: Portfolio.Token.Info}) => {
193195
<Space width="lg" />
194196

195197
<View style={styles.copiableText}>
196-
<CopiableText textStyle={styles.value} text={info.fingerprint} multiline />
198+
<CopiableText textToCopy={info.fingerprint}>
199+
<Text style={styles.value}>{info.fingerprint}</Text>
200+
</CopiableText>
197201
</View>
198202
</Row>
199203
)
@@ -333,6 +337,7 @@ const useStyles = () => {
333337
color: color.text_gray_low,
334338
},
335339
value: {
340+
...atoms.flex_1,
336341
...atoms.text_right,
337342
...atoms.body_2_md_regular,
338343
color: color.text_gray_max,

apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Overview/OverviewTab.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,18 @@ const SenderSection = ({
9393
ownedOutputs: FormattedOutputs
9494
}) => {
9595
const strings = useStrings()
96+
const {styles} = useStyles()
9697
const address = ownedOutputs[0]?.rewardAddress ?? ownedOutputs[0]?.address
9798

9899
return (
99100
<Accordion label={strings.myWalletLabel}>
100101
<Space height="lg" />
101102

102-
<CopiableText text={address} />
103+
<CopiableText textToCopy={address}>
104+
<Text style={styles.addressText} numberOfLines={1} ellipsizeMode="middle">
105+
{address}
106+
</Text>
107+
</CopiableText>
103108

104109
<Space height="sm" />
105110

@@ -180,7 +185,11 @@ const ReceiverSection = ({notOwnedOutputs}: {notOwnedOutputs: FormattedOutputs})
180185
<View style={styles.receiverAddress}>
181186
<Text>{isScriptAddress ? strings.receiveToScriptLabel : strings.receiveToLabel}:</Text>
182187

183-
<CopiableText text={address} textStyle={styles.receiverSectionAddress} />
188+
<CopiableText textToCopy={address}>
189+
<Text style={[styles.addressText, styles.receiverSectionAddress]} numberOfLines={1} ellipsizeMode="middle">
190+
{address}
191+
</Text>
192+
</CopiableText>
184193
</View>
185194
</>
186195
)
@@ -276,6 +285,11 @@ const useStyles = () => {
276285
receiverSectionAddress: {
277286
maxWidth: 260,
278287
},
288+
addressText: {
289+
...atoms.flex_1,
290+
...atoms.body_2_md_regular,
291+
color: color.text_gray_medium,
292+
},
279293
})
280294

281295
const colors = {

apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/UTxOs/UTxOsTab.tsx

+24-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,21 @@ const Input = ({input}: {input: FormattedInput}) => {
4848

4949
<Space height="lg" />
5050

51-
<CopiableText text={input.address} multiline />
51+
<CopiableText textToCopy={input.address}>
52+
<Text style={styles.addressText}>{input.address}</Text>
53+
</CopiableText>
5254

5355
<Space height="sm" />
5456

55-
<CopiableText index={input.txIndex} text={input.txHash} multiline />
57+
<CopiableText textToCopy={input.txHash}>
58+
<Text style={styles.addressText}>{input.txHash}</Text>
59+
60+
<Space width="sm" />
61+
62+
<Text style={styles.index}>{`#${input.txIndex}`}</Text>
63+
64+
<Space width="sm" />
65+
</CopiableText>
5666
</View>
5767

5868
<Space height="sm" />
@@ -82,7 +92,9 @@ const Output = ({output}: {output: FormattedOutput}) => {
8292

8393
<Space height="lg" />
8494

85-
<CopiableText text={output.address} multiline />
95+
<CopiableText textToCopy={output.address}>
96+
<Text style={styles.addressText}>{output.address}</Text>
97+
</CopiableText>
8698
</View>
8799

88100
<Space height="sm" />
@@ -184,6 +196,15 @@ const useStyles = () => {
184196
...atoms.body_2_md_regular,
185197
color: color.text_gray_medium,
186198
},
199+
addressText: {
200+
...atoms.flex_1,
201+
...atoms.body_2_md_regular,
202+
color: color.text_gray_medium,
203+
},
204+
index: {
205+
...atoms.body_2_md_medium,
206+
color: color.text_gray_medium,
207+
},
187208
})
188209

189210
return {styles} as const

0 commit comments

Comments
 (0)