use prompt component
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import {Modal, Pressable, View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {atoms as a, useTheme, web} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Robot_Filled_Corner2_Rounded as RobotIcon} from '#/components/icons/Robot'
|
import {Robot_Filled_Corner2_Rounded as RobotIcon} from '#/components/icons/Robot'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {navigate} from '#/Navigation'
|
import {navigate} from '#/Navigation'
|
||||||
|
|
||||||
@@ -24,88 +25,6 @@ export function BotAccountInfoDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function BotAccountOwnAlert({
|
export function BotAccountOwnAlert({
|
||||||
visible,
|
|
||||||
onClose,
|
|
||||||
}: {
|
|
||||||
visible: boolean
|
|
||||||
onClose: (cb?: () => void) => void
|
|
||||||
}) {
|
|
||||||
const {_} = useLingui()
|
|
||||||
const t = useTheme()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
visible={visible}
|
|
||||||
transparent
|
|
||||||
animationType="fade"
|
|
||||||
onRequestClose={() => onClose()}
|
|
||||||
accessibilityLabel={_(msg`Automated account`)}
|
|
||||||
accessibilityViewIsModal>
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel={_(msg`Close`)}
|
|
||||||
onPress={() => onClose()}
|
|
||||||
style={[
|
|
||||||
a.flex_1,
|
|
||||||
a.justify_center,
|
|
||||||
a.align_center,
|
|
||||||
a.px_xl,
|
|
||||||
{backgroundColor: 'rgba(0,0,0,0.5)'},
|
|
||||||
]}>
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
onPress={e => e.stopPropagation()}
|
|
||||||
style={[
|
|
||||||
t.atoms.bg,
|
|
||||||
a.w_full,
|
|
||||||
{borderRadius: 48},
|
|
||||||
a.p_2xl,
|
|
||||||
{maxWidth: 280},
|
|
||||||
]}>
|
|
||||||
<View style={[a.align_center, a.gap_md]}>
|
|
||||||
<View style={[t.atoms.shadow_sm]}>
|
|
||||||
<RobotIcon width={48} fill={t.atoms.text_contrast_medium.color} />
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Text style={[a.text_md, a.text_center, a.py_sm]}>
|
|
||||||
<Trans>
|
|
||||||
You have marked this account as automated. You can remove it at
|
|
||||||
any time from your account settings.
|
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
label={_(msg`Okay`)}
|
|
||||||
onPress={() => onClose()}
|
|
||||||
color="primary"
|
|
||||||
size="large"
|
|
||||||
style={[a.w_full]}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Okay</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
label={_(msg`Open settings`)}
|
|
||||||
onPress={() => {
|
|
||||||
onClose(() => {
|
|
||||||
navigate('AutomationLabelSettings')
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
color="secondary"
|
|
||||||
size="large"
|
|
||||||
style={[a.w_full]}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Open settings</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
</Button>
|
|
||||||
</View>
|
|
||||||
</Pressable>
|
|
||||||
</Pressable>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function BotAccountOwnAlertWeb({
|
|
||||||
control,
|
control,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
@@ -114,49 +33,35 @@ export function BotAccountOwnAlertWeb({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control} webOptions={{alignCenter: true}}>
|
<Prompt.Outer control={control} type="alert">
|
||||||
<Dialog.ScrollableInner
|
<Prompt.Content>
|
||||||
label={_(msg`Automated account`)}
|
<View style={[a.align_center, a.pb_sm]}>
|
||||||
style={web([{maxWidth: 320, borderRadius: 36}])}>
|
<RobotIcon width={48} fill={t.atoms.text_contrast_medium.color} />
|
||||||
<View style={[a.align_center, a.gap_2xl, a.py_md]}>
|
|
||||||
<View style={[t.atoms.shadow_sm]}>
|
|
||||||
<RobotIcon width={48} fill={t.atoms.text_contrast_medium.color} />
|
|
||||||
</View>
|
|
||||||
<Text style={[a.text_md, a.text_center]}>
|
|
||||||
<Trans>
|
|
||||||
You have marked this account as automated. You can remove it at
|
|
||||||
any time from your account settings.
|
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
<Button
|
|
||||||
label={_(msg`Okay`)}
|
|
||||||
onPress={() => control.close()}
|
|
||||||
color="primary"
|
|
||||||
size="large"
|
|
||||||
style={[a.w_full]}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Okay</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
label={_(msg`Open settings`)}
|
|
||||||
onPress={() => {
|
|
||||||
control.close(() => {
|
|
||||||
navigate('AutomationLabelSettings')
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
color="secondary"
|
|
||||||
size="large"
|
|
||||||
variant="ghost"
|
|
||||||
style={[a.w_full]}>
|
|
||||||
<ButtonText>
|
|
||||||
<Trans>Open settings</Trans>
|
|
||||||
</ButtonText>
|
|
||||||
</Button>
|
|
||||||
</View>
|
</View>
|
||||||
<Dialog.Close />
|
<Prompt.DescriptionText>
|
||||||
</Dialog.ScrollableInner>
|
<Trans>
|
||||||
</Dialog.Outer>
|
You have marked this account as automated. You can remove it at any
|
||||||
|
time from your account settings.
|
||||||
|
</Trans>
|
||||||
|
</Prompt.DescriptionText>
|
||||||
|
</Prompt.Content>
|
||||||
|
<Prompt.Actions>
|
||||||
|
<Prompt.Action cta={_(msg`Okay`)} onPress={() => {}} color="primary" />
|
||||||
|
<Button
|
||||||
|
label={_(msg`Open settings`)}
|
||||||
|
onPress={() => {
|
||||||
|
control.close(() => {
|
||||||
|
navigate('AutomationLabelSettings')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
color="secondary"
|
||||||
|
size="large">
|
||||||
|
<ButtonText>
|
||||||
|
<Trans>Open settings</Trans>
|
||||||
|
</ButtonText>
|
||||||
|
</Button>
|
||||||
|
</Prompt.Actions>
|
||||||
|
</Prompt.Outer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
import {useState} from 'react'
|
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {type ComAtprotoLabelDefs} from '@atproto/api'
|
import {type ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
import {msg} from '@lingui/core/macro'
|
import {msg} from '@lingui/core/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useAnalytics} from '#/analytics'
|
|
||||||
import {IS_NATIVE} from '#/env'
|
|
||||||
import {isBotAccount} from '#/lib/bots'
|
import {isBotAccount} from '#/lib/bots'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {
|
import {
|
||||||
BotAccountInfoDialog,
|
BotAccountInfoDialog,
|
||||||
BotAccountOwnAlert,
|
BotAccountOwnAlert,
|
||||||
BotAccountOwnAlertWeb,
|
|
||||||
} from '#/components/BotAccountInfoDialog'
|
} from '#/components/BotAccountInfoDialog'
|
||||||
import {Button} from '#/components/Button'
|
import {Button} from '#/components/Button'
|
||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {Robot_Filled_Corner2_Rounded as RobotIcon} from '#/components/icons/Robot'
|
import {Robot_Filled_Corner2_Rounded as RobotIcon} from '#/components/icons/Robot'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
|
|
||||||
export function BotBadge({
|
export function BotBadge({
|
||||||
profile,
|
profile,
|
||||||
@@ -53,7 +50,6 @@ export function BotBadgeButton({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {gtPhone} = useBreakpoints()
|
const {gtPhone} = useBreakpoints()
|
||||||
const control = useDialogControl()
|
const control = useDialogControl()
|
||||||
const [alertVisible, setAlertVisible] = useState(false)
|
|
||||||
|
|
||||||
if (!isBotAccount(profile)) {
|
if (!isBotAccount(profile)) {
|
||||||
return null
|
return null
|
||||||
@@ -66,8 +62,6 @@ export function BotBadgeButton({
|
|||||||
dimensions = 14
|
dimensions = 14
|
||||||
}
|
}
|
||||||
|
|
||||||
const useNativeAlert = isMe && IS_NATIVE
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
@@ -76,11 +70,7 @@ export function BotBadgeButton({
|
|||||||
onPress={evt => {
|
onPress={evt => {
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
ax.metric('bot:badge:click', {})
|
ax.metric('bot:badge:click', {})
|
||||||
if (useNativeAlert) {
|
control.open()
|
||||||
setAlertVisible(true)
|
|
||||||
} else {
|
|
||||||
control.open()
|
|
||||||
}
|
|
||||||
}}>
|
}}>
|
||||||
{({hovered}) => (
|
{({hovered}) => (
|
||||||
<View
|
<View
|
||||||
@@ -101,16 +91,8 @@ export function BotBadgeButton({
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
{useNativeAlert ? (
|
{isMe ? (
|
||||||
<BotAccountOwnAlert
|
<BotAccountOwnAlert control={control} />
|
||||||
visible={alertVisible}
|
|
||||||
onClose={cb => {
|
|
||||||
setAlertVisible(false)
|
|
||||||
cb?.()
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : isMe ? (
|
|
||||||
<BotAccountOwnAlertWeb control={control} />
|
|
||||||
) : (
|
) : (
|
||||||
<BotAccountInfoDialog control={control} />
|
<BotAccountInfoDialog control={control} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user