import {useCallback} from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useOpenLink} from '#/lib/hooks/useOpenLink'
import {isWeb} from '#/platform/detection'
import {useSetInAppBrowser} from '#/state/preferences/in-app-browser'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {SquareArrowTopRight_Stroke2_Corner0_Rounded as External} from '#/components/icons/SquareArrowTopRight'
import {Text} from '#/components/Typography'
import {useGlobalDialogsControlContext} from './Context'
export function InAppBrowserConsentDialog() {
const {inAppBrowserConsentControl} = useGlobalDialogsControlContext()
if (isWeb) return null
return (
)
}
function InAppBrowserConsentInner({href}: {href?: string}) {
const control = Dialog.useDialogContext()
const {_} = useLingui()
const t = useTheme()
const setInAppBrowser = useSetInAppBrowser()
const openLink = useOpenLink()
const onUseIAB = useCallback(() => {
control.close(() => {
setInAppBrowser(true)
if (href) {
openLink(href, true)
}
})
}, [control, setInAppBrowser, href, openLink])
const onUseLinking = useCallback(() => {
control.close(() => {
setInAppBrowser(false)
if (href) {
openLink(href, false)
}
})
}, [control, setInAppBrowser, href, openLink])
const onCancel = useCallback(() => {
control.close()
}, [control])
return (
How should we open this link?
Your choice will be remembered for future links. You can change it
at any time in settings.
)
}