[APP-656] make alt text expandable (#821)

* make alt text expandable

* clean code
zio/stable
Ansh 2023-06-01 08:47:17 -07:00 committed by GitHub
parent 5c25d670d0
commit 1fc694d488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 3 deletions

View File

@ -1,10 +1,11 @@
import React, {useCallback, useEffect} from 'react'
import React, {useCallback, useEffect, useState} from 'react'
import {
Image,
TouchableOpacity,
TouchableWithoutFeedback,
StyleSheet,
View,
Pressable,
} from 'react-native'
import {observer} from 'mobx-react-lite'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
@ -61,7 +62,8 @@ function LightboxInner({
initialIndex: number
onClose: () => void
}) {
const [index, setIndex] = React.useState<number>(initialIndex)
const [index, setIndex] = useState<number>(initialIndex)
const [isAltExpanded, setAltExpanded] = useState(false)
const canGoLeft = index >= 1
const canGoRight = index < imgs.length - 1
@ -140,7 +142,20 @@ function LightboxInner({
</TouchableWithoutFeedback>
{imgs[index].alt ? (
<View style={styles.footer}>
<Text style={s.white}>{imgs[index].alt}</Text>
<Pressable
accessibilityRole="button"
accessibilityLabel="Expand alt text"
accessibilityHint="If alt text is long, toggles alt text expanded state"
onPress={() => {
setAltExpanded(!isAltExpanded)
}}>
<Text
style={s.white}
numberOfLines={isAltExpanded ? 0 : 3}
ellipsizeMode="tail">
{imgs[index].alt}
</Text>
</Pressable>
</View>
) : null}
<View style={styles.closeBtn}>