Skip to content

Commit

Permalink
Fix #672
Browse files Browse the repository at this point in the history
Removed image focus as different clients implement this differently
  • Loading branch information
xmflsct committed Jan 23, 2023
1 parent 613cf13 commit 47d5b02
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 410 deletions.
3 changes: 1 addition & 2 deletions src/i18n/en/screens/compose.json
Expand Up @@ -153,8 +153,7 @@
"altText": {
"heading": "Describe media for the visually impaired",
"placeholder": "You can add a description, sometimes called alt-text, to your media so they are accessible to even more people, including those who are blind or visually impaired.\n\nGood descriptions are concise, but present what is in your media accurately enough to understand their context."
},
"imageFocus": "Drag the focus circle to update focus point"
}
}
},
"draftsList": {
Expand Down
70 changes: 64 additions & 6 deletions src/screens/Compose/EditAttachment.tsx
@@ -1,12 +1,14 @@
import haptics from '@components/haptics'
import { HeaderLeft, HeaderRight } from '@components/Header'
import CustomText from '@components/Text'
import apiInstance from '@utils/api/instance'
import { ScreenComposeStackScreenProps } from '@utils/navigation/navigators'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React, { useContext, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, KeyboardAvoidingView, Platform } from 'react-native'
import { Alert, KeyboardAvoidingView, Platform, ScrollView, TextInput } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
import ComposeEditAttachmentRoot from './EditAttachment/Root'
import ComposeContext from './utils/createContext'

const ComposeEditAttachment: React.FC<
Expand All @@ -17,12 +19,17 @@ const ComposeEditAttachment: React.FC<
params: { index }
}
}) => {
const { colors } = useTheme()
const { t } = useTranslation('screenCompose')

const { composeState } = useContext(ComposeContext)
const { composeState, composeDispatch } = useContext(ComposeContext)
const [isSubmitting, setIsSubmitting] = useState(false)

const theAttachment = composeState.attachments.uploads[index].remote!
const theAttachment = composeState.attachments.uploads[index].remote
if (!theAttachment) {
navigation.goBack()
return null
}

useEffect(() => {
navigation.setOptions({
Expand All @@ -37,6 +44,12 @@ const ComposeEditAttachment: React.FC<
content='Save'
loading={isSubmitting}
onPress={() => {
if (composeState.type === 'edit') {
composeDispatch({ type: 'attachment/edit', payload: { ...theAttachment } })
navigation.goBack()
return
}

setIsSubmitting(true)
const formData = new FormData()
if (theAttachment.description) {
Expand Down Expand Up @@ -80,8 +93,53 @@ const ComposeEditAttachment: React.FC<
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
style={{ flex: 1 }}
>
<SafeAreaView style={{ flex: 1 }} edges={['left', 'right', 'bottom']}>
<ComposeEditAttachmentRoot index={index} />
<SafeAreaView
style={{ flex: 1, padding: StyleConstants.Spacing.Global.PagePadding }}
edges={['left', 'right', 'bottom']}
>
<ScrollView>
<CustomText fontStyle='M' style={{ color: colors.primaryDefault }} fontWeight='Bold'>
{t('content.editAttachment.content.altText.heading')}
</CustomText>
<TextInput
style={{
height:
StyleConstants.Font.Size.M * 11 + StyleConstants.Spacing.Global.PagePadding * 2,
...StyleConstants.FontStyle.M,
marginTop: StyleConstants.Spacing.M,
marginBottom: StyleConstants.Spacing.S,
padding: StyleConstants.Spacing.Global.PagePadding,
borderWidth: 1,
borderColor: colors.border,
color: colors.primaryDefault
}}
maxLength={1500}
multiline
onChangeText={e =>
composeDispatch({
type: 'attachment/edit',
payload: {
...theAttachment,
description: e
}
})
}
placeholder={t('content.editAttachment.content.altText.placeholder')}
placeholderTextColor={colors.secondary}
value={theAttachment.description}
/>
<CustomText
fontStyle='S'
style={{
textAlign: 'right',
marginRight: StyleConstants.Spacing.S,
marginBottom: StyleConstants.Spacing.M,
color: colors.secondary
}}
>
{theAttachment.description?.length || 0} / 1500
</CustomText>
</ScrollView>
</SafeAreaView>
</KeyboardAvoidingView>
)
Expand Down
173 changes: 0 additions & 173 deletions src/screens/Compose/EditAttachment/Image.tsx

This file was deleted.

100 changes: 0 additions & 100 deletions src/screens/Compose/EditAttachment/Root.tsx

This file was deleted.

0 comments on commit 47d5b02

Please sign in to comment.