Skip to content

Commit 5efbebe

Browse files
committed
Style the bridge transaction confirmation
1 parent 893eda6 commit 5efbebe

File tree

3 files changed

+361
-106
lines changed

3 files changed

+361
-106
lines changed

packages/mobile-app/app/(drawer)/account/bridge/index.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StyleSheet, View } from "react-native";
33
import { Button, Card, Layout, Text } from "@ui-kitten/components";
44
import { oreoWallet } from "@/data/wallet/oreowalletWallet";
55
import { Network } from "@/data/constants";
6-
import { useCallback, useRef, useState } from "react";
6+
import { useCallback, useEffect, useRef, useState } from "react";
77
import * as Uint8ArrayUtils from "@/utils/uint8Array";
88
import { useFacade } from "@/data/facades";
99
import { Output } from "@/data/facades/wallet/types";
@@ -219,15 +219,13 @@ export default function MenuDebugBrowser() {
219219
},
220220
);
221221

222-
const handlePresentModalPress = useCallback(() => {
223-
bottomSheetModalRef.current?.present();
224-
setAccountModalVisible(true);
225-
}, []);
226-
227-
const handleDismissModalPress = useCallback(() => {
228-
bottomSheetModalRef.current?.dismiss();
229-
setAccountModalVisible(false);
230-
}, []);
222+
useEffect(() => {
223+
if (accountModalVisible) {
224+
bottomSheetModalRef.current?.present();
225+
} else {
226+
bottomSheetModalRef.current?.dismiss();
227+
}
228+
}, [accountModalVisible]);
231229

232230
const renderBackdrop = useCallback(
233231
(props: any) => (
@@ -379,7 +377,10 @@ export default function MenuDebugBrowser() {
379377
enablePanDownToClose
380378
backdropComponent={renderBackdrop}
381379
onDismiss={() => {
382-
messageHandler.current.updateActiveAccount(null);
380+
if (messageHandler.current.connectRequest) {
381+
messageHandler.current.connectRequest.resolve(null);
382+
messageHandler.current.connectRequest = null;
383+
}
383384
setAccountModalVisible(false);
384385
}}
385386
backgroundStyle={styles.bottomSheetModal}
@@ -391,7 +392,7 @@ export default function MenuDebugBrowser() {
391392
style={{ width: 48, height: 48 }}
392393
/>
393394
<Layout style={{ gap: 2 }}>
394-
<Text category="h5">Iron Fish Bridge</Text>
395+
<Text category="h5">Connect Account</Text>
395396
<Text category="s2" appearance="hint">
396397
{network}
397398
</Text>
@@ -412,34 +413,36 @@ export default function MenuDebugBrowser() {
412413
>
413414
<Button
414415
onPress={() => {
416+
messageHandler.current.updateActiveAccount(null);
417+
setAccountModalVisible(false);
418+
}}
419+
style={{ flex: 1 }}
420+
appearance="outline"
421+
>
422+
Cancel
423+
</Button>
424+
<Button
425+
onPress={async () => {
415426
if (!account.data) {
416427
console.error("No account loaded");
417428
return;
418429
}
419-
messageHandler.current.updateActiveAccount({
430+
await messageHandler.current.updateActiveAccount({
420431
name: account.data.name,
421432
address: account.data.publicAddress,
422433
});
423-
handleDismissModalPress();
434+
setAccountModalVisible(false);
424435
}}
425436
style={{ flex: 1 }}
426437
>
427438
Confirm
428439
</Button>
429-
<Button
430-
onPress={() => {
431-
messageHandler.current.updateActiveAccount(null);
432-
handleDismissModalPress();
433-
}}
434-
style={{ flex: 1 }}
435-
appearance="outline"
436-
>
437-
Cancel
438-
</Button>
439440
</Layout>
440441
</BottomSheetView>
441442
</BottomSheetModal>
442443
<SendTransactionModal
444+
network={network}
445+
renderBackdrop={renderBackdrop}
443446
sendTransactionData={sendTransactionData}
444447
cancel={() => {
445448
messageHandler.current.rejectSendTransactionRequest();
@@ -457,7 +460,7 @@ export default function MenuDebugBrowser() {
457460
onMessage={(event) => {
458461
messageHandler.current.handleMessage(
459462
event.nativeEvent.data,
460-
handlePresentModalPress,
463+
() => setAccountModalVisible(true),
461464
(data) => {
462465
setSendTransactionData(data);
463466
},

0 commit comments

Comments
 (0)