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

45 lines
1.7 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 { ChipList } from "../shared/ChipList";
import { StandardIndexCard } from "../shared/StandardIndexCard";
import type { CollectionItemRendererProps, CollectionRendererProps } from "../../types/renderer.types";
export function EovIndexCollectionRenderer(props: CollectionRendererProps) {
return <CollectionScaffold {...props} />;
}
export function EovCollectionRenderer(props: CollectionRendererProps) {
return <CollectionScaffold {...props} />;
}
export function EovIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
const a = item.attributes;
const subtitle =
asString(a.sub_title) ||
asString(a.subtitle) ||
(asStringArray(a.alt_name).length > 0 ? asStringArray(a.alt_name).join(", ") : asString(a.alt_name)) ||
null;
return (
<StandardIndexCard
title={asString(a.name) || item.title}
subtitle={subtitle}
count={asNumber(a.content_count)}
countLabel={asString(a.content_label) || null}
onPress={onPress}
/>
);
}
export function EovCardRenderer({ item, onPress }: CollectionItemRendererProps) {
const a = item.attributes;
return (
<Pressable onPress={onPress}>
<View style={{ padding: 14, gap: 6 }}>
<Text style={{ fontSize: 17, fontWeight: "700" }}>{asString(a.name) || item.title}</Text>
<ChipList items={asStringArray(a.alt_name)} />
<Text>Master: {asString(a.master_point)} · Paired: {asString(a.paired_meridian)}</Text>
</View>
</Pressable>
);
}