acupedia-mobile-ui/src/features/content/renderers/collections/MeridianRenderers.tsx

36 lines
1.3 KiB
TypeScript

import React from "react";
import { Pressable, Text, View } from "react-native";
import { asNumber, asString, asStringArray } from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold";
import { StandardIndexCard } from "../shared/StandardIndexCard";
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
export function MeridianIndexCollectionRenderer(props: CollectionRendererProps) {
return <CollectionScaffold {...props} />;
}
export function MeridianCollectionRenderer(props: CollectionRendererProps) {
return <CollectionScaffold {...props} />;
}
export function MeridianIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
const a = item.attributes;
return (
<StandardIndexCard
title={asString(a.name) || item.title}
count={asNumber(a.content_count)}
onPress={onPress}
/>
);
}
export function MeridianCardRenderer({ item, onPress }: CollectionItemRendererProps) {
const a = item.attributes;
return (
<Pressable onPress={onPress}>
<View style={{ padding: 14, gap: 5 }}>
<Text style={{ fontSize: 17, fontWeight: "700" }}>{asString(a.title) || item.title}</Text>
<Text>{asString(a.name)}</Text>
<Text>{asStringArray(a.point_codes).length} referenced points</Text>
</View>
</Pressable>
);
}