parent
5c25d670d0
commit
1fc694d488
|
@ -1,10 +1,11 @@
|
||||||
import React, {useCallback, useEffect} from 'react'
|
import React, {useCallback, useEffect, useState} from 'react'
|
||||||
import {
|
import {
|
||||||
Image,
|
Image,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
TouchableWithoutFeedback,
|
TouchableWithoutFeedback,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
View,
|
View,
|
||||||
|
Pressable,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {observer} from 'mobx-react-lite'
|
import {observer} from 'mobx-react-lite'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
|
@ -61,7 +62,8 @@ function LightboxInner({
|
||||||
initialIndex: number
|
initialIndex: number
|
||||||
onClose: () => void
|
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 canGoLeft = index >= 1
|
||||||
const canGoRight = index < imgs.length - 1
|
const canGoRight = index < imgs.length - 1
|
||||||
|
@ -140,7 +142,20 @@ function LightboxInner({
|
||||||
</TouchableWithoutFeedback>
|
</TouchableWithoutFeedback>
|
||||||
{imgs[index].alt ? (
|
{imgs[index].alt ? (
|
||||||
<View style={styles.footer}>
|
<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>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
<View style={styles.closeBtn}>
|
<View style={styles.closeBtn}>
|
||||||
|
|
Loading…
Reference in New Issue