import {memo, useCallback} from 'react' import {View} from 'react-native' import {plural} from '@lingui/core/macro' import {Trans, useLingui} from '@lingui/react/macro' import {useHaptics} from '#/lib/haptics' import {useRequireAuth} from '#/state/session' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {CloseQuote_Stroke2_Corner1_Rounded as QuoteIcon} from '#/components/icons/Quote' import { Repost_Stroke2_Corner3_Rounded as RepostIcon, RepostRepost_Stroke2_Corner2_Rounded as BumpRepostIcon, } from '#/components/icons/Repost' import {MetricCountLabel} from '#/components/PostControls/MetricCountLabel' import {Text} from '#/components/Typography' import {IS_IPAD} from '#/env' import {PostControlButton, PostControlButtonIcon} from './PostControlButton' import {RepostButtonMenu, type RepostButtonProps} from './RepostButtonMenu' let RepostButton = (props: RepostButtonProps): React.ReactNode => IS_IPAD ? ( ) : ( ) RepostButton = memo(RepostButton) export {RepostButton} function RepostButtonDialog({ isReposted, repostCount, metricsDisplay = 'visible', onRepost, onBumpRepost, onQuote, onLongPress, big, embeddingDisabled, }: RepostButtonProps): React.ReactNode { const t = useTheme() const {t: l} = useLingui() const requireAuth = useRequireAuth() const dialogControl = Dialog.useDialogControl() const onPress = () => requireAuth(() => dialogControl.open()) const onDefaultLongPress = () => requireAuth(() => { if (embeddingDisabled) { dialogControl.open() } else { onQuote() } }) return ( {typeof repostCount !== 'undefined' ? ( ) : null} ) } export const RepostButtonDialogInner = memo(function RepostButtonDialogInner({ isReposted, onRepost, onBumpRepost, onQuote, embeddingDisabled, }: { isReposted: boolean onRepost: () => void onBumpRepost?: () => void onQuote: () => void embeddingDisabled: boolean }): React.ReactNode { const t = useTheme() const {t: l} = useLingui() const haptics = useHaptics() const control = Dialog.useDialogContext() const onPressRepost = useCallback(() => { if (!isReposted) haptics.confirm() control.close(() => { onRepost() }) }, [control, isReposted, onRepost, haptics]) const onPressQuote = useCallback(() => { haptics.confirm() control.close(() => { onQuote() }) }, [control, onQuote, haptics]) const onPressClose = useCallback(() => control.close(), [control]) return ( {isReposted && onBumpRepost && ( )} ) })