Finish cleaning up theme stuff

This commit is contained in:
Gabriel Brown 2025-03-04 23:58:53 -06:00
parent 4775917db0
commit 4e93893319
14 changed files with 49 additions and 90 deletions

View File

@ -1,7 +0,0 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit",
"source.sortMembers": "explicit"
}
}

0
assets/fonts/SpaceMono-Regular.ttf Executable file → Normal file
View File

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { StyleSheet, Pressable, PressableProps } from 'react-native'; import { StyleSheet, Pressable, PressableProps } from 'react-native';
import { ThemedView } from '@/components/theme'; import ThemedView from '@/components/theme/default/ThemedView';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -24,7 +24,7 @@ const ThemedButton: React.FC<ThemedButtonProps> = ({
...restProps // This now includes onPress automatically ...restProps // This now includes onPress automatically
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<ThemedView <ThemedView
style={[ style={[
@ -37,12 +37,7 @@ const ThemedButton: React.FC<ThemedButtonProps> = ({
]} ]}
> >
<Pressable <Pressable
style={[ style={[styles.button, { backgroundColor: Colors[scheme].text }, buttonStyle, style]}
styles.button,
{ backgroundColor: Colors[scheme].text },
buttonStyle,
style,
]}
{...restProps} // This passes onPress and all other Pressable props {...restProps} // This passes onPress and all other Pressable props
> >
{children} {children}

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { TextStyle, PressableProps } from 'react-native'; import { TextStyle, PressableProps } from 'react-native';
import { ThemedButton, ThemedText } from '@/components/theme'; import ThemedButton from '@/components/theme/buttons/ThemedButton';
import ThemedText from '@/components/theme/default/ThemedText';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -28,10 +29,10 @@ const ThemedTextButton: React.FC<ThemedTextButtonProps> = ({
...restProps // This includes onPress and all other Pressable props ...restProps // This includes onPress and all other Pressable props
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<ThemedButton <ThemedButton
width={width} width={width}
height={height} height={height}
containerStyle={containerStyle} containerStyle={containerStyle}
buttonStyle={buttonStyle} buttonStyle={buttonStyle}

View File

@ -1,7 +1,8 @@
import React from 'react'; import React from 'react';
import { StyleSheet, ViewProps, View, DimensionValue } from 'react-native'; import { StyleSheet, ViewProps, DimensionValue } from 'react-native';
import ThemedView from '@/components/theme/default/ThemedView';
import ThemedTextInput from '@/components/theme/inputs/ThemedTextInput';
import { Ionicons } from '@expo/vector-icons'; import { Ionicons } from '@expo/vector-icons';
import { ThemedTextInput } from '@/components/theme';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -23,15 +24,10 @@ const ThemedSearchBar: React.FC<ThemedSearchBarProps> = ({
...restProps ...restProps
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<View style={[styles.container, { width }, style]} {...restProps}> <ThemedView style={[styles.container, { width }, style]} {...restProps}>
<Ionicons <Ionicons name='search' size={20} color={Colors[scheme].text} style={styles.icon} />
name="search"
size={20}
color={Colors[scheme].text}
style={styles.icon}
/>
<ThemedTextInput <ThemedTextInput
placeholder={placeholder} placeholder={placeholder}
value={value} value={value}
@ -40,7 +36,7 @@ const ThemedSearchBar: React.FC<ThemedSearchBarProps> = ({
width={width} width={width}
style={styles.input} style={styles.input}
/> />
</View> </ThemedView>
); );
}; };

View File

@ -5,16 +5,14 @@ import { useColorScheme } from '@/hooks/useColorScheme';
type ThemedSwitchProps = SwitchProps; type ThemedSwitchProps = SwitchProps;
const ThemedSwitch: React.FC<ThemedSwitchProps> = ({ const ThemedSwitch: React.FC<ThemedSwitchProps> = ({ ...props }) => {
...props
}) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<Switch <Switch
trackColor={{ trackColor={{
false: Colors[scheme].border, false: Colors[scheme].border,
true: Colors[scheme].tint + '80' true: Colors[scheme].tint + '80',
}} }}
thumbColor={props.value ? Colors[scheme].tint : Colors[scheme].card} thumbColor={props.value ? Colors[scheme].tint : Colors[scheme].card}
ios_backgroundColor={Colors[scheme].border} ios_backgroundColor={Colors[scheme].border}

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { StyleSheet, TextInput, TextInputProps, DimensionValue } from 'react-native'; import { StyleSheet, TextInput, TextInputProps, DimensionValue } from 'react-native';
import { ThemedView } from '@/components/theme'; import ThemedView from '@/components/theme/default/ThemedView';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -9,7 +9,7 @@ const DEFAULT_HEIGHT = 50;
type ThemedTextInputProps = TextInputProps & { type ThemedTextInputProps = TextInputProps & {
width?: DimensionValue; width?: DimensionValue;
height?: DimensionValue height?: DimensionValue;
containerStyle?: object; containerStyle?: object;
}; };
@ -21,19 +21,13 @@ const ThemedTextInput: React.FC<ThemedTextInputProps> = ({
...restProps ...restProps
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<ThemedView <ThemedView style={[styles.inputContainer, { width, height }, containerStyle]}>
style={[
styles.inputContainer,
{ width, height },
containerStyle,
]}
>
<TextInput <TextInput
style={[ style={[
styles.input, styles.input,
{ {
color: Colors[scheme].text, color: Colors[scheme].text,
backgroundColor: Colors[scheme].background, backgroundColor: Colors[scheme].background,
}, },

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { StyleSheet, Image, ImageProps, View } from 'react-native'; import { StyleSheet, Image, ImageProps, View } from 'react-native';
import { ThemedText } from '@/components/theme'; import ThemedText from '@/components/theme/default/ThemedText';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -23,20 +23,20 @@ const ThemedAvatar: React.FC<ThemedAvatarProps> = ({
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
const border = borderColor || Colors[scheme].tint; const border = borderColor || Colors[scheme].tint;
// Get initials from name // Get initials from name
const getInitials = (name?: string) => { const getInitials = (name?: string) => {
if (!name) return ''; if (!name) return '';
return name return name
.split(' ') .split(' ')
.map(part => part[0]) .map((part) => part[0])
.join('') .join('')
.toUpperCase() .toUpperCase()
.substring(0, 2); .substring(0, 2);
}; };
const initials = getInitials(name); const initials = getInitials(name);
return ( return (
<View <View
style={[ style={[

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { StyleSheet, ViewProps } from 'react-native'; import { StyleSheet, ViewProps } from 'react-native';
import { ThemedView, ThemedText } from '@/components/theme'; import ThemedText from '@/components/theme/default/ThemedText';
import ThemedView from '@/components/theme/default/ThemedView';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -22,7 +23,7 @@ const ThemedBadge: React.FC<ThemedBadgeProps> = ({
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
const badgeColor = color || Colors[scheme].tint; const badgeColor = color || Colors[scheme].tint;
const badgeTextColor = textColor || Colors[scheme].background; const badgeTextColor = textColor || Colors[scheme].background;
return ( return (
<ThemedView <ThemedView
style={[ style={[
@ -37,12 +38,7 @@ const ThemedBadge: React.FC<ThemedBadgeProps> = ({
]} ]}
{...restProps} {...restProps}
> >
<ThemedText <ThemedText style={[styles.text, { color: badgeTextColor, fontSize: size * 0.5 }]}>
style={[
styles.text,
{ color: badgeTextColor, fontSize: size * 0.5 }
]}
>
{value} {value}
</ThemedText> </ThemedText>
</ThemedView> </ThemedView>

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { StyleSheet, ViewProps, Platform, DimensionValue } from 'react-native'; import { StyleSheet, ViewProps, Platform, DimensionValue } from 'react-native';
import { ThemedView } from '@/components/theme'; import ThemedView from '@/components/theme/default/ThemedView';
import { Colors } from '@/constants/Colors'; import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme'; import { useColorScheme } from '@/hooks/useColorScheme';
@ -23,7 +23,7 @@ const ThemedCard: React.FC<ThemedCardProps> = ({
...restProps ...restProps
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
return ( return (
<ThemedView <ThemedView
style={[ style={[
@ -37,7 +37,7 @@ const ThemedCard: React.FC<ThemedCardProps> = ({
...Platform.select({ ...Platform.select({
ios: { ios: {
shadowColor: Colors[scheme].text, shadowColor: Colors[scheme].text,
shadowOffset: { width: 0, height: elevation/2 }, shadowOffset: { width: 0, height: elevation / 2 },
shadowOpacity: 0.1, shadowOpacity: 0.1,
shadowRadius: elevation, shadowRadius: elevation,
}, },

View File

@ -5,8 +5,8 @@ import { useColorScheme } from '@/hooks/useColorScheme';
type ThemedDividerProps = ViewProps & { type ThemedDividerProps = ViewProps & {
orientation?: 'horizontal' | 'vertical'; orientation?: 'horizontal' | 'vertical';
thickness?: DimensionValue thickness?: DimensionValue;
length?: DimensionValue length?: DimensionValue;
color?: string; color?: string;
}; };
@ -19,12 +19,12 @@ const ThemedDivider: React.FC<ThemedDividerProps> = ({
}) => { }) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
const color = restProps.color || Colors[scheme].border; const color = restProps.color || Colors[scheme].border;
return ( return (
<View <View
style={[ style={[
orientation === 'horizontal' orientation === 'horizontal'
? { height: thickness, width: length } ? { height: thickness, width: length }
: { width: thickness, height: length }, : { width: thickness, height: length },
{ backgroundColor: color }, { backgroundColor: color },
style, style,

View File

@ -10,25 +10,11 @@ type ThemedIconProps = ViewProps & {
color?: string; color?: string;
}; };
const ThemedIcon: React.FC<ThemedIconProps> = ({ const ThemedIcon: React.FC<ThemedIconProps> = ({ name, size = 24, color, style, ...restProps }) => {
name,
size = 24,
color,
style,
...restProps
}) => {
const scheme = useColorScheme() ?? 'dark'; const scheme = useColorScheme() ?? 'dark';
const iconColor = color || Colors[scheme].text; const iconColor = color || Colors[scheme].text;
return ( return <Ionicons name={name} size={size} color={iconColor} style={style} {...restProps} />;
<Ionicons
name={name}
size={size}
color={iconColor}
style={style}
{...restProps}
/>
);
}; };
export default ThemedIcon; export default ThemedIcon;

View File

@ -16,7 +16,7 @@ export const Colors = {
icon: iconColorLight, icon: iconColorLight,
tabIconDefault: iconColorLight, tabIconDefault: iconColorLight,
tabIconSelected: tintColorLight, tabIconSelected: tintColorLight,
// New colors // New colors
card: '#ffffff', card: '#ffffff',
border: '#d0d7de', border: '#d0d7de',
@ -26,7 +26,7 @@ export const Colors = {
subtle: '#f6f8fa', subtle: '#f6f8fa',
error: '#e5484d', error: '#e5484d',
success: '#46954a', success: '#46954a',
warning: '#daaa3f' warning: '#daaa3f',
}, },
dark: { dark: {
text: light, text: light,
@ -35,7 +35,7 @@ export const Colors = {
icon: iconColorDark, icon: iconColorDark,
tabIconDefault: iconColorDark, tabIconDefault: iconColorDark,
tabIconSelected: tintColorDark, tabIconSelected: tintColorDark,
// New colors // New colors
card: '#3a3b4a', card: '#3a3b4a',
border: '#444c56', border: '#444c56',
@ -45,6 +45,6 @@ export const Colors = {
subtle: '#272934', subtle: '#272934',
error: '#ff6369', error: '#ff6369',
success: '#3fb950', success: '#3fb950',
warning: '#d29922' warning: '#d29922',
}, },
}; };

0
scripts/reset-project.js Executable file → Normal file
View File