import React from "react"; import { Pressable, StyleSheet, Text, View } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { moderateScale, verticalScale } from "react-native-size-matters"; import { Colors } from "@/theme"; import { asNumber, asString, humanizeKey } from "../helpers/value"; import { CollectionScaffold } from "../shared/CollectionScaffold"; import { ContentCountBadge } from "../shared/ContentCountBadge"; import type { CollectionItemRendererProps, CollectionRendererProps, } from "../../types/renderer.types"; export function ModuleCatalogCollectionRenderer(props: CollectionRendererProps) { return ; } export function ModuleCatalogCardRenderer({ item, onPress, }: CollectionItemRendererProps) { const attributes = item.attributes; const rawTitle = asString(attributes.name) || item.title; const parenMatch = rawTitle.match(/^(.*?)\s*\(([^()]+)\)\s*(.*?)$/); const title = parenMatch ? [parenMatch[1], parenMatch[3]].filter(Boolean).join(" ").trim() : rawTitle; const parenSubtitle = parenMatch ? parenMatch[2].trim() : null; const rawLabel = parenSubtitle || asString(attributes.sub_title) || asString(attributes.pattern_category) || asString(attributes.category) || asString(attributes.classification) || (asString(attributes.title) && asString(attributes.title) !== title ? asString(attributes.title) : null) || asString(attributes.description) || item.summary || null; const cleanTitle = humanizeKey(title); const label = rawLabel ? humanizeKey(rawLabel) : null; return ( [styles.row, pressed && styles.pressed]} > {cleanTitle} {label ? ( {label} ) : null} ); } const styles = StyleSheet.create({ row: { minHeight: moderateScale(68), flexDirection: "row", alignItems: "center", padding: moderateScale(14), }, pressed: { opacity: 0.72, }, iconWrapper: { width: moderateScale(40), height: moderateScale(40), borderRadius: moderateScale(20), justifyContent: "center", alignItems: "center", backgroundColor: "#E8F5E9", }, textContainer: { flex: 1, marginLeft: moderateScale(12), marginRight: moderateScale(10), }, title: { fontSize: moderateScale(15), fontWeight: "600", color: Colors.textPrimary, marginBottom: verticalScale(2), }, description: { fontSize: moderateScale(12), color: Colors.textSecondary, }, });