Use i18next's native RTL detection

This commit is contained in:
xmflsct 2022-12-29 18:03:23 +01:00
parent 892e6c6131
commit 53ea661d9a
3 changed files with 10 additions and 19 deletions

View File

@ -90,7 +90,6 @@
"react-native-tab-view": "^3.3.4",
"react-redux": "^8.0.5",
"rn-placeholder": "^3.0.3",
"rtl-detect": "^1.0.4",
"valid-url": "^1.0.9",
"zeego": "^1.0.2"
},

View File

@ -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>

View File

@ -10232,7 +10232,7 @@ __metadata:
languageName: node
linkType: hard
"rtl-detect@npm:^1.0.2, rtl-detect@npm:^1.0.4":
"rtl-detect@npm:^1.0.2":
version: 1.0.4
resolution: "rtl-detect@npm:1.0.4"
checksum: d562535baa0db62f57f0a1d4676297bff72fd6b94e88f0f0900d5c3e810ab512c5c4cadffd3e05fbe8d9c74310c919afa3ea8c1001c244e5555e8eef12d02d6f
@ -11304,7 +11304,6 @@ __metadata:
react-native-tab-view: ^3.3.4
react-redux: ^8.0.5
rn-placeholder: ^3.0.3
rtl-detect: ^1.0.4
typescript: ^4.9.4
valid-url: ^1.0.9
zeego: ^1.0.2