Alt text for gifs (#3876)
* add alt text dialog * multiline alt text input * add pressable alt text badge * rename `ALT: ` to `Alt text: ` to avoid including old bad ones * reuse alt text reminder * reuse alt text reminder in gallery * add alt text reminder in the dialog itself * autofocus text input * reorder components to fix tab order * fix close btn position
This commit is contained in:
parent
ae7626ce6e
commit
c33c3b7d1e
9 changed files with 344 additions and 47 deletions
|
@ -59,6 +59,7 @@ import * as Toast from '../util/Toast'
|
|||
import {UserAvatar} from '../util/UserAvatar'
|
||||
import {CharProgress} from './char-progress/CharProgress'
|
||||
import {ExternalEmbed} from './ExternalEmbed'
|
||||
import {GifAltText} from './GifAltText'
|
||||
import {LabelsBtn} from './labels/LabelsBtn'
|
||||
import {Gallery} from './photos/Gallery'
|
||||
import {OpenCameraBtn} from './photos/OpenCameraBtn'
|
||||
|
@ -327,7 +328,7 @@ export const ComposePost = observer(function ComposePost({
|
|||
image: gif.media_formats.preview.url,
|
||||
likelyType: LikelyType.HTML,
|
||||
title: gif.content_description,
|
||||
description: `ALT: ${gif.content_description}`,
|
||||
description: '',
|
||||
},
|
||||
})
|
||||
setExtGif(gif)
|
||||
|
@ -335,6 +336,26 @@ export const ComposePost = observer(function ComposePost({
|
|||
[setExtLink],
|
||||
)
|
||||
|
||||
const handleChangeGifAltText = useCallback(
|
||||
(altText: string) => {
|
||||
setExtLink(ext =>
|
||||
ext && ext.meta
|
||||
? {
|
||||
...ext,
|
||||
meta: {
|
||||
...ext?.meta,
|
||||
description:
|
||||
altText.trim().length === 0
|
||||
? ''
|
||||
: `Alt text: ${altText.trim()}`,
|
||||
},
|
||||
}
|
||||
: ext,
|
||||
)
|
||||
},
|
||||
[setExtLink],
|
||||
)
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView
|
||||
testID="composePostView"
|
||||
|
@ -474,14 +495,21 @@ export const ComposePost = observer(function ComposePost({
|
|||
|
||||
<Gallery gallery={gallery} />
|
||||
{gallery.isEmpty && extLink && (
|
||||
<ExternalEmbed
|
||||
link={extLink}
|
||||
gif={extGif}
|
||||
onRemove={() => {
|
||||
setExtLink(undefined)
|
||||
setExtGif(undefined)
|
||||
}}
|
||||
/>
|
||||
<View style={a.relative}>
|
||||
<ExternalEmbed
|
||||
link={extLink}
|
||||
gif={extGif}
|
||||
onRemove={() => {
|
||||
setExtLink(undefined)
|
||||
setExtGif(undefined)
|
||||
}}
|
||||
/>
|
||||
<GifAltText
|
||||
link={extLink}
|
||||
gif={extGif}
|
||||
onSubmit={handleChangeGifAltText}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
{quote ? (
|
||||
<View style={[s.mt5, isWeb && s.mb10]}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue