diff --git a/src/screens/Shared/Compose.tsx b/src/screens/Shared/Compose.tsx index 8ca9a64f..bb987a2f 100644 --- a/src/screens/Shared/Compose.tsx +++ b/src/screens/Shared/Compose.tsx @@ -34,10 +34,10 @@ export type PostState = { active: boolean total: number options: { + '0': string | undefined '1': string | undefined '2': string | undefined '3': string | undefined - '4': string | undefined } multiple: boolean expire: diff --git a/src/screens/Shared/Compose/Actions.tsx b/src/screens/Shared/Compose/Actions.tsx index 2867c7c3..78e90a36 100644 --- a/src/screens/Shared/Compose/Actions.tsx +++ b/src/screens/Shared/Compose/Actions.tsx @@ -96,6 +96,30 @@ const ComposeActions: React.FC = ({ postState.attachmentUploadProgress ]) + const emojiColor = useMemo(() => { + if (!postState.emoji.emojis) return theme.disabled + if (postState.emoji.active) { + return theme.primary + } else { + return theme.secondary + } + }, [postState.emoji.active, postState.emoji.emojis]) + const emojiOnPress = useCallback(() => { + if (postState.emoji.emojis) { + if (postState.emoji.active) { + postDispatch({ + type: 'emoji', + payload: { ...postState.emoji, active: false } + }) + } else { + postDispatch({ + type: 'emoji', + payload: { ...postState.emoji, active: true } + }) + } + } + }, [postState.emoji.active, postState.emoji.emojis]) + return ( = ({ { - if (postState.emoji.active) { - postDispatch({ - type: 'emoji', - payload: { ...postState.emoji, active: false } - }) - } else { - Keyboard.dismiss() - postDispatch({ - type: 'emoji', - payload: { ...postState.emoji, active: true } - }) - } - } - })} + color={emojiColor} + onPress={emojiOnPress} /> = ({ postState, postDispatch }) => { renderItem={renderAttachment} ListFooterComponent={listFooter} showsHorizontalScrollIndicator={false} + keyboardShouldPersistTaps='handled' /> ) diff --git a/src/screens/Shared/Compose/Emojis.tsx b/src/screens/Shared/Compose/Emojis.tsx index 60a21db1..590f9692 100644 --- a/src/screens/Shared/Compose/Emojis.tsx +++ b/src/screens/Shared/Compose/Emojis.tsx @@ -31,6 +31,7 @@ const ComposeEmojis: React.FC = ({ item.shortcode} renderSectionHeader={({ section: { title } }) => ( diff --git a/src/screens/Shared/Compose/Poll.tsx b/src/screens/Shared/Compose/Poll.tsx index f44ad743..4f5cc9d7 100644 --- a/src/screens/Shared/Compose/Poll.tsx +++ b/src/screens/Shared/Compose/Poll.tsx @@ -1,12 +1,5 @@ import React, { Dispatch, useEffect, useState } from 'react' -import { - ActionSheetIOS, - Pressable, - StyleSheet, - Text, - TextInput, - View -} from 'react-native' +import { ActionSheetIOS, StyleSheet, TextInput, View } from 'react-native' import { Feather } from '@expo/vector-icons' import { PostAction, PostState } from '../Compose' @@ -41,35 +34,51 @@ const ComposePoll: React.FC = ({ postState, postDispatch }) => { return ( - {[...Array(postState.poll.total)].map((e, i) => ( - - - - postDispatch({ - type: 'poll', - payload: { - ...postState.poll, - options: { ...postState.poll.options, [i]: e } + {[...Array(postState.poll.total)].map((e, i) => { + const restOptions = Object.keys(postState.poll.options).filter( + o => parseInt(o) !== i && parseInt(o) < postState.poll.total + ) + let hasConflict = false + restOptions.forEach(o => { + // @ts-ignore + if (postState.poll.options[o] === postState.poll.options[i]) { + hasConflict = true + } + }) + return ( + + + - - ))} + ]} + placeholder={`选项`} + placeholderTextColor={theme.secondary} + maxLength={50} + // @ts-ignore + value={postState.poll.options[i]} + onChangeText={e => + postDispatch({ + type: 'poll', + payload: { + ...postState.poll, + options: { ...postState.poll.options, [i]: e } + } + }) + } + /> + + ) + })} diff --git a/src/screens/Shared/Compose/Root.tsx b/src/screens/Shared/Compose/Root.tsx index f76f6c04..8798cf5f 100644 --- a/src/screens/Shared/Compose/Root.tsx +++ b/src/screens/Shared/Compose/Root.tsx @@ -92,6 +92,7 @@ const ComposeRoot: React.FC = ({ postState, postDispatch }) => { progressViewStyle='bar' /> { + const { theme } = useTheme() + + return ( + + {text} + + ) +} + const debouncedSuggestions = debounce( (postDispatch, tag) => { postDispatch({ type: 'tag', payload: tag }) @@ -77,11 +88,7 @@ const formatText = ({ const prevPart = parts.shift() children.push(prevPart) contentLength = contentLength + (prevPart ? prevPart.length : 0) - children.push( - - {tag!.text} - - ) + children.push() switch (tag!.type) { case 'url': contentLength = contentLength + 23