168 lines
5.2 KiB
TypeScript
168 lines
5.2 KiB
TypeScript
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 { asNumber, asString } from "../helpers/value";
|
|
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
|
import { ContentCountBadge } from "../shared/ContentCountBadge";
|
|
import type {
|
|
CollectionItemRendererProps,
|
|
CollectionRendererProps,
|
|
} from "../../types/renderer.types";
|
|
|
|
export function FiveElementsCollectionRenderer(props: CollectionRendererProps) {
|
|
const header = (
|
|
<View style={styles.overviewContainer}>
|
|
<View style={styles.overviewCard}>
|
|
<View style={styles.overviewHeader}>
|
|
<Ionicons name="information-circle" size={20} color={Colors.primary} />
|
|
<Text style={styles.overviewTitle}>Overview</Text>
|
|
</View>
|
|
<Text style={styles.overviewText}>
|
|
The identification of patterns according to the Five Elements is based on the pathological changes occurring in dysfunctions of the Generating, Overacting and Insulting sequences of the Five Elements.
|
|
</Text>
|
|
<Text style={styles.overviewParagraph}>
|
|
These patterns describe clinical conditions which are often expressed by the Internal Organ patterns, but in certain cases, Five-Element patterns describe conditions falling outside their scope (such as Deficient Qi of Wood manifesting with timidity and indecision).
|
|
</Text>
|
|
<Text style={styles.overviewParagraph}>
|
|
The sequences below detail the Generating, Overacting, and Insulting relationships and their specific clinical presentations.
|
|
</Text>
|
|
</View>
|
|
<Text style={styles.sectionHeading}>Sequences</Text>
|
|
</View>
|
|
);
|
|
|
|
const sortedItems = React.useMemo(() => {
|
|
return [...props.items].sort((a, b) => {
|
|
const orderA = asNumber(a.attributes.sort_order) ?? 999;
|
|
const orderB = asNumber(b.attributes.sort_order) ?? 999;
|
|
return orderA - orderB;
|
|
});
|
|
}, [props.items]);
|
|
|
|
return <CollectionScaffold {...props} items={sortedItems} header={header} />;
|
|
}
|
|
|
|
export function FiveElementsCardRenderer({
|
|
item,
|
|
onPress,
|
|
}: CollectionItemRendererProps) {
|
|
const attributes = item.attributes;
|
|
const title = asString(attributes.title) || asString(attributes.name) || item.title;
|
|
const label =
|
|
asString(attributes.content_label) ||
|
|
asString(attributes.description) ||
|
|
item.summary ||
|
|
"Open sequence";
|
|
|
|
const sortOrder = asNumber(attributes.sort_order);
|
|
const sequenceNumber = typeof sortOrder === "number" ? sortOrder + 1 : undefined;
|
|
|
|
return (
|
|
<Pressable
|
|
accessibilityRole="button"
|
|
onPress={onPress}
|
|
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
|
|
>
|
|
<View style={styles.iconWrapper}>
|
|
<Text style={styles.sequenceNumber}>{sequenceNumber !== undefined ? sequenceNumber : "•"}</Text>
|
|
</View>
|
|
|
|
<View style={styles.textContainer}>
|
|
<Text style={styles.title}>{title}</Text>
|
|
<Text style={styles.description} numberOfLines={1}>
|
|
{label}
|
|
</Text>
|
|
</View>
|
|
|
|
<ContentCountBadge
|
|
count={asNumber(attributes.content_count)}
|
|
label={asString(attributes.content_label)}
|
|
/>
|
|
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
|
</Pressable>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
overviewContainer: {
|
|
marginBottom: verticalScale(14),
|
|
},
|
|
overviewCard: {
|
|
backgroundColor: "#FFFFFF",
|
|
borderRadius: moderateScale(16),
|
|
borderWidth: 1,
|
|
borderColor: "#E2EAE5",
|
|
padding: moderateScale(16),
|
|
marginBottom: verticalScale(14),
|
|
},
|
|
overviewHeader: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
marginBottom: verticalScale(8),
|
|
gap: moderateScale(8),
|
|
},
|
|
overviewTitle: {
|
|
fontSize: moderateScale(16),
|
|
fontWeight: "700",
|
|
color: Colors.textPrimary,
|
|
},
|
|
overviewText: {
|
|
fontSize: moderateScale(13),
|
|
lineHeight: verticalScale(19),
|
|
color: Colors.textSecondary,
|
|
},
|
|
overviewParagraph: {
|
|
fontSize: moderateScale(13),
|
|
lineHeight: verticalScale(19),
|
|
color: Colors.textSecondary,
|
|
marginTop: verticalScale(10),
|
|
},
|
|
sectionHeading: {
|
|
fontSize: moderateScale(15),
|
|
fontWeight: "700",
|
|
color: Colors.textPrimary,
|
|
marginBottom: verticalScale(4),
|
|
marginLeft: moderateScale(4),
|
|
},
|
|
row: {
|
|
minHeight: moderateScale(68),
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
padding: moderateScale(14),
|
|
},
|
|
pressed: {
|
|
opacity: 0.72,
|
|
},
|
|
iconWrapper: {
|
|
width: moderateScale(40),
|
|
height: moderateScale(40),
|
|
borderRadius: moderateScale(20),
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
backgroundColor: "#E8F5E9",
|
|
},
|
|
sequenceNumber: {
|
|
fontSize: moderateScale(16),
|
|
fontWeight: "800",
|
|
color: Colors.primaryDark,
|
|
},
|
|
textContainer: {
|
|
flex: 1,
|
|
marginLeft: moderateScale(12),
|
|
marginRight: moderateScale(10),
|
|
},
|
|
title: {
|
|
fontSize: moderateScale(15),
|
|
fontWeight: "600",
|
|
color: Colors.textPrimary,
|
|
marginBottom: verticalScale(2),
|
|
},
|
|
description: {
|
|
fontSize: moderateScale(12),
|
|
color: Colors.textSecondary,
|
|
},
|
|
});
|