Clean up dialogs (#8934)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
import {type AppBskyActorDefs, moderateProfile} from '@atproto/api'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
@@ -27,30 +27,12 @@ export function NewskieDialog({
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
const {currentAccount} = useSession()
|
|
||||||
const timeAgo = useGetTimeAgo()
|
|
||||||
const control = useDialogControl()
|
const control = useDialogControl()
|
||||||
|
|
||||||
const isMe = profile.did === currentAccount?.did
|
|
||||||
const createdAt = profile.createdAt as string | undefined
|
const createdAt = profile.createdAt as string | undefined
|
||||||
|
|
||||||
const profileName = React.useMemo(() => {
|
const [now] = useState(() => Date.now())
|
||||||
const name = profile.displayName || profile.handle
|
const daysOld = useMemo(() => {
|
||||||
|
|
||||||
if (isMe) {
|
|
||||||
return _(msg`You`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moderationOpts) return name
|
|
||||||
const moderation = moderateProfile(profile, moderationOpts)
|
|
||||||
|
|
||||||
return sanitizeDisplayName(name, moderation.ui('displayName'))
|
|
||||||
}, [_, isMe, moderationOpts, profile])
|
|
||||||
|
|
||||||
const [now] = React.useState(() => Date.now())
|
|
||||||
const daysOld = React.useMemo(() => {
|
|
||||||
if (!createdAt) return Infinity
|
if (!createdAt) return Infinity
|
||||||
return differenceInSeconds(now, new Date(createdAt)) / 86400
|
return differenceInSeconds(now, new Date(createdAt)) / 86400
|
||||||
}, [createdAt, now])
|
}, [createdAt, now])
|
||||||
@@ -77,11 +59,48 @@ export function NewskieDialog({
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
|
<DialogInner profile={profile} createdAt={createdAt} now={now} />
|
||||||
|
</Dialog.Outer>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogInner({
|
||||||
|
profile,
|
||||||
|
createdAt,
|
||||||
|
now,
|
||||||
|
}: {
|
||||||
|
profile: AppBskyActorDefs.ProfileViewDetailed
|
||||||
|
createdAt: string
|
||||||
|
now: number
|
||||||
|
}) {
|
||||||
|
const control = Dialog.useDialogContext()
|
||||||
|
const {_} = useLingui()
|
||||||
|
const t = useTheme()
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
|
const timeAgo = useGetTimeAgo()
|
||||||
|
const isMe = profile.did === currentAccount?.did
|
||||||
|
|
||||||
|
const profileName = useMemo(() => {
|
||||||
|
const name = profile.displayName || profile.handle
|
||||||
|
|
||||||
|
if (isMe) {
|
||||||
|
return _(msg`You`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moderationOpts) return name
|
||||||
|
const moderation = moderateProfile(profile, moderationOpts)
|
||||||
|
|
||||||
|
return sanitizeDisplayName(name, moderation.ui('displayName'))
|
||||||
|
}, [_, isMe, moderationOpts, profile])
|
||||||
|
|
||||||
|
return (
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
label={_(msg`New user info dialog`)}
|
label={_(msg`New user info dialog`)}
|
||||||
style={web({width: 'auto', maxWidth: 400, minWidth: 200})}>
|
style={web({maxWidth: 400})}>
|
||||||
<View style={[a.gap_md]}>
|
<View style={[a.gap_md]}>
|
||||||
<View style={[a.align_center]}>
|
<View style={[a.align_center]}>
|
||||||
<View
|
<View
|
||||||
@@ -99,11 +118,7 @@ export function NewskieDialog({
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text style={[a.font_bold, a.text_xl]}>
|
<Text style={[a.font_bold, a.text_xl]}>
|
||||||
{isMe ? (
|
{isMe ? <Trans>Welcome, friend!</Trans> : <Trans>Say hello!</Trans>}
|
||||||
<Trans>Welcome, friend!</Trans>
|
|
||||||
) : (
|
|
||||||
<Trans>Say hello!</Trans>
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={[a.text_md, a.text_center, a.leading_snug]}>
|
<Text style={[a.text_md, a.text_center, a.leading_snug]}>
|
||||||
@@ -122,9 +137,7 @@ export function NewskieDialog({
|
|||||||
{profile.joinedViaStarterPack ? (
|
{profile.joinedViaStarterPack ? (
|
||||||
<StarterPackCard.Link
|
<StarterPackCard.Link
|
||||||
starterPack={profile.joinedViaStarterPack}
|
starterPack={profile.joinedViaStarterPack}
|
||||||
onPress={() => {
|
onPress={() => control.close()}>
|
||||||
control.close()
|
|
||||||
}}>
|
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.w_full,
|
a.w_full,
|
||||||
@@ -144,7 +157,6 @@ export function NewskieDialog({
|
|||||||
{isNative && (
|
{isNative && (
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Close`)}
|
label={_(msg`Close`)}
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
style={[a.mt_sm]}
|
style={[a.mt_sm]}
|
||||||
@@ -158,7 +170,5 @@ export function NewskieDialog({
|
|||||||
|
|
||||||
<Dialog.Close />
|
<Dialog.Close />
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
</Dialog.Outer>
|
|
||||||
</View>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {lazy} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
// @ts-expect-error missing types
|
// @ts-expect-error missing types
|
||||||
import QRCode from 'react-native-qrcode-styled'
|
import QRCode from 'react-native-qrcode-styled'
|
||||||
@@ -15,20 +15,20 @@ import {LinearGradientBackground} from '#/components/LinearGradientBackground'
|
|||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
const LazyViewShot = React.lazy(
|
const LazyViewShot = lazy(
|
||||||
// @ts-expect-error dynamic import
|
// @ts-expect-error dynamic import
|
||||||
() => import('react-native-view-shot/src/index'),
|
() => import('react-native-view-shot/src/index'),
|
||||||
)
|
)
|
||||||
|
|
||||||
interface Props {
|
export function QrCode({
|
||||||
|
starterPack,
|
||||||
|
link,
|
||||||
|
ref,
|
||||||
|
}: {
|
||||||
starterPack: AppBskyGraphDefs.StarterPackView
|
starterPack: AppBskyGraphDefs.StarterPackView
|
||||||
link: string
|
link: string
|
||||||
}
|
ref: React.Ref<ViewShot>
|
||||||
|
}) {
|
||||||
export const QrCode = React.forwardRef<ViewShot, Props>(function QrCode(
|
|
||||||
{starterPack, link},
|
|
||||||
ref,
|
|
||||||
) {
|
|
||||||
const {record} = starterPack
|
const {record} = starterPack
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -93,7 +93,7 @@ export const QrCode = React.forwardRef<ViewShot, Props>(function QrCode(
|
|||||||
</LinearGradientBackground>
|
</LinearGradientBackground>
|
||||||
</LazyViewShot>
|
</LazyViewShot>
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
|
||||||
export function QrCodeInner({link}: {link: string}) {
|
export function QrCodeInner({link}: {link: string}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {Suspense, useRef, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import type ViewShot from 'react-native-view-shot'
|
import type ViewShot from 'react-native-view-shot'
|
||||||
import {requestMediaLibraryPermissionsAsync} from 'expo-image-picker'
|
import {requestMediaLibraryPermissionsAsync} from 'expo-image-picker'
|
||||||
@@ -8,16 +8,18 @@ import {type AppBskyGraphDefs, AppBskyGraphStarterpack} from '@atproto/api'
|
|||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isNative, isWeb} from '#/platform/detection'
|
import {isNative, isWeb} from '#/platform/detection'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import {atoms as a, useBreakpoints} from '#/alf'
|
||||||
import {atoms as a} from '#/alf'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {type DialogControlProps} from '#/components/Dialog'
|
import {type DialogControlProps} from '#/components/Dialog'
|
||||||
|
import {ArrowOutOfBoxModified_Stroke2_Corner2_Rounded as ShareIcon} from '#/components/icons/ArrowOutOfBox'
|
||||||
|
import {ChainLink_Stroke2_Corner0_Rounded as ChainLinkIcon} from '#/components/icons/ChainLink'
|
||||||
|
import {FloppyDisk_Stroke2_Corner0_Rounded as FloppyDiskIcon} from '#/components/icons/FloppyDisk'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {QrCode} from '#/components/StarterPack/QrCode'
|
import {QrCode} from '#/components/StarterPack/QrCode'
|
||||||
|
import * as Toast from '#/components/Toast'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function QrCodeDialog({
|
export function QrCodeDialog({
|
||||||
@@ -30,9 +32,11 @@ export function QrCodeDialog({
|
|||||||
control: DialogControlProps
|
control: DialogControlProps
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [isProcessing, setIsProcessing] = React.useState(false)
|
const {gtMobile} = useBreakpoints()
|
||||||
|
const [isSaveProcessing, setIsSaveProcessing] = useState(false)
|
||||||
|
const [isCopyProcessing, setIsCopyProcessing] = useState(false)
|
||||||
|
|
||||||
const ref = React.useRef<ViewShot>(null)
|
const ref = useRef<ViewShot>(null)
|
||||||
|
|
||||||
const getCanvas = (base64: string): Promise<HTMLCanvasElement> => {
|
const getCanvas = (base64: string): Promise<HTMLCanvasElement> => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -68,15 +72,14 @@ export function QrCodeDialog({
|
|||||||
try {
|
try {
|
||||||
await createAssetAsync(`file://${uri}`)
|
await createAssetAsync(`file://${uri}`)
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
Toast.show(
|
Toast.show(_(msg`An error occurred while saving the QR code!`), {
|
||||||
_(msg`An error occurred while saving the QR code!`),
|
type: 'error',
|
||||||
'xmark',
|
})
|
||||||
)
|
|
||||||
logger.error('Failed to save QR code', {error: e})
|
logger.error('Failed to save QR code', {error: e})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsProcessing(true)
|
setIsSaveProcessing(true)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!bsky.validate(
|
!bsky.validate(
|
||||||
@@ -101,12 +104,12 @@ export function QrCodeDialog({
|
|||||||
link.click()
|
link.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
logEvent('starterPack:share', {
|
logger.metric('starterPack:share', {
|
||||||
starterPack: starterPack.uri,
|
starterPack: starterPack.uri,
|
||||||
shareType: 'qrcode',
|
shareType: 'qrcode',
|
||||||
qrShareType: 'save',
|
qrShareType: 'save',
|
||||||
})
|
})
|
||||||
setIsProcessing(false)
|
setIsSaveProcessing(false)
|
||||||
Toast.show(
|
Toast.show(
|
||||||
isWeb
|
isWeb
|
||||||
? _(msg`QR code has been downloaded!`)
|
? _(msg`QR code has been downloaded!`)
|
||||||
@@ -117,7 +120,7 @@ export function QrCodeDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onCopyPress = async () => {
|
const onCopyPress = async () => {
|
||||||
setIsProcessing(true)
|
setIsCopyProcessing(true)
|
||||||
ref.current?.capture?.().then(async (uri: string) => {
|
ref.current?.capture?.().then(async (uri: string) => {
|
||||||
const canvas = await getCanvas(uri)
|
const canvas = await getCanvas(uri)
|
||||||
// @ts-expect-error web only
|
// @ts-expect-error web only
|
||||||
@@ -126,13 +129,13 @@ export function QrCodeDialog({
|
|||||||
navigator.clipboard.write([item])
|
navigator.clipboard.write([item])
|
||||||
})
|
})
|
||||||
|
|
||||||
logEvent('starterPack:share', {
|
logger.metric('starterPack:share', {
|
||||||
starterPack: starterPack.uri,
|
starterPack: starterPack.uri,
|
||||||
shareType: 'qrcode',
|
shareType: 'qrcode',
|
||||||
qrShareType: 'copy',
|
qrShareType: 'copy',
|
||||||
})
|
})
|
||||||
Toast.show(_(msg`QR code copied to your clipboard!`))
|
Toast.show(_(msg`QR code copied to your clipboard!`))
|
||||||
setIsProcessing(false)
|
setIsCopyProcessing(false)
|
||||||
control.close()
|
control.close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -142,7 +145,7 @@ export function QrCodeDialog({
|
|||||||
control.close(() => {
|
control.close(() => {
|
||||||
Sharing.shareAsync(uri, {mimeType: 'image/png', UTI: 'image/png'}).then(
|
Sharing.shareAsync(uri, {mimeType: 'image/png', UTI: 'image/png'}).then(
|
||||||
() => {
|
() => {
|
||||||
logEvent('starterPack:share', {
|
logger.metric('starterPack:share', {
|
||||||
starterPack: starterPack.uri,
|
starterPack: starterPack.uri,
|
||||||
shareType: 'qrcode',
|
shareType: 'qrcode',
|
||||||
qrShareType: 'share',
|
qrShareType: 'share',
|
||||||
@@ -154,49 +157,57 @@ export function QrCodeDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
label={_(msg`Create a QR code for a starter pack`)}>
|
label={_(msg`Create a QR code for a starter pack`)}>
|
||||||
<View style={[a.flex_1, a.align_center, a.gap_5xl]}>
|
<View style={[a.flex_1, a.align_center, a.gap_5xl]}>
|
||||||
<React.Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
{!link ? (
|
{!link ? (
|
||||||
<Loading />
|
<Loading />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<QrCode starterPack={starterPack} link={link} ref={ref} />
|
<QrCode starterPack={starterPack} link={link} ref={ref} />
|
||||||
{isProcessing ? (
|
|
||||||
<View>
|
|
||||||
<Loader size="xl" />
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
<View
|
<View
|
||||||
style={[a.w_full, a.gap_md, isWeb && [a.flex_row_reverse]]}>
|
style={[
|
||||||
|
a.w_full,
|
||||||
|
a.gap_md,
|
||||||
|
gtMobile && [a.flex_row, a.justify_center, a.flex_wrap],
|
||||||
|
]}>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Copy QR code`)}
|
label={_(msg`Copy QR code`)}
|
||||||
variant="solid"
|
color="primary_subtle"
|
||||||
color="secondary"
|
size="large"
|
||||||
size="small"
|
|
||||||
onPress={isWeb ? onCopyPress : onSharePress}>
|
onPress={isWeb ? onCopyPress : onSharePress}>
|
||||||
|
<ButtonIcon
|
||||||
|
icon={
|
||||||
|
isCopyProcessing
|
||||||
|
? Loader
|
||||||
|
: isWeb
|
||||||
|
? ChainLinkIcon
|
||||||
|
: ShareIcon
|
||||||
|
}
|
||||||
|
/>
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
{isWeb ? <Trans>Copy</Trans> : <Trans>Share</Trans>}
|
{isWeb ? <Trans>Copy</Trans> : <Trans>Share</Trans>}
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Save QR code`)}
|
label={_(msg`Save QR code`)}
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="large"
|
||||||
onPress={onSavePress}>
|
onPress={onSavePress}>
|
||||||
|
<ButtonIcon
|
||||||
|
icon={isSaveProcessing ? Loader : FloppyDiskIcon}
|
||||||
|
/>
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Save</Trans>
|
<Trans>Save</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</React.Suspense>
|
</Suspense>
|
||||||
</View>
|
</View>
|
||||||
<Dialog.Close />
|
<Dialog.Close />
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
@@ -206,7 +217,7 @@ export function QrCodeDialog({
|
|||||||
|
|
||||||
function Loading() {
|
function Loading() {
|
||||||
return (
|
return (
|
||||||
<View style={[a.align_center, a.p_xl]}>
|
<View style={[a.align_center, a.justify_center, {minHeight: 400}]}>
|
||||||
<Loader size="xl" />
|
<Loader size="xl" />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,16 +4,18 @@ import {type AppBskyGraphDefs} from '@atproto/api'
|
|||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
|
||||||
import {useSaveImageToMediaLibrary} from '#/lib/media/save-image'
|
import {useSaveImageToMediaLibrary} from '#/lib/media/save-image'
|
||||||
import {shareUrl} from '#/lib/sharing'
|
import {shareUrl} from '#/lib/sharing'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
|
||||||
import {getStarterPackOgCard} from '#/lib/strings/starter-pack'
|
import {getStarterPackOgCard} from '#/lib/strings/starter-pack'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {isNative, isWeb} from '#/platform/detection'
|
import {isNative, isWeb} from '#/platform/detection'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import {type DialogControlProps} from '#/components/Dialog'
|
import {type DialogControlProps} from '#/components/Dialog'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
import {ChainLink_Stroke2_Corner0_Rounded as ChainLinkIcon} from '#/components/icons/ChainLink'
|
||||||
|
import {Download_Stroke2_Corner0_Rounded as DownloadIcon} from '#/components/icons/Download'
|
||||||
|
import {QrCode_Stroke2_Corner0_Rounded as QrCodeIcon} from '#/components/icons/QrCode'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
@@ -27,7 +29,9 @@ interface Props {
|
|||||||
|
|
||||||
export function ShareDialog(props: Props) {
|
export function ShareDialog(props: Props) {
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={props.control}>
|
<Dialog.Outer
|
||||||
|
control={props.control}
|
||||||
|
nativeOptions={{preventExpansion: true}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<ShareDialogInner {...props} />
|
<ShareDialogInner {...props} />
|
||||||
</Dialog.Outer>
|
</Dialog.Outer>
|
||||||
@@ -43,14 +47,14 @@ function ShareDialogInner({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {isTabletOrDesktop} = useWebMediaQueries()
|
const {gtMobile} = useBreakpoints()
|
||||||
|
|
||||||
const imageUrl = getStarterPackOgCard(starterPack)
|
const imageUrl = getStarterPackOgCard(starterPack)
|
||||||
|
|
||||||
const onShareLink = async () => {
|
const onShareLink = async () => {
|
||||||
if (!link) return
|
if (!link) return
|
||||||
shareUrl(link)
|
shareUrl(link)
|
||||||
logEvent('starterPack:share', {
|
logger.metric('starterPack:share', {
|
||||||
starterPack: starterPack.uri,
|
starterPack: starterPack.uri,
|
||||||
shareType: 'link',
|
shareType: 'link',
|
||||||
})
|
})
|
||||||
@@ -67,12 +71,12 @@ function ShareDialogInner({
|
|||||||
<>
|
<>
|
||||||
<Dialog.ScrollableInner label={_(msg`Share link dialog`)}>
|
<Dialog.ScrollableInner label={_(msg`Share link dialog`)}>
|
||||||
{!imageLoaded || !link ? (
|
{!imageLoaded || !link ? (
|
||||||
<View style={[a.p_xl, a.align_center]}>
|
<View style={[a.align_center, a.justify_center, {minHeight: 350}]}>
|
||||||
<Loader size="xl" />
|
<Loader size="xl" />
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
<View style={[!isTabletOrDesktop && a.gap_lg]}>
|
<View style={[!gtMobile && a.gap_lg]}>
|
||||||
<View style={[a.gap_sm, isTabletOrDesktop && a.pb_lg]}>
|
<View style={[a.gap_sm, gtMobile && a.pb_lg]}>
|
||||||
<Text style={[a.font_bold, a.text_2xl]}>
|
<Text style={[a.font_bold, a.text_2xl]}>
|
||||||
<Trans>Invite people to this starter pack!</Trans>
|
<Trans>Invite people to this starter pack!</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
@@ -89,8 +93,8 @@ function ShareDialogInner({
|
|||||||
a.rounded_sm,
|
a.rounded_sm,
|
||||||
{
|
{
|
||||||
aspectRatio: 1200 / 630,
|
aspectRatio: 1200 / 630,
|
||||||
transform: [{scale: isTabletOrDesktop ? 0.85 : 1}],
|
transform: [{scale: gtMobile ? 0.85 : 1}],
|
||||||
marginTop: isTabletOrDesktop ? -20 : 0,
|
marginTop: gtMobile ? -20 : 0,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
accessibilityIgnoresInvertColors={true}
|
accessibilityIgnoresInvertColors={true}
|
||||||
@@ -98,30 +102,33 @@ function ShareDialogInner({
|
|||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.gap_md,
|
a.gap_md,
|
||||||
isWeb && [a.gap_sm, a.flex_row_reverse, {marginLeft: 'auto'}],
|
gtMobile && [
|
||||||
|
a.gap_sm,
|
||||||
|
a.justify_center,
|
||||||
|
a.flex_row,
|
||||||
|
a.flex_wrap,
|
||||||
|
],
|
||||||
]}>
|
]}>
|
||||||
<Button
|
<Button
|
||||||
label={isWeb ? _(msg`Copy link`) : _(msg`Share link`)}
|
label={isWeb ? _(msg`Copy link`) : _(msg`Share link`)}
|
||||||
variant="solid"
|
color="primary_subtle"
|
||||||
color="secondary"
|
size="large"
|
||||||
size="small"
|
|
||||||
style={[isWeb && a.self_center]}
|
|
||||||
onPress={onShareLink}>
|
onPress={onShareLink}>
|
||||||
|
<ButtonIcon icon={ChainLinkIcon} />
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
{isWeb ? <Trans>Copy Link</Trans> : <Trans>Share link</Trans>}
|
{isWeb ? <Trans>Copy Link</Trans> : <Trans>Share link</Trans>}
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Share QR code`)}
|
label={_(msg`Share QR code`)}
|
||||||
variant="solid"
|
color="primary_subtle"
|
||||||
color="secondary"
|
size="large"
|
||||||
size="small"
|
|
||||||
style={[isWeb && a.self_center]}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
control.close(() => {
|
control.close(() => {
|
||||||
qrDialogControl.open()
|
qrDialogControl.open()
|
||||||
})
|
})
|
||||||
}}>
|
}}>
|
||||||
|
<ButtonIcon icon={QrCodeIcon} />
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Share QR code</Trans>
|
<Trans>Share QR code</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
@@ -129,11 +136,10 @@ function ShareDialogInner({
|
|||||||
{isNative && (
|
{isNative && (
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Save image`)}
|
label={_(msg`Save image`)}
|
||||||
variant="ghost"
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="small"
|
size="large"
|
||||||
style={[isWeb && a.self_center]}
|
|
||||||
onPress={onSave}>
|
onPress={onSave}>
|
||||||
|
<ButtonIcon icon={DownloadIcon} />
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Save image</Trans>
|
<Trans>Save image</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import {
|
|||||||
} from '#/lib/strings/embed-player'
|
} from '#/lib/strings/embed-player'
|
||||||
import {useSetExternalEmbedPref} from '#/state/preferences'
|
import {useSetExternalEmbedPref} from '#/state/preferences'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Button, ButtonText} from '../Button'
|
import {Text} from '#/components/Typography'
|
||||||
import {Text} from '../Typography'
|
|
||||||
|
|
||||||
export function EmbedConsentDialog({
|
export function EmbedConsentDialog({
|
||||||
control,
|
control,
|
||||||
@@ -48,7 +48,7 @@ export function EmbedConsentDialog({
|
|||||||
}, [control, setExternalEmbedPref, source])
|
}, [control, setExternalEmbedPref, source])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
label={_(msg`External Media`)}
|
label={_(msg`External Media`)}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import {useCallback, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
@@ -18,14 +18,14 @@ import {Text} from '#/components/Typography'
|
|||||||
export function ExportCarDialog({
|
export function ExportCarDialog({
|
||||||
control,
|
control,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogControlProps
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const [loading, setLoading] = React.useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const download = React.useCallback(async () => {
|
const download = useCallback(async () => {
|
||||||
if (!agent.session) {
|
if (!agent.session) {
|
||||||
return // shouldnt ever happen
|
return // shouldnt ever happen
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ export function ExportCarDialog({
|
|||||||
}, [_, control, agent])
|
}, [_, control, agent])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
accessibilityDescribedBy="dialog-description"
|
accessibilityDescribedBy="dialog-description"
|
||||||
@@ -63,7 +63,7 @@ export function ExportCarDialog({
|
|||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
nativeID="dialog-description"
|
nativeID="dialog-description"
|
||||||
style={[a.text_sm, a.leading_normal, t.atoms.text_contrast_high]}>
|
style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_high]}>
|
||||||
<Trans>
|
<Trans>
|
||||||
Your account repository, containing all public data records, can
|
Your account repository, containing all public data records, can
|
||||||
be downloaded as a "CAR" file. This file does not include media
|
be downloaded as a "CAR" file. This file does not include media
|
||||||
@@ -73,7 +73,6 @@ export function ExportCarDialog({
|
|||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="solid"
|
|
||||||
color="primary"
|
color="primary"
|
||||||
size="large"
|
size="large"
|
||||||
label={_(msg`Download CAR file`)}
|
label={_(msg`Download CAR file`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user