From cf14ebea78ac5c1d52b31dca9c2585c599811e98 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:41:49 -0300 Subject: [PATCH] fix: scroll the pages New Message, Search for Rooms, Messages and Threads (#4952) * [FIX] Scroll the pages Directory, New Message, Search for Rooms, Messages and Threads * flex for the flatlist * minor tweak at roomslistview and remove the keyboard from directoryview --------- Co-authored-by: Gleidson Daniel Silva --- app/containers/KeyboardView.tsx | 2 +- app/views/NewMessageView/index.tsx | 47 ++++++++++++++------------ app/views/RoomsListView/index.tsx | 23 +++++++------ app/views/SearchMessagesView/index.tsx | 27 ++++++++------- app/views/ThreadMessagesView/index.tsx | 23 +++++++------ 5 files changed, 67 insertions(+), 55 deletions(-) diff --git a/app/containers/KeyboardView.tsx b/app/containers/KeyboardView.tsx index 99df6f923..8bfd8ce93 100644 --- a/app/containers/KeyboardView.tsx +++ b/app/containers/KeyboardView.tsx @@ -6,7 +6,7 @@ import scrollPersistTaps from '../lib/methods/helpers/scrollPersistTaps'; interface IKeyboardViewProps extends KeyboardAwareScrollViewProps { keyboardVerticalOffset?: number; scrollEnabled?: boolean; - children: React.ReactElement[] | React.ReactElement; + children: React.ReactElement[] | React.ReactElement | null | (React.ReactElement | null)[]; } const KeyboardView = ({ style, contentContainerStyle, scrollEnabled, keyboardVerticalOffset, children }: IKeyboardViewProps) => ( diff --git a/app/views/NewMessageView/index.tsx b/app/views/NewMessageView/index.tsx index f393a9f91..6e91d3ae2 100644 --- a/app/views/NewMessageView/index.tsx +++ b/app/views/NewMessageView/index.tsx @@ -5,6 +5,7 @@ import { FlatList } from 'react-native'; import { shallowEqual } from 'react-redux'; import { useNavigation } from '@react-navigation/native'; +import KeyboardView from '../../containers/KeyboardView'; import * as HeaderButton from '../../containers/HeaderButton'; import * as List from '../../containers/List'; import SafeAreaView from '../../containers/SafeAreaView'; @@ -82,29 +83,31 @@ const NewMessageView = () => { return ( - - 0 ? search : chats} - keyExtractor={item => item._id || item.rid} - ListHeaderComponent={} - renderItem={({ item }) => { - const itemSearch = item as ISearch; - const itemModel = item as TSubscriptionModel; + + + 0 ? search : chats} + keyExtractor={item => item._id || item.rid} + ListHeaderComponent={} + renderItem={({ item }) => { + const itemSearch = item as ISearch; + const itemModel = item as TSubscriptionModel; - return ( - goRoom(itemModel)} - testID={`new-message-view-item-${item.name}`} - /> - ); - }} - ItemSeparatorComponent={List.Separator} - ListFooterComponent={List.Separator} - contentContainerStyle={{ backgroundColor: colors.backgroundColor }} - keyboardShouldPersistTaps='always' - /> + return ( + goRoom(itemModel)} + testID={`new-message-view-item-${item.name}`} + /> + ); + }} + ItemSeparatorComponent={List.Separator} + ListFooterComponent={List.Separator} + contentContainerStyle={{ backgroundColor: colors.backgroundColor }} + keyboardShouldPersistTaps='always' + /> + ); }; diff --git a/app/views/RoomsListView/index.tsx b/app/views/RoomsListView/index.tsx index a204364b3..a40aaadcb 100644 --- a/app/views/RoomsListView/index.tsx +++ b/app/views/RoomsListView/index.tsx @@ -11,6 +11,7 @@ import { Header } from '@react-navigation/elements'; import { CompositeNavigationProp, RouteProp } from '@react-navigation/native'; import { Dispatch } from 'redux'; +import KeyboardView from '../../containers/KeyboardView'; import database from '../../lib/database'; import RoomItem, { ROW_HEIGHT, ROW_HEIGHT_CONDENSED } from '../../containers/RoomItem'; import log, { logEvent, events } from '../../lib/methods/helpers/log'; @@ -62,8 +63,8 @@ import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from import { Services } from '../../lib/services'; type TNavigation = CompositeNavigationProp< - StackNavigationProp, - CompositeNavigationProp, StackNavigationProp> +StackNavigationProp, +CompositeNavigationProp, StackNavigationProp> >; interface IRoomsListViewProps { @@ -479,11 +480,11 @@ class RoomsListView extends React.Component, - props: Readonly + | (( + prevState: Readonly, + props: Readonly ) => Pick | IRoomsListViewState | null) - | (Pick | IRoomsListViewState | null), + | (Pick | IRoomsListViewState | null), callback?: () => void ) => { if (this.animated) { @@ -907,7 +908,7 @@ class RoomsListView extends React.Component (this.scroll = ref); + getScrollRef = (ref: FlatList) => this.scroll = ref; renderListHeader = () => { const { searching } = this.state; @@ -1025,9 +1026,11 @@ class RoomsListView extends React.Component - - {this.renderHeader()} - {this.renderScroll()} + + + {this.renderHeader()} + {this.renderScroll()} + {/* TODO - this ts-ignore is here because the route props, on IBaseScreen*/} {/* @ts-ignore*/} {showServerDropdown ? : null} diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index b83d07779..3bb5a97af 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -39,6 +39,7 @@ import { ICustomEmoji } from '../../definitions'; import { Services } from '../../lib/services'; +import KeyboardView from '../../containers/KeyboardView'; const QUERY_SIZE = 50; @@ -327,18 +328,20 @@ class SearchMessagesView extends React.Component - - - - - - {this.renderList()} + + + + + + + {this.renderList()} + ); } diff --git a/app/views/ThreadMessagesView/index.tsx b/app/views/ThreadMessagesView/index.tsx index 2769b3302..8cfbecb6a 100644 --- a/app/views/ThreadMessagesView/index.tsx +++ b/app/views/ThreadMessagesView/index.tsx @@ -35,6 +35,7 @@ import styles from './styles'; import { IApplicationState, IBaseScreen, IMessage, SubscriptionType, TSubscriptionModel, TThreadModel } from '../../definitions'; import { getUidDirectMessage, debounce, isIOS } from '../../lib/methods/helpers'; import { Services } from '../../lib/services'; +import KeyboardView from '../../containers/KeyboardView'; const API_FETCH_COUNT = 50; @@ -516,16 +517,18 @@ class ThreadMessagesView extends React.Component - - {this.renderContent()} - {showFilterDropdown ? ( - - ) : null} + + + {this.renderContent()} + {showFilterDropdown ? ( + + ) : null} + ); }