Points #78
|
|
@ -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 ? (
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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" },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ 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";
|
||||||
|
|
||||||
|
|
@ -12,9 +13,10 @@ interface DetailPageShellProps extends PropsWithChildren {
|
||||||
title: string;
|
title: string;
|
||||||
subtitle?: string;
|
subtitle?: string;
|
||||||
onBack?: () => void;
|
onBack?: () => void;
|
||||||
|
tone?: PageTone;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
|
export function DetailPageShell({ children, onBack, tone }: DetailPageShellProps) {
|
||||||
const [isFavorite, setIsFavorite] = useState(false);
|
const [isFavorite, setIsFavorite] = useState(false);
|
||||||
const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
|
const { moduleCode } = useLocalSearchParams<{ moduleCode?: string }>();
|
||||||
const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
|
const currentModuleCode = typeof moduleCode === "string" ? moduleCode : "";
|
||||||
|
|
@ -54,6 +56,7 @@ export function DetailPageShell({ children, onBack }: DetailPageShellProps) {
|
||||||
<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
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,42 @@
|
||||||
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;
|
||||||
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,
|
||||||
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 || contextTone || "purple";
|
||||||
|
const currentTone = cardTones[effectiveTone] || cardTones.purple;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
|
@ -47,8 +45,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: tone.soft }]}>
|
<View style={[styles.accent, { backgroundColor: currentTone.soft }]}>
|
||||||
<View style={[styles.accentDot, { backgroundColor: tone.accent }]} />
|
<View style={[styles.accentDot, { backgroundColor: currentTone.accent }]} />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.titleBlock}>
|
<View style={styles.titleBlock}>
|
||||||
|
|
@ -63,8 +61,8 @@ 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}>
|
||||||
{countLabel}
|
{countLabel}
|
||||||
|
|
|
||||||
|
|
@ -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];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 { 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,19 +132,48 @@ export function CollectionTemplateScreen({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
|
<PageToneProvider tone="purple">
|
||||||
<ContentPageHeader
|
<SafeAreaView style={styles.screen} edges={["top", "left", "right"]}>
|
||||||
title={moduleDisplay.name}
|
<ContentPageHeader
|
||||||
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
|
title={moduleDisplay.name}
|
||||||
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
|
onTitlePress={() => router.push(moduleDisplay.homeRoute as never)}
|
||||||
right={headerActions}
|
titleAccessibilityLabel={`Open ${moduleDisplay.name} home`}
|
||||||
/>
|
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}
|
||||||
|
|
@ -166,56 +196,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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,43 @@ 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}>
|
>
|
||||||
<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}
|
||||||
|
|
@ -131,25 +156,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>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue