-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adjusted the entry UI display for Keystone.
- Loading branch information
1 parent
60c6ff6
commit 584dde0
Showing
7 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,92 @@ | ||
import { HARDWARE_WALLETS, HardwareWalletType } from '@/shared/constant'; | ||
import { Card, Column, Image, Row, Text } from '@/ui/components'; | ||
import { useTools } from '@/ui/components/ActionComponent'; | ||
import { BottomModal } from '@/ui/components/BottomModal'; | ||
import { useExtensionIsInTab } from '@/ui/features/browser/tabs'; | ||
import { colors } from '@/ui/theme/colors'; | ||
import { useWallet } from '@/ui/utils'; | ||
import { CloseOutlined } from '@ant-design/icons'; | ||
|
||
import { useNavigate } from '../MainRoute'; | ||
|
||
function WalletItem(props: { walletType: HardwareWalletType; onClick?: () => void; disabled?: boolean }) { | ||
const walletInfo = HARDWARE_WALLETS[props.walletType]; | ||
const tools = useTools(); | ||
|
||
return ( | ||
<Card | ||
style={{ backgroundColor: 'rgba(255,255,255,0.1)', borderRadius: 10, opacity: props.disabled ? 0.4 : 1 }} | ||
mt="lg" | ||
onClick={() => { | ||
if (props.disabled) { | ||
tools.toast('Coming soon'); | ||
} else { | ||
props.onClick && props.onClick(); | ||
} | ||
}}> | ||
<Row fullX> | ||
<Row itemsCenter> | ||
<Image src={walletInfo.img} size={30} /> | ||
<Text text={walletInfo.name} /> | ||
</Row> | ||
</Row> | ||
</Card> | ||
); | ||
} | ||
|
||
export const ConnectHardwareModal = ({ onClose }: { onClose: () => void }) => { | ||
const wallet = useWallet(); | ||
|
||
const isInTab = useExtensionIsInTab(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<BottomModal onClose={onClose}> | ||
<Column justifyCenter itemsCenter> | ||
<Row justifyBetween itemsCenter style={{ height: 20 }} fullX> | ||
<Row /> | ||
<Text text="Connect to Hardware Wallet" textCenter size="md" /> | ||
<Row | ||
onClick={() => { | ||
onClose(); | ||
}}> | ||
<CloseOutlined /> | ||
</Row> | ||
</Row> | ||
|
||
<Row fullX style={{ borderTopWidth: 1, borderColor: colors.border }} my="md" /> | ||
|
||
<Column gap="zero" mt="sm" mb="lg"> | ||
<Text | ||
size="sm" | ||
color="textDim" | ||
text={`The hardware wallet feature is experimental. Use it with caution as potential issues may arise`} | ||
/> | ||
|
||
<WalletItem | ||
walletType={HardwareWalletType.Keystone} | ||
onClick={async () => { | ||
const isBooted = await wallet.isBooted(); | ||
if (!isInTab) { | ||
if (isBooted) { | ||
window.open('#/account/create-keystone-wallet'); | ||
} else { | ||
window.open('#/account/create-password?isKeystone=true'); | ||
} | ||
return; | ||
} | ||
if (isBooted) { | ||
navigate('CreateKeystoneWalletScreen'); | ||
} else { | ||
navigate('CreatePasswordScreen', { isKeystone: true }); | ||
} | ||
}} | ||
/> | ||
|
||
<WalletItem walletType={HardwareWalletType.Ledger} disabled /> | ||
<WalletItem walletType={HardwareWalletType.Trezor} disabled /> | ||
</Column> | ||
</Column> | ||
</BottomModal> | ||
); | ||
}; |
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