Fix Android expand

This commit is contained in:
Zhiyuan Zheng 2021-01-27 00:42:56 +01:00
parent 41bfeed56f
commit 6c6d563aae
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
1 changed files with 12 additions and 6 deletions

View File

@ -10,7 +10,7 @@ import { useTheme } from '@utils/styles/ThemeManager'
import { LinearGradient } from 'expo-linear-gradient'
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Pressable, Text, View } from 'react-native'
import { Platform, Pressable, Text, View } from 'react-native'
import HTMLView from 'react-native-htmlview'
// Prevent going to the same hashtag multiple times
@ -214,11 +214,17 @@ const ParseHTML: React.FC<Props> = ({
const [expanded, setExpanded] = useState(false)
const onTextLayout = useCallback(({ nativeEvent }) => {
if (
nativeEvent.lines &&
nativeEvent.lines.length === numberOfLines + 1
) {
setExpandAllow(true)
switch (Platform.OS) {
case 'ios':
if (nativeEvent.lines.length === numberOfLines + 1) {
setExpandAllow(true)
}
break
case 'android':
if (nativeEvent.lines.length > numberOfLines + 1) {
setExpandAllow(true)
}
break
}
}, [])