From f9e012398606a85d286087f3e94bf8b95a52df55 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 14 Nov 2018 16:27:27 -0800 Subject: feat: make onUnlockWalletClick different based on ON --- .../src/components/coinbase_wallet_logo.tsx | 33 +++------------------- packages/instant/src/components/payment_method.tsx | 33 +++++++++++++++++++--- .../containers/connected_account_payment_method.ts | 27 ++++++++++++++++-- 3 files changed, 58 insertions(+), 35 deletions(-) diff --git a/packages/instant/src/components/coinbase_wallet_logo.tsx b/packages/instant/src/components/coinbase_wallet_logo.tsx index f3c9ccdc2..845b96d73 100644 --- a/packages/instant/src/components/coinbase_wallet_logo.tsx +++ b/packages/instant/src/components/coinbase_wallet_logo.tsx @@ -5,22 +5,13 @@ export interface CoinbaseWalletLogoProps { } export const CoinbaseWalletLogo: React.StatelessComponent = ({ width }) => ( - - + + - ); @@ -30,19 +21,3 @@ CoinbaseWalletLogo.displayName = 'CoinbaseWalletLogo'; CoinbaseWalletLogo.defaultProps = { width: 164, }; - -export interface CoinbaseWalletAppLogoProps { - width?: number; -} - -export const CoinbaseWalletAppLogo: React.StatelessComponent = ({ width }) => ( - - - - -); diff --git a/packages/instant/src/components/payment_method.tsx b/packages/instant/src/components/payment_method.tsx index 662dd9d22..21bb2902b 100644 --- a/packages/instant/src/components/payment_method.tsx +++ b/packages/instant/src/components/payment_method.tsx @@ -1,11 +1,16 @@ import * as _ from 'lodash'; import * as React from 'react'; +import { + COINBASE_WALLET_ANDROID_APP_STORE_URL, + COINBASE_WALLET_IOS_APP_STORE_URL, + COINBASE_WALLET_SITE_URL, +} from '../constants'; import { ColorOption } from '../style/theme'; -import { Account, AccountState, Network } from '../types'; +import { Account, AccountState, Network, OperatingSystem } from '../types'; import { envUtil } from '../util/env'; -import { CoinbaseWalletAppLogo } from './coinbase_wallet_logo'; +import { CoinbaseWalletLogo } from './coinbase_wallet_logo'; import { MetaMaskLogo } from './meta_mask_logo'; import { PaymentMethodDropdown } from './payment_method_dropdown'; import { Circle } from './ui/circle'; @@ -77,7 +82,7 @@ export class PaymentMethod extends React.Component { private readonly _renderMainContent = (): React.ReactNode => { const { account, network } = this.props; const isMobile = envUtil.isMobileOperatingSystem(); - const logo = isMobile ? : ; + const logo = isMobile ? : ; const primaryColor = isMobile ? ColorOption.darkBlue : ColorOption.darkOrange; const secondaryColor = isMobile ? ColorOption.lightBlue : ColorOption.lightOrange; const colors = { primaryColor, secondaryColor }; @@ -97,7 +102,7 @@ export class PaymentMethod extends React.Component { ); case AccountState.None: return ( - + {isMobile ? 'Install Coinbase Wallet' : 'Install MetaMask'} ); @@ -111,4 +116,24 @@ export class PaymentMethod extends React.Component { ); } }; + private readonly _handleInstallWalletClick = (): void => { + const isMobile = envUtil.isMobileOperatingSystem(); + if (!isMobile) { + this.props.onInstallWalletClick(); + return; + } + const operatingSystem = envUtil.getOperatingSystem(); + let url = COINBASE_WALLET_SITE_URL; + switch (operatingSystem) { + case OperatingSystem.Android: + url = COINBASE_WALLET_ANDROID_APP_STORE_URL; + break; + case OperatingSystem.iOS: + url = COINBASE_WALLET_IOS_APP_STORE_URL; + break; + default: + break; + } + window.open(url, '_blank'); + }; } diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts index 69c2ddf19..beaaccf2f 100644 --- a/packages/instant/src/containers/connected_account_payment_method.ts +++ b/packages/instant/src/containers/connected_account_payment_method.ts @@ -3,10 +3,16 @@ import { connect } from 'react-redux'; import { Dispatch } from 'redux'; import { PaymentMethod, PaymentMethodProps } from '../components/payment_method'; +import { + COINBASE_WALLET_ANDROID_APP_STORE_URL, + COINBASE_WALLET_IOS_APP_STORE_URL, + COINBASE_WALLET_SITE_URL, +} from '../constants'; import { Action, actions } from '../redux/actions'; import { asyncData } from '../redux/async_data'; import { State } from '../redux/reducer'; -import { Network, Omit, ProviderState, StandardSlidingPanelContent } from '../types'; +import { Network, Omit, OperatingSystem, ProviderState, StandardSlidingPanelContent } from '../types'; +import { envUtil } from '../util/env'; export interface ConnectedAccountPaymentMethodProps {} @@ -49,7 +55,24 @@ const mergeProps = ( onInstallWalletClick: connectedDispatch.onInstallWalletClick, walletName: connectedState.providerState.name, onUnlockWalletClick: () => { - connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + const isMobile = envUtil.isMobileOperatingSystem(); + if (!isMobile) { + connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + return; + } + const operatingSystem = envUtil.getOperatingSystem(); + let url = COINBASE_WALLET_SITE_URL; + switch (operatingSystem) { + case OperatingSystem.Android: + url = COINBASE_WALLET_ANDROID_APP_STORE_URL; + break; + case OperatingSystem.iOS: + url = COINBASE_WALLET_IOS_APP_STORE_URL; + break; + default: + break; + } + window.open(url, '_blank'); }, }); -- cgit