eletrotupi / tcc/ frontend/components/ui/Cards.tsx2cac61aec19417cac5972c03ed16933d7f291846
1.4 KB | 63 lines Raw
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 { ThemedText } from '@/components/misc/themed-text'
12

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

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

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

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

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