UNPKG

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

Version:

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

80 lines (77 loc) 2.28 kB
"use strict"; // External imports. import * as React from 'react'; import { StyleSheet } from 'react-native'; import { withTheme, Text as PaperText, Title, Caption } from 'react-native-paper'; // Types imports. // Internal imports. import ResponsiveDimensions from "../../utils/ResponsiveDimensions.js"; import { jsx as _jsx } from "react/jsx-runtime"; const Text = /*#__PURE__*/React.memo(props => { const { size, type, variant, style, children, theme, ...other } = props; let _textSize = 13; switch (type) { case 'caption': _textSize = 11; break; case 'bold': _textSize = 15; break; default: _textSize = 13; break; } const _textStyle = StyleSheet.flatten([{ fontSize: (size == null || size === undefined) && (variant == null || variant === undefined) ? ResponsiveDimensions.ms(_textSize) : size ? ResponsiveDimensions.ms(size) : variant && theme.isV3 ? theme.fonts[variant].fontSize : undefined, lineHeight: (size == null || size === undefined) && (variant == null || variant === undefined) ? ResponsiveDimensions.ms(_textSize) * 2 : size ? ResponsiveDimensions.ms(size) * 2 : variant && theme.isV3 ? theme.fonts[variant].lineHeight : undefined }, style]); if (variant) { return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: variant, ...other, children: children }); } switch (type) { case 'caption': return theme.isV3 ? /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "bodySmall", ...other, children: children }) : /*#__PURE__*/_jsx(Caption, { style: _textStyle, ...other, children: children }); case 'bold': return theme.isV3 ? /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "titleMedium", ...other, children: children }) : /*#__PURE__*/_jsx(Title, { style: _textStyle, ...other, children: children }); default: return /*#__PURE__*/_jsx(PaperText, { style: _textStyle, variant: "bodyMedium", ...other, children: children }); } }); export default withTheme(Text); //# sourceMappingURL=Text.js.map