import React from "react"; import { StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { moderateScale, verticalScale } from "react-native-size-matters"; import { Colors } from "@/theme"; export interface OverviewCardProps { title?: string; icon?: keyof typeof Ionicons.glyphMap; iconColor?: string; iconSize?: number; text?: string | null; paragraphs?: Array; children?: React.ReactNode; style?: StyleProp; titleStyle?: StyleProp; textStyle?: StyleProp; } export function OverviewCard({ title = "Overview", icon = "information-circle", iconColor = Colors.primary, iconSize = moderateScale(20), text, paragraphs, children, style, titleStyle, textStyle, }: OverviewCardProps) { const filteredParagraphs = paragraphs?.filter( (p): p is string => typeof p === "string" && p.trim().length > 0, ); const hasText = typeof text === "string" && text.trim().length > 0; const hasParagraphs = Array.isArray(filteredParagraphs) && filteredParagraphs.length > 0; if (!hasText && !hasParagraphs && !children) { return null; } return ( {icon ? ( ) : null} {title} {hasText ? ( {text} ) : null} {hasParagraphs ? filteredParagraphs.map((para, index) => ( {para} )) : null} {children} ); } const styles = StyleSheet.create({ card: { backgroundColor: Colors.surface, borderRadius: moderateScale(12), padding: moderateScale(14), borderWidth: 1, borderColor: Colors.border, }, header: { flexDirection: "row", alignItems: "center", gap: moderateScale(8), marginBottom: verticalScale(8), }, title: { fontSize: moderateScale(16), fontWeight: "700", color: Colors.textPrimary, }, text: { fontSize: moderateScale(13), lineHeight: moderateScale(20), color: Colors.textSecondary, }, paragraph: { fontSize: moderateScale(13), lineHeight: moderateScale(20), color: Colors.textSecondary, marginTop: verticalScale(8), }, });