-
Notifications
You must be signed in to change notification settings - Fork 6
feat: suggest downloading the mobile app #813
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
Open
leanmendoza
wants to merge
7
commits into
master
Choose a base branch
from
feat/mobile-app-download
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+330
−163
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
77e8175
feat: suggest downloading the mobile app
leanmendoza ea077b6
Merge branch 'master' into feat/mobile-app-download
leanmendoza aec17f4
apply review
leanmendoza fdf5ea8
use ui2
leanmendoza 48c6bc3
fix eslint/prettier
leanmendoza 09ee2a1
clean up
leanmendoza 289338e
show only PlayStore (Android) badge
leanmendoza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
src/components/MobileDownloadModal/MobileDownloadModal.tsx
This file contains hidden or 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,89 @@ | ||
| import React, { useCallback, useState } from "react" | ||
|
|
||
| import { useAdvancedUserAgentData } from "@dcl/hooks" | ||
| import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" | ||
| import { ExplorerJumpIn } from "decentraland-ui2/dist/components/Modal/DownloadModal/ExplorerJumpIn" | ||
| import { | ||
| ModalContent, | ||
| ModalDescription, | ||
| ModalImageContainer, | ||
| ModalTitle, | ||
| } from "decentraland-ui2/dist/components/Modal/MobileDownloadModal/MobileDownloadModal.styled" | ||
| import { Modal } from "decentraland-ui2/dist/components/Modal/Modal" | ||
|
|
||
| import { launchDesktopApp, styled } from "decentraland-ui2" | ||
|
|
||
| import { MobileStoreBadges } from "../MobileStoreBadges/MobileStoreBadges" | ||
|
|
||
| export interface MobileDownloadModalProps { | ||
| open: boolean | ||
| onClose: () => void | ||
| } | ||
|
|
||
| export const MobileDownloadModal: React.FC<MobileDownloadModalProps> = ({ | ||
| open, | ||
| onClose, | ||
| }) => { | ||
| const l = useFormatMessage() | ||
|
|
||
| return ( | ||
| <Modal open={open} size="tiny" onClose={onClose}> | ||
| <ModalContent> | ||
| <ModalImageContainer> | ||
| <ExplorerJumpIn /> | ||
| </ModalImageContainer> | ||
| <ModalTitle variant="h2"> | ||
| {l("components.modal.download.title")} | ||
| </ModalTitle> | ||
| <ModalDescription variant="body1"> | ||
| {l("components.modal.mobile_download.description")} | ||
| </ModalDescription> | ||
| <MobileStoreBadges size="large" /> | ||
| </ModalContent> | ||
| </Modal> | ||
| ) | ||
| } | ||
|
|
||
| const CaptureContainer = styled("div")({ | ||
| display: "contents", | ||
| }) | ||
|
|
||
| export function MobileJumpInWrapper({ | ||
| children, | ||
| desktopAppOptions, | ||
| }: { | ||
| children: React.ReactNode | ||
| desktopAppOptions?: Parameters<typeof launchDesktopApp>[0] | ||
| }) { | ||
| const [, userAgentData] = useAdvancedUserAgentData() | ||
| const isAndroid = | ||
| (userAgentData?.mobile ?? false) && userAgentData?.os?.name === "Android" | ||
| const [showModal, setShowModal] = useState(false) | ||
|
|
||
| const handleCapture = useCallback( | ||
| async (e: React.MouseEvent) => { | ||
| if (isAndroid) { | ||
| e.stopPropagation() | ||
| e.preventDefault() | ||
| // The mobile app also handles decentraland:// deep links | ||
| const hasLauncher = await launchDesktopApp(desktopAppOptions ?? {}) | ||
| if (!hasLauncher) { | ||
| setShowModal(true) | ||
| } | ||
| } | ||
| }, | ||
| [isAndroid, desktopAppOptions] | ||
| ) | ||
|
|
||
| return ( | ||
| <> | ||
| <CaptureContainer onClickCapture={handleCapture}> | ||
| {children} | ||
| </CaptureContainer> | ||
| <MobileDownloadModal | ||
| open={showModal} | ||
| onClose={() => setShowModal(false)} | ||
| /> | ||
| </> | ||
| ) | ||
| } |
This file contains hidden or 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,33 @@ | ||
| import React from "react" | ||
|
|
||
| import { GooglePlayBadge } from "decentraland-ui2/dist/components/MobileStoreBadges/GooglePlayBadge" | ||
| import { | ||
| StoreBadgeIconWrapper, | ||
| StoreBadgeLink, | ||
| StoreBadgesContainer, | ||
| } from "decentraland-ui2/dist/components/MobileStoreBadges/MobileStoreBadges.styled" | ||
| import { config } from "decentraland-ui2/dist/config" | ||
|
|
||
| export interface MobileStoreBadgesProps { | ||
| size?: "small" | "large" | ||
| } | ||
|
|
||
| const MobileStoreBadges = React.memo( | ||
| ({ size = "small" }: MobileStoreBadgesProps) => { | ||
| return ( | ||
| <StoreBadgesContainer> | ||
| <StoreBadgeLink | ||
| href={config.get("ANDROID_STORE_URL")} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| <StoreBadgeIconWrapper badgeSize={size}> | ||
| <GooglePlayBadge /> | ||
| </StoreBadgeIconWrapper> | ||
| </StoreBadgeLink> | ||
| </StoreBadgesContainer> | ||
| ) | ||
| } | ||
| ) | ||
|
|
||
| export { MobileStoreBadges } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about reusar of UI2 component