mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Use i18next's native RTL detection
This commit is contained in:
@ -3,10 +3,10 @@ import CustomText from '@components/Text'
|
||||
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import i18next from 'i18next'
|
||||
import React, { useContext } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Platform, View } from 'react-native'
|
||||
import { isRtlLang } from 'rtl-detect'
|
||||
import StatusContext from './Context'
|
||||
|
||||
export interface Props {
|
||||
@ -23,6 +23,11 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||
|
||||
const { data: preferences } = usePreferencesQuery()
|
||||
|
||||
const isRTLiOSTextStyles =
|
||||
Platform.OS === 'ios' && status.language && i18next.dir(status.language) === 'rtl'
|
||||
? ({ writingDirection: 'rtl' } as { writingDirection: 'rtl' })
|
||||
: undefined
|
||||
|
||||
return (
|
||||
<View>
|
||||
{status.spoiler_text?.length ? (
|
||||
@ -37,11 +42,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||
numberOfLines={999}
|
||||
highlighted={highlighted}
|
||||
disableDetails={disableDetails}
|
||||
textStyles={
|
||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
||||
? { writingDirection: 'rtl' }
|
||||
: undefined
|
||||
}
|
||||
textStyles={isRTLiOSTextStyles}
|
||||
/>
|
||||
{inThread ? (
|
||||
<CustomText
|
||||
@ -73,11 +74,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||
setSpoilerExpanded={setSpoilerExpanded}
|
||||
highlighted={highlighted}
|
||||
disableDetails={disableDetails}
|
||||
textStyles={
|
||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
||||
? { writingDirection: 'rtl' }
|
||||
: undefined
|
||||
}
|
||||
textStyles={isRTLiOSTextStyles}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
@ -90,11 +87,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||
tags={status.tags}
|
||||
numberOfLines={highlighted || inThread ? 999 : notificationOwnToot ? 2 : undefined}
|
||||
disableDetails={disableDetails}
|
||||
textStyles={
|
||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
||||
? { writingDirection: 'rtl' }
|
||||
: undefined
|
||||
}
|
||||
textStyles={isRTLiOSTextStyles}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
Reference in New Issue
Block a user