Points #78

Merged
amit merged 8 commits from Points into main 2026-10-26 02:19:52 +00:00
24 changed files with 414 additions and 187 deletions

View File

@ -5,6 +5,11 @@ import { router, useFocusEffect } from "expo-router";
import { moderateScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import {
type PageTone,
toneColors,
usePageTone,
} from "../../context/PageToneContext";
export interface ContentPageHeaderProps {
title: string;
@ -14,6 +19,8 @@ export interface ContentPageHeaderProps {
onTitlePress?: () => void;
titleAccessibilityLabel?: string;
onBack?: () => void;
tone?: PageTone;
titleColor?: string;
}
export function ContentPageHeader({
@ -24,7 +31,15 @@ export function ContentPageHeader({
onTitlePress,
titleAccessibilityLabel,
onBack,
tone,
titleColor,
}: ContentPageHeaderProps) {
const { tone: contextTone } = usePageTone();
const effectiveTone = tone || contextTone;
const resolvedTitleColor =
titleColor ||
(effectiveTone && toneColors[effectiveTone]?.title) ||
Colors.textPrimary;
useFocusEffect(
useCallback(() => {
if (!onBack) return;
@ -59,7 +74,7 @@ export function ContentPageHeader({
const titleContent = (
<View style={styles.titleContent}>
<Text numberOfLines={1} style={styles.title}>
<Text numberOfLines={1} style={[styles.title, { color: resolvedTitleColor }]}>
{title}
</Text>
{subtitle ? (

View File

@ -36,7 +36,7 @@ export const DivergentChannel = ({ data }: { data: Record<string, unknown> }) =>
export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => (
<SectionCard title="Luo-Connecting Channel">
<BulletList items={asStringArray(data.luo_connecting_channel)} />
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
<ObjectSections value={asRecord(data.luo_connecting_vessel)} withTopDivider />
</SectionCard>
);

View File

@ -0,0 +1,69 @@
import React, {
createContext,
useContext,
useState,
useEffect,
type PropsWithChildren,
} from "react";
import { Colors } from "@/theme";
export type PageTone = "purple" | "blue" | "green";
export interface ToneColorScheme {
accent: string;
soft: string;
border: string;
title: string;
}
export const toneColors: Record<PageTone, ToneColorScheme> = {
purple: {
accent: Colors.purple, // "#75649B"
soft: Colors.purpleSoft, // "#F6F3FA"
border: "#E8E2F2",
title: Colors.purple, // "#75649B"
},
blue: {
accent: Colors.blue, // "#4E7496"
soft: Colors.blueSoft, // "#F1F6FA"
border: "#DAE6F0",
title: Colors.blue, // "#4E7496"
},
green: {
accent: Colors.primary, // "#2E7D32"
soft: "#F2F8F4",
border: "#DCEADF",
title: Colors.primary, // "#2E7D32"
},
};
export interface PageToneContextType {
tone: PageTone;
setTone: (tone: PageTone) => void;
}
export const PageToneContext = createContext<PageToneContextType>({
tone: "green",
setTone: () => {},
});
export function PageToneProvider({
tone: initialTone = "green",
children,
}: PropsWithChildren<{ tone?: PageTone }>) {
const [tone, setTone] = useState<PageTone>(initialTone);
useEffect(() => {
setTone(initialTone);
}, [initialTone]);
return (
<PageToneContext.Provider value={{ tone, setTone }}>
{children}
</PageToneContext.Provider>
);
}
export function usePageTone(): PageToneContextType {
return useContext(PageToneContext);
}

View File

@ -1,10 +1,23 @@
import { useMemo } from "react";
import { buildModuleTemplateReference } from "@/features/modules/module-index";
import {
buildModuleTemplateReference,
isPointsModule,
resolveModuleCategory,
} from "@/features/modules/module-index";
import { buildContentReferenceRoute } from "../utils/content-reference";
import { useModulesQuery } from "./use-content-queries";
export function useModuleDisplayName(moduleCode: string) {
export interface ModuleDisplayInfo {
name: string;
homeRoute: string;
category: string | null;
isPointsModule: boolean;
isLoading: boolean;
isError: boolean;
}
export function useModuleDisplayName(moduleCode: string): ModuleDisplayInfo {
const query = useModulesQuery();
const resolved = useMemo(() => {
@ -13,6 +26,8 @@ export function useModuleDisplayName(moduleCode: string) {
return {
name: "Content",
homeRoute: "/modules",
category: null,
isPointsModule: false,
};
}
@ -24,14 +39,20 @@ export function useModuleDisplayName(moduleCode: string) {
return {
name: "Content",
homeRoute: "/modules",
category: null,
isPointsModule: isPointsModule(null, moduleCode),
};
}
const category = resolveModuleCategory(module);
return {
name: module.name?.trim() || "Content",
homeRoute: buildContentReferenceRoute(
buildModuleTemplateReference(module),
),
category,
isPointsModule: isPointsModule(module, moduleCode),
};
}, [moduleCode, query.data?.modules]);

View File

@ -33,6 +33,9 @@ export function EarAcupunctureCatalogCardRenderer({
const contentCount = asNumber(attributes.content_count);
const contentLabel = asString(attributes.content_label).trim();
const isCatalog =
contentCount !== null ||
(attributes.link as Record<string, unknown> | undefined)?.type === "template_ref";
return (
<StandardIndexCard
@ -40,6 +43,8 @@ export function EarAcupunctureCatalogCardRenderer({
subtitle={item.summary || null}
count={contentCount}
countLabel={contentLabel || null}
icon={isCatalog ? "book" : "dot"}
tone={isCatalog ? "green" : undefined}
onPress={onPress}
/>
);

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

@ -17,6 +17,7 @@ export function MeridianIndexCardRenderer({ item, onPress }: CollectionItemRende
<StandardIndexCard
title={asString(a.name) || item.title}
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,14 +22,12 @@ export function ModuleCatalogCardRenderer({
}: CollectionItemRendererProps) {
const attributes = item.attributes;
const title = asString(attributes.name) || item.title;
const label =
const subtitle =
asString(attributes.sub_title) ||
asString(attributes.content_label) ||
(asString(attributes.title) && asString(attributes.title) !== title
? asString(attributes.title)
: null) ||
asString(attributes.description) ||
item.summary ||
asString(attributes.subtitle) ||
(asStringArray(attributes.alt_name).length > 0
? asStringArray(attributes.alt_name).join(", ")
: asString(attributes.alt_name)) ||
null;
return (
@ -44,9 +42,9 @@ export function ModuleCatalogCardRenderer({
<View style={styles.textContainer}>
<Text style={styles.title}>{title}</Text>
{label ? (
<Text style={styles.description} numberOfLines={1}>
{label}
{subtitle ? (
<Text numberOfLines={2} style={styles.subtitle}>
{subtitle}
</Text>
) : null}
</View>
@ -87,10 +85,11 @@ const styles = StyleSheet.create({
fontSize: moderateScale(15),
fontWeight: "600",
color: Colors.textPrimary,
marginBottom: verticalScale(2),
},
description: {
subtitle: {
fontSize: moderateScale(12),
color: Colors.textSecondary,
marginTop: verticalScale(2),
lineHeight: moderateScale(16),
},
});

View File

@ -145,7 +145,10 @@ export function MeridianDetailRenderer({
<>
<BulletList items={asStringArray(value)} />
{isPresent(data.luo_connecting_vessel) ? (
<ObjectSections value={asRecord(data.luo_connecting_vessel)} />
<ObjectSections
value={asRecord(data.luo_connecting_vessel)}
withTopDivider
/>
) : null}
</>
);

View File

@ -68,6 +68,7 @@ export function MeridianPointsDetailRenderer({
<Hero
title={rawTitle}
subtitle={totalCount ? `${totalCount} ${countLabel}` : undefined}
tone="blue"
/>
<View style={styles.list}>
@ -87,6 +88,7 @@ export function MeridianPointsDetailRenderer({
<StandardIndexCard
title={title}
subtitle={subtitle}
tone="blue"
onPress={() =>
router.push(buildContentReferenceRoute(ref) as never)
}

View File

@ -1,6 +1,8 @@
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { Colors } from "@/theme";
export function BulletList({ items }: { items: string[] }) {
if (!items.length) return null;
return (
@ -23,7 +25,7 @@ const styles = StyleSheet.create({
height: 6,
marginTop: 9,
borderRadius: 3,
backgroundColor: "#5B806D",
backgroundColor: Colors.primary,
},
text: { flex: 1, fontSize: 16, lineHeight: 25, color: "#334155" },
});

View File

@ -1,21 +1,16 @@
import React from "react";
import { StyleSheet, Text, View } from "react-native";
const chipTones = [
{ bg: "#EEF7F1", border: "#D5E8DB", text: "#35664E" },
{ bg: "#EFF5FA", border: "#D7E5F0", text: "#3C617E" },
{ bg: "#FAF4EB", border: "#EEDFC9", text: "#805C31" },
];
const greenChipTone = { bg: "#EEF7F1", border: "#D5E8DB", text: "#35664E" };
export function ChipList({ items }: { items: string[] }) {
if (!items.length) return null;
return (
<View style={styles.root}>
{items.map((item, index) => {
const tone = chipTones[index % chipTones.length];
{items.map((item) => {
return (
<View key={item} style={[styles.chip, { backgroundColor: tone.bg, borderColor: tone.border }]}>
<Text style={[styles.text, { color: tone.text }]}>{item}</Text>
<View key={item} style={[styles.chip, { backgroundColor: greenChipTone.bg, borderColor: greenChipTone.border }]}>
<Text style={[styles.text, { color: greenChipTone.text }]}>{item}</Text>
</View>
);
})}

View File

@ -29,6 +29,12 @@ function containsNavigableReference(value: unknown): boolean {
return false;
}
const DEFAULT_EXCLUDED_KEYS = new Set([
"point_codes",
"source_point",
"source_points",
]);
export function ContentLinkAttributeSections({
data,
definitions = [],
@ -40,10 +46,13 @@ export function ContentLinkAttributeSections({
[presentationAttributes],
);
const excluded = useMemo(
() => new Set(excludeAttributeKeys.map((key) => bareAttributeKey(key))),
[excludeAttributeKeys],
);
const excluded = useMemo(() => {
const set = new Set<string>(DEFAULT_EXCLUDED_KEYS);
for (const key of excludeAttributeKeys) {
set.add(bareAttributeKey(key));
}
return set;
}, [excludeAttributeKeys]);
const items = useMemo(() => {
const roots = [...definitions]

View File

@ -5,21 +5,38 @@ import { Ionicons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { Colors } from "@/theme";
import { type PageTone } from "../../context/PageToneContext";
import { ContentPageHeader } from "../../components/layout/ContentPageHeader";
import { useModuleDisplayName } from "../../hooks/use-module-display-name";
interface DetailPageShellProps extends PropsWithChildren {
export interface DetailPageShellProps extends PropsWithChildren {
title: string;
subtitle?: string;
onBack?: () => void;
tone?: PageTone;
moduleCode?: string;
hideFavorite?: boolean;
}
export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
export function DetailPageShell({
children,
onBack,
tone,
moduleCode: propModuleCode,
hideFavorite,
}: DetailPageShellProps) {
const [isFavorite, setIsFavorite] = useState(false);
const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
const params = useLocalSearchParams<{ moduleCode?: string }>();
const currentModuleCode =
typeof propModuleCode === "string" && propModuleCode.trim()
? propModuleCode.trim()
: typeof params.moduleCode === "string"
? params.moduleCode.trim()
: "";
const moduleDisplay = useModuleDisplayName(currentModuleCode);
const shouldHideFavorite = hideFavorite ?? moduleDisplay.isPointsModule;
const searchAction = currentModuleCode ? (
<Pressable
accessibilityRole="button"
@ -34,7 +51,7 @@ export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
</Pressable>
) : null;
const favoriteAction = (
const favoriteAction = !shouldHideFavorite ? (
<Pressable
accessibilityRole="button"
accessibilityLabel={isFavorite ? "Remove from favorites" : "Add to favorites"}
@ -48,12 +65,13 @@ export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
color={isFavorite ? Colors.error : Colors.textPrimary}
/>
</Pressable>
);
) : null;
return (
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
<ContentPageHeader
title={moduleDisplay.name}
tone={tone}
onBack={onBack}
onTitlePress={
currentModuleCode

View File

@ -3,24 +3,44 @@ import { StyleSheet, Text, View } from "react-native";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import {
type PageTone,
toneColors,
usePageTone,
} from "../../context/PageToneContext";
export function Hero({
eyebrow,
title,
subtitle,
meta,
tone,
}: {
eyebrow?: string;
title: string;
subtitle?: string;
meta?: string;
tone?: PageTone;
}) {
const { tone: contextTone } = usePageTone();
const currentTone = tone || contextTone || "green";
const colors = toneColors[currentTone] || toneColors.green;
return (
<View style={styles.card}>
<View style={styles.accent} />
<View
style={[
styles.card,
{ backgroundColor: colors.soft, borderColor: colors.border },
]}
>
<View style={[styles.accent, { backgroundColor: colors.accent }]} />
<View style={styles.content}>
{eyebrow ? <Text style={styles.eyebrow}>{eyebrow}</Text> : null}
<Text style={styles.title}>{title}</Text>
{eyebrow ? (
<Text style={[styles.eyebrow, { color: colors.accent }]}>
{eyebrow}
</Text>
) : null}
<Text style={[styles.title, { color: colors.title }]}>{title}</Text>
{subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}
{meta ? <Text style={styles.meta}>{meta}</Text> : null}
</View>

View File

@ -9,7 +9,13 @@ import { ContentValue } from "./ContentValue";
* content references. ContentValue recursively handles arrays, objects and
* hydrated content/template references.
*/
export function ObjectSections({ value }: { value: Record<string, unknown> }) {
export function ObjectSections({
value,
withTopDivider = false,
}: {
value: Record<string, unknown>;
withTopDivider?: boolean;
}) {
const entries = Object.entries(value).filter(([, child]) =>
isPresent(child),
);
@ -18,8 +24,14 @@ export function ObjectSections({ value }: { value: Record<string, unknown> }) {
return (
<View style={styles.root}>
{entries.map(([key, child]) => (
<View key={key} style={styles.section}>
{entries.map(([key, child], index) => (
<View
key={key}
style={[
styles.section,
(index > 0 || withTopDivider) && styles.divider,
]}
>
<Text style={styles.label}>{humanizeKey(key)}</Text>
<ContentValue value={child} />
</View>
@ -39,7 +51,14 @@ function isPresent(value: unknown): boolean {
const styles = StyleSheet.create({
root: { gap: 16 },
section: { gap: 7 },
section: {
gap: 7,
},
divider: {
paddingTop: 12,
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: "#E8ECEF",
},
label: {
fontWeight: "700",
fontSize: 13,

View File

@ -1,44 +1,44 @@
import React, { useMemo } from "react";
import React from "react";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { Colors } from "@/theme";
import {
type PageTone,
toneColors,
usePageTone,
} from "../../context/PageToneContext";
export type StandardIndexCardTone = PageTone;
export const cardTones = toneColors;
export interface StandardIndexCardProps {
title: string;
subtitle?: string | null;
count?: number | null;
countLabel?: string | null;
tone?: StandardIndexCardTone;
icon?: "dot" | "book";
onPress: () => void;
}
const tones = [
{ soft: "#F0F7F3", accent: "#3F7D62" },
{ soft: "#F1F6FA", accent: "#4E7496" },
{ soft: "#FBF6EE", accent: "#A06E35" },
{ soft: "#F6F3FA", accent: "#75649B" },
];
function toneFor(value: string) {
let hash = 0;
for (let i = 0; i < value.length; i += 1) {
hash = (hash * 31 + value.charCodeAt(i)) >>> 0;
}
return tones[hash % tones.length];
}
/** Canonical soothing index row for CT0002 / CT0004 / CT0006 / CT0008. */
export function StandardIndexCard({
title,
subtitle,
count,
countLabel,
tone,
icon = "dot",
onPress,
}: StandardIndexCardProps) {
const { tone: contextTone } = usePageTone();
const normalizedTitle = title.trim();
const normalizedSubtitle = subtitle?.trim() || null;
const tone = useMemo(() => toneFor(normalizedTitle), [normalizedTitle]);
const effectiveTone = tone || (icon === "book" ? "green" : contextTone) || "purple";
const currentTone = cardTones[effectiveTone] || cardTones.purple;
return (
<Pressable
@ -47,8 +47,12 @@ export function StandardIndexCard({
onPress={onPress}
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
>
<View style={[styles.accent, { backgroundColor: tone.soft }]}>
<View style={[styles.accentDot, { backgroundColor: tone.accent }]} />
<View style={[styles.accent, { backgroundColor: currentTone.soft }]}>
{icon === "book" ? (
<Ionicons name="book-outline" size={19} color={currentTone.accent} />
) : (
<View style={[styles.accentDot, { backgroundColor: currentTone.accent }]} />
)}
</View>
<View style={styles.titleBlock}>
@ -63,10 +67,10 @@ export function StandardIndexCard({
</View>
{count !== null && count !== undefined ? (
<View style={[styles.countBadge, { backgroundColor: tone.soft }]}>
<Text style={[styles.countText, { color: tone.accent }]}>{count}</Text>
<View style={[styles.countBadge, { backgroundColor: currentTone.soft }]}>
<Text style={[styles.countText, { color: currentTone.accent }]}>{count}</Text>
{countLabel ? (
<Text numberOfLines={1} style={styles.countLabel}>
<Text numberOfLines={1} style={[styles.countLabel, { color: currentTone.accent }]}>
{countLabel}
</Text>
) : null}
@ -113,10 +117,10 @@ const styles = StyleSheet.create({
color: Colors.textSecondary,
},
countBadge: {
minWidth: moderateScale(34),
minWidth: moderateScale(38),
maxWidth: moderateScale(82),
paddingHorizontal: moderateScale(9),
paddingVertical: verticalScale(6),
paddingHorizontal: moderateScale(8),
paddingVertical: verticalScale(5),
borderRadius: moderateScale(12),
alignItems: "center",
justifyContent: "center",
@ -128,8 +132,8 @@ const styles = StyleSheet.create({
},
countLabel: {
marginTop: 1,
fontSize: moderateScale(9.5),
lineHeight: moderateScale(12),
color: Colors.textSecondary,
fontSize: moderateScale(9),
lineHeight: moderateScale(11),
fontWeight: "600",
},
});

View File

@ -5,24 +5,13 @@ export interface ReadingTone {
title: string;
}
const tones: readonly ReadingTone[] = [
{ accent: "#3F7D62", soft: "#F0F7F3", border: "#D7E9DE", title: "#285A44" },
{ accent: "#4E7496", soft: "#F1F6FA", border: "#D9E6F0", title: "#365B78" },
{ accent: "#A06E35", soft: "#FBF6EE", border: "#EEE0CC", title: "#7E5529" },
{ accent: "#75649B", soft: "#F6F3FA", border: "#E4DDF0", title: "#594978" },
{ accent: "#A15D63", soft: "#FBF3F4", border: "#EEDBDE", title: "#7C4248" },
];
export const greenTone: ReadingTone = {
accent: "#3F7D62",
soft: "#F0F7F3",
border: "#D7E9DE",
title: "#285A44",
};
export function readingToneForTitle(title: string): ReadingTone {
const normalized = title.trim().toLowerCase();
if (normalized.includes("caution") || normalized.includes("warning")) {
return { accent: "#B45353", soft: "#FFF5F5", border: "#F2D7D7", title: "#8D3F3F" };
}
let hash = 0;
for (let index = 0; index < normalized.length; index += 1) {
hash = (hash * 31 + normalized.charCodeAt(index)) >>> 0;
}
return tones[hash % tones.length];
export function readingToneForTitle(_title?: string): ReadingTone {
return greenTone;
}

View File

@ -5,6 +5,7 @@ import { Ionicons } from "@expo/vector-icons";
import { router } from "expo-router";
import { Colors } from "@/theme";
import { type PageTone, PageToneProvider } from "../context/PageToneContext";
import { ContentPageHeader } from "../components/layout/ContentPageHeader";
import { ScreenError } from "../components/ContentScreenState";
import { ContractSortModal } from "../components/search/ContractSortModal";
@ -130,20 +131,56 @@ export function CollectionTemplateScreen({
</View>
);
return (
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
<ContentPageHeader
title={moduleDisplay.name}
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
right={headerActions}
/>
const isCatalog =
collectionRendererCode === "module_catalog_collection" ||
itemRendererCode === "module_catalog_card" ||
templateCode === "m0001_ct0001" ||
templateCode === "m0002_ct0001";
const pageTone: PageTone = isCatalog ? "green" : "purple";
<RendererFallbackBoundary
rendererKind="collection"
rendererCode={collectionRendererCode}
fallback={
<GenericCollectionRenderer
return (
<PageToneProvider tone={pageTone}>
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
<ContentPageHeader
title={moduleDisplay.name}
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
right={headerActions}
/>
<RendererFallbackBoundary
rendererKind="collection"
rendererCode={collectionRendererCode}
fallback={
<GenericCollectionRenderer
items={merged.items}
total={merged.total}
isLoading={query.isLoading}
isRefreshing={query.isRefetching && !query.isFetchingNextPage}
isFetchingNextPage={query.isFetchingNextPage}
onRefresh={() => void query.refetch()}
onLoadMore={() => {
if (query.hasNextPage && !query.isFetchingNextPage) {
void query.fetchNextPage();
}
}}
onItemPress={(item) => {
const references = Object.values(item.attributes).flatMap((value) =>
getNavigableContentReferences(value),
);
if (references.length === 1) {
router.push(buildContentReferenceRoute(references[0]) as never);
return;
}
onContentPress(item.id);
}}
renderItem={({ item, onPress }) => (
<GenericCardRenderer item={item} onPress={onPress} />
)}
/>
}
>
<CollectionRenderer
items={merged.items}
total={merged.total}
isLoading={query.isLoading}
@ -166,56 +203,29 @@ export function CollectionTemplateScreen({
onContentPress(item.id);
}}
renderItem={({ item, onPress }) => (
<GenericCardRenderer item={item} onPress={onPress} />
<RendererFallbackBoundary
rendererKind="collection_item"
rendererCode={itemRendererCode}
fallback={<GenericCardRenderer item={item} onPress={onPress} />}
>
<ItemRenderer item={item} onPress={onPress} />
</RendererFallbackBoundary>
)}
/>
}
>
<CollectionRenderer
items={merged.items}
total={merged.total}
isLoading={query.isLoading}
isRefreshing={query.isRefetching && !query.isFetchingNextPage}
isFetchingNextPage={query.isFetchingNextPage}
onRefresh={() => void query.refetch()}
onLoadMore={() => {
if (query.hasNextPage && !query.isFetchingNextPage) {
void query.fetchNextPage();
}
}}
onItemPress={(item) => {
const references = Object.values(item.attributes).flatMap((value) =>
getNavigableContentReferences(value),
);
if (references.length === 1) {
router.push(buildContentReferenceRoute(references[0]) as never);
return;
}
onContentPress(item.id);
}}
renderItem={({ item, onPress }) => (
<RendererFallbackBoundary
rendererKind="collection_item"
rendererCode={itemRendererCode}
fallback={<GenericCardRenderer item={item} onPress={onPress} />}
>
<ItemRenderer item={item} onPress={onPress} />
</RendererFallbackBoundary>
)}
/>
</RendererFallbackBoundary>
</RendererFallbackBoundary>
{hasSort ? (
<ContractSortModal
visible={sortVisible}
fields={contract.search.sort_fields}
sort={search.sort}
defaultSort={contract.search.default_sort}
onApply={search.setSort}
onClose={() => setSortVisible(false)}
/>
) : null}
</SafeAreaView>
{hasSort ? (
<ContractSortModal
visible={sortVisible}
fields={contract.search.sort_fields}
sort={search.sort}
defaultSort={contract.search.default_sort}
onApply={search.setSort}
onClose={() => setSortVisible(false)}
/>
) : null}
</SafeAreaView>
</PageToneProvider>
);
}

View File

@ -8,6 +8,7 @@ import { RendererFallbackBoundary } from "../renderers/shared/RendererFallbackBo
import { DetailPageShell } from "../renderers/shared/DetailPageShell";
import { applyPresentationContractToData } from "../utils/attribute-presentation";
import { BackActionContext } from "../context/BackActionContext";
import { PageToneProvider, type PageTone } from "../context/PageToneContext";
export interface ContentDetailScreenProps {
moduleCode: string;
@ -105,19 +106,44 @@ function ContentDetailScreenResolved({
.map((value) => value.trim())
.join(" · ");
const isIntermediateList =
rendererCode === "meridian_points_detail" ||
rendererCode === "meridian_index_detail" ||
templateCode === "m0001_ct0002";
const pageTone: PageTone = isIntermediateList ? "blue" : "green";
return (
<DetailPageShell
title={displayTitle}
subtitle={alternateNames || undefined}
onBack={customBack ?? undefined}
>
<BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}>
<ContentMediaProvider media={response.media}>
<RendererFallbackBoundary
rendererKind="detail"
rendererCode={rendererCode}
fallback={
<GenericDetailRenderer
<PageToneProvider tone={pageTone}>
<DetailPageShell
title={displayTitle}
subtitle={alternateNames || undefined}
onBack={customBack ?? undefined}
tone={pageTone}
moduleCode={moduleCode}
>
<BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}>
<ContentMediaProvider media={response.media}>
<RendererFallbackBoundary
rendererKind="detail"
rendererCode={rendererCode}
fallback={
<GenericDetailRenderer
moduleCode={moduleCode}
templateCode={templateCode}
contentId={response.content.id}
content={{
id: response.content.id,
title: response.content.title,
slug: response.content.slug,
summary: response.content.summary,
}}
data={presentedData}
definitions={screen.definitionsQuery.data?.attributes ?? []}
presentationAttributes={presentationAttributes}
/>
}
>
<Renderer
moduleCode={moduleCode}
templateCode={templateCode}
contentId={response.content.id}
@ -131,25 +157,10 @@ function ContentDetailScreenResolved({
definitions={screen.definitionsQuery.data?.attributes ?? []}
presentationAttributes={presentationAttributes}
/>
}
>
<Renderer
moduleCode={moduleCode}
templateCode={templateCode}
contentId={response.content.id}
content={{
id: response.content.id,
title: response.content.title,
slug: response.content.slug,
summary: response.content.summary,
}}
data={presentedData}
definitions={screen.definitionsQuery.data?.attributes ?? []}
presentationAttributes={presentationAttributes}
/>
</RendererFallbackBoundary>
</ContentMediaProvider>
</BackActionContext.Provider>
</DetailPageShell>
</RendererFallbackBoundary>
</ContentMediaProvider>
</BackActionContext.Provider>
</DetailPageShell>
</PageToneProvider>
);
}

View File

@ -64,7 +64,11 @@ export function SingleTemplateScreen({
const displayTitle = pointName || name || content.title;
return (
<DetailPageShell title={content.title || moduleCode} onBack={customBack ?? undefined}>
<DetailPageShell
title={content.title || moduleCode}
onBack={customBack ?? undefined}
moduleCode={moduleCode}
>
<BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}>
<ContentMediaProvider media={media}>
<RendererFallbackBoundary

View File

@ -179,6 +179,22 @@ export function resolveModuleCategory(module: ModuleResponse): string {
}
}
export function isPointsModule(
module?: ModuleResponse | null,
moduleCode?: string | null,
): boolean {
if (module) {
return resolveModuleCategory(module) === "Points";
}
if (moduleCode) {
const visual = MODULE_VISUALS[moduleCode.trim().toLowerCase()];
if (visual?.planCode?.startsWith("POINTS_")) {
return true;
}
}
return false;
}
export function resolveModuleEntryTemplateCode(module: ModuleResponse): string {
const visual = MODULE_VISUALS[module.code.toLowerCase()];
if (visual?.entryTemplateCode) return visual.entryTemplateCode.toLowerCase();

View File

@ -338,7 +338,7 @@ const styles = StyleSheet.create({
headerTitle: {
fontSize: moderateScale(18),
fontWeight: "700",
color: Colors.textPrimary,
color: Colors.primary,
},
headerActions: {
flexDirection: "row",

View File

@ -5,6 +5,14 @@ export const Colors = {
secondary: "#1565C0",
purple: "#75649B",
purpleSoft: "#F6F3FA",
blue: "#4E7496",
blueSoft: "#F1F6FA",
greenSoft: "#E8F5E9",
background: "#FFFFFF",
surface: "#F8F9FA",