11import { CloseButton } from "@/components/close-button" ;
22import { QRCode } from "@/components/qr-code" ;
33import { ThemedText } from "@/components/themed-text" ;
4+ import { WalletConnectLoading } from "@/components/walletconnect-loading" ;
45import { BorderRadius , Spacing } from "@/constants/spacing" ;
56import { usePOS } from "@/context/POSContext" ;
67import { usePOSListener } from "@/hooks/use-pos-listener" ;
@@ -29,6 +30,7 @@ export default function QRModalScreen() {
2930 const params = useLocalSearchParams < ScreenParams > ( ) ;
3031
3132 const [ qrUri , setQrUri ] = useState ( "" ) ;
33+ const [ isLoading , setIsLoading ] = useState ( false ) ;
3234 const { posClient } = usePOS ( ) ;
3335 const Theme = useTheme ( ) ;
3436
@@ -48,6 +50,7 @@ export default function QRModalScreen() {
4850 recipientAddress,
4951 } ,
5052 } ) ;
53+ setIsLoading ( false ) ;
5154 } , [ amount , token , networkCaipId , recipientAddress ] ) ;
5255
5356 usePOSListener ( "connection_failed" , ( { error } ) => {
@@ -64,8 +67,9 @@ export default function QRModalScreen() {
6467 setQrUri ( uri ) ;
6568 } ) ;
6669
67- usePOSListener ( "payment_requested " , ( ) => {
70+ usePOSListener ( "connected " , ( ) => {
6871 Haptics . impactAsync ( Haptics . ImpactFeedbackStyle . Heavy ) ;
72+ setIsLoading ( true ) ;
6973 } ) ;
7074
7175 usePOSListener ( "payment_rejected" , ( { error } ) => {
@@ -97,6 +101,7 @@ export default function QRModalScreen() {
97101 recipientAddress : recipientAddress ,
98102 } ,
99103 } ) ;
104+ setIsLoading ( false ) ;
100105 } ) ;
101106
102107 const handleOnClosePress = ( ) => {
@@ -146,36 +151,51 @@ export default function QRModalScreen() {
146151
147152 return (
148153 < View style = { styles . container } >
149- < View style = { styles . amountContainer } >
150- < ThemedText
151- style = { [ styles . amountText , { color : Theme [ "text-tertiary" ] } ] }
152- >
153- Scan to pay
154- </ ThemedText >
155- < ThemedText
156- style = { [
157- styles . amountValue ,
158- { color : Theme [ "text-primary" ] , textTransform : "uppercase" } ,
159- ] }
160- >
161- ${ amount }
162- </ ThemedText >
163- </ View >
164- < QRCode size = { 300 } uri = { qrUri } logoBorderRadius = { 55 } >
165- < ImageBackground
166- source = { getIcon ( tokenData ?. icon ) }
167- style = { styles . tokenIcon }
168- resizeMode = "contain"
169- >
170- < Image
171- source = { getIcon ( networkData ?. icon ) }
172- style = { [ styles . chainIcon , { borderColor : Theme [ "bg-primary" ] } ] }
173- cachePolicy = "memory-disk"
174- priority = "high"
175- />
176- </ ImageBackground >
177- </ QRCode >
178- < View style = { { flex : 1 } } />
154+ { isLoading ? (
155+ < View style = { styles . loadingContainer } >
156+ < WalletConnectLoading size = { 180 } />
157+ < ThemedText
158+ style = { [ styles . amountText , { color : Theme [ "text-primary" ] } ] }
159+ fontSize = { 16 }
160+ lineHeight = { 18 }
161+ >
162+ Waiting for payment confirmation…
163+ </ ThemedText >
164+ </ View >
165+ ) : (
166+ < View style = { styles . scanContainer } >
167+ < View style = { styles . amountContainer } >
168+ < ThemedText
169+ style = { [ styles . amountText , { color : Theme [ "text-tertiary" ] } ] }
170+ >
171+ Scan to pay
172+ </ ThemedText >
173+ < ThemedText
174+ style = { [
175+ styles . amountValue ,
176+ { color : Theme [ "text-primary" ] , textTransform : "uppercase" } ,
177+ ] }
178+ >
179+ ${ amount }
180+ </ ThemedText >
181+ </ View >
182+ < QRCode size = { 300 } uri = { qrUri } logoBorderRadius = { 55 } >
183+ < ImageBackground
184+ source = { getIcon ( tokenData ?. icon ) }
185+ style = { styles . tokenIcon }
186+ resizeMode = "contain"
187+ >
188+ < Image
189+ source = { getIcon ( networkData ?. icon ) }
190+ style = { [ styles . chainIcon , { borderColor : Theme [ "bg-primary" ] } ] }
191+ cachePolicy = "memory-disk"
192+ priority = "high"
193+ />
194+ </ ImageBackground >
195+ </ QRCode >
196+ < View style = { { flex : 1 } } />
197+ </ View >
198+ ) }
179199 < CloseButton style = { styles . closeButton } onPress = { handleOnClosePress } />
180200 </ View >
181201 ) ;
@@ -184,6 +204,16 @@ export default function QRModalScreen() {
184204const styles = StyleSheet . create ( {
185205 container : {
186206 flex : 1 ,
207+ } ,
208+ loadingContainer : {
209+ flex : 1 ,
210+ alignItems : "center" ,
211+ justifyContent : "center" ,
212+ gap : Spacing [ "spacing-6" ] ,
213+ paddingHorizontal : Spacing [ "spacing-5" ] ,
214+ } ,
215+ scanContainer : {
216+ flex : 1 ,
187217 paddingHorizontal : Spacing [ "spacing-5" ] ,
188218 paddingVertical : Spacing [ "spacing-5" ] ,
189219 alignItems : "center" ,
@@ -222,5 +252,6 @@ const styles = StyleSheet.create({
222252 } ,
223253 closeButton : {
224254 position : "absolute" ,
255+ alignSelf : "center" ,
225256 } ,
226257} ) ;
0 commit comments