feat(renderers): add four levels detail renderer
This commit is contained in:
parent
62e11a5665
commit
ef7ed5d2a3
|
|
@ -0,0 +1,114 @@
|
|||
import React from "react";
|
||||
import { ScrollView, StyleSheet } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { asString } from "../helpers/value";
|
||||
|
||||
export function FourLevelsDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const title =
|
||||
asString(data.name) ||
|
||||
asString(data.title) ||
|
||||
content.title;
|
||||
|
||||
const overview = asString(data.overview);
|
||||
const clinicalManifestations =
|
||||
asString(data.clinical_menifestation) ||
|
||||
asString(data.clinical_manifestations);
|
||||
const tongue = asString(data.tongue);
|
||||
const pulse = asString(data.pulse);
|
||||
const pathology = asString(data.pathology);
|
||||
const treatmentPrinciple =
|
||||
asString(data.treatment_principle) ||
|
||||
asString(data["treatment principle"]);
|
||||
const treatment = asString(data.treatment);
|
||||
const explanation = asString(data.explanation);
|
||||
const contentText = asString(data.content);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={styles.content}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero title={title} />
|
||||
|
||||
{overview ? (
|
||||
<SectionCard title="Overview">
|
||||
<Paragraphs items={[overview]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{clinicalManifestations ? (
|
||||
<SectionCard title="Clinical Manifestations">
|
||||
<Paragraphs items={[clinicalManifestations]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{tongue ? (
|
||||
<SectionCard title="Tongue">
|
||||
<Paragraphs items={[tongue]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{pulse ? (
|
||||
<SectionCard title="Pulse">
|
||||
<Paragraphs items={[pulse]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{pathology ? (
|
||||
<SectionCard title="Pathology">
|
||||
<Paragraphs items={[pathology]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{treatmentPrinciple ? (
|
||||
<SectionCard title="Treatment Principle">
|
||||
<Paragraphs items={[treatmentPrinciple]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{treatment ? (
|
||||
<SectionCard title="Treatment">
|
||||
<Paragraphs items={[treatment]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{explanation ? (
|
||||
<SectionCard title="Explanation">
|
||||
<Paragraphs items={[explanation]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{contentText ? (
|
||||
<SectionCard title="Content">
|
||||
<Paragraphs items={[contentText]} />
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
<ContentLinkAttributeSections
|
||||
data={data}
|
||||
definitions={definitions}
|
||||
presentationAttributes={presentationAttributes}
|
||||
/>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
content: {
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
},
|
||||
});
|
||||
|
|
@ -30,6 +30,8 @@ import { ReturningYangDetailRenderer } from "./details/ReturningYangDetailRender
|
|||
import { EarAcupunctureCatalogCollectionRenderer, EarAcupunctureCatalogCardRenderer, EarAcupunctureCollectionRenderer, EarAcupunctureCardRenderer } from "./collections/EarAcupunctureRenderers";
|
||||
import { EarAcupunctureCatalogDetailRenderer } from "./details/EarAcupunctureCatalogDetailRenderer";
|
||||
import { EarAcupunctureDetailRenderer } from "./details/EarAcupunctureDetailRenderer";
|
||||
import { FourLevelsCollectionRenderer, FourLevelsCardRenderer } from "./collections/FourLevelsRenderers";
|
||||
import { FourLevelsDetailRenderer } from "./details/FourLevelsDetailRenderer";
|
||||
|
||||
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
||||
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
||||
|
|
@ -42,6 +44,7 @@ export const collectionRenderers: Readonly<Record<string, CollectionRendererComp
|
|||
point_category_index_collection: PointCategoryIndexCollectionRenderer,
|
||||
ear_acupuncture_catalog_collection: EarAcupunctureCatalogCollectionRenderer,
|
||||
ear_acupuncture_collection: EarAcupunctureCollectionRenderer,
|
||||
four_levels_collection: FourLevelsCollectionRenderer,
|
||||
});
|
||||
export const collectionItemRenderers: Readonly<Record<string, CollectionItemRendererComponent>> = Object.freeze({
|
||||
module_catalog_card: ModuleCatalogCardRenderer,
|
||||
|
|
@ -54,6 +57,7 @@ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRend
|
|||
point_category_index_card: PointCategoryIndexCardRenderer,
|
||||
ear_acupuncture_catalog_card: EarAcupunctureCatalogCardRenderer,
|
||||
ear_acupuncture_card: EarAcupunctureCardRenderer,
|
||||
four_levels_card: FourLevelsCardRenderer,
|
||||
});
|
||||
export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({
|
||||
module_catalog_detail: IndexEntryDetailRenderer,
|
||||
|
|
@ -82,6 +86,7 @@ export const detailRenderers: Readonly<Record<string, DetailRendererComponent>>
|
|||
returning_yang_detail: ReturningYangDetailRenderer,
|
||||
ear_acupuncture_catalog_detail: EarAcupunctureCatalogDetailRenderer,
|
||||
ear_acupuncture_detail: EarAcupunctureDetailRenderer,
|
||||
four_levels_detail: FourLevelsDetailRenderer,
|
||||
});
|
||||
function reportMissingRenderer(kind: string, code?: string | null) {
|
||||
if (__DEV__) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue