Merge branch 'origin/main' into patterns and resolve conflicts

This commit is contained in:
ShivaniKhaire 2026-10-26 09:24:13 +05:30
commit 9ff35bcd70
27 changed files with 466 additions and 199 deletions

View File

@ -89,7 +89,7 @@ export default function ForgotPasswordScreen() {
} else if (!/[0-9]/.test(newPassword)) {
setPasswordError("Must contain at least one number");
hasError = true;
} else if (!/[^A-Za-z0-9\s]/.test(newPassword)) {
} else if (!/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(newPassword)) {
setPasswordError("Must contain at least one special character");
hasError = true;
}

View File

@ -54,7 +54,7 @@ export default function ChangePasswordScreen() {
} else if (!/[0-9]/.test(newPassword)) {
setNewError("Must contain at least one number");
hasError = true;
} else if (!/[^A-Za-z0-9\s]/.test(newPassword)) {
} else if (!/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(newPassword)) {
setNewError("Must contain at least one special character");
hasError = true;
}

View File

@ -4,6 +4,7 @@ import {
BackHandler,
Linking,
Platform,
Pressable,
ScrollView,
StyleSheet,
Text,
@ -13,7 +14,7 @@ import {
import { SafeAreaView } from "react-native-safe-area-context";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
import { moderateScale, verticalScale } from "react-native-size-matters";
import { moderateScale, scale, verticalScale } from "react-native-size-matters";
import Constants from "expo-constants";
import { Colors } from "@/theme";
@ -166,15 +167,22 @@ export default function SubscriptionScreen() {
return (
<SafeAreaView style={styles.safeArea} edges={["top", "bottom", "left", "right"]}>
<View style={styles.header}>
<TouchableOpacity
<Pressable
onPress={handleBack}
style={styles.backButton}
style={({ pressed }) => [
styles.backButton,
pressed && styles.backButtonPressed,
]}
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
accessibilityRole="button"
accessibilityLabel="Go back"
>
<Ionicons name="chevron-back" size={24} color={Colors.textPrimary} />
</TouchableOpacity>
<Ionicons
name="chevron-back"
size={moderateScale(24)}
color={Colors.textPrimary}
/>
</Pressable>
<Text style={styles.headerTitle} numberOfLines={1}>
{title}
</Text>
@ -237,10 +245,15 @@ const styles = StyleSheet.create({
backgroundColor: "#FFFFFF",
},
backButton: {
width: moderateScale(36),
height: moderateScale(36),
alignItems: "center",
width: scale(38),
height: scale(38),
borderRadius: scale(19),
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F1F5F9",
},
backButtonPressed: {
backgroundColor: "#E2E8F0",
},
headerTitle: {
flex: 1,
@ -250,7 +263,7 @@ const styles = StyleSheet.create({
textAlign: "center",
marginHorizontal: moderateScale(8),
},
placeholder: { width: moderateScale(36) },
placeholder: { width: scale(38), height: scale(38) },
scrollContent: {
flexGrow: 1,
justifyContent: "center",

View File

@ -72,7 +72,7 @@ export default function SignUpForm() {
} else if (!/[0-9]/.test(password)) {
setPasswordError("Password must contain at least one number (0-9)");
hasError = true;
} else if (!/[^A-Za-z0-9\s]/.test(password)) {
} else if (!/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(password)) {
setPasswordError("Password must contain at least one special character (!@#$)");
hasError = true;
}

View File

@ -2,9 +2,14 @@ import React, { type ReactNode, useCallback } from "react";
import { BackHandler, Platform, Pressable, StyleSheet, Text, View } from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { router, useFocusEffect } from "expo-router";
import { moderateScale } from "react-native-size-matters";
import { moderateScale, scale } 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 ? (
@ -76,16 +91,16 @@ export function ContentPageHeader({
<Pressable
accessibilityRole="button"
accessibilityLabel="Go back"
hitSlop={10}
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
onPress={handleBack}
style={({ pressed }) => [
styles.iconButton,
pressed && styles.pressed,
styles.backButton,
pressed && styles.backButtonPressed,
]}
>
<Ionicons
name="chevron-back"
size={24}
size={moderateScale(24)}
color={Colors.textPrimary}
/>
</Pressable>
@ -139,12 +154,16 @@ const styles = StyleSheet.create({
alignItems: "center",
justifyContent: "flex-end",
},
iconButton: {
width: 40,
height: 40,
borderRadius: 20,
alignItems: "center",
backButton: {
width: scale(38),
height: scale(38),
borderRadius: scale(19),
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F1F5F9",
},
backButtonPressed: {
backgroundColor: "#E2E8F0",
},
pressed: {
opacity: 0.65,

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, humanizeKey } from "../helpers/value";
import { asNumber, asString, asStringArray, humanizeKey } from "../helpers/value";
import { CollectionScaffold } from "../shared/CollectionScaffold";
import { ContentCountBadge } from "../shared/ContentCountBadge";
import type {
@ -31,6 +31,10 @@ export function ModuleCatalogCardRenderer({
const rawLabel =
parenSubtitle ||
asString(attributes.sub_title) ||
asString(attributes.subtitle) ||
(asStringArray(attributes.alt_name).length > 0
? asStringArray(attributes.alt_name).join(", ")
: asString(attributes.alt_name)) ||
asString(attributes.pattern_category) ||
asString(attributes.category) ||
asString(attributes.classification) ||
@ -57,7 +61,7 @@ export function ModuleCatalogCardRenderer({
<View style={styles.textContainer}>
<Text style={styles.title}>{cleanTitle}</Text>
{label ? (
<Text style={styles.description} numberOfLines={1}>
<Text numberOfLines={2} style={styles.subtitle}>
{label}
</Text>
) : null}
@ -99,10 +103,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

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

@ -1,25 +1,44 @@
import React, { type PropsWithChildren } from "react";
import React, { type PropsWithChildren, useState } from "react";
import { Pressable, StyleSheet, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
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;
rightAction?: React.ReactNode;
}
export function DetailPageShell({ children, onBack, rightAction }: DetailPageShellProps) {
const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
export function DetailPageShell({
children,
onBack,
tone,
moduleCode: propModuleCode,
hideFavorite,
rightAction,
}: DetailPageShellProps) {
const [isFavorite, setIsFavorite] = useState(false);
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,9 +53,26 @@ export function DetailPageShell({ children, onBack, rightAction }: DetailPageShe
</Pressable>
) : null;
const headerActions = searchAction || rightAction ? (
const favoriteAction = !shouldHideFavorite ? (
<Pressable
accessibilityRole="button"
accessibilityLabel={isFavorite ? "Remove from favorites" : "Add to favorites"}
hitSlop={10}
onPress={() => setIsFavorite((value) => !value)}
style={({ pressed }) => [styles.iconButton, pressed && styles.pressed]}
>
<Ionicons
name={isFavorite ? "heart" : "heart-outline"}
size={22}
color={isFavorite ? Colors.error : Colors.textPrimary}
/>
</Pressable>
) : null;
const headerActions = searchAction || favoriteAction || rightAction ? (
<View style={styles.actions}>
{searchAction}
{favoriteAction}
{rightAction}
</View>
) : undefined;
@ -45,6 +81,7 @@ export function DetailPageShell({ children, onBack, rightAction }: DetailPageShe
<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

@ -51,7 +51,9 @@ function isPresent(value: unknown): boolean {
const styles = StyleSheet.create({
root: { gap: 16 },
section: { gap: 7 },
section: {
gap: 7,
},
divider: {
paddingTop: 12,
borderTopWidth: StyleSheet.hairlineWidth,

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

@ -3,6 +3,7 @@ import { Platform, Pressable, StyleSheet, Text, TextInput, View } from "react-na
import { SafeAreaView } from "react-native-safe-area-context";
import { Ionicons } from "@expo/vector-icons";
import { router } from "expo-router";
import { moderateScale, scale } from "react-native-size-matters";
import { Colors } from "@/theme";
import { useDebouncedValue } from "@/features/content/hooks/use-debounced-value";
@ -150,12 +151,18 @@ export default function FacetedSearchScreen({
<SafeAreaView style={styles.safe} edges={["top", "left", "right"]}>
<View style={styles.header}>
<Pressable
accessibilityRole="button"
accessibilityLabel="Go back"
hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
onPress={() => router.back()}
style={styles.headerButton}
style={({ pressed }) => [
styles.backButton,
pressed && styles.backButtonPressed,
]}
>
<Ionicons
name="chevron-back"
size={24}
size={moderateScale(24)}
color={Colors.textPrimary}
/>
</Pressable>
@ -167,7 +174,7 @@ export default function FacetedSearchScreen({
</Text>
) : null}
</View>
<View style={styles.headerButton} />
<View style={styles.headerPlaceholder} />
</View>
<View style={styles.controls}>
@ -346,7 +353,18 @@ const styles = StyleSheet.create({
borderBottomColor: "#ECECEC",
backgroundColor: Colors.white,
},
headerButton: { width: 32, padding: 4 },
backButton: {
width: scale(38),
height: scale(38),
borderRadius: scale(19),
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F1F5F9",
},
backButtonPressed: {
backgroundColor: "#E2E8F0",
},
headerPlaceholder: { width: scale(38), height: scale(38) },
headerCenter: { flex: 1, alignItems: "center" },
headerTitle: {
fontSize: 18,

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",