From 726ff6bb01d63c060c49bc1ea20fa1812e18723e Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 18 Jan 2023 13:21:23 -0600 Subject: [PATCH] Focus the text input on tap during the composer --- src/view/com/composer/ComposePost.tsx | 298 +++++++++++++------------- 1 file changed, 154 insertions(+), 144 deletions(-) diff --git a/src/view/com/composer/ComposePost.tsx b/src/view/com/composer/ComposePost.tsx index eaf92798..3cb31c53 100644 --- a/src/view/com/composer/ComposePost.tsx +++ b/src/view/com/composer/ComposePost.tsx @@ -9,6 +9,7 @@ import { StyleSheet, TextInput, TouchableOpacity, + TouchableWithoutFeedback, View, } from 'react-native' import LinearGradient from 'react-native-linear-gradient' @@ -88,6 +89,9 @@ export const ComposePost = observer(function ComposePost({ } }, []) + const onPressContainer = () => { + textInput.current?.focus() + } const onPressSelectPhotos = () => { if (isSelectingPhotos) { setIsSelectingPhotos(false) @@ -183,156 +187,162 @@ export const ComposePost = observer(function ComposePost({ testID="composePostView" behavior={Platform.OS === 'ios' ? 'padding' : 'height'} style={[pal.view, styles.outer]}> - - - - Cancel - - - {isProcessing ? ( - - - - ) : canPost ? ( + + + - - - {replyTo ? 'Reply' : 'Post'} - - + testID="composerCancelButton" + onPress={onPressCancel}> + Cancel - ) : ( - - Post - - )} - - {isProcessing ? ( - - {processingState} - - ) : undefined} - {error !== '' && ( - - - - - {error} - - )} - - {replyTo ? ( - - - - - - {replyTo.text} - + + {isProcessing ? ( + + - - ) : undefined} - - - onChangeText(text)} - placeholder={selectTextInputPlaceholder} - placeholderTextColor={pal.colors.textLight} - style={[pal.text, styles.textInput]}> - {textDecorated} - - - - - {isSelectingPhotos && - localPhotos.photos != null && - selectedPhotos.length < 4 && ( - - )} - - - - - - - {MAX_TEXT_LENGTH - text.length} - - - {text.length > DANGER_TEXT_LENGTH ? ( - + ) : canPost ? ( + + + + {replyTo ? 'Reply' : 'Post'} + + + ) : ( - + + Post + )} - - - + {isProcessing ? ( + + {processingState} + + ) : undefined} + {error !== '' && ( + + + + + {error} + + )} + + {replyTo ? ( + + + + + + {replyTo.text} + + + + ) : undefined} + + + onChangeText(text)} + placeholder={selectTextInputPlaceholder} + placeholderTextColor={pal.colors.textLight} + style={[pal.text, styles.textInput]}> + {textDecorated} + + + + + {isSelectingPhotos && + localPhotos.photos != null && + selectedPhotos.length < 4 && ( + + )} + + + + + + + {MAX_TEXT_LENGTH - text.length} + + + {text.length > DANGER_TEXT_LENGTH ? ( + + ) : ( + + )} + + + + + ) })