1+ import Clipboard from '@react-native-clipboard/clipboard'
12import * as React from 'react'
23import { View } from 'react-native'
34import IonIcon from 'react-native-vector-icons/Ionicons'
45
6+ import { useHandler } from '../../hooks/useHandler'
57import { lstrings } from '../../locales/strings'
68import type { EdgeAppSceneProps } from '../../types/routerTypes'
79import { SceneButtons } from '../buttons/SceneButtons'
810import { EdgeCard } from '../cards/EdgeCard'
11+ import { EdgeTouchableOpacity } from '../common/EdgeTouchableOpacity'
912import { SceneWrapper } from '../common/SceneWrapper'
10- import { styled } from '../hoc/styled'
13+ import { SectionHeader } from '../common/SectionHeader'
14+ import { CopyIcon } from '../icons/ThemedIcons'
1115import { SceneContainer } from '../layout/SceneContainer'
12- import { useTheme } from '../services/ThemeContext'
16+ import { EdgeRow } from '../rows/EdgeRow'
17+ import { showToast } from '../services/AirshipInstance'
18+ import { cacheStyles , type Theme , useTheme } from '../services/ThemeContext'
1319import { EdgeText , Paragraph } from '../themed/EdgeText'
1420
1521export interface BankInfo {
@@ -31,61 +37,73 @@ export const RampBankRoutingDetailsScene: React.FC<Props> = props => {
3137 const { route } = props
3238 const { bank, fiatCurrencyCode, fiatAmount, onDone } = route . params
3339
34- const amountToSendText = `${ fiatAmount } ${ fiatCurrencyCode } `
35-
3640 const theme = useTheme ( )
41+ const styles = getStyles ( theme )
3742
38- const renderInfoRow = ( label : string , value : string ) : React . ReactElement => (
39- < InfoRowContainer >
40- < InfoLabel > { label } </ InfoLabel >
41- < InfoValue selectable > { value } </ InfoValue >
42- </ InfoRowContainer >
43- )
43+ const amountToSendText = ` ${ fiatAmount } ${ fiatCurrencyCode } `
44+
45+ const handleCopyAmount = useHandler ( ( ) => {
46+ Clipboard . setString ( amountToSendText )
47+ showToast ( lstrings . fragment_copied )
48+ } )
4449
4550 return (
4651 < SceneWrapper scroll hasTabs >
4752 < SceneContainer headerTitle = { lstrings . ramp_bank_routing_title } >
48- < ContentContainer >
49- < InstructionContainer >
50- < StyledIcon
51- name = "information-circle-outline"
52- size = { theme . rem ( 2.5 ) }
53- color = { theme . primaryText }
54- />
55- < Paragraph style = { { flexShrink : 1 } } >
56- { lstrings . ramp_bank_routing_instructions }
57- </ Paragraph >
58- </ InstructionContainer >
59-
60- < EdgeCard >
61- < CardContent >
62- < AmountLabel > { lstrings . ramp_send_amount_label } </ AmountLabel >
63- < AmountValue > { amountToSendText } </ AmountValue >
64- </ CardContent >
65- </ EdgeCard >
66-
67- < EdgeCard >
68- < CardContent >
69- < SectionTitle >
70- { lstrings . ramp_bank_details_section_title }
71- </ SectionTitle >
72-
73- { renderInfoRow ( lstrings . ramp_bank_name_label , bank . name ) }
74- { renderInfoRow (
75- lstrings . ramp_account_number_label ,
76- bank . accountNumber
77- ) }
78- { renderInfoRow (
79- lstrings . ramp_routing_number_label ,
80- bank . routingNumber
81- ) }
82- </ CardContent >
83- </ EdgeCard >
84-
85- < WarningTextContainer >
86- < WarningText > { lstrings . ramp_bank_routing_warning } </ WarningText >
87- </ WarningTextContainer >
88- </ ContentContainer >
53+ { /* TODO: This is a strange one-off UI. Consider a warning card here instead? */ }
54+ < View style = { styles . instructionContainer } >
55+ < IonIcon
56+ name = "information-circle-outline"
57+ size = { theme . rem ( 2.5 ) }
58+ color = { theme . primaryText }
59+ />
60+ < Paragraph style = { styles . instructionText } >
61+ { lstrings . ramp_bank_routing_instructions }
62+ </ Paragraph >
63+ </ View >
64+
65+ < EdgeCard >
66+ < View style = { styles . cardContent } >
67+ < View style = { styles . amountRow } >
68+ < View style = { styles . amountTextContainer } >
69+ < EdgeText style = { styles . amountLabel } >
70+ { lstrings . ramp_send_amount_label }
71+ </ EdgeText >
72+ < EdgeText style = { styles . amountValue } >
73+ { amountToSendText }
74+ </ EdgeText >
75+ </ View >
76+ < EdgeTouchableOpacity onPress = { handleCopyAmount } >
77+ < CopyIcon style = { styles . copyIcon } size = { theme . rem ( 1 ) } />
78+ </ EdgeTouchableOpacity >
79+ </ View >
80+ </ View >
81+ </ EdgeCard >
82+
83+ < SectionHeader leftTitle = { lstrings . ramp_bank_details_section_title } />
84+ < EdgeCard sections >
85+ < EdgeRow
86+ title = { lstrings . ramp_bank_name_label }
87+ body = { bank . name }
88+ rightButtonType = "copy"
89+ />
90+ < EdgeRow
91+ title = { lstrings . ramp_account_number_label }
92+ body = { bank . accountNumber }
93+ rightButtonType = "copy"
94+ />
95+ < EdgeRow
96+ title = { lstrings . ramp_routing_number_label }
97+ body = { bank . routingNumber }
98+ rightButtonType = "copy"
99+ />
100+ </ EdgeCard >
101+
102+ < View style = { styles . warningTextContainer } >
103+ < EdgeText style = { styles . warningText } >
104+ { lstrings . ramp_bank_routing_warning }
105+ </ EdgeText >
106+ </ View >
89107
90108 < SceneButtons
91109 primary = { {
@@ -98,67 +116,51 @@ export const RampBankRoutingDetailsScene: React.FC<Props> = props => {
98116 )
99117}
100118
101- // Styled components
102- const ContentContainer = styled ( View ) ( theme => ( {
103- flex : 1 ,
104- paddingHorizontal : theme . rem ( 0.5 )
105- } ) )
106-
107- const InstructionContainer = styled ( View ) ( theme => ( {
108- alignItems : 'center' ,
109- flexDirection : 'row' ,
110- paddingVertical : theme . rem ( 0.5 ) ,
111- paddingHorizontal : theme . rem ( 0.5 )
112- } ) )
113-
114- const StyledIcon = styled ( IonIcon ) ( theme => ( {
115- marginBottom : theme . rem ( 0.5 )
116- } ) )
117-
118- const CardContent = styled ( View ) ( theme => ( {
119- padding : theme . rem ( 1 )
120- } ) )
121-
122- const AmountLabel = styled ( EdgeText ) ( theme => ( {
123- fontSize : theme . rem ( 0.75 ) ,
124- color : theme . secondaryText ,
125- marginBottom : theme . rem ( 0.25 )
126- } ) )
127-
128- const AmountValue = styled ( EdgeText ) ( theme => ( {
129- fontSize : theme . rem ( 1.5 ) ,
130- fontFamily : theme . fontFaceBold ,
131- color : theme . primaryText
132- } ) )
133-
134- const SectionTitle = styled ( EdgeText ) ( theme => ( {
135- fontSize : theme . rem ( 1 ) ,
136- fontFamily : theme . fontFaceMedium ,
137- marginBottom : theme . rem ( 1 )
138- } ) )
139-
140- const InfoRowContainer = styled ( View ) ( theme => ( {
141- marginBottom : theme . rem ( 0.75 )
142- } ) )
143-
144- const InfoLabel = styled ( EdgeText ) ( theme => ( {
145- fontSize : theme . rem ( 0.75 ) ,
146- color : theme . secondaryText ,
147- marginBottom : theme . rem ( 0.25 )
148- } ) )
149-
150- const InfoValue = styled ( EdgeText ) ( theme => ( {
151- fontSize : theme . rem ( 1 ) ,
152- fontFamily : theme . fontFaceMedium ,
153- color : theme . primaryText
154- } ) )
155-
156- const WarningTextContainer = styled ( View ) ( theme => ( {
157- paddingHorizontal : theme . rem ( 1 )
158- } ) )
159-
160- const WarningText = styled ( EdgeText ) ( theme => ( {
161- fontSize : theme . rem ( 0.75 ) ,
162- fontStyle : 'italic' ,
163- textAlign : 'center'
119+ const getStyles = cacheStyles ( ( theme : Theme ) => ( {
120+ instructionContainer : {
121+ alignItems : 'center' ,
122+ flexDirection : 'row' ,
123+ paddingVertical : theme . rem ( 0.5 ) ,
124+ paddingHorizontal : theme . rem ( 0.5 )
125+ } ,
126+ copyIcon : {
127+ color : theme . iconTappable
128+ } ,
129+ instructionText : {
130+ flexShrink : 1
131+ } ,
132+ cardContent : {
133+ padding : theme . rem ( 0.5 )
134+ } ,
135+ amountLabel : {
136+ fontSize : theme . rem ( 0.75 ) ,
137+ color : theme . secondaryText ,
138+ marginBottom : theme . rem ( 0.25 )
139+ } ,
140+ amountValue : {
141+ fontSize : theme . rem ( 1.5 ) ,
142+ fontFamily : theme . fontFaceBold ,
143+ color : theme . primaryText
144+ } ,
145+ amountRow : {
146+ flexDirection : 'row' ,
147+ alignItems : 'center' ,
148+ justifyContent : 'space-between'
149+ } ,
150+ amountTextContainer : {
151+ flex : 1
152+ } ,
153+ sectionTitle : {
154+ fontSize : theme . rem ( 1 ) ,
155+ fontFamily : theme . fontFaceMedium ,
156+ marginBottom : theme . rem ( 1 )
157+ } ,
158+ warningTextContainer : {
159+ paddingHorizontal : theme . rem ( 1 )
160+ } ,
161+ warningText : {
162+ fontSize : theme . rem ( 0.75 ) ,
163+ fontStyle : 'italic' ,
164+ textAlign : 'center'
165+ }
164166} ) )
0 commit comments