-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): add walletconnect
- Loading branch information
Showing
23 changed files
with
462 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './screens/ConnectPopupScreen'; | ||
export * from './screens/WalletConnectSessionPopupScreen'; | ||
export * from './screens/WalletConnectPairScreen'; | ||
export * from './hooks/useConnectPopupNavigation'; | ||
export * from './hooks/useIsConnectPopupOpened'; |
107 changes: 107 additions & 0 deletions
107
suite-native/module-connect-popup/src/screens/WalletConnectPairScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { useState } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import { | ||
selectSessions, | ||
walletConnectDisconnectThunk, | ||
walletConnectPairThunk, | ||
} from '@suite-common/walletconnect'; | ||
import { Button, Divider, HStack, IconButton, Input, Text, VStack } from '@suite-native/atoms'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { Screen, ScreenHeader } from '@suite-native/navigation'; | ||
import { ScanQRBottomSheet } from '@suite-native/qr-code'; | ||
|
||
export const WalletConnectPairScreen = () => { | ||
const dispatch = useDispatch(); | ||
const sessions = useSelector(selectSessions); | ||
|
||
const [uri, setUri] = useState(''); | ||
const [qrVisible, setQrVisible] = useState(false); | ||
|
||
const handlePair = () => { | ||
dispatch(walletConnectPairThunk({ uri })); | ||
setUri(''); | ||
}; | ||
const handleQr = () => { | ||
setQrVisible(true); | ||
}; | ||
|
||
return ( | ||
<Screen | ||
header={ | ||
<ScreenHeader | ||
closeActionType="close" | ||
content={ | ||
<Text> | ||
<Translation id="moduleConnectPopup.walletConnect.title" /> | ||
</Text> | ||
} | ||
/> | ||
} | ||
> | ||
<VStack spacing="sp24"> | ||
<VStack> | ||
<Input | ||
value={uri} | ||
onChangeText={setUri} | ||
placeholder="Connection URI..." | ||
rightIcon={ | ||
<IconButton | ||
iconName="qrCode" | ||
onPress={handleQr} | ||
colorScheme="tertiaryElevation0" | ||
/> | ||
} | ||
/> | ||
<Button colorScheme="primary" onPress={handlePair}> | ||
<Translation id="moduleConnectPopup.walletConnect.connect" /> | ||
</Button> | ||
</VStack> | ||
|
||
<Divider /> | ||
|
||
<VStack> | ||
<Text variant="highlight"> | ||
<Translation id="moduleConnectPopup.walletConnect.activeConnections" />: | ||
</Text> | ||
{sessions.map(session => ( | ||
<HStack key={session.topic} spacing="sp12"> | ||
<VStack flex={1} spacing="sp1"> | ||
<Text>{session.peer.metadata.name}</Text> | ||
<Text color="textSubdued">{session.peer.metadata.url}</Text> | ||
<Text color="textSubdued" numberOfLines={1}> | ||
{session.topic} | ||
</Text> | ||
</VStack> | ||
<VStack> | ||
<Button | ||
onPress={() => { | ||
dispatch( | ||
walletConnectDisconnectThunk({ topic: session.topic }), | ||
); | ||
}} | ||
size="small" | ||
colorScheme="redElevation0" | ||
> | ||
<Translation id="moduleConnectPopup.walletConnect.disconnect" /> | ||
</Button> | ||
</VStack> | ||
</HStack> | ||
))} | ||
{sessions.length === 0 && ( | ||
<Text> | ||
<Translation id="moduleConnectPopup.walletConnect.noActiveConnections" /> | ||
</Text> | ||
)} | ||
</VStack> | ||
</VStack> | ||
|
||
<ScanQRBottomSheet | ||
title={<Translation id="moduleConnectPopup.walletConnect.title" />} | ||
isVisible={qrVisible} | ||
onCodeScanned={setUri} | ||
onClose={() => setQrVisible(false)} | ||
/> | ||
</Screen> | ||
); | ||
}; |
Oops, something went wrong.