react-native-paper
Version:
Material design for React Native
84 lines (82 loc) • 3.32 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.DialogIcon = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _theming = require("../../core/theming");
var _Icon = _interopRequireDefault(require("../Icon"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
/**
* @supported Available in v5.x with theme version 3
* A component to show an icon in a Dialog.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { StyleSheet } 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.Icon icon="alert" />
* <Dialog.Title style={styles.title}>This is a title</Dialog.Title>
* <Dialog.Content>
* <Text variant="bodyMedium">This is simple dialog</Text>
* </Dialog.Content>
* </Dialog>
* </Portal>
* );
* };
*
* const styles = StyleSheet.create({
* title: {
* textAlign: 'center',
* },
* })
*
* export default MyComponent;
* ```
*/
const DialogIcon = _ref => {
let {
size = 24,
color,
icon,
theme: themeOverrides
} = _ref;
const theme = (0, _theming.useInternalTheme)(themeOverrides);
if (!theme.isV3) {
return null;
}
//@ts-ignore
const iconColor = color || theme.colors.secondary;
return /*#__PURE__*/React.createElement(_reactNative.View, {
style: styles.wrapper
}, /*#__PURE__*/React.createElement(_Icon.default, {
source: icon,
color: iconColor,
size: size
}));
};
exports.DialogIcon = DialogIcon;
DialogIcon.displayName = 'Dialog.Icon';
const styles = _reactNative.StyleSheet.create({
wrapper: {
alignItems: 'center',
justifyContent: 'center',
paddingTop: 24
}
});
var _default = DialogIcon; // @component-docs ignore-next-line
exports.default = _default;
//# sourceMappingURL=DialogIcon.js.map
;