From 8198e52b93a8660693a91e036430f1bc3b98c160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 3 Nov 2017 11:10:58 +0100 Subject: [PATCH] [RN] Add SimpleBottomSheet component It emulates Android's BottomSheet in pure JavaScript. It's implemented as another Dialog, so it can be used instead of one. The implementation only supports text options with an associated icon, and an optional 'selected' marker. --- .../components/SimpleBottomSheet.native.js | 186 ++++++++++++++++++ .../components/SimpleBottomSheet.web.js | 0 .../features/base/dialog/components/index.js | 1 + .../features/base/dialog/components/styles.js | 81 ++++++++ 4 files changed, 268 insertions(+) create mode 100644 react/features/base/dialog/components/SimpleBottomSheet.native.js create mode 100644 react/features/base/dialog/components/SimpleBottomSheet.web.js diff --git a/react/features/base/dialog/components/SimpleBottomSheet.native.js b/react/features/base/dialog/components/SimpleBottomSheet.native.js new file mode 100644 index 000000000..b79b76c91 --- /dev/null +++ b/react/features/base/dialog/components/SimpleBottomSheet.native.js @@ -0,0 +1,186 @@ +// @flow + +import React, { Component } from 'react'; +import { + Modal, + Text, + TouchableHighlight, + TouchableWithoutFeedback, + View +} from 'react-native'; +import { connect } from 'react-redux'; + +import { Icon } from '../../font-icons'; + +import { bottomSheet as styles } from './styles'; + +/** + * Underlay color for the buttons on the sheet. + * + * @type {string} + */ +const BUTTON_UNDERLAY_COLOR = '#eee'; + +/** + * {@code SimpleBottomSheet}'s React {@code Component} prop types. + */ + +type Option = { + + /** + * Name of the icon which will be rendered on the right. + */ + iconName: string, + + /** + * True if the element is selected (will be highlighted in blue), + * false otherwise. + */ + selected: boolean, + + /** + * Text which will be rendered in the row. + */ + text: string +}; + +type Props = { + + /** + * Handler for the cancel event, which happens when the user dismisses + * the sheet. + */ + onCancel: Function, + + /** + * Handler for the event when an option has been selected in the sheet. + */ + onSubmit: Function, + + /** + * Array of options which will be rendered as rows. + */ + options: Array