Render subtitle generically in EOV and module catalog cards
This commit is contained in:
parent
7289125e91
commit
dc1659b44a
|
|
@ -14,9 +14,16 @@ export function EovCollectionRenderer(props: CollectionRendererProps) {
|
||||||
}
|
}
|
||||||
export function EovIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
export function EovIndexCardRenderer({ item, onPress }: CollectionItemRendererProps) {
|
||||||
const a = item.attributes;
|
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 (
|
return (
|
||||||
<StandardIndexCard
|
<StandardIndexCard
|
||||||
title={asString(a.name) || item.title}
|
title={asString(a.name) || item.title}
|
||||||
|
subtitle={subtitle}
|
||||||
count={asNumber(a.content_count)}
|
count={asNumber(a.content_count)}
|
||||||
countLabel={asString(a.content_label) || null}
|
countLabel={asString(a.content_label) || null}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { Ionicons } from "@expo/vector-icons";
|
||||||
import { moderateScale, verticalScale } from "react-native-size-matters";
|
import { moderateScale, verticalScale } from "react-native-size-matters";
|
||||||
|
|
||||||
import { Colors } from "@/theme";
|
import { Colors } from "@/theme";
|
||||||
import { asNumber, asString } from "../helpers/value";
|
import { asNumber, asString, asStringArray } from "../helpers/value";
|
||||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||||
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -22,6 +22,13 @@ export function ModuleCatalogCardRenderer({
|
||||||
}: CollectionItemRendererProps) {
|
}: CollectionItemRendererProps) {
|
||||||
const attributes = item.attributes;
|
const attributes = item.attributes;
|
||||||
const title = asString(attributes.name) || item.title;
|
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 (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
|
@ -35,6 +42,11 @@ export function ModuleCatalogCardRenderer({
|
||||||
|
|
||||||
<View style={styles.textContainer}>
|
<View style={styles.textContainer}>
|
||||||
<Text style={styles.title}>{title}</Text>
|
<Text style={styles.title}>{title}</Text>
|
||||||
|
{subtitle ? (
|
||||||
|
<Text numberOfLines={2} style={styles.subtitle}>
|
||||||
|
{subtitle}
|
||||||
|
</Text>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ContentCountBadge
|
<ContentCountBadge
|
||||||
|
|
@ -74,4 +86,10 @@ const styles = StyleSheet.create({
|
||||||
fontWeight: "600",
|
fontWeight: "600",
|
||||||
color: Colors.textPrimary,
|
color: Colors.textPrimary,
|
||||||
},
|
},
|
||||||
|
subtitle: {
|
||||||
|
fontSize: moderateScale(12),
|
||||||
|
color: Colors.textSecondary,
|
||||||
|
marginTop: verticalScale(2),
|
||||||
|
lineHeight: moderateScale(16),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue