Unfortunately iOS does not display RTL languages automatically like Android does, so some simple JS library is needed
This commit is contained in:
xmflsct 2022-12-15 00:03:09 +01:00
parent 4a35e910c1
commit c90c8ee8d4
7 changed files with 28 additions and 2 deletions

View File

@ -2,6 +2,8 @@ Enjoy toooting! This version includes following improvements and fixes:
- Automatic setting detected language when tooting
- Remember public timeline type selection
- Show diffing of edit history
- Allow hiding boosts and replies in home timeline
- Support toot in RTL languages
- Added notification for admins
- Fix whole word filter matching
- Fix tablet cannot delete toot drafts

View File

@ -2,6 +2,8 @@ toooting愉快此版本包括以下改进和修复
- 自动识别发嘟语言
- 记住上次公共时间轴选项
- 显示编辑历史的差异
- 关注列表可隐藏转嘟和回复
- 新增管理员推送通知
- 支持嘟文右到左文字
- 修复过滤整词功能
- 修复平板不能删除草稿

View File

@ -93,6 +93,7 @@
"react-redux": "^8.0.5",
"redux-persist": "^6.0.0",
"rn-placeholder": "^3.0.3",
"rtl-detect": "^1.0.4",
"valid-url": "^1.0.9",
"zeego": "^0.5.0"
},

View File

@ -3,6 +3,7 @@ declare module 'htmlparser2-without-node-native'
declare module 'react-native-feather'
declare module 'react-native-htmlview'
declare module 'react-native-toast-message'
declare module 'rtl-detect'
declare module '@helpers/features' {
const features: { feature: string; version: number; reference?: string }[]

View File

@ -13,7 +13,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
import { isEqual } from 'lodash'
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Platform, Pressable, View } from 'react-native'
import { Platform, Pressable, TextStyleIOS, View } from 'react-native'
import HTMLView from 'react-native-htmlview'
import { useSelector } from 'react-redux'
@ -154,6 +154,7 @@ const renderNode = ({
export interface Props {
content: string
size?: 'S' | 'M' | 'L'
textStyles?: TextStyleIOS
adaptiveSize?: boolean
emojis?: Mastodon.Emoji[]
mentions?: Mastodon.Mention[]
@ -171,6 +172,7 @@ const ParseHTML = React.memo(
({
content,
size = 'M',
textStyles,
adaptiveSize = false,
emojis,
mentions,
@ -294,6 +296,7 @@ const ParseHTML = React.memo(
}
}}
style={{
...textStyles,
height: numberOfLines === 1 && !expanded ? 0 : undefined
}}
numberOfLines={

View File

@ -2,7 +2,9 @@ import { ParseHTML } from '@components/Parse'
import { getInstanceAccount } from '@utils/slices/instancesSlice'
import React, { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { Platform } from 'react-native'
import { useSelector } from 'react-redux'
import { isRtlLang } from 'rtl-detect'
import StatusContext from './Context'
export interface Props {
@ -31,6 +33,11 @@ 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
}
/>
<ParseHTML
content={status.content}
@ -50,6 +57,11 @@ 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
}
/>
</>
) : (
@ -62,6 +74,11 @@ 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
}
/>
)}
</>

View File

@ -11339,7 +11339,7 @@ router-ips@^1.0.0:
resolved "https://registry.yarnpkg.com/router-ips/-/router-ips-1.0.0.tgz#44e00858ebebc0133d58e40b2cd8a1fbb04203f5"
integrity sha512-yBo6F52Un/WYioXbedBGvrKIiofbwt+4cUhdqDb9fNMJBI4D4jOy7jlxxaRVEvICPKU7xMmJDtDFR6YswX/sFQ==
rtl-detect@^1.0.2:
rtl-detect@^1.0.2, rtl-detect@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.4.tgz#40ae0ea7302a150b96bc75af7d749607392ecac6"
integrity sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ==