acupedia-mobile-ui/src/features/content/renderers/collections/PathogenicFactorsRenderers.tsx

176 lines
5.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 type {
CollectionItemRendererProps,
CollectionRendererProps,
} from "../../types/renderer.types";
export function PathogenicFactorsCollectionRenderer(
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}>
This method of pattern identification is based on the pathological changes occurring when the body is invaded by pathogenic factors such as Wind, Cold, Summer-Heat, Dampness, Dryness and Fire. Each of these pathogenic factors may be exterior or interior.
</Text>
<Text style={styles.overviewParagraph}>
They always correspond to a Full pattern according to the Eight Principles. Indeed, from the Eight-Principle point of view, a Full condition is defined as one characterized by the presence of a pathogenic factor while the body’s Qi is still relatively intact.
</Text>
<Text style={styles.overviewParagraph}>
The pathogenic factor is frequently associated with a Deficiency, in which case the condition is a combined Full–Empty condition. With regard to pathogenic factors, a combined Full-Empty condition can arise in one of two ways: a pathogenic factor can give rise to a Deficiency (e.g. Fire weakens Yin) or a Deficiency can give rise to a pathogenic factor (e.g. Spleen-Qi deficiency gives rise to Dampness).
</Text>
<Text style={styles.overviewParagraph}>
Generally speaking, pathogenic factors are more relevant as patterns of disharmony than as causes of disease. The diagnosis of a pathogenic factor is made not on the basis of the patient’s history, but on the basis of the pattern of symptoms and signs presented.
</Text>
</View>
<Text style={styles.sectionHeading}>Pathogenic Factors</Text>
</View>
);
return <CollectionScaffold {...props} header={header} />;
}
export function PathogenicFactorsCardRenderer({
item,
onPress,
}: CollectionItemRendererProps) {
const a = item.attributes;
const title =
asString(a.name) ||
asString(a.title) ||
item.title;
const overview =
asString(a.overview) ||
asString(a.content) ||
item.summary;
const sortOrder = asNumber(a.sort_order);
const factorNumber = typeof sortOrder === "number" && sortOrder > 0 ? sortOrder : undefined;
return (
<Pressable
accessibilityRole="button"
accessibilityLabel={title}
onPress={onPress}
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
>
<View style={styles.iconBox}>
{factorNumber !== undefined ? (
<Text style={styles.factorNumber}>{factorNumber}</Text>
) : (
<Ionicons name="leaf-outline" size={20} color={Colors.textPrimary} />
)}
</View>
<View style={styles.content}>
<Text numberOfLines={2} style={styles.title}>
{title}
</Text>
{overview ? (
<Text numberOfLines={3} style={styles.subtitle}>
{overview}
</Text>
) : null}
</View>
<Ionicons name="chevron-forward" size={19} color="#94A3B8" />
</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: verticalScale(72),
flexDirection: "row",
alignItems: "center",
paddingHorizontal: moderateScale(14),
paddingVertical: verticalScale(13),
gap: moderateScale(11),
},
pressed: {
opacity: 0.72,
},
iconBox: {
width: moderateScale(40),
height: moderateScale(40),
borderRadius: moderateScale(20),
alignItems: "center",
justifyContent: "center",
backgroundColor: "#E8F5E9",
},
factorNumber: {
fontSize: moderateScale(16),
fontWeight: "800",
color: Colors.primaryDark,
},
content: {
flex: 1,
gap: verticalScale(3),
},
title: {
fontSize: moderateScale(16),
lineHeight: moderateScale(22),
fontWeight: "700",
color: Colors.textPrimary,
},
subtitle: {
fontSize: moderateScale(12.5),
lineHeight: moderateScale(18),
color: Colors.textSecondary,
},
});