-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
108 lines (102 loc) · 3.25 KB
/
Copy pathApp.tsx
File metadata and controls
108 lines (102 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import React, { useCallback, useState } from 'react';
import { StyleSheet, Text, View, ScrollView, ActivityIndicator, Image, SafeAreaView } from 'react-native';
import { useWindowDimensions } from "react-native-use-dimensions";
import { withWalletConnect, useWalletConnect } from "react-native-walletconnect";
import Etherscan from "react-use-etherscan";
import Constants from "expo-constants";
import Pyongyang from "pyongyang";
import Outpost, { useAllCommunities } from "react-outpost";
import { Login, CommunityCard, UploadImage } from "./components";
function CommunityList({ authToken }: { authToken: string | null }) {
const { loading, error, communities } = useAllCommunities();
if (error) {
return <Text style={styles.error} children={error.message} />
} else if (loading) {
return <ActivityIndicator style={styles.loading} />
}
return (
<>
{communities.map((community, i) => (
<CommunityCard
key={i}
community={community}
authToken={authToken}
/>
))}
</>
)
}
const { ETHERSCAN_API_KEY } = Constants.manifest.extra;
function App() {
const [authToken, onAuthTokenChanged] = useState<string | null>(null);
const { session, signPersonalMessage } = useWalletConnect();
const { width } = useWindowDimensions();
const logoSize = width * 0.6;
const onRequestSignMessage = useCallback(async (address: string, signInToken: string) => {
if (!session.length) {
return Promise.reject(new Error(`Unable to sign message; wallet not initialized`));
}
return signPersonalMessage([
signInToken,
address,
]);
}, [session, signPersonalMessage]);
return (
<Pyongyang>
<Etherscan
apiKey={ETHERSCAN_API_KEY}
network="mainnet"
>
<Outpost onRequestSignMessage={onRequestSignMessage}>
<ScrollView style={StyleSheet.absoluteFill}>
<View style={styles.safeAreaView} />
<View style={styles.logoContainer}>
<Image
style={{
width: logoSize,
height: logoSize,
}}
source={{ uri: "https://outpost-protocol.com/logo/Outpost_black.png"}}
/>
<Text style={styles.title} children="OUTPOST" />
</View>
<UploadImage authToken={authToken} />
<CommunityList authToken={authToken} />
<View style={styles.safeAreaView}/>
</ScrollView>
<View style={StyleSheet.absoluteFill} pointerEvents="box-none">
<SafeAreaView />
<Login style={styles.login} onAuthTokenChanged={onAuthTokenChanged} />
</View>
</Outpost>
</Etherscan>
</Pyongyang>
);
}
const styles = StyleSheet.create({
error: {
color: "red",
padding: 10,
width: "100%",
},
icon: {
borderRadius: 64,
height: 128,
overflow: 'hidden',
width: 128,
},
loading: {},
login: { padding: 15, flexDirection: "row", justifyContent: "flex-end" },
logoContainer: {
alignItems: "center",
justifyContent: "center",
width: "100%"
},
row: {
width: "100%",
padding: 10,
},
safeAreaView: { height: 50 },
title: { fontSize: 50, marginBottom: 50 },
});
export default withWalletConnect(App);