Compare commits

..

No commits in common. "aaa23fedfe0d3152c770636ae68f7f2a199dc1f0" and "31b6476d149a9f1f5f61fde4adce020fa3d1f169" have entirely different histories.

24 changed files with 186 additions and 413 deletions

View File

@ -5,11 +5,6 @@ import { router, useFocusEffect } from "expo-router";
import { moderateScale, scale } from "react-native-size-matters"; import { moderateScale, scale } 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;
@ -19,8 +14,6 @@ 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({
@ -31,15 +24,7 @@ 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;
@ -74,7 +59,7 @@ export function ContentPageHeader({
const titleContent = ( const titleContent = (
<View style={styles.titleContent}> <View style={styles.titleContent}>
<Text numberOfLines={1} style={[styles.title, { color: resolvedTitleColor }]}> <Text numberOfLines={1} style={styles.title}>
{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)} withTopDivider /> <ObjectSections value={asRecord(data.luo_connecting_vessel)} />
</SectionCard> </SectionCard>
); );

View File

@ -1,69 +0,0 @@
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,23 +1,10 @@
import { useMemo } from "react"; import { useMemo } from "react";
import { import { buildModuleTemplateReference } from "@/features/modules/module-index";
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 interface ModuleDisplayInfo { export function useModuleDisplayName(moduleCode: string) {
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(() => {
@ -26,8 +13,6 @@ export function useModuleDisplayName(moduleCode: string): ModuleDisplayInfo {
return { return {
name: "Content", name: "Content",
homeRoute: "/modules", homeRoute: "/modules",
category: null,
isPointsModule: false,
}; };
} }
@ -39,20 +24,14 @@ export function useModuleDisplayName(moduleCode: string): ModuleDisplayInfo {
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,9 +33,6 @@ 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
@ -43,8 +40,6 @@ 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,16 +14,9 @@ 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,7 +17,6 @@ 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, asStringArray } from "../helpers/value"; import { asNumber, asString } 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,12 +22,14 @@ 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 = const label =
asString(attributes.sub_title) || asString(attributes.sub_title) ||
asString(attributes.subtitle) || asString(attributes.content_label) ||
(asStringArray(attributes.alt_name).length > 0 (asString(attributes.title) && asString(attributes.title) !== title
? asStringArray(attributes.alt_name).join(", ") ? asString(attributes.title)
: asString(attributes.alt_name)) || : null) ||
asString(attributes.description) ||
item.summary ||
null; null;
return ( return (
@ -42,9 +44,9 @@ export function ModuleCatalogCardRenderer({
<View style={styles.textContainer}> <View style={styles.textContainer}>
<Text style={styles.title}>{title}</Text> <Text style={styles.title}>{title}</Text>
{subtitle ? ( {label ? (
<Text numberOfLines={2} style={styles.subtitle}> <Text style={styles.description} numberOfLines={1}>
{subtitle} {label}
</Text> </Text>
) : null} ) : null}
</View> </View>
@ -85,11 +87,10 @@ const styles = StyleSheet.create({
fontSize: moderateScale(15), fontSize: moderateScale(15),
fontWeight: "600", fontWeight: "600",
color: Colors.textPrimary, color: Colors.textPrimary,
marginBottom: verticalScale(2),
}, },
subtitle: { description: {
fontSize: moderateScale(12), fontSize: moderateScale(12),
color: Colors.textSecondary, color: Colors.textSecondary,
marginTop: verticalScale(2),
lineHeight: moderateScale(16),
}, },
}); });

View File

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

View File

@ -68,7 +68,6 @@ 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}>
@ -88,7 +87,6 @@ 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,8 +1,6 @@
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 (
@ -25,7 +23,7 @@ const styles = StyleSheet.create({
height: 6, height: 6,
marginTop: 9, marginTop: 9,
borderRadius: 3, borderRadius: 3,
backgroundColor: Colors.primary, backgroundColor: "#5B806D",
}, },
text: { flex: 1, fontSize: 16, lineHeight: 25, color: "#334155" }, text: { flex: 1, fontSize: 16, lineHeight: 25, color: "#334155" },
}); });

View File

@ -1,16 +1,21 @@
import React from "react"; import React from "react";
import { StyleSheet, Text, View } from "react-native"; import { StyleSheet, Text, View } from "react-native";
const greenChipTone = { bg: "#EEF7F1", border: "#D5E8DB", text: "#35664E" }; const chipTones = [
{ 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) => { {items.map((item, index) => {
const tone = chipTones[index % chipTones.length];
return ( return (
<View key={item} style={[styles.chip, { backgroundColor: greenChipTone.bg, borderColor: greenChipTone.border }]}> <View key={item} style={[styles.chip, { backgroundColor: tone.bg, borderColor: tone.border }]}>
<Text style={[styles.text, { color: greenChipTone.text }]}>{item}</Text> <Text style={[styles.text, { color: tone.text }]}>{item}</Text>
</View> </View>
); );
})} })}

View File

@ -29,12 +29,6 @@ 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 = [],
@ -46,13 +40,10 @@ export function ContentLinkAttributeSections({
[presentationAttributes], [presentationAttributes],
); );
const excluded = useMemo(() => { const excluded = useMemo(
const set = new Set<string>(DEFAULT_EXCLUDED_KEYS); () => new Set(excludeAttributeKeys.map((key) => bareAttributeKey(key))),
for (const key of excludeAttributeKeys) { [excludeAttributeKeys],
set.add(bareAttributeKey(key)); );
}
return set;
}, [excludeAttributeKeys]);
const items = useMemo(() => { const items = useMemo(() => {
const roots = [...definitions] const roots = [...definitions]

View File

@ -5,38 +5,21 @@ 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";
export interface DetailPageShellProps extends PropsWithChildren { 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({ export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
children,
onBack,
tone,
moduleCode: propModuleCode,
hideFavorite,
}: DetailPageShellProps) {
const [isFavorite, setIsFavorite] = useState(false); const [isFavorite, setIsFavorite] = useState(false);
const params = useLocalSearchParams<{ moduleCode?: string }>(); const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
const currentModuleCode = const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
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"
@ -51,7 +34,7 @@ export function DetailPageShell({
</Pressable> </Pressable>
) : null; ) : null;
const favoriteAction = !shouldHideFavorite ? ( const favoriteAction = (
<Pressable <Pressable
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel={isFavorite ? "Remove from favorites" : "Add to favorites"} accessibilityLabel={isFavorite ? "Remove from favorites" : "Add to favorites"}
@ -65,13 +48,12 @@ export function DetailPageShell({
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,44 +3,24 @@ 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 <View style={styles.card}>
style={[ <View style={styles.accent} />
styles.card,
{ backgroundColor: colors.soft, borderColor: colors.border },
]}
>
<View style={[styles.accent, { backgroundColor: colors.accent }]} />
<View style={styles.content}> <View style={styles.content}>
{eyebrow ? ( {eyebrow ? <Text style={styles.eyebrow}>{eyebrow}</Text> : null}
<Text style={[styles.eyebrow, { color: colors.accent }]}> <Text style={styles.title}>{title}</Text>
{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,13 +9,7 @@ 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({ export function ObjectSections({ value }: { value: Record<string, unknown> }) {
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),
); );
@ -24,14 +18,8 @@ export function ObjectSections({
return ( return (
<View style={styles.root}> <View style={styles.root}>
{entries.map(([key, child], index) => ( {entries.map(([key, child]) => (
<View <View key={key} style={styles.section}>
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>
@ -51,14 +39,7 @@ function isPresent(value: unknown): boolean {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
root: { gap: 16 }, root: { gap: 16 },
section: { section: { gap: 7 },
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 from "react"; import React, { useMemo } 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 effectiveTone = tone || (icon === "book" ? "green" : contextTone) || "purple"; const tone = useMemo(() => toneFor(normalizedTitle), [normalizedTitle]);
const currentTone = cardTones[effectiveTone] || cardTones.purple;
return ( return (
<Pressable <Pressable
@ -47,12 +47,8 @@ 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: currentTone.soft }]}> <View style={[styles.accent, { backgroundColor: tone.soft }]}>
{icon === "book" ? ( <View style={[styles.accentDot, { backgroundColor: tone.accent }]} />
<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}>
@ -67,10 +63,10 @@ export function StandardIndexCard({
</View> </View>
{count !== null && count !== undefined ? ( {count !== null && count !== undefined ? (
<View style={[styles.countBadge, { backgroundColor: currentTone.soft }]}> <View style={[styles.countBadge, { backgroundColor: tone.soft }]}>
<Text style={[styles.countText, { color: currentTone.accent }]}>{count}</Text> <Text style={[styles.countText, { color: tone.accent }]}>{count}</Text>
{countLabel ? ( {countLabel ? (
<Text numberOfLines={1} style={[styles.countLabel, { color: currentTone.accent }]}> <Text numberOfLines={1} style={styles.countLabel}>
{countLabel} {countLabel}
</Text> </Text>
) : null} ) : null}
@ -117,10 +113,10 @@ const styles = StyleSheet.create({
color: Colors.textSecondary, color: Colors.textSecondary,
}, },
countBadge: { countBadge: {
minWidth: moderateScale(38), minWidth: moderateScale(34),
maxWidth: moderateScale(82), maxWidth: moderateScale(82),
paddingHorizontal: moderateScale(8), paddingHorizontal: moderateScale(9),
paddingVertical: verticalScale(5), paddingVertical: verticalScale(6),
borderRadius: moderateScale(12), borderRadius: moderateScale(12),
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
@ -132,8 +128,8 @@ const styles = StyleSheet.create({
}, },
countLabel: { countLabel: {
marginTop: 1, marginTop: 1,
fontSize: moderateScale(9), fontSize: moderateScale(9.5),
lineHeight: moderateScale(11), lineHeight: moderateScale(12),
fontWeight: "600", color: Colors.textSecondary,
}, },
}); });

View File

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

View File

@ -5,7 +5,6 @@ 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";
@ -131,56 +130,20 @@ export function CollectionTemplateScreen({
</View> </View>
); );
const isCatalog =
collectionRendererCode === "module_catalog_collection" ||
itemRendererCode === "module_catalog_card" ||
templateCode === "m0001_ct0001" ||
templateCode === "m0002_ct0001";
const pageTone: PageTone = isCatalog ? "green" : "purple";
return ( return (
<PageToneProvider tone={pageTone}> <SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}> <ContentPageHeader
<ContentPageHeader title={moduleDisplay.name}
title={moduleDisplay.name} onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)} titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`} right={headerActions}
right={headerActions} />
/>
<RendererFallbackBoundary <RendererFallbackBoundary
rendererKind="collection" rendererKind="collection"
rendererCode={collectionRendererCode} rendererCode={collectionRendererCode}
fallback={ fallback={
<GenericCollectionRenderer <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}
@ -203,29 +166,56 @@ export function CollectionTemplateScreen({
onContentPress(item.id); onContentPress(item.id);
}} }}
renderItem={({ item, onPress }) => ( renderItem={({ item, onPress }) => (
<RendererFallbackBoundary <GenericCardRenderer item={item} onPress={onPress} />
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,7 +8,6 @@ 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;
@ -106,44 +105,19 @@ 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 (
<PageToneProvider tone={pageTone}> <DetailPageShell
<DetailPageShell title={displayTitle}
title={displayTitle} subtitle={alternateNames || undefined}
subtitle={alternateNames || undefined} onBack={customBack ?? undefined}
onBack={customBack ?? undefined} >
tone={pageTone} <BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}>
moduleCode={moduleCode} <ContentMediaProvider media={response.media}>
> <RendererFallbackBoundary
<BackActionContext.Provider value={{ setCustomBackAction: setCustomBack }}> rendererKind="detail"
<ContentMediaProvider media={response.media}> rendererCode={rendererCode}
<RendererFallbackBoundary fallback={
rendererKind="detail" <GenericDetailRenderer
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}
@ -157,10 +131,25 @@ function ContentDetailScreenResolved({
definitions={screen.definitionsQuery.data?.attributes ?? []} definitions={screen.definitionsQuery.data?.attributes ?? []}
presentationAttributes={presentationAttributes} presentationAttributes={presentationAttributes}
/> />
</RendererFallbackBoundary> }
</ContentMediaProvider> >
</BackActionContext.Provider> <Renderer
</DetailPageShell> moduleCode={moduleCode}
</PageToneProvider> 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>
); );
} }

View File

@ -64,11 +64,7 @@ export function SingleTemplateScreen({
const displayTitle = pointName || name || content.title; const displayTitle = pointName || name || content.title;
return ( return (
<DetailPageShell <DetailPageShell title={content.title || moduleCode} onBack={customBack ?? undefined}>
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,22 +179,6 @@ 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.primary, color: Colors.textPrimary,
}, },
headerActions: { headerActions: {
flexDirection: "row", flexDirection: "row",

View File

@ -5,14 +5,6 @@ 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",