From 29d02f0a2bce1a271daf7414703f8ed1815f0239 Mon Sep 17 00:00:00 2001 From: Calinteodor Date: Mon, 30 Oct 2023 12:59:05 +0200 Subject: [PATCH] feat(chat/native): fixed keyboard overlapping chat input bar (#13984) * feat(chat/native): fixed keyboard overlapping chat input bar --- .../features/chat/components/native/Chat.tsx | 6 ++- .../chat/components/native/ChatInputBar.tsx | 45 +++++++++++++++---- .../features/chat/components/native/styles.ts | 26 ++++++----- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/react/features/chat/components/native/Chat.tsx b/react/features/chat/components/native/Chat.tsx index 4024fb949b4c..f14ed9505489 100644 --- a/react/features/chat/components/native/Chat.tsx +++ b/react/features/chat/components/native/Chat.tsx @@ -59,13 +59,17 @@ class Chat extends Component { return ( + + } hasBottomTextInput = { true } hasTabNavigator = { true } style = { styles.chatContainer }> {/* @ts-ignore */} - ); } diff --git a/react/features/chat/components/native/ChatInputBar.tsx b/react/features/chat/components/native/ChatInputBar.tsx index 53777fec31d7..b0fcf1f42258 100644 --- a/react/features/chat/components/native/ChatInputBar.tsx +++ b/react/features/chat/components/native/ChatInputBar.tsx @@ -1,18 +1,26 @@ import React, { Component } from 'react'; import { WithTranslation } from 'react-i18next'; -import { Platform, ViewStyle } from 'react-native'; -import { SafeAreaView } from 'react-native-safe-area-context'; +import { Platform, View, ViewStyle } from 'react-native'; +import { connect } from 'react-redux'; +import { IReduxState } from '../../../app/types'; import { translate } from '../../../base/i18n/functions'; import { IconSend } from '../../../base/icons/svg'; +import { ASPECT_RATIO_WIDE } from '../../../base/responsive-ui/constants'; import IconButton from '../../../base/ui/components/native/IconButton'; import Input from '../../../base/ui/components/native/Input'; import { BUTTON_TYPES } from '../../../base/ui/constants.native'; import styles from './styles'; + interface IProps extends WithTranslation { + /** + * Application's aspect ratio. + */ + aspectRatio: Symbol; + /** * Callback to invoke on message send. */ @@ -66,11 +74,18 @@ class ChatInputBar extends Component { * @inheritdoc */ render() { + let inputBarStyles; + + if (this.props.aspectRatio === ASPECT_RATIO_WIDE) { + inputBarStyles = styles.inputBarWide; + } else { + inputBarStyles = styles.inputBarNarrow; + } + return ( - { disabled = { !this.state.message } onPress = { this._onSubmit } src = { IconSend } - style = { styles.sendButton } type = { BUTTON_TYPES.PRIMARY } /> - + ); } @@ -137,4 +151,19 @@ class ChatInputBar extends Component { } } -export default translate(ChatInputBar); +/** + * Maps part of the Redux state to the props of this component. + * + * @param {Object} state - The redux state. + * @private + * @returns {IProps} + */ +function _mapStateToProps(state: IReduxState) { + const { aspectRatio } = state['features/base/responsive-ui']; + + return { + aspectRatio + }; +} + +export default translate(connect(_mapStateToProps)(ChatInputBar)); diff --git a/react/features/chat/components/native/styles.ts b/react/features/chat/components/native/styles.ts index fa3909add60e..9c5d3d511306 100644 --- a/react/features/chat/components/native/styles.ts +++ b/react/features/chat/components/native/styles.ts @@ -14,6 +14,12 @@ const recipientContainer = { padding: BaseTheme.spacing[2] }; +const inputBar = { + alignItems: 'center', + flexDirection: 'row', + justifyContent: 'space-between' +}; + /** * The styles of the feature chat. * @@ -116,12 +122,16 @@ export default { paddingBottom: 30 }, - inputBar: { - alignItems: 'center', - flexDirection: 'row', - justifyContent: 'space-between', - marginLeft: BaseTheme.spacing[3], - width: '100%' + inputBarNarrow: { + ...inputBar, + height: 112, + marginHorizontal: BaseTheme.spacing[3] + }, + + inputBarWide: { + ...inputBar, + height: 88, + marginHorizontal: BaseTheme.spacing[9] }, customInputContainer: { @@ -157,10 +167,6 @@ export default { flexDirection: 'row' }, - sendButton: { - marginRight: BaseTheme.spacing[5] - }, - /** * Style modifier for system (error) messages. */