mirror of
https://github.com/tooot-app/app
synced 2025-01-03 13:10:23 +01:00
Spoiler now supports emoji as well
This commit is contained in:
parent
2df23a8a2e
commit
b44370d3ec
@ -362,8 +362,20 @@ const ScreenCompose: React.FC<RootStackScreenProps<'Screen-Compose'>> = ({
|
||||
composeState.text.selection,
|
||||
selection => composeDispatch({ type: 'text', payload: { selection } })
|
||||
],
|
||||
isFocused: useRef<boolean>(composeState.textInputFocus.current === 'text'),
|
||||
maxLength: maxTootChars
|
||||
isFocused: composeState.textInputFocus.isFocused.text,
|
||||
maxLength: maxTootChars - (composeState.spoiler.active ? composeState.spoiler.count : 0)
|
||||
},
|
||||
{
|
||||
value: [
|
||||
composeState.spoiler.raw,
|
||||
content => formatText({ textInput: 'spoiler', composeDispatch, content })
|
||||
],
|
||||
selection: [
|
||||
composeState.spoiler.selection,
|
||||
selection => composeDispatch({ type: 'spoiler', payload: { selection } })
|
||||
],
|
||||
isFocused: composeState.textInputFocus.isFocused.spoiler,
|
||||
maxLength: maxTootChars - composeState.text.count
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -16,14 +16,8 @@ const ComposeSpoilerInput: React.FC = () => {
|
||||
const { colors, mode } = useTheme()
|
||||
|
||||
const adaptiveFontsize = useSelector(getSettingsFontsize)
|
||||
const adaptedFontsize = adaptiveScale(
|
||||
StyleConstants.Font.Size.M,
|
||||
adaptiveFontsize
|
||||
)
|
||||
const adaptedLineheight = adaptiveScale(
|
||||
StyleConstants.Font.LineHeight.M,
|
||||
adaptiveFontsize
|
||||
)
|
||||
const adaptedFontsize = adaptiveScale(StyleConstants.Font.Size.M, adaptiveFontsize)
|
||||
const adaptedLineheight = adaptiveScale(StyleConstants.Font.LineHeight.M, adaptiveFontsize)
|
||||
|
||||
return (
|
||||
<TextInput
|
||||
@ -65,12 +59,16 @@ const ComposeSpoilerInput: React.FC = () => {
|
||||
})
|
||||
}}
|
||||
scrollEnabled={false}
|
||||
onFocus={() =>
|
||||
onFocus={() => {
|
||||
composeDispatch({
|
||||
type: 'textInputFocus',
|
||||
payload: { current: 'spoiler' }
|
||||
})
|
||||
}
|
||||
composeState.textInputFocus.isFocused.spoiler.current = true
|
||||
}}
|
||||
onBlur={() => {
|
||||
composeState.textInputFocus.isFocused.spoiler.current = false
|
||||
}}
|
||||
>
|
||||
<CustomText>{composeState.spoiler.formatted}</CustomText>
|
||||
</TextInput>
|
||||
|
@ -18,20 +18,11 @@ const ComposeTextInput: React.FC = () => {
|
||||
const { t } = useTranslation('screenCompose')
|
||||
const { colors, mode } = useTheme()
|
||||
|
||||
const maxAttachments = useSelector(
|
||||
getInstanceConfigurationStatusMaxAttachments,
|
||||
() => true
|
||||
)
|
||||
const maxAttachments = useSelector(getInstanceConfigurationStatusMaxAttachments, () => true)
|
||||
|
||||
const adaptiveFontsize = useSelector(getSettingsFontsize)
|
||||
const adaptedFontsize = adaptiveScale(
|
||||
StyleConstants.Font.Size.M,
|
||||
adaptiveFontsize
|
||||
)
|
||||
const adaptedLineheight = adaptiveScale(
|
||||
StyleConstants.Font.LineHeight.M,
|
||||
adaptiveFontsize
|
||||
)
|
||||
const adaptedFontsize = adaptiveScale(StyleConstants.Font.Size.M, adaptiveFontsize)
|
||||
const adaptedLineheight = adaptiveScale(StyleConstants.Font.LineHeight.M, adaptiveFontsize)
|
||||
|
||||
return (
|
||||
<PasteInput
|
||||
@ -59,12 +50,16 @@ const ComposeTextInput: React.FC = () => {
|
||||
content
|
||||
})
|
||||
}
|
||||
onFocus={() =>
|
||||
onFocus={() => {
|
||||
composeDispatch({
|
||||
type: 'textInputFocus',
|
||||
payload: { current: 'text' }
|
||||
})
|
||||
}
|
||||
composeState.textInputFocus.isFocused.text.current = true
|
||||
}}
|
||||
onBlur={() => {
|
||||
composeState.textInputFocus.isFocused.text.current = false
|
||||
}}
|
||||
onSelectionChange={({
|
||||
nativeEvent: {
|
||||
selection: { start, end }
|
||||
@ -79,20 +74,13 @@ const ComposeTextInput: React.FC = () => {
|
||||
scrollEnabled={false}
|
||||
disableCopyPaste={false}
|
||||
onPaste={(error: string | null | undefined, files: PastedFile[]) => {
|
||||
if (
|
||||
composeState.attachments.uploads.length + files.length >
|
||||
maxAttachments
|
||||
) {
|
||||
if (composeState.attachments.uploads.length + files.length > maxAttachments) {
|
||||
Alert.alert(
|
||||
t(
|
||||
'content.root.header.textInput.keyboardImage.exceedMaximum.title'
|
||||
),
|
||||
t('content.root.header.textInput.keyboardImage.exceedMaximum.title'),
|
||||
undefined,
|
||||
[
|
||||
{
|
||||
text: t(
|
||||
'content.root.header.textInput.keyboardImage.exceedMaximum.OK'
|
||||
),
|
||||
text: t('content.root.header.textInput.keyboardImage.exceedMaximum.OK'),
|
||||
style: 'default'
|
||||
}
|
||||
]
|
||||
|
@ -39,7 +39,8 @@ const composeInitialState: Omit<ComposeState, 'timestamp'> = {
|
||||
replyToStatus: undefined,
|
||||
textInputFocus: {
|
||||
current: 'text',
|
||||
refs: { text: createRef() }
|
||||
refs: { text: createRef() },
|
||||
isFocused: { text: createRef(), spoiler: createRef() }
|
||||
}
|
||||
}
|
||||
|
||||
|
1
src/screens/Compose/utils/types.d.ts
vendored
1
src/screens/Compose/utils/types.d.ts
vendored
@ -59,6 +59,7 @@ export type ComposeState = {
|
||||
textInputFocus: {
|
||||
current: 'text' | 'spoiler'
|
||||
refs: { text: RefObject<TextInput> }
|
||||
isFocused: { text: MutableRefObject<boolean>, spoiler: MutableRefObject<boolean> }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user