@@ -10,8 +10,10 @@ import {
10
10
Icon ,
11
11
IconProps ,
12
12
Spinner ,
13
+ Modal ,
13
14
} from "@ui-kitten/components" ;
14
15
import { StyleSheet } from "react-native" ;
16
+ import { setStringAsync } from "expo-clipboard" ;
15
17
import Animated , {
16
18
useAnimatedScrollHandler ,
17
19
useSharedValue ,
@@ -22,6 +24,7 @@ import { Asset } from "../../data/facades/chain/types";
22
24
import { useAccount } from "../../providers/AccountProvider" ;
23
25
import { router } from "expo-router" ;
24
26
import { SafeAreaView } from "react-native-safe-area-context" ;
27
+ import { CurrencyUtils } from "@ironfish/sdk" ;
25
28
26
29
const MenuIcon = ( props : IconProps ) => < Icon { ...props } name = "menu-outline" /> ;
27
30
const SettingsIcon = ( props : IconProps ) => (
@@ -48,11 +51,18 @@ export default function Balances() {
48
51
const { account, accountName, isLoading } = useAccount ( ) ;
49
52
const scrollYOffset = useSharedValue ( 0 ) ;
50
53
const [ selectedIndex , setSelectedIndex ] = useState ( 0 ) ;
54
+ const [ addressModalVisible , setAddressModalVisible ] = useState ( false ) ;
51
55
52
56
const scrollHandler = useAnimatedScrollHandler ( ( event ) => {
53
57
scrollYOffset . value = event . contentOffset . y ;
54
58
} ) ;
55
59
60
+ const copyAddressToClipboard = async ( ) => {
61
+ if ( account ) {
62
+ await setStringAsync ( account . publicAddress ) ;
63
+ }
64
+ } ;
65
+
56
66
const getTransactionsResult = facade . getTransactions . useQuery (
57
67
{ accountName } ,
58
68
{
@@ -96,7 +106,7 @@ export default function Balances() {
96
106
} ,
97
107
) ;
98
108
99
- if ( isLoading ) {
109
+ if ( isLoading || ! account ) {
100
110
return (
101
111
< SafeAreaView >
102
112
< Layout style = { [ styles . container , styles . loadingContainer ] } >
@@ -115,6 +125,30 @@ export default function Balances() {
115
125
116
126
return (
117
127
< SafeAreaView >
128
+ < Modal
129
+ visible = { addressModalVisible }
130
+ backdropStyle = { styles . backdrop }
131
+ onBackdropPress = { ( ) => setAddressModalVisible ( false ) }
132
+ >
133
+ < Card disabled style = { styles . modalCard } >
134
+ < Text category = "h6" style = { styles . modalTitle } >
135
+ Your Iron Fish Address
136
+ </ Text >
137
+ < Text selectable style = { styles . address } >
138
+ { account . publicAddress }
139
+ </ Text >
140
+ < Button onPress = { copyAddressToClipboard } style = { { marginBottom : 8 } } >
141
+ Copy Address
142
+ </ Button >
143
+ < Button
144
+ appearance = "ghost"
145
+ onPress = { ( ) => setAddressModalVisible ( false ) }
146
+ >
147
+ Close
148
+ </ Button >
149
+ </ Card >
150
+ </ Modal >
151
+
118
152
< Animated . ScrollView
119
153
scrollEventThrottle = { 16 }
120
154
onScroll = { scrollHandler }
@@ -144,7 +178,7 @@ export default function Balances() {
144
178
</ Layout >
145
179
< Layout style = { styles . headerBalance } >
146
180
< Text category = "h1" style = { styles . balanceAmount } >
147
- { account ?. balances . iron . confirmed ?? "0.00" }
181
+ { CurrencyUtils . render ( account ?. balances . iron . confirmed ?? "0" ) }
148
182
</ Text >
149
183
< Text category = "s1" appearance = "hint" >
150
184
{ getIronAsset . data ?. verification . status === "verified"
@@ -157,7 +191,7 @@ export default function Balances() {
157
191
appearance = "ghost"
158
192
accessoryLeft = { ReceiveIcon }
159
193
style = { styles . actionButton }
160
- onPress = { ( ) => router . push ( "/address/" ) }
194
+ onPress = { ( ) => setAddressModalVisible ( true ) }
161
195
>
162
196
Receive
163
197
</ Button >
@@ -173,6 +207,7 @@ export default function Balances() {
173
207
appearance = "ghost"
174
208
accessoryLeft = { BridgeIcon }
175
209
style = { styles . actionButton }
210
+ onPress = { ( ) => router . push ( "/menu/debug/browser" ) }
176
211
>
177
212
Bridge
178
213
</ Button >
@@ -224,7 +259,9 @@ export default function Balances() {
224
259
? getIronAsset . data . verification . symbol
225
260
: ( getIronAsset . data ?. name ?? "IRON" )
226
261
}
227
- amount = { account . balances . iron . confirmed }
262
+ amount = { CurrencyUtils . render (
263
+ account . balances . iron . confirmed ,
264
+ ) }
228
265
verified = {
229
266
getIronAsset . data ?. verification . status === "verified"
230
267
}
@@ -241,7 +278,14 @@ export default function Balances() {
241
278
? asset . verification . symbol
242
279
: ( asset ?. name ?? balance . assetId )
243
280
}
244
- amount = { balance . confirmed }
281
+ amount = { CurrencyUtils . render (
282
+ balance . confirmed ,
283
+ false ,
284
+ balance . assetId ,
285
+ asset ?. verification . status === "verified"
286
+ ? asset . verification
287
+ : undefined ,
288
+ ) }
245
289
verified = { asset ?. verification . status === "verified" }
246
290
/>
247
291
) ;
@@ -401,4 +445,21 @@ const styles = StyleSheet.create({
401
445
transactionCard : {
402
446
marginVertical : 4 ,
403
447
} ,
448
+ backdrop : {
449
+ backgroundColor : "rgba(0, 0, 0, 0.5)" ,
450
+ } ,
451
+ modalCard : {
452
+ margin : 16 ,
453
+ paddingHorizontal : 16 ,
454
+ paddingTop : 16 ,
455
+ } ,
456
+ modalTitle : {
457
+ textAlign : "center" ,
458
+ marginBottom : 16 ,
459
+ } ,
460
+ address : {
461
+ textAlign : "center" ,
462
+ marginBottom : 16 ,
463
+ fontSize : 30 ,
464
+ } ,
404
465
} ) ;
0 commit comments