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

View File

@ -36,7 +36,7 @@ export const DivergentChannel = ({ data }: { data: Record<string, unknown> }) =>
export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => ( export const LuoChannel = ({ data }: { data: Record<string, unknown> }) => (
<SectionCard title="Luo-Connecting Channel"> <SectionCard title="Luo-Connecting Channel">
<BulletList items={asStringArray(data.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> </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 { 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 { buildContentReferenceRoute } from "../utils/content-reference";
import { useModulesQuery } from "./use-content-queries"; 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 query = useModulesQuery();
const resolved = useMemo(() => { const resolved = useMemo(() => {
@ -13,6 +26,8 @@ export function useModuleDisplayName(moduleCode: string) {
return { return {
name: "Content", name: "Content",
homeRoute: "/modules", homeRoute: "/modules",
category: null,
isPointsModule: false,
}; };
} }
@ -24,14 +39,20 @@ export function useModuleDisplayName(moduleCode: string) {
return { return {
name: "Content", name: "Content",
homeRoute: "/modules", homeRoute: "/modules",
category: null,
isPointsModule: isPointsModule(null, moduleCode),
}; };
} }
const category = resolveModuleCategory(module);
return { return {
name: module.name?.trim() || "Content", name: module.name?.trim() || "Content",
homeRoute: buildContentReferenceRoute( homeRoute: buildContentReferenceRoute(
buildModuleTemplateReference(module), buildModuleTemplateReference(module),
), ),
category,
isPointsModule: isPointsModule(module, moduleCode),
}; };
}, [moduleCode, query.data?.modules]); }, [moduleCode, query.data?.modules]);

View File

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

View File

@ -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}

View File

@ -17,6 +17,7 @@ export function MeridianIndexCardRenderer({ item, onPress }: CollectionItemRende
<StandardIndexCard <StandardIndexCard
title={asString(a.name) || item.title} title={asString(a.name) || item.title}
count={asNumber(a.content_count)} count={asNumber(a.content_count)}
countLabel={asString(a.content_label) || null}
onPress={onPress} onPress={onPress}
/> />
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,13 @@ import { ContentValue } from "./ContentValue";
* content references. ContentValue recursively handles arrays, objects and * content references. ContentValue recursively handles arrays, objects and
* hydrated content/template references. * 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]) => const entries = Object.entries(value).filter(([, child]) =>
isPresent(child), isPresent(child),
); );
@ -18,8 +24,14 @@ export function ObjectSections({ value }: { value: Record<string, unknown> }) {
return ( return (
<View style={styles.root}> <View style={styles.root}>
{entries.map(([key, child]) => ( {entries.map(([key, child], index) => (
<View key={key} style={styles.section}> <View
key={key}
style={[
styles.section,
(index > 0 || withTopDivider) && styles.divider,
]}
>
<Text style={styles.label}>{humanizeKey(key)}</Text> <Text style={styles.label}>{humanizeKey(key)}</Text>
<ContentValue value={child} /> <ContentValue value={child} />
</View> </View>
@ -39,7 +51,14 @@ function isPresent(value: unknown): boolean {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
root: { gap: 16 }, root: { gap: 16 },
section: { gap: 7 }, section: {
gap: 7,
},
divider: {
paddingTop: 12,
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: "#E8ECEF",
},
label: { label: {
fontWeight: "700", fontWeight: "700",
fontSize: 13, 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 { Pressable, StyleSheet, Text, View } from "react-native";
import { Ionicons } from "@expo/vector-icons"; 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 {
type PageTone,
toneColors,
usePageTone,
} from "../../context/PageToneContext";
export type StandardIndexCardTone = PageTone;
export const cardTones = toneColors;
export interface StandardIndexCardProps { export interface StandardIndexCardProps {
title: string; title: string;
subtitle?: string | null; subtitle?: string | null;
count?: number | null; count?: number | null;
countLabel?: string | null; countLabel?: string | null;
tone?: StandardIndexCardTone;
icon?: "dot" | "book";
onPress: () => void; 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. */ /** Canonical soothing index row for CT0002 / CT0004 / CT0006 / CT0008. */
export function StandardIndexCard({ export function StandardIndexCard({
title, title,
subtitle, subtitle,
count, count,
countLabel, countLabel,
tone,
icon = "dot",
onPress, onPress,
}: StandardIndexCardProps) { }: StandardIndexCardProps) {
const { tone: contextTone } = usePageTone();
const normalizedTitle = title.trim(); const normalizedTitle = title.trim();
const normalizedSubtitle = subtitle?.trim() || null; 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 ( return (
<Pressable <Pressable
@ -47,8 +47,12 @@ export function StandardIndexCard({
onPress={onPress} onPress={onPress}
style={({ pressed }) => [styles.row, pressed && styles.pressed]} style={({ pressed }) => [styles.row, pressed && styles.pressed]}
> >
<View style={[styles.accent, { backgroundColor: tone.soft }]}> <View style={[styles.accent, { backgroundColor: currentTone.soft }]}>
<View style={[styles.accentDot, { backgroundColor: tone.accent }]} /> {icon === "book" ? (
<Ionicons name="book-outline" size={19} color={currentTone.accent} />
) : (
<View style={[styles.accentDot, { backgroundColor: currentTone.accent }]} />
)}
</View> </View>
<View style={styles.titleBlock}> <View style={styles.titleBlock}>
@ -63,10 +67,10 @@ export function StandardIndexCard({
</View> </View>
{count !== null && count !== undefined ? ( {count !== null && count !== undefined ? (
<View style={[styles.countBadge, { backgroundColor: tone.soft }]}> <View style={[styles.countBadge, { backgroundColor: currentTone.soft }]}>
<Text style={[styles.countText, { color: tone.accent }]}>{count}</Text> <Text style={[styles.countText, { color: currentTone.accent }]}>{count}</Text>
{countLabel ? ( {countLabel ? (
<Text numberOfLines={1} style={styles.countLabel}> <Text numberOfLines={1} style={[styles.countLabel, { color: currentTone.accent }]}>
{countLabel} {countLabel}
</Text> </Text>
) : null} ) : null}
@ -113,10 +117,10 @@ const styles = StyleSheet.create({
color: Colors.textSecondary, color: Colors.textSecondary,
}, },
countBadge: { countBadge: {
minWidth: moderateScale(34), minWidth: moderateScale(38),
maxWidth: moderateScale(82), maxWidth: moderateScale(82),
paddingHorizontal: moderateScale(9), paddingHorizontal: moderateScale(8),
paddingVertical: verticalScale(6), paddingVertical: verticalScale(5),
borderRadius: moderateScale(12), borderRadius: moderateScale(12),
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
@ -128,8 +132,8 @@ const styles = StyleSheet.create({
}, },
countLabel: { countLabel: {
marginTop: 1, marginTop: 1,
fontSize: moderateScale(9.5), fontSize: moderateScale(9),
lineHeight: moderateScale(12), lineHeight: moderateScale(11),
color: Colors.textSecondary, fontWeight: "600",
}, },
}); });

View File

@ -5,24 +5,13 @@ export interface ReadingTone {
title: string; title: string;
} }
const tones: readonly ReadingTone[] = [ export const greenTone: ReadingTone = {
{ accent: "#3F7D62", soft: "#F0F7F3", border: "#D7E9DE", title: "#285A44" }, accent: "#3F7D62",
{ accent: "#4E7496", soft: "#F1F6FA", border: "#D9E6F0", title: "#365B78" }, soft: "#F0F7F3",
{ accent: "#A06E35", soft: "#FBF6EE", border: "#EEE0CC", title: "#7E5529" }, border: "#D7E9DE",
{ accent: "#75649B", soft: "#F6F3FA", border: "#E4DDF0", title: "#594978" }, title: "#285A44",
{ accent: "#A15D63", soft: "#FBF3F4", border: "#EEDBDE", title: "#7C4248" }, };
];
export function readingToneForTitle(title: string): ReadingTone { export function readingToneForTitle(_title?: string): ReadingTone {
const normalized = title.trim().toLowerCase(); return greenTone;
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];
} }

View File

@ -5,6 +5,7 @@ import { Ionicons } from "@expo/vector-icons";
import { router } from "expo-router"; import { router } from "expo-router";
import { Colors } from "@/theme"; import { Colors } from "@/theme";
import { type PageTone, PageToneProvider } from "../context/PageToneContext";
import { ContentPageHeader } from "../components/layout/ContentPageHeader"; import { ContentPageHeader } from "../components/layout/ContentPageHeader";
import { ScreenError } from "../components/ContentScreenState"; import { ScreenError } from "../components/ContentScreenState";
import { ContractSortModal } from "../components/search/ContractSortModal"; import { ContractSortModal } from "../components/search/ContractSortModal";
@ -130,20 +131,56 @@ export function CollectionTemplateScreen({
</View> </View>
); );
return ( const isCatalog =
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}> collectionRendererCode === "module_catalog_collection" ||
<ContentPageHeader itemRendererCode === "module_catalog_card" ||
title={moduleDisplay.name} templateCode === "m0001_ct0001" ||
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)} templateCode === "m0002_ct0001";
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`} const pageTone: PageTone = isCatalog ? "green" : "purple";
right={headerActions}
/>
<RendererFallbackBoundary return (
rendererKind="collection" <PageToneProvider tone={pageTone}>
rendererCode={collectionRendererCode} <SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
fallback={ <ContentPageHeader
<GenericCollectionRenderer 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} items={merged.items}
total={merged.total} total={merged.total}
isLoading={query.isLoading} isLoading={query.isLoading}
@ -166,56 +203,29 @@ export function CollectionTemplateScreen({
onContentPress(item.id); onContentPress(item.id);
}} }}
renderItem={({ item, onPress }) => ( 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>
)} )}
/> />
} </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>
{hasSort ? ( {hasSort ? (
<ContractSortModal <ContractSortModal
visible={sortVisible} visible={sortVisible}
fields={contract.search.sort_fields} fields={contract.search.sort_fields}
sort={search.sort} sort={search.sort}
defaultSort={contract.search.default_sort} defaultSort={contract.search.default_sort}
onApply={search.setSort} onApply={search.setSort}
onClose={() => setSortVisible(false)} onClose={() => setSortVisible(false)}
/> />
) : null} ) : null}
</SafeAreaView> </SafeAreaView>
</PageToneProvider>
); );
} }

View File

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

View File

@ -64,7 +64,11 @@ export function SingleTemplateScreen({
const displayTitle = pointName || name || content.title; const displayTitle = pointName || name || content.title;
return ( return (
<DetailPageShell title={content.title || moduleCode} onBack={customBack ?? undefined}> <DetailPageShell
title={content.title || moduleCode}
onBack={customBack ?? undefined}
moduleCode={moduleCode}
>
<BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}> <BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}>
<ContentMediaProvider media={media}> <ContentMediaProvider media={media}>
<RendererFallbackBoundary <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 { export function resolveModuleEntryTemplateCode(module: ModuleResponse): string {
const visual = MODULE_VISUALS[module.code.toLowerCase()]; const visual = MODULE_VISUALS[module.code.toLowerCase()];
if (visual?.entryTemplateCode) return visual.entryTemplateCode.toLowerCase(); if (visual?.entryTemplateCode) return visual.entryTemplateCode.toLowerCase();

View File

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

View File

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