feat(gynecology): remove view full details, explanation links, and disable clicks on empty catalog items
This commit is contained in:
parent
3663323c20
commit
203fbbc0c9
|
|
@ -47,41 +47,9 @@ function normalizePointCode(raw: string): string {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderExplanationParts(
|
|
||||||
text: string,
|
|
||||||
onPointPress: (code: string) => void,
|
|
||||||
) {
|
|
||||||
const pointRegex = /\b([A-Za-z]{1,4}-\d{1,2})\b/g;
|
|
||||||
const parts: React.ReactNode[] = [];
|
|
||||||
let lastIndex = 0;
|
|
||||||
let match: RegExpExecArray | null;
|
|
||||||
|
|
||||||
while ((match = pointRegex.exec(text)) !== null) {
|
|
||||||
if (match.index > lastIndex) {
|
|
||||||
parts.push(text.substring(lastIndex, match.index));
|
|
||||||
}
|
|
||||||
const ptCode = match[1];
|
|
||||||
parts.push(
|
|
||||||
<Text
|
|
||||||
key={`pt-${match.index}`}
|
|
||||||
accessibilityRole="button"
|
|
||||||
onPress={() => onPointPress(ptCode)}
|
|
||||||
style={accordionStyles.pointTextLink}
|
|
||||||
>
|
|
||||||
{ptCode}
|
|
||||||
</Text>
|
|
||||||
);
|
|
||||||
lastIndex = match.index + match[0].length;
|
|
||||||
}
|
|
||||||
if (lastIndex < text.length) {
|
|
||||||
parts.push(text.substring(lastIndex));
|
|
||||||
}
|
|
||||||
return parts.length > 0 ? parts : text;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PatternAccordionCardRenderer({
|
export function PatternAccordionCardRenderer({
|
||||||
item,
|
item,
|
||||||
onPress,
|
|
||||||
}: CollectionItemRendererProps) {
|
}: CollectionItemRendererProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
|
|
@ -340,9 +308,7 @@ export function PatternAccordionCardRenderer({
|
||||||
{explanations.map((exp, idx) => (
|
{explanations.map((exp, idx) => (
|
||||||
<View key={idx} style={accordionStyles.explanationRow}>
|
<View key={idx} style={accordionStyles.explanationRow}>
|
||||||
<View style={accordionStyles.explanationDot} />
|
<View style={accordionStyles.explanationDot} />
|
||||||
<Text style={accordionStyles.explanationText}>
|
<Text style={accordionStyles.explanationText}>{exp}</Text>
|
||||||
{renderExplanationParts(exp, handlePointPress)}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -359,22 +325,6 @@ export function PatternAccordionCardRenderer({
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{/* Optional link to navigate to full detail screen */}
|
|
||||||
{onPress ? (
|
|
||||||
<Pressable
|
|
||||||
accessibilityRole="button"
|
|
||||||
onPress={onPress}
|
|
||||||
style={({ pressed }) => [
|
|
||||||
accordionStyles.viewFullDetailBtn,
|
|
||||||
pressed && accordionStyles.pressed,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Text style={accordionStyles.viewFullDetailText}>
|
|
||||||
View Full Details
|
|
||||||
</Text>
|
|
||||||
<Ionicons name="arrow-forward" size={14} color={greenTone.accent} />
|
|
||||||
</Pressable>
|
|
||||||
) : null}
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -393,7 +343,7 @@ export function ModuleCatalogCardRenderer({
|
||||||
|
|
||||||
// If this item points to a pattern content item, render inline accordion
|
// If this item points to a pattern content item, render inline accordion
|
||||||
if (isContentRef) {
|
if (isContentRef) {
|
||||||
return <PatternAccordionCardRenderer item={item} onPress={onPress} />;
|
return <PatternAccordionCardRenderer item={item} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawTitle = asString(attributes.name) || item.title;
|
const rawTitle = asString(attributes.name) || item.title;
|
||||||
|
|
@ -422,12 +372,23 @@ export function ModuleCatalogCardRenderer({
|
||||||
|
|
||||||
const cleanTitle = humanizeKey(title);
|
const cleanTitle = humanizeKey(title);
|
||||||
const label = rawLabel ? humanizeKey(rawLabel) : null;
|
const label = rawLabel ? humanizeKey(rawLabel) : null;
|
||||||
|
const count = asNumber(attributes.content_count);
|
||||||
|
const itemCode = asString(attributes.code).toLowerCase().trim();
|
||||||
|
const rawTitleLower = rawTitle.toLowerCase().trim();
|
||||||
|
const isClickable =
|
||||||
|
count !== 0 &&
|
||||||
|
!["diseases_after_childbirth", "other"].includes(itemCode) &&
|
||||||
|
!["diseases after childbirth", "other"].includes(rawTitleLower);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
accessibilityRole="button"
|
accessibilityRole={isClickable ? "button" : undefined}
|
||||||
onPress={onPress}
|
disabled={!isClickable}
|
||||||
style={({ pressed }) => [styles.row, pressed && styles.pressed]}
|
onPress={isClickable ? onPress : undefined}
|
||||||
|
style={({ pressed }) => [
|
||||||
|
styles.row,
|
||||||
|
isClickable && pressed && styles.pressed,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<View style={styles.iconWrapper}>
|
<View style={styles.iconWrapper}>
|
||||||
<Ionicons name="book-outline" size={22} color={Colors.primary} />
|
<Ionicons name="book-outline" size={22} color={Colors.primary} />
|
||||||
|
|
@ -443,10 +404,12 @@ export function ModuleCatalogCardRenderer({
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ContentCountBadge
|
<ContentCountBadge
|
||||||
count={asNumber(attributes.content_count)}
|
count={count}
|
||||||
label={asString(attributes.content_label)}
|
label={asString(attributes.content_label)}
|
||||||
/>
|
/>
|
||||||
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
{isClickable ? (
|
||||||
|
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
||||||
|
) : null}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -626,11 +589,6 @@ const accordionStyles = StyleSheet.create({
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
color: "#35664E",
|
color: "#35664E",
|
||||||
},
|
},
|
||||||
pointTextLink: {
|
|
||||||
color: "#285A44",
|
|
||||||
fontWeight: "700",
|
|
||||||
textDecorationLine: "underline",
|
|
||||||
},
|
|
||||||
methodContainer: {
|
methodContainer: {
|
||||||
marginTop: verticalScale(4),
|
marginTop: verticalScale(4),
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
|
|
@ -697,18 +655,6 @@ const accordionStyles = StyleSheet.create({
|
||||||
fontWeight: "600",
|
fontWeight: "600",
|
||||||
color: "#35664E",
|
color: "#35664E",
|
||||||
},
|
},
|
||||||
viewFullDetailBtn: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "flex-end",
|
|
||||||
gap: moderateScale(6),
|
|
||||||
paddingTop: verticalScale(6),
|
|
||||||
},
|
|
||||||
viewFullDetailText: {
|
|
||||||
fontSize: moderateScale(13),
|
|
||||||
fontWeight: "600",
|
|
||||||
color: greenTone.accent,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue