mirror of https://github.com/tooot-app/app
Use i18next's native RTL detection
This commit is contained in:
parent
892e6c6131
commit
53ea661d9a
|
@ -90,7 +90,6 @@
|
||||||
"react-native-tab-view": "^3.3.4",
|
"react-native-tab-view": "^3.3.4",
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"rn-placeholder": "^3.0.3",
|
"rn-placeholder": "^3.0.3",
|
||||||
"rtl-detect": "^1.0.4",
|
|
||||||
"valid-url": "^1.0.9",
|
"valid-url": "^1.0.9",
|
||||||
"zeego": "^1.0.2"
|
"zeego": "^1.0.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,10 +3,10 @@ import CustomText from '@components/Text'
|
||||||
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
||||||
import { StyleConstants } from '@utils/styles/constants'
|
import { StyleConstants } from '@utils/styles/constants'
|
||||||
import { useTheme } from '@utils/styles/ThemeManager'
|
import { useTheme } from '@utils/styles/ThemeManager'
|
||||||
|
import i18next from 'i18next'
|
||||||
import React, { useContext } from 'react'
|
import React, { useContext } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Platform, View } from 'react-native'
|
import { Platform, View } from 'react-native'
|
||||||
import { isRtlLang } from 'rtl-detect'
|
|
||||||
import StatusContext from './Context'
|
import StatusContext from './Context'
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
@ -23,6 +23,11 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||||
|
|
||||||
const { data: preferences } = usePreferencesQuery()
|
const { data: preferences } = usePreferencesQuery()
|
||||||
|
|
||||||
|
const isRTLiOSTextStyles =
|
||||||
|
Platform.OS === 'ios' && status.language && i18next.dir(status.language) === 'rtl'
|
||||||
|
? ({ writingDirection: 'rtl' } as { writingDirection: 'rtl' })
|
||||||
|
: undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
{status.spoiler_text?.length ? (
|
{status.spoiler_text?.length ? (
|
||||||
|
@ -37,11 +42,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||||
numberOfLines={999}
|
numberOfLines={999}
|
||||||
highlighted={highlighted}
|
highlighted={highlighted}
|
||||||
disableDetails={disableDetails}
|
disableDetails={disableDetails}
|
||||||
textStyles={
|
textStyles={isRTLiOSTextStyles}
|
||||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
|
||||||
? { writingDirection: 'rtl' }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
{inThread ? (
|
{inThread ? (
|
||||||
<CustomText
|
<CustomText
|
||||||
|
@ -73,11 +74,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||||
setSpoilerExpanded={setSpoilerExpanded}
|
setSpoilerExpanded={setSpoilerExpanded}
|
||||||
highlighted={highlighted}
|
highlighted={highlighted}
|
||||||
disableDetails={disableDetails}
|
disableDetails={disableDetails}
|
||||||
textStyles={
|
textStyles={isRTLiOSTextStyles}
|
||||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
|
||||||
? { writingDirection: 'rtl' }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
@ -90,11 +87,7 @@ const TimelineContent: React.FC<Props> = ({ notificationOwnToot = false, setSpoi
|
||||||
tags={status.tags}
|
tags={status.tags}
|
||||||
numberOfLines={highlighted || inThread ? 999 : notificationOwnToot ? 2 : undefined}
|
numberOfLines={highlighted || inThread ? 999 : notificationOwnToot ? 2 : undefined}
|
||||||
disableDetails={disableDetails}
|
disableDetails={disableDetails}
|
||||||
textStyles={
|
textStyles={isRTLiOSTextStyles}
|
||||||
Platform.OS === 'ios' && status.language && isRtlLang(status.language)
|
|
||||||
? { writingDirection: 'rtl' }
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -10232,7 +10232,7 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"rtl-detect@npm:^1.0.2, rtl-detect@npm:^1.0.4":
|
"rtl-detect@npm:^1.0.2":
|
||||||
version: 1.0.4
|
version: 1.0.4
|
||||||
resolution: "rtl-detect@npm:1.0.4"
|
resolution: "rtl-detect@npm:1.0.4"
|
||||||
checksum: d562535baa0db62f57f0a1d4676297bff72fd6b94e88f0f0900d5c3e810ab512c5c4cadffd3e05fbe8d9c74310c919afa3ea8c1001c244e5555e8eef12d02d6f
|
checksum: d562535baa0db62f57f0a1d4676297bff72fd6b94e88f0f0900d5c3e810ab512c5c4cadffd3e05fbe8d9c74310c919afa3ea8c1001c244e5555e8eef12d02d6f
|
||||||
|
@ -11304,7 +11304,6 @@ __metadata:
|
||||||
react-native-tab-view: ^3.3.4
|
react-native-tab-view: ^3.3.4
|
||||||
react-redux: ^8.0.5
|
react-redux: ^8.0.5
|
||||||
rn-placeholder: ^3.0.3
|
rn-placeholder: ^3.0.3
|
||||||
rtl-detect: ^1.0.4
|
|
||||||
typescript: ^4.9.4
|
typescript: ^4.9.4
|
||||||
valid-url: ^1.0.9
|
valid-url: ^1.0.9
|
||||||
zeego: ^1.0.2
|
zeego: ^1.0.2
|
||||||
|
|
Loading…
Reference in New Issue