-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat: add android announcement banner #7551
Changes from all commits
736c677
1e3f954
cda4e1c
0848045
757cb04
890b4e7
fab1421
e153c45
2b9857b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Trans } from '@lingui/macro' | ||
import { InterfaceElementName } from '@uniswap/analytics-events' | ||
import { useAndroidGALaunchFlagEnabled } from 'featureFlags/flags/androidGALaunch' | ||
import { useScreenSize } from 'hooks/useScreenSize' | ||
import { useLocation } from 'react-router-dom' | ||
import { useHideAndroidAnnouncementBanner } from 'state/user/hooks' | ||
import { ThemedText } from 'theme/components' | ||
import { useIsDarkMode } from 'theme/components/ThemeToggle' | ||
import { openDownloadApp } from 'utils/openDownloadApp' | ||
import { isMobileSafari } from 'utils/userAgent' | ||
|
||
import androidAnnouncementBannerQR from '../../../assets/images/androidAnnouncementBannerQR.png' | ||
import darkAndroidThumbnail from '../../../assets/images/AndroidWallet-Thumbnail-Dark.png' | ||
import lightAndroidThumbnail from '../../../assets/images/AndroidWallet-Thumbnail-Light.png' | ||
import { | ||
Container, | ||
DownloadButton, | ||
PopupContainer, | ||
StyledQrCode, | ||
StyledXButton, | ||
TextContainer, | ||
Thumbnail, | ||
} from './styled' | ||
|
||
export default function AndroidAnnouncementBanner() { | ||
const [hideAndroidAnnouncementBanner, toggleHideAndroidAnnouncementBanner] = useHideAndroidAnnouncementBanner() | ||
const location = useLocation() | ||
const isLandingScreen = location.search === '?intro=true' || location.pathname === '/' | ||
const screenSize = useScreenSize() | ||
|
||
const shouldDisplay = Boolean(!hideAndroidAnnouncementBanner && !isLandingScreen) | ||
const isDarkMode = useIsDarkMode() | ||
|
||
const isAndroidGALaunched = useAndroidGALaunchFlagEnabled() | ||
const onClick = () => | ||
openDownloadApp({ | ||
element: InterfaceElementName.UNISWAP_WALLET_BANNER_DOWNLOAD_BUTTON, | ||
isAndroidGALaunched, | ||
}) | ||
|
||
if (!isAndroidGALaunched || isMobileSafari) return null | ||
|
||
return ( | ||
<PopupContainer show={shouldDisplay}> | ||
<Container> | ||
<Thumbnail src={isDarkMode ? darkAndroidThumbnail : lightAndroidThumbnail} alt="Android app thumbnail" /> | ||
<TextContainer onClick={!screenSize['xs'] ? onClick : undefined}> | ||
<ThemedText.BodySmall lineHeight="20px"> | ||
<Trans>Uniswap on Android</Trans> | ||
</ThemedText.BodySmall> | ||
<ThemedText.LabelMicro> | ||
<Trans>Available now - download from the Google Play Store today</Trans> | ||
</ThemedText.LabelMicro> | ||
<DownloadButton onClick={onClick}> | ||
<Trans>Download now</Trans> | ||
</DownloadButton> | ||
</TextContainer> | ||
<StyledQrCode src={androidAnnouncementBannerQR} alt="App OneLink QR code" /> | ||
<StyledXButton | ||
data-testid="uniswap-wallet-banner" | ||
size={24} | ||
onClick={(e) => { | ||
// prevent click from bubbling to UI on the page underneath, i.e. clicking a token row | ||
e.preventDefault() | ||
e.stopPropagation() | ||
toggleHideAndroidAnnouncementBanner() | ||
}} | ||
/> | ||
</Container> | ||
</PopupContainer> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { ButtonText } from 'components/Button' | ||
import { OpacityHoverState } from 'components/Common' | ||
import { X } from 'react-feather' | ||
import styled from 'styled-components' | ||
import { BREAKPOINTS } from 'theme' | ||
import { Z_INDEX } from 'theme/zIndex' | ||
|
||
export const PopupContainer = styled.div<{ show: boolean }>` | ||
${({ show }) => !show && 'display: none'}; | ||
background-color: ${({ theme }) => theme.surface2}; | ||
color: ${({ theme }) => theme.neutral1}; | ||
position: fixed; | ||
z-index: ${Z_INDEX.sticky}; | ||
user-select: none; | ||
border-radius: 20px; | ||
bottom: 40px; | ||
right: 20px; | ||
width: 360px; | ||
height: 92px; | ||
border: 1.3px solid ${({ theme }) => theme.surface3}; | ||
|
||
@media only screen and (max-width: ${BREAKPOINTS.md}px) { | ||
bottom: 62px; | ||
} | ||
|
||
@media only screen and (max-width: ${BREAKPOINTS.xs}px) { | ||
width: unset; | ||
right: 10px; | ||
left: 10px; | ||
} | ||
` | ||
export const StyledXButton = styled(X)` | ||
cursor: pointer; | ||
position: absolute; | ||
top: -30px; | ||
right: 0px; | ||
padding: 4px; | ||
border-radius: 50%; | ||
|
||
background-color: ${({ theme }) => theme.surface5}; | ||
color: ${({ theme }) => theme.neutral2}; | ||
${OpacityHoverState}; | ||
|
||
@media only screen and (max-width: ${BREAKPOINTS.xs}px) { | ||
top: 8px; | ||
right: 8px; | ||
} | ||
` | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-start; | ||
align-items: center; | ||
height: 100%; | ||
overflow: hidden; | ||
border-radius: 20px; | ||
gap: 16px; | ||
` | ||
export const Thumbnail = styled.img` | ||
width: 82px; | ||
` | ||
export const TextContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 2px; | ||
color: ${({ theme }) => theme.neutral2}; | ||
padding: 10px 0px 10px; | ||
line-height: 16px; | ||
|
||
@media only screen and (max-width: ${BREAKPOINTS.xs}px) { | ||
width: 220px; | ||
} | ||
` | ||
export const StyledQrCode = styled.img` | ||
padding: 2px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. confirming 2px and not 4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes - qr code was too small so phil wanted to decrease padding |
||
border-radius: 8px; | ||
width: 64px; | ||
height: 64px; | ||
background-color: ${({ theme }) => theme.white}; | ||
margin-right: 16px; | ||
|
||
@media only screen and (max-width: ${BREAKPOINTS.xs}px) { | ||
display: none; | ||
} | ||
` | ||
export const DownloadButton = styled(ButtonText)` | ||
line-height: 16px; | ||
font-size: 14px; | ||
color: ${({ theme }) => theme.accent1}; | ||
` |
This file was deleted.
This file was deleted.
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.
confirming 2px here and not 4px