import {Text, View} from 'react-native' import {Trans, useLingui} from '@lingui/react/macro' import {atoms as a, ios, platform, useTheme} from '#/alf' import {useAnalytics} from '#/analytics' import {type app} from '#/lexicons' /** * How far the inline badge is nudged below the text baseline. Android's * containing `RichText` reserves matching room via `suffixOffset`. */ export const POST_NUMBER_INLINE_OFFSET = 6 export function useHasThreadItemPostNumber( value: app.bsky.unspecced.defs.ThreadItemPost, ) { const ax = useAnalytics() const index = value.opThreadPostIndex const count = value.opThreadPostCount return ( ax.features.enabled(ax.features.CanonicalPostNumberingEnable) && index !== undefined && count !== undefined && index >= 1 && count >= 1 && index <= count ) } export function ThreadItemPostNumber({ value, inline = true, }: { value: app.bsky.unspecced.defs.ThreadItemPost inline?: boolean }) { const t = useTheme() const {t: l} = useLingui() const shouldRender = useHasThreadItemPostNumber(value) const index = value.opThreadPostIndex const count = value.opThreadPostCount if (!shouldRender) { return null } return ( {index}/{count} ) }