-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
196 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Divider, Stack } from '@chakra-ui/react' | ||
import ViewLayout from '../ViewLayout' | ||
import WalletTypeCard from '../WalletTypeCard' | ||
import ChromeIcon from '../Icons/chrome.svg' | ||
import { Wallet } from '../../data/wallets' | ||
import { FCL_SERVICE_METHODS } from '../../helpers/constants' | ||
import { toTitleCase } from '../../helpers/strings' | ||
import { toLower } from 'rambda' | ||
import * as fcl from '@onflow/fcl' | ||
import { Fragment } from 'react' | ||
|
||
const CANNONICAL_SERVICE_NAMES = { | ||
'WC/RPC': 'Mobile App', | ||
[FCL_SERVICE_METHODS.EXT]: 'Browser Extension', | ||
[FCL_SERVICE_METHODS.HTTP]: 'Web Browser', | ||
[FCL_SERVICE_METHODS.TAB]: 'Web Browser', | ||
[FCL_SERVICE_METHODS.POP]: 'Web Browser', | ||
[FCL_SERVICE_METHODS.IFRAME]: 'Web Browser', | ||
} | ||
|
||
interface GetWalletProps { | ||
onBack: () => void | ||
onCloseModal: () => void | ||
wallet: Wallet | ||
} | ||
|
||
export default function ConnectWallet({ | ||
onBack, | ||
onCloseModal, | ||
wallet, | ||
}: GetWalletProps) { | ||
return ( | ||
<ViewLayout | ||
header={{ | ||
title: `Connect to ${wallet.name}`, | ||
onBack, | ||
onClose: onCloseModal, | ||
}} | ||
> | ||
<Stack flexGrow={1} alignItems="center" spacing={4} px={6} pb={6}> | ||
{wallet.services.map((service, i) => { | ||
const cannonicalName = CANNONICAL_SERVICE_NAMES[service.method] | ||
return ( | ||
<Fragment key={i}> | ||
<WalletTypeCard | ||
icon={ChromeIcon} | ||
title={`${wallet.name} ${toTitleCase(cannonicalName)}`} | ||
description={`Confirm the connection in the ${toLower( | ||
cannonicalName | ||
)}`} | ||
button={{ | ||
text: `Connect`, | ||
onClick: () => fcl.WalletUtils.redirect(service), | ||
}} | ||
unstyled | ||
></WalletTypeCard> | ||
{i < wallet.services.length - 1 && <Divider w="80%" />} | ||
</Fragment> | ||
) | ||
})} | ||
</Stack> | ||
</ViewLayout> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createContext, useContext, useState } from 'react' | ||
|
||
export const NavigationContext = createContext({ | ||
navigate: (route: string) => { | ||
console.log('Navigate to', route) | ||
}, | ||
goBack: () => { | ||
console.log('Go back') | ||
}, | ||
history: [], | ||
currentRoute: '', | ||
}) | ||
|
||
export function Navigator({ children }) { | ||
const [history, setHistory] = useState([]) | ||
const [currentRoute, setCurrentRoute] = useState('') | ||
|
||
const navigate = route => { | ||
setHistory([...history, currentRoute]) | ||
setCurrentRoute(route) | ||
} | ||
|
||
const goBack = () => { | ||
const previousRoute = history.pop() | ||
setCurrentRoute(previousRoute) | ||
} | ||
|
||
return ( | ||
<NavigationContext.Provider | ||
value={{ navigate, goBack, history, currentRoute }} | ||
></NavigationContext.Provider> | ||
) | ||
} | ||
|
||
export function Route({ component }) { | ||
return component | ||
} | ||
|
||
export function useNavigation() { | ||
return useContext(NavigationContext) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.