From 48af78314d2d878992fa9a33b9448ff08cdc99fc Mon Sep 17 00:00:00 2001 From: Chetas Sharma Date: Wed, 10 Nov 2021 11:10:34 +0530 Subject: [PATCH] composeBox: move attachments row below the composeBox --- src/common/Icons.js | 1 + src/compose/ComposeBox.js | 51 +++++++++++++++++++------ src/compose/ComposeMenu.js | 76 ++++++++++++-------------------------- 3 files changed, 65 insertions(+), 63 deletions(-) diff --git a/src/common/Icons.js b/src/common/Icons.js index 5218f4aa379..dadf585f420 100644 --- a/src/common/Icons.js +++ b/src/common/Icons.js @@ -75,6 +75,7 @@ export const IconSettings: SpecificIconType = makeIcon(Feather, 'settings'); export const IconRight: SpecificIconType = makeIcon(Feather, 'chevron-right'); export const IconPlusCircle: SpecificIconType = makeIcon(Feather, 'plus-circle'); export const IconLeft: SpecificIconType = makeIcon(Feather, 'chevron-left'); +export const IconUp: SpecificIconType = makeIcon(Feather, 'chevron-up'); export const IconPeople: SpecificIconType = makeIcon(Feather, 'users'); export const IconPerson: SpecificIconType = makeIcon(Feather, 'user'); export const IconImage: SpecificIconType = makeIcon(Feather, 'image'); diff --git a/src/compose/ComposeBox.js b/src/compose/ComposeBox.js index b1c8be9946e..785be8c2241 100644 --- a/src/compose/ComposeBox.js +++ b/src/compose/ComposeBox.js @@ -11,7 +11,7 @@ import invariant from 'invariant'; import * as apiConstants from '../api/constants'; import { withSafeAreaInsets } from '../react-native-safe-area-context'; import type { ThemeData } from '../styles'; -import { ThemeContext } from '../styles'; +import { ThemeContext, BRAND_COLOR } from '../styles'; import type { Auth, Narrow, @@ -29,7 +29,7 @@ import { withGetText } from '../boot/TranslationProvider'; import { draftUpdate, sendTypingStart, sendTypingStop } from '../actions'; import { FloatingActionButton, Input } from '../common'; import { showToast, showErrorAlert } from '../utils/info'; -import { IconDone, IconSend } from '../common/Icons'; +import { IconDone, IconSend, IconUp, IconPlusCircle } from '../common/Icons'; import { isConversationNarrow, isStreamNarrow, @@ -123,6 +123,7 @@ type State = {| isFocused: boolean, isMenuExpanded: boolean, + showAttachmentRow: boolean, topic: string, message: string, height: number, @@ -166,6 +167,7 @@ class ComposeBoxInner extends PureComponent { isTopicFocused: false, isFocused: false, isMenuExpanded: false, + showAttachmentRow: false, height: 20, topic: this.props.initialTopic @@ -341,6 +343,7 @@ class ComposeBoxInner extends PureComponent { }; handleMessageFocus = () => { + this.setState({ showAttachmentRow: true }); if ( !this.props.isEditing && isStreamNarrow(this.props.narrow) @@ -364,6 +367,7 @@ class ComposeBoxInner extends PureComponent { this.setState({ isMessageFocused: false, isMenuExpanded: false, + showAttachmentRow: false, }); const { dispatch, narrow } = this.props; dispatch(sendTypingStop(narrow)); @@ -452,7 +456,7 @@ class ComposeBoxInner extends PureComponent { }, composeBox: { flexDirection: 'row', - alignItems: 'flex-end', + alignItems: 'flex-start', flexShrink: 1, }, composeText: { @@ -462,6 +466,10 @@ class ComposeBoxInner extends PureComponent { composeSendButton: { padding: 8, }, + expandButton: { + padding: 12, + color: BRAND_COLOR, + }, topicInput: { borderWidth: 0, borderRadius: 5, @@ -478,7 +486,15 @@ class ComposeBoxInner extends PureComponent { }; render() { - const { isTopicFocused, isMenuExpanded, height, message, topic, selection } = this.state; + const { + isTopicFocused, + showAttachmentRow, + isMenuExpanded, + height, + message, + topic, + selection, + } = this.state; const { ownUserId, narrow, @@ -525,13 +541,20 @@ class ComposeBoxInner extends PureComponent { /> - + {!isMenuExpanded && !showAttachmentRow && ( + + )} + {isMenuExpanded && !showAttachmentRow && ( + + )} { onSelectionChange={this.handleMessageSelectionChange} onTouchStart={this.handleInputTouchStart} /> + Promise, insertVideoCallLink: (() => void) | null, - onExpandContract: () => void, |}>; type SelectorProps = $ReadOnly<{||}>; @@ -222,10 +213,6 @@ class ComposeMenuInner extends PureComponent { flexDirection: 'row', overflow: 'hidden', }, - expandButton: { - padding: 12, - color: BRAND_COLOR, - }, composeMenuButton: { padding: 12, marginRight: -8, @@ -234,52 +221,37 @@ class ComposeMenuInner extends PureComponent { }); render() { - const { expanded, insertVideoCallLink, onExpandContract } = this.props; - const numIcons = - 2 + (Platform.OS === 'android' ? 1 : 0) + (insertVideoCallLink !== null ? 1 : 0); + const { expanded, insertVideoCallLink } = this.props; return ( - - - - {Platform.OS === 'android' && ( - - )} - + {Platform.OS === 'android' && ( + - + + {insertVideoCallLink !== null ? ( + - {insertVideoCallLink !== null ? ( - - ) : null} - - - {!expanded && ( - - )} - {expanded && ( - - )} - + ) : null} + + ) ); } }