| 1 | import React from 'react';
|
| 2 | import {
|
| 3 | View,
|
| 4 | StyleSheet,
|
| 5 | Pressable,
|
| 6 | ViewStyle,
|
| 7 | } from 'react-native';
|
| 8 |
|
| 9 | import { Colors, Typography, Spacing, BorderRadius, Shadows } from '@/constants/theme';
|
| 10 | import { useThemeColor } from '@/hooks/use-theme-color';
|
| 11 | import { Text } from '@/components/ui/Text'
|
| 12 | import { Ionicons } from '@expo/vector-icons';
|
| 13 |
|
| 14 | interface CardProps {
|
| 15 | children: React.ReactNode;
|
| 16 | onPress?: () => void;
|
| 17 | variant?: 'default' | 'highlighted';
|
| 18 | style?: ViewStyle;
|
| 19 | }
|
| 20 |
|
| 21 | export const Card: React.FC<CardProps> = ({
|
| 22 | children,
|
| 23 | onPress,
|
| 24 | variant = 'default',
|
| 25 | style,
|
| 26 | }) => {
|
| 27 | const isHighlighted = variant === 'highlighted';
|
| 28 |
|
| 29 | const surfaceColor = useThemeColor({}, 'surface');
|
| 30 | const cardBorderColor = useThemeColor({}, 'cardBorder');
|
| 31 | const accentBlueColor = useThemeColor({}, 'accentBlue');
|
| 32 |
|
| 33 | const styles = StyleSheet.create({
|
| 34 | card: {
|
| 35 | backgroundColor: surfaceColor,
|
| 36 | borderRadius: BorderRadius.lg,
|
| 37 | borderWidth: 1,
|
| 38 | borderColor: cardBorderColor,
|
| 39 | padding: Spacing.internalPadding,
|
| 40 | marginBottom: Spacing.cardGap,
|
| 41 | ...(isHighlighted && {
|
| 42 | backgroundColor: accentBlueColor,
|
| 43 | borderColor: 'transparent',
|
| 44 | }),
|
| 45 | ...Shadows.sm,
|
| 46 | },
|
| 47 | });
|
| 48 |
|
| 49 | return (
|
| 50 | <Pressable
|
| 51 | onPress={onPress}
|
| 52 | disabled={!onPress}
|
| 53 | style={({ pressed }) => [
|
| 54 | styles.card,
|
| 55 | pressed && onPress && {
|
| 56 | opacity: 0.8,
|
| 57 | },
|
| 58 | style,
|
| 59 | ]}
|
| 60 | >
|
| 61 | {children}
|
| 62 | </Pressable>
|
| 63 | );
|
| 64 | };
|
| 65 |
|
| 66 | interface SubtleInfoCardProps {
|
| 67 | text: string;
|
| 68 | style?: ViewStyle;
|
| 69 | };
|
| 70 |
|
| 71 | export const SubtleInfoCard: React.FC<SubtleInfoCardProps> = ({
|
| 72 | text,
|
| 73 | style
|
| 74 | }) => {
|
| 75 | const accentBlueColor = useThemeColor({}, 'accentBlue');
|
| 76 |
|
| 77 | const styles = StyleSheet.create({
|
| 78 | card: {
|
| 79 | backgroundColor: accentBlueColor,
|
| 80 | borderRadius: BorderRadius.lg,
|
| 81 | padding: Spacing.cardGap,
|
| 82 | marginBottom: Spacing.cardGap,
|
| 83 | flex: 1,
|
| 84 | flexDirection: 'row',
|
| 85 | alignItems: 'top'
|
| 86 | },
|
| 87 | text: {
|
| 88 | fontSize: 12,
|
| 89 | lineHeight: 18,
|
| 90 | color: Colors.light.textSecondary,
|
| 91 | marginLeft: 10
|
| 92 | },
|
| 93 | });
|
| 94 |
|
| 95 | return (
|
| 96 | <View style={[styles.card, style]}>
|
| 97 | <Ionicons name="information-circle-outline" size={20} color="gray" />
|
| 98 |
|
| 99 | <Text style={styles.text}>
|
| 100 | {text.replace(/\s+/g, ' ').trim()}
|
| 101 | </Text>
|
| 102 | </View>
|
| 103 | )
|
| 104 | }
|