Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(chat): align message search with chat input
Calin-Teodorec1c6d47cf82
diff --git a/react/features/chat/components/native/ChatInputBar.tsx b/react/features/chat/components/native/ChatInputBar.tsxindex 41308cbbb7..6fad8bcd25 100644--- a/react/features/chat/components/native/ChatInputBar.tsx+++ b/react/features/chat/components/native/ChatInputBar.tsx@@ -1,11 +1,11 @@import React, { Component } from 'react';import { WithTranslation } from 'react-i18next';-import { Platform, TextStyle, View, ViewStyle } from 'react-native';+import { EmitterSubscription, Keyboard, Platform, TextStyle, View, ViewStyle } from 'react-native';import { Text } from 'react-native-paper';import { connect } from 'react-redux';import { IReduxState } from '../../../app/types';-import { translate } from '../../../base/i18n/functions';+import { translate } from '../../../base/i18n/functions.native';import { IconSend } from '../../../base/icons/svg';import IconButton from '../../../base/ui/components/native/IconButton';import Input from '../../../base/ui/components/native/Input';@@ -79,6 +79,8 @@ function _isSendDisabled({* Implements the chat input bar with text field and action(s).*/class ChatInputBar extends Component<IProps, IState> {+ _keyboardSubscriptions: EmitterSubscription[] = [];+/*** Instantiates a new instance of the component.*@@ -94,10 +96,36 @@ class ChatInputBar extends Component<IProps, IState> {};this._onChangeText = this._onChangeText.bind(this);- this._onFocused = this._onFocused.bind(this);this._onSubmit = this._onSubmit.bind(this);}+ /**+ * Tracks keyboard visibility (not input focus) so the bar also stays above the keyboard while the+ * search input is focused.+ *+ * @inheritdoc+ */+ override componentDidMount() {+ if (Platform.OS !== 'android') {+ return;+ }++ this._keyboardSubscriptions = [+ Keyboard.addListener('keyboardDidShow', () => this.setState({ addPadding: true })),+ Keyboard.addListener('keyboardDidHide', () => this.setState({ addPadding: false }))+ ];+ }++ /**+ * Implements {@code Component#componentWillUnmount}.+ *+ * @inheritdoc+ */+ override componentWillUnmount() {+ this._keyboardSubscriptions.forEach(subscription => subscription.remove());+ this._keyboardSubscriptions = [];+ }+/*** Implements {@code Component#render}.*@@ -128,9 +156,7 @@ class ChatInputBar extends Component<IProps, IState> {customStyles = {{ container: styles.customInputContainer }}id = 'chat-input-messagebox'multiline = { false }- onBlur = { this._onFocused(false) }onChange = { this._onChangeText }- onFocus = { this._onFocused(true) }onSubmitEditing = { this._onSubmit }placeholder = { this.props.t('chat.fieldPlaceHolder') }returnKeyType = 'send'@@ -159,20 +185,6 @@ class ChatInputBar extends Component<IProps, IState> {});}- /**- * Constructs a callback to be used to update the padding of the field if necessary.- *- * @param {boolean} focused - True of the field is focused.- * @returns {Function}- */- _onFocused(focused: boolean) {- return () => {- Platform.OS === 'android' && this.setState({- addPadding: focused- });- };- }-/*** Callback to handle the submit event of the text field.*diff --git a/react/features/chat/components/native/ChatSearchBar.tsx b/react/features/chat/components/native/ChatSearchBar.tsxindex 08652f5a8f..93b2197092 100644--- a/react/features/chat/components/native/ChatSearchBar.tsx+++ b/react/features/chat/components/native/ChatSearchBar.tsx@@ -1,4 +1,4 @@-import React, { useCallback } from 'react';+import React, { useCallback, useState } from 'react';import { Text, TouchableOpacity, View, ViewStyle } from 'react-native';import { useDispatch, useSelector } from 'react-redux';@@ -25,6 +25,7 @@ interface IProps {*/const ChatSearchBar = ({ t }: IProps) => {const dispatch = useDispatch();+ const [ focused, setFocused ] = useState(false);const query = useSelector((state: IReduxState) => getChatSearchQuery(state));const matches = useSelector((state: IReduxState) => getChatSearchMatches(state));const matchIndex = useSelector((state: IReduxState) => getChatSearchMatchIndex(state));@@ -52,12 +53,19 @@ const ChatSearchBar = ({ t }: IProps) => {dispatch(setChatSearchMatchIndex((matchIndex + 1) % matches.length));}, [ dispatch, matchIndex, matches.length ]);+ const _onFocus = useCallback(() => setFocused(true), []);+ const _onBlur = useCallback(() => setFocused(false), []);+const _onSubmitEditing = useCallback(() => {_onNext();}, [ _onNext ]);return (- <View style = { styles.searchBarContainer as ViewStyle }>+ <View+ style = { [+ styles.searchBarContainer,+ focused && styles.searchBarContainerFocused+ ] as ViewStyle[] }><Inputclearable = { true }customStyles = {{@@ -65,7 +73,9 @@ const ChatSearchBar = ({ t }: IProps) => {container: styles.searchInputContainer,input: styles.searchInput}}+ onBlur = { _onBlur }onChange = { _onChangeText }+ onFocus = { _onFocus }onSubmitEditing = { _onSubmitEditing }placeholder = { t('chat.search.placeholder') }returnKeyType = 'search'diff --git a/react/features/chat/components/native/styles.ts b/react/features/chat/components/native/styles.tsindex 96975f57ac..2345684ea5 100644--- a/react/features/chat/components/native/styles.ts+++ b/react/features/chat/components/native/styles.ts@@ -3,6 +3,11 @@ import BaseTheme from '../../../base/ui/components/BaseTheme.native';const BUBBLE_RADIUS = 8;+// Matches the chat input (native Input) so both fields line up.+const SEARCH_BAR_BORDER_WIDTH = 2;+const SEARCH_BAR_HEIGHT = BaseTheme.spacing[7];+const SEARCH_BAR_INNER_HEIGHT = SEARCH_BAR_HEIGHT - (2 * SEARCH_BAR_BORDER_WIDTH);+const recipientContainer = {alignItems: 'center',backgroundColor: BaseTheme.palette.support05,@@ -100,13 +105,18 @@ export default {backgroundColor: BaseTheme.palette.ui03,borderColor: BaseTheme.palette.ui03,borderRadius: BaseTheme.shape.borderRadius,- borderWidth: 2,+ borderWidth: SEARCH_BAR_BORDER_WIDTH,flexDirection: 'row',- height: 40,+ height: SEARCH_BAR_HEIGHT,marginBottom: BaseTheme.spacing[1],- marginHorizontal: BaseTheme.spacing[3],+ marginHorizontal: BaseTheme.spacing[4],marginTop: BaseTheme.spacing[2],- paddingHorizontal: BaseTheme.spacing[2]+ paddingLeft: BaseTheme.spacing[3],+ paddingRight: BaseTheme.spacing[2]+ },++ searchBarContainerFocused: {+ borderColor: BaseTheme.palette.focus01},searchBarCounter: {@@ -124,7 +134,7 @@ export default {searchClearButton: {alignItems: 'center',- height: 40,+ height: SEARCH_BAR_INNER_HEIGHT,justifyContent: 'center',top: 0},@@ -137,7 +147,7 @@ export default {searchInput: {backgroundColor: 'transparent',borderWidth: 0,- height: 40,+ height: SEARCH_BAR_INNER_HEIGHT,paddingHorizontal: 0},