Fix cannot scroll acknowledgement bottom sheet of user list when there are many users (#7489)

* Fix cannot scroll acknowledgement bottom sheet of user list when there are many users

* - Updated showing user list for Tablet
- Added GestureHandlerRootView to avoid bug not show the list

* Wrap BottomSheet inside withGestures function

* Remove GestureHandlerRootView for BottomSheet component since it's been wrapped inside withGesture function
This commit is contained in:
Khanh P. Huynh 2023-08-09 15:48:21 +07:00 committed by GitHub
parent eb7432dc27
commit 0d8466a055
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 26 deletions

View file

@ -1,9 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {BottomSheetFlatList} from '@gorhom/bottom-sheet';
import React, {useCallback, useRef} from 'react';
import {FlatList} from 'react-native-gesture-handler';
import {useIsTablet} from '@hooks/device';
import UserListItem from './user_list_item';
import type UserModel from '@typings/database/models/servers/user';
@ -18,6 +21,7 @@ type Props = {
};
const UsersList = ({channelId, location, users, userAcknowledgements, timezone}: Props) => {
const isTablet = useIsTablet();
const listRef = useRef<FlatList>(null);
const renderItem = useCallback(({item}: ListRenderItemInfo<UserModel>) => (
@ -30,10 +34,20 @@ const UsersList = ({channelId, location, users, userAcknowledgements, timezone}:
/>
), [channelId, location, timezone]);
if (isTablet) {
return (
<FlatList
data={users}
ref={listRef}
renderItem={renderItem}
overScrollMode={'always'}
/>
);
}
return (
<FlatList
<BottomSheetFlatList
data={users}
ref={listRef}
renderItem={renderItem}
overScrollMode={'always'}
/>

View file

@ -4,7 +4,6 @@
import BottomSheetM, {BottomSheetBackdrop, type BottomSheetBackdropProps, type BottomSheetFooterProps} from '@gorhom/bottom-sheet';
import React, {type ReactNode, useCallback, useEffect, useMemo, useRef} from 'react';
import {DeviceEventEmitter, type Handle, InteractionManager, Keyboard, type StyleProp, View, type ViewStyle} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {Events} from '@constants';
import {useTheme} from '@context/theme';
@ -39,7 +38,6 @@ const PADDING_TOP_TABLET = 8;
export const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
container: {flex: 1},
bottomSheet: {
backgroundColor: theme.centerChannelBg,
borderTopStartRadius: 24,
@ -199,27 +197,25 @@ const BottomSheet = ({
}
return (
<GestureHandlerRootView style={styles.container}>
<BottomSheetM
ref={sheetRef}
index={initialSnapIndex}
snapPoints={snapPoints}
animateOnMount={true}
backdropComponent={renderBackdrop}
onAnimate={handleAnimationStart}
onChange={handleChange}
animationConfigs={animatedConfig}
handleComponent={Indicator}
style={styles.bottomSheet}
backgroundStyle={bottomSheetBackgroundStyle}
footerComponent={footerComponent}
keyboardBehavior='extend'
keyboardBlurBehavior='restore'
onClose={close}
>
{renderContainerContent()}
</BottomSheetM>
</GestureHandlerRootView>
<BottomSheetM
ref={sheetRef}
index={initialSnapIndex}
snapPoints={snapPoints}
animateOnMount={true}
backdropComponent={renderBackdrop}
onAnimate={handleAnimationStart}
onChange={handleChange}
animationConfigs={animatedConfig}
handleComponent={Indicator}
style={styles.bottomSheet}
backgroundStyle={bottomSheetBackgroundStyle}
footerComponent={footerComponent}
keyboardBehavior='extend'
keyboardBlurBehavior='restore'
onClose={close}
>
{renderContainerContent()}
</BottomSheetM>
);
};

View file

@ -69,7 +69,7 @@ Navigation.setLazyComponentRegistrator((screenName) => {
case Screens.BOTTOM_SHEET:
screen = withServerDatabase(require('@screens/bottom_sheet').default);
Navigation.registerComponent(Screens.BOTTOM_SHEET, () =>
withSafeAreaInsets(withManagedConfig(screen)),
withGestures(withSafeAreaInsets(withManagedConfig(screen)), undefined),
);
return;
case Screens.BROWSE_CHANNELS: