Fix color schemes!
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { StyleSheet, Text, type TextProps } from 'react-native';
|
||||
|
||||
import { useThemeColor } from '@/hooks/useThemeColor';
|
||||
import { useTheme } from 'react-native-paper';
|
||||
|
||||
export type ThemedTextProps = TextProps & {
|
||||
lightColor?: string;
|
||||
@@ -15,17 +14,24 @@ export function ThemedText({
|
||||
type = 'default',
|
||||
...rest
|
||||
}: ThemedTextProps) {
|
||||
const color = useThemeColor({ light: lightColor, dark: darkColor }, 'text');
|
||||
const theme = useTheme();
|
||||
|
||||
// Only use override colors if provided
|
||||
let color = theme.colors.onSurface; // default
|
||||
if (lightColor || darkColor) {
|
||||
color = theme.dark ? (darkColor || lightColor || color) : (lightColor || darkColor || color);
|
||||
}
|
||||
|
||||
// Special case for link type
|
||||
if (type === 'link') {
|
||||
color = lightColor || darkColor || theme.colors.primary;
|
||||
}
|
||||
|
||||
return (
|
||||
<Text
|
||||
style={[
|
||||
{ color },
|
||||
type === 'default' ? styles.default : undefined,
|
||||
type === 'title' ? styles.title : undefined,
|
||||
type === 'defaultSemiBold' ? styles.defaultSemiBold : undefined,
|
||||
type === 'subtitle' ? styles.subtitle : undefined,
|
||||
type === 'link' ? styles.link : undefined,
|
||||
styles[type],
|
||||
style,
|
||||
]}
|
||||
{...rest}
|
||||
@@ -46,7 +52,7 @@ const styles = StyleSheet.create({
|
||||
title: {
|
||||
fontSize: 32,
|
||||
fontWeight: 'bold',
|
||||
lineHeight: 32,
|
||||
lineHeight: 40,
|
||||
},
|
||||
subtitle: {
|
||||
fontSize: 20,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { View, type ViewProps } from 'react-native';
|
||||
|
||||
import { useThemeColor } from '@/hooks/useThemeColor';
|
||||
import { useTheme } from 'react-native-paper';
|
||||
|
||||
export type ThemedViewProps = ViewProps & {
|
||||
lightColor?: string;
|
||||
@@ -8,7 +8,8 @@ export type ThemedViewProps = ViewProps & {
|
||||
};
|
||||
|
||||
export function ThemedView({ style, lightColor, darkColor, ...otherProps }: ThemedViewProps) {
|
||||
const backgroundColor = useThemeColor({ light: lightColor, dark: darkColor }, 'background');
|
||||
const theme = useTheme();
|
||||
const backgroundColor = theme.colors.background;
|
||||
|
||||
return <View style={[{ backgroundColor }, style]} {...otherProps} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user