mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 12:18:08 +00:00
In the past we used a PanResponder to detect user gestures in the sheet to show a reduced version or a full-height version of it, and also to close it. There is an obvious conflic between the gestures and scrolling, which didn't work all that great, but we could live with it. After reactions were introduced we no longer rendered the 2 different heights, so that functionaligy stopped being used but the PanResponder still remained there. This commit removes it completely and sets a max height of 75% on any BottomSheet, so any tap outside will close it.
120 lines
3.2 KiB
JavaScript
120 lines
3.2 KiB
JavaScript
import React, { PureComponent, type Node } from 'react';
|
|
import { SafeAreaView, ScrollView, View } from 'react-native';
|
|
|
|
import { SlidingView } from '../../../react';
|
|
|
|
import { bottomSheetStyles as styles } from './styles';
|
|
|
|
/**
|
|
* The type of {@code BottomSheet}'s React {@code Component} prop types.
|
|
*/
|
|
type Props = {
|
|
|
|
/**
|
|
* Whether to add padding to scroll view.
|
|
*/
|
|
addScrollViewPadding?: boolean,
|
|
|
|
/**
|
|
* The children to be displayed within this component.
|
|
*/
|
|
children: Node,
|
|
|
|
/**
|
|
* Handler for the cancel event, which happens when the user dismisses
|
|
* the sheet.
|
|
*/
|
|
onCancel: ?Function,
|
|
|
|
/**
|
|
* Function to render a bottom sheet header element, if necessary.
|
|
*/
|
|
renderHeader: ?Function,
|
|
|
|
/**
|
|
* Function to render a bottom sheet footer element, if necessary.
|
|
*/
|
|
renderFooter: ?Function,
|
|
|
|
/**
|
|
* Whether to show sliding view or not.
|
|
*/
|
|
showSlidingView?: boolean,
|
|
|
|
/**
|
|
* The component's external style.
|
|
*/
|
|
style: Object
|
|
};
|
|
|
|
/**
|
|
* A component emulating Android's BottomSheet.
|
|
*/
|
|
class BottomSheet extends PureComponent<Props> {
|
|
/**
|
|
* Default values for {@code BottomSheet} component's properties.
|
|
*
|
|
* @static
|
|
*/
|
|
static defaultProps = {
|
|
addScrollViewPadding: true,
|
|
showSlidingView: true
|
|
};
|
|
|
|
/**
|
|
* Implements React's {@link Component#render()}.
|
|
*
|
|
* @inheritdoc
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
const {
|
|
addScrollViewPadding,
|
|
renderHeader,
|
|
renderFooter,
|
|
showSlidingView,
|
|
style
|
|
} = this.props;
|
|
|
|
return (
|
|
<SlidingView
|
|
accessibilityRole = 'menu'
|
|
accessibilityViewIsModal = { true }
|
|
onHide = { this.props.onCancel }
|
|
position = 'bottom'
|
|
show = { showSlidingView }>
|
|
<View
|
|
pointerEvents = 'box-none'
|
|
style = { styles.sheetContainer }>
|
|
<View
|
|
pointerEvents = 'box-none'
|
|
style = { styles.sheetAreaCover } />
|
|
{ renderHeader && renderHeader() }
|
|
<SafeAreaView
|
|
style = { [
|
|
styles.sheetItemContainer,
|
|
renderHeader
|
|
? styles.sheetHeader
|
|
: styles.sheet,
|
|
renderFooter && styles.sheetFooter,
|
|
style
|
|
] }>
|
|
<ScrollView
|
|
bounces = { false }
|
|
showsVerticalScrollIndicator = { false }
|
|
style = { [
|
|
renderFooter && styles.sheet,
|
|
addScrollViewPadding && styles.scrollView
|
|
] } >
|
|
{ this.props.children }
|
|
</ScrollView>
|
|
{ renderFooter && renderFooter() }
|
|
</SafeAreaView>
|
|
</View>
|
|
</SlidingView>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default BottomSheet;
|