jiti-meet/react/features/base/dialog/components/native/BottomSheet.js

93 lines
2.4 KiB
JavaScript
Raw Normal View History

// @flow
import React, { PureComponent, type Node } from 'react';
2019-11-22 07:34:17 +00:00
import { SafeAreaView, ScrollView, View } from 'react-native';
2019-01-09 16:58:29 +00:00
import { ColorSchemeRegistry } from '../../../color-scheme';
import { SlidingView } from '../../../react';
2019-03-21 16:38:29 +00:00
import { connect } from '../../../redux';
import { StyleType } from '../../../styles';
import { bottomSheetStyles as styles } from './styles';
/**
* The type of {@code BottomSheet}'s React {@code Component} prop types.
*/
type Props = {
/**
* The color-schemed stylesheet of the feature.
*/
_styles: StyleType,
/**
* 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
};
/**
* A component emulating Android's BottomSheet.
*/
class BottomSheet extends PureComponent<Props> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
const { _styles } = this.props;
return (
<SlidingView
onHide = { this.props.onCancel }
position = 'bottom'
show = { true }>
2019-05-24 07:24:47 +00:00
<View
pointerEvents = 'box-none'
style = { styles.sheetContainer }>
<View
pointerEvents = 'box-none'
style = { styles.sheetAreaCover } />
<View
style = { [
styles.sheetItemContainer,
_styles.sheet
] }>
2019-11-22 07:34:17 +00:00
<SafeAreaView>
<ScrollView
bounces = { false }
showsVerticalScrollIndicator = { false } >
{ this.props.children }
</ScrollView>
</SafeAreaView>
</View>
2019-05-24 07:24:47 +00:00
</View>
</SlidingView>
);
}
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {{
* _styles: StyleType
* }}
*/
function _mapStateToProps(state) {
return {
_styles: ColorSchemeRegistry.get(state, 'BottomSheet')
};
}
export default connect(_mapStateToProps)(BottomSheet);