UNPKG

react-native-paper

Version:
68 lines (67 loc) 3.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _theming = require("../../core/theming"); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** * A component to show a scrollable content in a Dialog. The component only provides appropriate styling. * For the scrollable content you can use `ScrollView`, `FlatList` etc. depending on your requirement. * * ## Usage * ```js * import * as React from 'react'; * import { ScrollView } from 'react-native'; * import { Dialog, Portal, Text } from 'react-native-paper'; * * const MyComponent = () => { * const [visible, setVisible] = React.useState(false); * * const hideDialog = () => setVisible(false); * * return ( * <Portal> * <Dialog visible={visible} onDismiss={hideDialog}> * <Dialog.ScrollArea> * <ScrollView contentContainerStyle={{paddingHorizontal: 24}}> * <Text>This is a scrollable area</Text> * </ScrollView> * </Dialog.ScrollArea> * </Dialog> * </Portal> * ); * }; * * export default MyComponent; * ``` */ const DialogScrollArea = props => { const theme = (0, _theming.useInternalTheme)(props.theme); const borderStyles = { borderColor: theme.isV3 ? theme.colors.surfaceVariant : 'rgba(0, 0, 0, .12)', borderTopWidth: theme.isV3 ? 1 : _reactNative.StyleSheet.hairlineWidth, borderBottomWidth: theme.isV3 ? 1 : _reactNative.StyleSheet.hairlineWidth }; return /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, props, { style: [styles.container, borderStyles, theme.isV3 && styles.v3Container, props.style] }), props.children); }; DialogScrollArea.displayName = 'Dialog.ScrollArea'; const styles = _reactNative.StyleSheet.create({ container: { paddingHorizontal: 24, flexGrow: 1, flexShrink: 1 }, v3Container: { marginBottom: 24 } }); var _default = DialogScrollArea; exports.default = _default; //# sourceMappingURL=DialogScrollArea.js.map