2025-02-04 11:13:04 -05:00
|
|
|
// components/ThemedText.tsx
|
|
|
|
import React from 'react';
|
|
|
|
import { Text, TextProps, StyleSheet } from 'react-native';
|
|
|
|
import { useAppearance } from '@/contexts/AppearanceContext';
|
2025-02-01 21:07:25 -05:00
|
|
|
|
2025-02-04 11:13:04 -05:00
|
|
|
export type TextType = 'default' | 'title' | 'subtitle' | 'link' | 'error';
|
2025-02-01 21:07:25 -05:00
|
|
|
|
2025-02-04 11:13:04 -05:00
|
|
|
interface ThemedTextProps extends TextProps {
|
|
|
|
type?: TextType;
|
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
2025-02-01 21:07:25 -05:00
|
|
|
|
2025-02-04 11:13:04 -05:00
|
|
|
export function ThemedText({
|
|
|
|
style,
|
|
|
|
type = 'default',
|
|
|
|
children,
|
|
|
|
...props
|
2025-02-01 21:07:25 -05:00
|
|
|
}: ThemedTextProps) {
|
2025-02-04 11:13:04 -05:00
|
|
|
const { colors } = useAppearance();
|
|
|
|
|
|
|
|
const baseStyle = { color: colors.text };
|
|
|
|
const typeStyle = styles[type] || {};
|
|
|
|
|
|
|
|
if (type === 'link') {
|
|
|
|
baseStyle.color = colors.primary;
|
|
|
|
} else if (type === 'error') {
|
|
|
|
baseStyle.color = 'red';
|
|
|
|
}
|
2025-02-01 21:07:25 -05:00
|
|
|
|
|
|
|
return (
|
2025-02-04 11:13:04 -05:00
|
|
|
<Text
|
|
|
|
style={[baseStyle, typeStyle, style]}
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Text>
|
2025-02-01 21:07:25 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
default: {
|
|
|
|
fontSize: 16,
|
|
|
|
},
|
|
|
|
title: {
|
2025-02-04 11:13:04 -05:00
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: '600',
|
2025-02-01 21:07:25 -05:00
|
|
|
},
|
|
|
|
subtitle: {
|
2025-02-04 11:13:04 -05:00
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: '500',
|
2025-02-01 21:07:25 -05:00
|
|
|
},
|
|
|
|
link: {
|
|
|
|
fontSize: 16,
|
2025-02-04 11:13:04 -05:00
|
|
|
textDecorationLine: 'underline',
|
|
|
|
},
|
|
|
|
error: {
|
|
|
|
fontSize: 14,
|
2025-02-01 21:07:25 -05:00
|
|
|
},
|
2025-02-04 11:13:04 -05:00
|
|
|
});
|