-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add app modal * Detect mobile devices * Extract app badge component
- Loading branch information
Showing
14 changed files
with
261 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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,54 @@ | ||
import { Box, Stack, StackProps, useTheme } from '@mui/material' | ||
import { useMemo } from 'react' | ||
|
||
import { config } from '@/config' | ||
|
||
type AppBadgeType = 'app-store' | 'google-play' | ||
interface AppBadgeProps { | ||
type: AppBadgeType | ||
link: string | ||
} | ||
|
||
function AppBadge({ type, link }: AppBadgeProps) { | ||
const { spacing } = useTheme() | ||
|
||
const imgSrc = useMemo(() => { | ||
const srcRecord: Record<AppBadgeType, string> = { | ||
'app-store': '/imgs/app-store-badge.svg', | ||
'google-play': '/imgs/google-play-badge.svg', | ||
} | ||
|
||
return srcRecord[type] | ||
}, [type]) | ||
|
||
const imgAlt = useMemo(() => { | ||
const altRecord: Record<AppBadgeType, string> = { | ||
'app-store': 'App Store', | ||
'google-play': 'Google Play', | ||
} | ||
|
||
return altRecord[type] | ||
}, [type]) | ||
|
||
return link ? ( | ||
<Stack component='a' href={link} target='_blank' rel='noreferrer'> | ||
<Box | ||
component='img' | ||
src={imgSrc} | ||
alt={imgAlt} | ||
height={spacing(10)} | ||
width='auto' | ||
sx={{ objectFit: 'contain' }} | ||
/> | ||
</Stack> | ||
) : null | ||
} | ||
|
||
export default function RarimeAppBadges(props: StackProps) { | ||
return ( | ||
<Stack direction='row' spacing={6} {...props}> | ||
<AppBadge type='app-store' link={config.APP_STORE_APP_LINK} /> | ||
<AppBadge type='google-play' link={config.GOOGLE_PLAY_APP_LINK} /> | ||
</Stack> | ||
) | ||
} |
This file contains 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,53 @@ | ||
import { Dialog, DialogProps, Divider, Stack, Typography, useTheme } from '@mui/material' | ||
import { QRCode } from 'react-qrcode-logo' | ||
|
||
import { config } from '@/config' | ||
import { RoutePaths } from '@/enums' | ||
import { UiDialogContent, UiDialogTitle } from '@/ui' | ||
|
||
import RarimeAppBadges from './RarimeAppBadges' | ||
|
||
export default function RarimeAppModal(props: DialogProps) { | ||
const { palette, spacing } = useTheme() | ||
|
||
return ( | ||
<Dialog | ||
{...props} | ||
PaperProps={{ | ||
...props.PaperProps, | ||
sx: { width: spacing(110) }, | ||
}} | ||
> | ||
<UiDialogTitle onClose={props.onClose}>Rarime App</UiDialogTitle> | ||
<UiDialogContent> | ||
<Stack spacing={6}> | ||
<Stack spacing={4}> | ||
<Stack | ||
justifyContent='center' | ||
alignItems='center' | ||
width={spacing(45)} | ||
height={spacing(45)} | ||
mx='auto' | ||
borderRadius={4} | ||
border={1} | ||
borderColor={palette.divider} | ||
> | ||
<QRCode value={config.APP_HOST_URL + RoutePaths.DownloadApp} size={140} /> | ||
</Stack> | ||
<Typography | ||
variant='body3' | ||
color={palette.text.secondary} | ||
maxWidth={spacing(60)} | ||
mx='auto' | ||
textAlign='center' | ||
> | ||
Scan this code with your phone to download Rarime app | ||
</Typography> | ||
</Stack> | ||
<Divider /> | ||
<RarimeAppBadges justifyContent='center' /> | ||
</Stack> | ||
</UiDialogContent> | ||
</Dialog> | ||
) | ||
} |
This file contains 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 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 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 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,11 @@ | ||
export function isIos() { | ||
return /iPhone|iPad|iPod/i.test(navigator.userAgent) | ||
} | ||
|
||
export function isAndroid() { | ||
return /Android/i.test(navigator.userAgent) | ||
} | ||
|
||
export function isMobile() { | ||
return isIos() || isAndroid() || /webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent) | ||
} |
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './device' | ||
export * from './error-handler' | ||
export * from './event-bus' | ||
export * from './format' | ||
|
This file contains 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 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,36 @@ | ||
import { Paper, Stack, Typography, useTheme } from '@mui/material' | ||
import { useEffect } from 'react' | ||
import { Navigate } from 'react-router-dom' | ||
|
||
import { RarimeAppBadges } from '@/common' | ||
import { config } from '@/config' | ||
import { RoutePaths } from '@/enums' | ||
import { isAndroid, isIos, isMobile } from '@/helpers' | ||
|
||
export default function DownloadApp() { | ||
const { palette } = useTheme() | ||
|
||
useEffect(() => { | ||
if (isIos() && config.APP_STORE_APP_LINK) { | ||
location.replace(config.APP_STORE_APP_LINK) | ||
} | ||
if (isAndroid() && config.GOOGLE_PLAY_APP_LINK) { | ||
location.replace(config.GOOGLE_PLAY_APP_LINK) | ||
} | ||
}, []) | ||
|
||
return isMobile() ? ( | ||
<Paper component={Stack} spacing={6} sx={{ borderRadius: 2 }}> | ||
<Stack spacing={1}> | ||
<Typography variant='subtitle2'>Download Rarime App</Typography> | ||
<Typography variant='body3' color={palette.text.secondary}> | ||
Manage your identity credentials, generate Zero-Knowledge Proofs and share without | ||
exposing personal data | ||
</Typography> | ||
</Stack> | ||
<RarimeAppBadges spacing={4} /> | ||
</Paper> | ||
) : ( | ||
<Navigate to={RoutePaths.Dashboard} replace /> | ||
) | ||
} |
This file contains 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 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.