import { useState } from "react"; import type { ThirdwebClient } from "../../../../client/client.js"; import { isMobile } from "../../../../utils/web/isMobile.js"; import { openWindow } from "../../../../utils/web/openWindow.js"; import type { Wallet } from "../../../../wallets/interfaces/wallet.js"; import type { WalletInfo } from "../../../../wallets/wallet-info.js"; import type { WalletId } from "../../../../wallets/wallet-types.js"; import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js"; import { iconSize, radius, spacing, } from "../../../core/design-system/index.js"; import { AppleIcon } from "../../ui/ConnectWallet/icons/AppleIcon.js"; import { ChromeIcon } from "../../ui/ConnectWallet/icons/ChromeIcon.js"; import { PlayStoreIcon } from "../../ui/ConnectWallet/icons/PlayStoreIcon.js"; import { Container, ModalHeader } from "../../ui/components/basic.js"; import { QRCode } from "../../ui/components/QRCode.js"; import { Spacer } from "../../ui/components/Spacer.js"; import { Text } from "../../ui/components/text.js"; import { WalletImage } from "../../ui/components/WalletImage.js"; import { StyledButton } from "../../ui/design-system/elements.js"; import type { InjectedWalletLocale } from "../injected/locale/types.js"; /** * @internal */ export const GetStartedScreen: React.FC<{ onBack?: () => void; wallet: Wallet; walletInfo: WalletInfo; header?: React.ReactNode; footer?: React.ReactNode; showBack?: boolean; locale: InjectedWalletLocale; client: ThirdwebClient; }> = ({ wallet, walletInfo, header, footer, onBack, locale, client }) => { const [showScreen, setShowScreen] = useState< "base" | "android-scan" | "ios-scan" >("base"); const isScanScreen = showScreen === "android-scan" || showScreen === "ios-scan"; const handleBack = onBack ? () => { if (showScreen === "base") { onBack(); } else { setShowScreen("base"); } } : undefined; return ( {showScreen === "android-scan" && walletInfo.app.android && ( } url={walletInfo.app.android} walletId={wallet.id} walletName={walletInfo.name} /> )} {showScreen === "ios-scan" && walletInfo.app.ios && ( } url={walletInfo.app.ios} walletId={wallet.id} walletName={walletInfo.name} /> )} {showScreen === "base" && ( {header || ( )} {/* Chrome Extension */} {walletInfo.app.chrome && ( { openWindow(walletInfo.app.chrome || ""); }} > {locale.download.chrome} )} {/* Google Play store */} {walletInfo.app.android && ( { if (isMobile()) { openWindow(walletInfo.app.android || ""); } else { setShowScreen("android-scan"); } }} > {locale.download.android} )} {/* App Store */} {walletInfo.app.ios && ( { if (isMobile()) { openWindow(walletInfo.app.ios || ""); } else { setShowScreen("ios-scan"); } }} > {locale.download.iOS} )} )} {!isScanScreen && footer} ); }; /** * @internal */ const InstallScanScreen: React.FC<{ url: string; platform: string; walletName: string; platformIcon: React.ReactNode; walletId: WalletId; onBack?: () => void; locale: { scanToDownload: string; }; client: ThirdwebClient; }> = (props) => { return ( } qrCodeUri={props.url} /> {props.locale.scanToDownload} ); }; const ButtonLink = /* @__PURE__ */ StyledButton((_) => { const theme = useCustomTheme(); return { all: "unset", "&:hover": { background: theme.colors.secondaryButtonHoverBg, color: theme.colors.primaryText, textDecoration: "none", }, alignItems: "center", background: theme.colors.secondaryButtonBg, borderRadius: radius.sm, boxSizing: "border-box", color: theme.colors.secondaryButtonText, cursor: "pointer", display: "flex", fontWeight: 500, gap: spacing.md, padding: `${spacing.sm} ${spacing.md}`, textDecoration: "none", transition: "100ms ease", width: "100%", }; });