139 lines
5.7 KiB
TypeScript
139 lines
5.7 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 { OverviewCard } from "../shared/OverviewCard";
|
||
import type {
|
||
CollectionItemRendererProps,
|
||
CollectionRendererProps,
|
||
} from "../../types/renderer.types";
|
||
|
||
export function FourLevelsCollectionRenderer(props: CollectionRendererProps) {
|
||
const header = (
|
||
<View style={styles.overviewContainer}>
|
||
<OverviewCard
|
||
style={styles.overviewCard}
|
||
paragraphs={[
|
||
"The Four Levels of Diagnosis in Traditional Chinese Medicine (TCM) is a framework mainly used in Warm Disease Theory (Wen Bing), which deals with febrile (heat) diseases caused by external pathogens, especially warm pathogens like viruses or bacteria. It helps practitioners understand the progression of the disease and guide treatment.",
|
||
"The interpretation of clinical manifestations of Warm Diseases according to the Four Levels was formulated by Ye Tian Shi. This is a brilliant theory that provides the most clinically useful tool to diagnose, interpret and treat diseases caused by external Wind-Heat and their consequences, whether they are Warm Diseases or not.",
|
||
"The theory of the Four Levels is clinically more relevant than that of the Six Stages. For example, one of the most common consequences of an invasion of Wind-Heat is the transformation of external Wind-Heat into interior Phlegm-Heat in the Lungs, causing a chest infection: this situation is contemplated in the Four Levels (corresponding to Lung-Heat, Qi level), while it is not contemplated in the Six Stages.",
|
||
"The Qi level contemplates the pattern of Damp-Heat in Stomach and Spleen as a consequence of an invasion of Wind-Heat: this is a very common clinical situation and yet it is one that is not contemplated in the Six Stages.",
|
||
"The Blood level includes patterns which are characterized by convulsions from the development of internal Wind: these are typical complications of children’s diseases such as meningitis but they are not contemplated in the Six Stages.",
|
||
"The Four Levels are the Defensive Qi, Qi, Nutritive Qi and Blood levels (Wei, Qi, Ying, Xue): the first level is the only exterior one characterized by the presence of the external Wind-Heat on the energetic surface of the body. The other three levels are all interior and all characterized by interior Heat; however, the brilliance of this theory lies in its identification of three different depths of penetration of interior pathogenic Heat. Each level has its own distinctive pathology and treatment.",
|
||
]}
|
||
/>
|
||
<Text style={styles.sectionHeading}>Levels</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 FourLevelsCardRenderer({
|
||
item,
|
||
onPress,
|
||
}: CollectionItemRendererProps) {
|
||
const attributes = item.attributes;
|
||
const title = asString(attributes.title) || asString(attributes.name) || item.title;
|
||
const subtitle =
|
||
asString(attributes.sub_title) ||
|
||
asString(attributes.description) ||
|
||
(item.summary && item.summary !== "Open content" ? item.summary : null);
|
||
|
||
const sortOrder = asNumber(attributes.sort_order);
|
||
const levelNumber = 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.levelNumber}>{levelNumber !== undefined ? levelNumber : "•"}</Text>
|
||
</View>
|
||
|
||
<View style={styles.textContainer}>
|
||
<Text style={styles.title}>{title}</Text>
|
||
{subtitle ? (
|
||
<Text style={styles.description} numberOfLines={1}>
|
||
{subtitle}
|
||
</Text>
|
||
) : null}
|
||
</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: {
|
||
marginBottom: verticalScale(14),
|
||
},
|
||
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",
|
||
},
|
||
levelNumber: {
|
||
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,
|
||
},
|
||
});
|