Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/wallet modal ios detection #201

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/pancake-uikit/src/widgets/WalletModal/WalletCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Text from "../../components/Text/Text";
import MoreHoriz from "../../components/Svg/Icons/MoreHoriz";
import { ButtonProps } from "../../components/Button";
import { connectorLocalStorageKey } from "./config";
import { Login, Config } from "./types";
import { Login, Config, ConnectorNames } from "./types";

interface Props {
walletConfig: Config;
Expand Down Expand Up @@ -40,7 +40,15 @@ const WalletCard: React.FC<Props> = ({ login, walletConfig, onDismiss }) => {
<WalletButton
variant="tertiary"
onClick={() => {
login(walletConfig.connectorId);
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;

// Since iOS does not support Trust Wallet we fall back to WalletConnect
if (walletConfig.title === "Trust Wallet" && isIOS) {
login(ConnectorNames.WalletConnect);
} else {
login(walletConfig.connectorId);
}

window.localStorage.setItem(connectorLocalStorageKey, walletConfig.connectorId);
onDismiss();
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/pancake-uikit/src/widgets/WalletModal/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const connectors: Config[] = [
priority: 2,
},
{
title: "TrustWallet",
title: "Trust Wallet",
icon: TrustWallet,
connectorId: ConnectorNames.Injected,
priority: 3,
Expand Down