eletrotupi / tcc/ frontend/components/ui/Cards.tsxd514519d4f8fe5f8547a2f8b0c67f21e790b7480
2.3 KB | 105 lines Raw
1
import React from 'react';
2
import {
3
  View,
4
  StyleSheet,
5
  Pressable,
6
  ViewStyle,
7
  Text
8
} from 'react-native';
9

10
import { Colors, Typography, Spacing, BorderRadius, Shadows } from '@/constants/theme';
11
import { useThemeColor } from '@/hooks/use-theme-color';
12
import { ThemedText } from '@/components/misc/themed-text'
13
import { Ionicons } from '@expo/vector-icons';
14

15
interface CardProps {
16
  children: React.ReactNode;
17
  onPress?: () => void;
18
  variant?: 'default' | 'highlighted';
19
  style?: ViewStyle;
20
}
21

22
export const Card: React.FC<CardProps> = ({
23
  children,
24
  onPress,
25
  variant = 'default',
26
  style,
27
}) => {
28
  const isHighlighted = variant === 'highlighted';
29

30
  const surfaceColor = useThemeColor({}, 'surface');
31
  const cardBorderColor = useThemeColor({}, 'cardBorder');
32
  const accentBlueColor = useThemeColor({}, 'accentBlue');
33

34
  const styles = StyleSheet.create({
35
    card: {
36
      backgroundColor: surfaceColor,
37
      borderRadius: BorderRadius.lg,
38
      borderWidth: 1,
39
      borderColor: cardBorderColor,
40
      padding: Spacing.internalPadding,
41
      marginBottom: Spacing.cardGap,
42
      ...(isHighlighted && {
43
        backgroundColor: accentBlueColor,
44
        borderColor: 'transparent',
45
      }),
46
      ...Shadows.sm,
47
    },
48
  });
49

50
  return (
51
    <Pressable
52
      onPress={onPress}
53
      disabled={!onPress}
54
      style={({ pressed }) => [
55
        styles.card,
56
        pressed && onPress && {
57
          opacity: 0.8,
58
        },
59
        style,
60
      ]}
61
    >
62
      {children}
63
    </Pressable>
64
  );
65
};
66

67
interface SubtleInfoCardProps {
68
  text: string;
69
  style?: ViewStyle;
70
};
71

72
export const SubtleInfoCard: React.FC<SubtleInfoCardProps> = ({
73
  text,
74
  style
75
}) => {
76
  const accentBlueColor = useThemeColor({}, 'accentBlue');
77

78
  const styles = StyleSheet.create({
79
    card: {
80
      backgroundColor: accentBlueColor,
81
      borderRadius: BorderRadius.lg,
82
      padding: Spacing.cardGap,
83
      marginBottom: Spacing.cardGap,
84
      flex: 1,
85
      flexDirection: 'row',
86
      alignItems: 'top'
87
    },
88
    text: {
89
      fontSize: 12,
90
      lineHeight: 18,
91
      color: Colors.light.textSecondary,
92
      marginLeft: 10
93
    },
94
  });
95

96
  return (
97
    <View style={[styles.card, style]}>
98
      <Ionicons name="information-circle-outline" size={20} color="gray" />
99

100
      <Text style={styles.text}>
101
        {text.replace(/\s+/g, ' ').trim()}
102
      </Text>
103
    </View>
104
  )
105
}