@@ -10,6 +10,7 @@ import {
10
10
TouchableOpacity ,
11
11
TouchableOpacityProps ,
12
12
useWindowDimensions ,
13
+ useWindowDimensions ,
13
14
View ,
14
15
ViewProps ,
15
16
} from 'react-native'
@@ -39,6 +40,7 @@ import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelec
39
40
import { CollateralInfoModal } from './CollateralInfoModal'
40
41
import { createCollateralEntry } from './helpers'
41
42
import { InitialCollateralInfoModal } from './InitialCollateralInfoModal'
43
+ import { InitialCollateralInfoModal } from './InitialCollateralInfoModal'
42
44
import { useNavigateTo } from './navigation'
43
45
import { useStrings } from './strings'
44
46
@@ -49,15 +51,19 @@ export const ManageCollateralScreen = () => {
49
51
meta : { addressMode} ,
50
52
} = useSelectedWallet ( )
51
53
const screenHeight = useWindowDimensions ( ) . height
54
+ const screenHeight = useWindowDimensions ( ) . height
52
55
const { amount, collateralId, utxo} = useCollateralInfo ( wallet )
53
56
const hasCollateral = collateralId !== '' && utxo !== undefined
54
57
const didSpend = collateralId !== '' && utxo === undefined
55
58
const navigateTo = useNavigateTo ( )
56
59
const { openModal} = useModal ( )
60
+ const { openModal} = useModal ( )
57
61
const strings = useStrings ( )
58
62
const balances = useBalances ( wallet )
59
63
const { navigateToTxReview} = useWalletNavigation ( )
60
64
const { unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged} = useReviewTx ( )
65
+ const { navigateToTxReview} = useWalletNavigation ( )
66
+ const { unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged} = useReviewTx ( )
61
67
const lockedAmount = asQuantity ( wallet . primaryBreakdown . lockedAsStorageCost . toString ( ) )
62
68
63
69
const params = useUnsafeParams < SettingsStackRoutes [ 'manage-collateral' ] > ( )
@@ -88,6 +94,16 @@ export const ManageCollateralScreen = () => {
88
94
navigateTo . failedTx ( )
89
95
}
90
96
97
+ const onSuccess = ( signedTx : YoroiSignedTx ) => {
98
+ navigateTo . submittedTx ( )
99
+ const collateralId = `${ signedTx . signedTx . id } :0`
100
+ setCollateralId ( collateralId )
101
+ }
102
+
103
+ const onError = ( ) => {
104
+ navigateTo . failedTx ( )
105
+ }
106
+
91
107
const createCollateralTransaction = ( ) => {
92
108
LayoutAnimation . configureNext ( LayoutAnimation . Presets . easeInEaseOut )
93
109
@@ -98,6 +114,11 @@ export const ManageCollateralScreen = () => {
98
114
onSuccessChanged ( onSuccess )
99
115
onErrorChanged ( onError )
100
116
navigateToTxReview ( )
117
+ unsignedTxChanged ( yoroiUnsignedTx )
118
+ operationsChanged ( [ < Operation key = "0" /> ] )
119
+ onSuccessChanged ( onSuccess )
120
+ onErrorChanged ( onError )
121
+ navigateToTxReview ( )
101
122
} ,
102
123
} )
103
124
}
@@ -137,6 +158,14 @@ export const ManageCollateralScreen = () => {
137
158
)
138
159
}
139
160
161
+ const handleCollateralInfoModal = ( ) => {
162
+ openModal (
163
+ strings . initialCollateralInfoModalTitle ,
164
+ < InitialCollateralInfoModal onConfirm = { handleGenerateCollateral } /> ,
165
+ Math . min ( screenHeight * 0.9 , 650 ) ,
166
+ )
167
+ }
168
+
140
169
const shouldShowPrimaryButton = ! hasCollateral || didSpend
141
170
const shouldShowBackButton = ! shouldShowPrimaryButton && ! ! params ?. backButton
142
171
@@ -183,6 +212,7 @@ export const ManageCollateralScreen = () => {
183
212
< Button
184
213
title = { strings . generateCollateral }
185
214
onPress = { handleCollateralInfoModal }
215
+ onPress = { handleCollateralInfoModal }
186
216
shelleyTheme
187
217
disabled = { isLoading }
188
218
/>
@@ -261,20 +291,49 @@ const Operation = () => {
261
291
)
262
292
}
263
293
294
+ const Operation = ( ) => {
295
+ const { styles, colors} = useStyles ( )
296
+ const strings = useStrings ( )
297
+ const { openModal} = useModal ( )
298
+
299
+ const handleOnPressInfo = ( ) => {
300
+ openModal ( strings . collateralInfoModalTitle , < CollateralInfoModal /> , 500 )
301
+ }
302
+
303
+ return (
304
+ < View style = { styles . operation } >
305
+ < Text style = { styles . operationText } > { strings . collateralInfoModalLabel } </ Text >
306
+
307
+ < Space width = "xs" />
308
+
309
+ < TouchableOpacity onPress = { handleOnPressInfo } >
310
+ < Info size = { 24 } color = { colors . iconColor } />
311
+ </ TouchableOpacity >
312
+ </ View >
313
+ )
314
+ }
315
+
264
316
const useStyles = ( ) => {
317
+ const { color, atoms} = useTheme ( )
265
318
const { color, atoms} = useTheme ( )
266
319
const styles = StyleSheet . create ( {
267
320
safeAreaView : {
268
321
backgroundColor : color . bg_color_max ,
269
322
...atoms . flex_1 ,
270
323
...atoms . px_lg ,
324
+ ...atoms . flex_1 ,
325
+ ...atoms . px_lg ,
271
326
} ,
272
327
amountItem : {
273
328
...atoms . flex_row ,
274
329
...atoms . justify_between ,
275
330
...atoms . align_center ,
331
+ ...atoms . flex_row ,
332
+ ...atoms . justify_between ,
333
+ ...atoms . align_center ,
276
334
} ,
277
335
heading : {
336
+ ...atoms . flex_1 ,
278
337
...atoms . flex_1 ,
279
338
alignSelf : 'center' ,
280
339
} ,
@@ -286,11 +345,21 @@ const useStyles = () => {
286
345
...atoms . body_2_md_regular ,
287
346
color : color . text_gray_medium ,
288
347
} ,
348
+ operation : {
349
+ ...atoms . flex_row ,
350
+ ...atoms . align_center ,
351
+ } ,
352
+ operationText : {
353
+ ...atoms . body_2_md_regular ,
354
+ color : color . text_gray_medium ,
355
+ } ,
289
356
} )
290
357
291
358
const colors = {
292
359
iconColor : color . gray_900 ,
360
+ iconColor : color . gray_900 ,
293
361
}
294
362
295
363
return { styles, colors} as const
364
+ return { styles, colors} as const
296
365
}
0 commit comments