acupedia-mobile-ui/src/features/content/renderers/GenericCardRenderer.tsx

53 lines
1.3 KiB
TypeScript

import React from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { Colors } from "@/theme";
import type { CollectionItemRendererProps } from "../types/renderer.types";
/** Safe, schema-agnostic fallback for collection items. */
export function GenericCardRenderer({ item, onPress }: CollectionItemRendererProps) {
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={`Open ${item.title}`}
onPress={onPress}
style={({ pressed }) => [styles.pressable, pressed && styles.pressed]}
>
<View style={styles.card}>
<Text style={styles.title}>{item.title || "Untitled content"}</Text>
{item.summary ? <Text style={styles.summary}>{item.summary}</Text> : null}
</View>
</Pressable>
);
}
const styles = StyleSheet.create({
pressable: {
marginHorizontal: 16,
marginVertical: 5,
},
pressed: {
opacity: 0.72,
},
card: {
paddingHorizontal: 16,
paddingVertical: 14,
borderRadius: 14,
borderWidth: 1,
borderColor: "#DDE7E1",
backgroundColor: "#FFFFFF",
},
title: {
fontSize: 17,
lineHeight: 23,
fontWeight: "700",
color: Colors.textPrimary,
},
summary: {
marginTop: 5,
fontSize: 14,
lineHeight: 20,
color: Colors.textSecondary,
},
});