@oxyhq/services
Version:
56 lines (55 loc) • 1.72 kB
JavaScript
;
import * as React from 'react';
import { Animated, I18nManager, StyleSheet } from 'react-native';
import { useInternalTheme } from "../theming.js";
import { forwardRef } from "../utils/forwardRef.js";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Animated text component which follows styles from the theme.
*
* @extends Text props https://reactnative.dev/docs/text#props
*/
const AnimatedText = forwardRef(function AnimatedText({
style,
theme: themeOverrides,
variant,
...rest
}, ref) {
const theme = useInternalTheme(themeOverrides);
const writingDirection = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';
if (theme.isV3 && variant) {
const font = theme.fonts[variant];
if (typeof font !== 'object') {
throw new Error(`Variant ${variant} was not provided properly. Valid variants are ${Object.keys(theme.fonts).join(', ')}.`);
}
return /*#__PURE__*/_jsx(Animated.Text, {
ref: ref,
...rest,
style: [font, styles.text, {
writingDirection,
color: theme.colors.onSurface
}, style]
});
} else {
const font = !theme.isV3 ? theme.fonts.regular || theme.fonts.default : theme.fonts.bodyMedium;
const textStyle = {
...font,
color: theme.isV3 ? theme.colors.onSurface : theme.colors.text || theme.colors.onSurface
};
return /*#__PURE__*/_jsx(Animated.Text, {
ref: ref,
...rest,
style: [styles.text, textStyle, {
writingDirection
}, style]
});
}
});
const styles = StyleSheet.create({
text: {
textAlign: 'left'
}
});
export const customAnimatedText = () => AnimatedText;
export default AnimatedText;
//# sourceMappingURL=AnimatedText.js.map