import React from "react"; import { StyleSheet, Text, View } from "react-native"; import { Image } from "expo-image"; import { ContentMediaGallery } from "../../media/ContentMediaGallery"; import { useRelationalContentMedia } from "../../media/ContentMediaContext"; import { asString } from "../helpers/value"; import type { ContentMediaItem } from "../../types/media.types"; export function ImageGallery({ images }: { images: Record[] }) { const relationalMedia = useRelationalContentMedia(); if (relationalMedia.length > 0) { return ; } const visible = images.filter((item) => asString(item.image_path).trim().length > 0); if (!visible.length) return null; const fallbackMedia: ContentMediaItem[] = visible.map((item, index) => { const path = asString(item.image_path).trim(); const name = asString(item.image_name).trim(); return { id: `${path}-${index}`, media_asset_id: `${path}-${index}`, media_role: index === 0 ? "primary" : "gallery", usage_type: "visual_reference", sort_order: index, caption: name || null, alt_text: name || "Module image", mime_type: "image/jpeg", width: null, height: null, url: path, storage_key: null, requires_auth: false, }; }); return ; } const styles = StyleSheet.create({ root: { gap: 14 }, item: { gap: 7 }, imageFrame: { overflow: "hidden", borderRadius: 18, backgroundColor: "#F4F7F5", borderWidth: 1, borderColor: "#DDE7E1", }, image: { width: "100%", height: 270 }, caption: { fontSize: 13, lineHeight: 19, color: "#64748B", textAlign: "center", }, });