Skip to content

Commit 87c6c6b

Browse files
authored
Receive button displays address as modal (#112)
* Receive button displays address as modal * Bump up font size
1 parent de3953d commit 87c6c6b

File tree

6 files changed

+66
-54
lines changed

6 files changed

+66
-54
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mobile-app/app/(tabs)/index.tsx

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {
1010
Icon,
1111
IconProps,
1212
Spinner,
13+
Modal,
1314
} from "@ui-kitten/components";
1415
import { StyleSheet } from "react-native";
16+
import { setStringAsync } from "expo-clipboard";
1517
import Animated, {
1618
useAnimatedScrollHandler,
1719
useSharedValue,
@@ -48,11 +50,18 @@ export default function Balances() {
4850
const { account, accountName, isLoading } = useAccount();
4951
const scrollYOffset = useSharedValue(0);
5052
const [selectedIndex, setSelectedIndex] = useState(0);
53+
const [addressModalVisible, setAddressModalVisible] = useState(false);
5154

5255
const scrollHandler = useAnimatedScrollHandler((event) => {
5356
scrollYOffset.value = event.contentOffset.y;
5457
});
5558

59+
const copyAddressToClipboard = async () => {
60+
if (account) {
61+
await setStringAsync(account.publicAddress);
62+
}
63+
};
64+
5665
const getTransactionsResult = facade.getTransactions.useQuery(
5766
{ accountName },
5867
{
@@ -96,7 +105,7 @@ export default function Balances() {
96105
},
97106
);
98107

99-
if (isLoading) {
108+
if (isLoading || !account) {
100109
return (
101110
<SafeAreaView>
102111
<Layout style={[styles.container, styles.loadingContainer]}>
@@ -115,6 +124,30 @@ export default function Balances() {
115124

116125
return (
117126
<SafeAreaView>
127+
<Modal
128+
visible={addressModalVisible}
129+
backdropStyle={styles.backdrop}
130+
onBackdropPress={() => setAddressModalVisible(false)}
131+
>
132+
<Card disabled style={styles.modalCard}>
133+
<Text category="h6" style={styles.modalTitle}>
134+
Your Iron Fish Address
135+
</Text>
136+
<Text selectable style={styles.address}>
137+
{account.publicAddress}
138+
</Text>
139+
<Button onPress={copyAddressToClipboard} style={{ marginBottom: 8 }}>
140+
Copy Address
141+
</Button>
142+
<Button
143+
appearance="ghost"
144+
onPress={() => setAddressModalVisible(false)}
145+
>
146+
Close
147+
</Button>
148+
</Card>
149+
</Modal>
150+
118151
<Animated.ScrollView
119152
scrollEventThrottle={16}
120153
onScroll={scrollHandler}
@@ -157,7 +190,7 @@ export default function Balances() {
157190
appearance="ghost"
158191
accessoryLeft={ReceiveIcon}
159192
style={styles.actionButton}
160-
onPress={() => router.push("/address/")}
193+
onPress={() => setAddressModalVisible(true)}
161194
>
162195
Receive
163196
</Button>
@@ -401,4 +434,21 @@ const styles = StyleSheet.create({
401434
transactionCard: {
402435
marginVertical: 4,
403436
},
437+
backdrop: {
438+
backgroundColor: "rgba(0, 0, 0, 0.5)",
439+
},
440+
modalCard: {
441+
margin: 16,
442+
paddingHorizontal: 16,
443+
paddingTop: 16,
444+
},
445+
modalTitle: {
446+
textAlign: "center",
447+
marginBottom: 16,
448+
},
449+
address: {
450+
textAlign: "center",
451+
marginBottom: 16,
452+
fontSize: 30,
453+
},
404454
});

packages/mobile-app/app/account-settings/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ const ACCOUNT_SETTINGS_ROUTES = {
2525
title: "Account Name",
2626
href: "account-settings/account-name",
2727
},
28-
address: {
29-
title: "Address",
30-
href: "address",
31-
},
3228
exportAccount: {
3329
title: "Export Account",
3430
href: "account-settings/export-account",

packages/mobile-app/app/address/index.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/mobile-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"react-native-screens": "~4.4.0",
4343
"react-native-svg": "9.13.6",
4444
"react-native-webview": "13.13.2",
45-
"zod": "^3.22.4"
45+
"zod": "^3.22.4",
46+
"expo-clipboard": "~7.0.1"
4647
},
4748
"devDependencies": {
4849
"@babel/core": "^7.20.0",

packages/mobile-app/providers/AccountProvider.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,7 @@ import { useRouter, useSegments } from "expo-router";
33
import { useFacade } from "../data/facades";
44
import { ActivityIndicator, SafeAreaView, Text } from "react-native";
55
import { StyleSheet } from "react-native";
6-
7-
interface Balance {
8-
assetId: string;
9-
confirmed: string;
10-
available: string;
11-
}
12-
13-
interface Account {
14-
name: string;
15-
balances: {
16-
iron: Balance;
17-
custom: Balance[];
18-
};
19-
head?: {
20-
sequence: number;
21-
};
22-
}
6+
import { Account } from "../data/facades/wallet/types";
237

248
interface AccountContextType {
259
isLoading: boolean;

0 commit comments

Comments
 (0)