Render subtitle generically in EOV and module catalog cards

This commit is contained in:
ShivaniKhaire 2026-10-23 10:47:20 +05:30
parent 7289125e91
commit dc1659b44a
2 changed files with 26 additions and 1 deletions

View File

@ -14,9 +14,16 @@ export function EovCollectionRenderer(props: CollectionRendererProps) {
}
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}

View File

@ -4,7 +4,7 @@ import { Ionicons } from "@expo/vector-icons";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import { asNumber, asString } from "../helpers/value";
import { asNumber, asString, asStringArray } from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold";
import { ContentCountBadge } from "../shared/ContentCountBadge";
import type {
@ -22,6 +22,13 @@ export function ModuleCatalogCardRenderer({
}: CollectionItemRendererProps) {
const attributes = item.attributes;
const title = asString(attributes.name) || item.title;
const subtitle =
asString(attributes.sub_title) ||
asString(attributes.subtitle) ||
(asStringArray(attributes.alt_name).length > 0
? asStringArray(attributes.alt_name).join(", ")
: asString(attributes.alt_name)) ||
null;
return (
<Pressable
@ -35,6 +42,11 @@ export function ModuleCatalogCardRenderer({
<View style={styles.textContainer}>
<Text style={styles.title}>{title}</Text>
{subtitle ? (
<Text numberOfLines={2} style={styles.subtitle}>
{subtitle}
</Text>
) : null}
</View>
<ContentCountBadge
@ -74,4 +86,10 @@ const styles = StyleSheet.create({
fontWeight: "600",
color: Colors.textPrimary,
},
subtitle: {
fontSize: moderateScale(12),
color: Colors.textSecondary,
marginTop: verticalScale(2),
lineHeight: moderateScale(16),
},
});