UNPKG

@eslam-elmeniawy/react-native-common-components

Version:

Common `ReactNative` components packed in library for usage in projects.

98 lines (93 loc) 2.4 kB
"use strict"; // External imports. import * as React from 'react'; import { StyleSheet } from 'react-native'; import { withTheme, Text as PaperText } from 'react-native-paper'; // Types imports. // Internal imports. import ResponsiveDimensions from "../../utils/ResponsiveDimensions.js"; /** * Text component (unwrapped, for testing) * Renders text with responsive sizing and theme support * @internal For testing purposes only. Do not use in production code. */ import { jsx as _jsx } from "react/jsx-runtime"; export const TextComponent = /*#__PURE__*/React.memo(props => { const { size, type, variant, style, children, theme, ...other } = props; const _calculateTextSize = () => { switch (type) { case 'caption': return ResponsiveDimensions.ms(11); case 'bold': return ResponsiveDimensions.ms(15); default: return ResponsiveDimensions.ms(13); } }; const _calculateFontSize = () => { if (size) { return ResponsiveDimensions.ms(size); } if (variant && theme.isV3) { return theme.fonts[variant].fontSize; } return _calculateTextSize(); }; const _fontSize = _calculateFontSize(); const _calculateLineHeight = () => { if (variant && theme.isV3) { return theme.fonts[variant].lineHeight; } return _fontSize * 2; }; const _textStyle = StyleSheet.flatten([{ fontSize: _fontSize, lineHeight: _calculateLineHeight() }, style]); if (variant) { return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: variant, ...other, children: children }); } switch (type) { case 'caption': return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "bodySmall", ...other, children: children }); case 'bold': return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "titleLarge", ...other, children: children }); default: return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "bodyMedium", ...other, children: children }); } }); TextComponent.displayName = 'TextComponent'; /** * Text component (wrapped with theme, for production) */ const Text = withTheme(TextComponent); export default Text; //# sourceMappingURL=Text.js.map