parent
91c3dbd812
commit
117926357d
|
@ -8,7 +8,10 @@ import {Button, ButtonColor, ButtonProps, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export {useDialogControl as usePromptControl} from '#/components/Dialog'
|
export {
|
||||||
|
type DialogControlProps as PromptControlProps,
|
||||||
|
useDialogControl as usePromptControl,
|
||||||
|
} from '#/components/Dialog'
|
||||||
|
|
||||||
const Context = React.createContext<{
|
const Context = React.createContext<{
|
||||||
titleId: string
|
titleId: string
|
||||||
|
@ -23,7 +26,7 @@ export function Outer({
|
||||||
control,
|
control,
|
||||||
testID,
|
testID,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogControlProps
|
||||||
testID?: string
|
testID?: string
|
||||||
}>) {
|
}>) {
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, {useCallback} from 'react'
|
import React, {useCallback} from 'react'
|
||||||
|
import {Keyboard} from 'react-native'
|
||||||
import {
|
import {
|
||||||
ImagePickerAsset,
|
ImagePickerAsset,
|
||||||
launchImageLibraryAsync,
|
launchImageLibraryAsync,
|
||||||
|
@ -10,11 +11,14 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useVideoLibraryPermission} from '#/lib/hooks/usePermissions'
|
import {useVideoLibraryPermission} from '#/lib/hooks/usePermissions'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
|
import {useModalControls} from '#/state/modals'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button} from '#/components/Button'
|
import {Button} from '#/components/Button'
|
||||||
import {VideoClip_Stroke2_Corner0_Rounded as VideoClipIcon} from '#/components/icons/VideoClip'
|
import {VideoClip_Stroke2_Corner0_Rounded as VideoClipIcon} from '#/components/icons/VideoClip'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
|
|
||||||
const VIDEO_MAX_DURATION = 90
|
const VIDEO_MAX_DURATION = 60
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onSelectVideo: (video: ImagePickerAsset) => void
|
onSelectVideo: (video: ImagePickerAsset) => void
|
||||||
|
@ -26,12 +30,18 @@ export function SelectVideoBtn({onSelectVideo, disabled, setError}: Props) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {requestVideoAccessIfNeeded} = useVideoLibraryPermission()
|
const {requestVideoAccessIfNeeded} = useVideoLibraryPermission()
|
||||||
|
const control = Prompt.usePromptControl()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
const onPressSelectVideo = useCallback(async () => {
|
const onPressSelectVideo = useCallback(async () => {
|
||||||
if (isNative && !(await requestVideoAccessIfNeeded())) {
|
if (isNative && !(await requestVideoAccessIfNeeded())) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!currentAccount?.emailConfirmed) {
|
||||||
|
Keyboard.dismiss()
|
||||||
|
control.open()
|
||||||
|
} else {
|
||||||
const response = await launchImageLibraryAsync({
|
const response = await launchImageLibraryAsync({
|
||||||
exif: false,
|
exif: false,
|
||||||
mediaTypes: MediaTypeOptions.Videos,
|
mediaTypes: MediaTypeOptions.Videos,
|
||||||
|
@ -52,7 +62,15 @@ export function SelectVideoBtn({onSelectVideo, disabled, setError}: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [onSelectVideo, requestVideoAccessIfNeeded, setError, _])
|
}
|
||||||
|
}, [
|
||||||
|
onSelectVideo,
|
||||||
|
requestVideoAccessIfNeeded,
|
||||||
|
setError,
|
||||||
|
_,
|
||||||
|
control,
|
||||||
|
currentAccount?.emailConfirmed,
|
||||||
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -71,6 +89,32 @@ export function SelectVideoBtn({onSelectVideo, disabled, setError}: Props) {
|
||||||
style={disabled && t.atoms.text_contrast_low}
|
style={disabled && t.atoms.text_contrast_low}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<VerifyEmailPrompt control={control} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function VerifyEmailPrompt({control}: {control: Prompt.PromptControlProps}) {
|
||||||
|
const {_} = useLingui()
|
||||||
|
const {openModal} = useModalControls()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Prompt.Basic
|
||||||
|
control={control}
|
||||||
|
title={_(msg`Verified email required`)}
|
||||||
|
description={_(
|
||||||
|
msg`To upload videos to Bluesky, you must first verify your email.`,
|
||||||
|
)}
|
||||||
|
confirmButtonCta={_(msg`Verify now`)}
|
||||||
|
confirmButtonColor="primary"
|
||||||
|
onConfirm={() => {
|
||||||
|
control.close(() => {
|
||||||
|
openModal({
|
||||||
|
name: 'verify-email',
|
||||||
|
showReminder: false,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue