Merge pull request #3012 from saghul/overflow-menu-dismiss

[RN] Dismiss OverflowMenu after selecting an option
This commit is contained in:
Zoltan Bettenbuk 2018-05-22 17:57:23 +02:00 committed by GitHub
commit 62cc44f791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View File

@ -7,6 +7,11 @@ import ToolboxItem from './ToolboxItem';
export type Props = { export type Props = {
/**
* Function to be called after the click handler has been processed.
*/
afterClick: ?Function,
/** /**
* Whether to show the label or not. * Whether to show the label or not.
*/ */
@ -38,6 +43,7 @@ export type Props = {
*/ */
export default class AbstractButton<P: Props, S: *> extends Component<P, S> { export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
static defaultProps = { static defaultProps = {
afterClick: undefined,
showLabel: false, showLabel: false,
styles: undefined, styles: undefined,
toggledStyles: undefined, toggledStyles: undefined,
@ -165,7 +171,10 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
* @returns {void} * @returns {void}
*/ */
_onClick() { _onClick() {
const { afterClick } = this.props;
this._handleClick(); this._handleClick();
afterClick && afterClick();
} }
/** /**

View File

@ -56,23 +56,19 @@ class OverflowMenu extends Component<Props> {
* @returns {ReactElement} * @returns {ReactElement}
*/ */
render() { render() {
const buttonProps = {
afterClick: this._onCancel,
showLabel: true,
styles: overflowMenuItemStyles
};
return ( return (
<BottomSheet onCancel = { this._onCancel }> <BottomSheet onCancel = { this._onCancel }>
<AudioRouteButton <AudioRouteButton { ...buttonProps } />
showLabel = { true } <ToggleCameraButton { ...buttonProps } />
styles = { overflowMenuItemStyles } /> <AudioOnlyButton { ...buttonProps } />
<ToggleCameraButton <RoomLockButton { ...buttonProps } />
showLabel = { true } <PictureInPictureButton { ...buttonProps } />
styles = { overflowMenuItemStyles } />
<AudioOnlyButton
showLabel = { true }
styles = { overflowMenuItemStyles } />
<RoomLockButton
showLabel = { true }
styles = { overflowMenuItemStyles } />
<PictureInPictureButton
showLabel = { true }
styles = { overflowMenuItemStyles } />
</BottomSheet> </BottomSheet>
); );
} }