From 5bb8751bc1d7d279ac1bbcf3a8ecb74af96ca59f Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 16 Nov 2022 14:28:33 -0600 Subject: Fix input positioning for small screens --- src/view/com/composer/ComposePost.tsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/view/com/composer/ComposePost.tsx') diff --git a/src/view/com/composer/ComposePost.tsx b/src/view/com/composer/ComposePost.tsx index 85a389320..30e5d0176 100644 --- a/src/view/com/composer/ComposePost.tsx +++ b/src/view/com/composer/ComposePost.tsx @@ -1,6 +1,7 @@ import React, {useEffect, useMemo, useState} from 'react' import { ActivityIndicator, + KeyboardAvoidingView, StyleSheet, Text, TextInput, @@ -20,7 +21,7 @@ import {s, colors, gradients} from '../../lib/styles' const MAX_TEXT_LENGTH = 256 const WARNING_TEXT_LENGTH = 200 -const DANGER_TEXT_LENGTH = 255 +const DANGER_TEXT_LENGTH = MAX_TEXT_LENGTH export function ComposePost({ replyTo, @@ -56,9 +57,6 @@ export function ComposePost({ }) const onChangeText = (newText: string) => { - if (newText.length > MAX_TEXT_LENGTH) { - newText = newText.slice(0, MAX_TEXT_LENGTH) - } setText(newText) const prefix = extractTextAutocompletePrefix(newText) @@ -81,6 +79,9 @@ export function ComposePost({ if (isProcessing) { return } + if (text.length > MAX_TEXT_LENGTH) { + return + } setError('') if (text.trim().length === 0) { setError('Did you want to say anything?') @@ -112,6 +113,7 @@ export function ComposePost({ setAutocompleteOptions([]) } + const canPost = text.length <= MAX_TEXT_LENGTH const progressColor = text.length > DANGER_TEXT_LENGTH ? '#e60000' @@ -133,7 +135,7 @@ export function ComposePost({ }, [text]) return ( - + Cancel @@ -143,7 +145,7 @@ export function ComposePost({ - ) : ( + ) : canPost ? ( Post + ) : ( + + Post + )} {error !== '' && ( @@ -176,8 +182,11 @@ export function ComposePost({ style={styles.textInput}> {textDecorated} - + + + {text.length} / {MAX_TEXT_LENGTH} + - + ) } @@ -219,6 +228,7 @@ const styles = StyleSheet.create({ paddingTop: 10, paddingBottom: 5, paddingHorizontal: 5, + height: 50, }, postBtn: { borderRadius: 20, -- cgit 1.4.1