forked from WorldHealthOrganization/app
/
ProtectYourself.tsx
59 lines (57 loc) · 1.79 KB
/
ProtectYourself.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React from 'react';
import {
IonContent,
IonPage,
IonSlides,
IonSlide,
IonCard,
IonCardContent,
IonImg,
} from '@ionic/react';
import TopNav from '../components/TopNav';
import 'tachyons';
import useDynamicFlow from '../hooks/useDynamicFlow';
const ProtectYourself: React.FC = () => {
// TODO: Refactor this out to separate Flow components. Use a dictionary
// of screen archetypes.
const flow = useDynamicFlow('protect');
return (
<IonPage className="pa3">
<TopNav />
<IonContent>
{flow.content && flow.content.screens && (
<IonSlides pager={true}>
{flow.content.screens.map(screen => {
switch (screen.type) {
case 'TextImage':
return (
<IonSlide>
<IonCard>
<IonCardContent className="pb3 tc ph5">
{screen.bottomImageUri && (
/* TODO: actual css */
<IonImg
className="w-80 center"
style={{
width: 260,
}}
src={flow.imgPrefix + '/' + screen.bottomImageUri}
/>
)}
{screen.bodyTexts &&
screen.bodyTexts.map(txt => <p>{txt}</p>)}
</IonCardContent>
</IonCard>
</IonSlide>
);
default:
/** TODO: Handle errors of unsupported screen types correctly. */
}
})}
</IonSlides>
)}
</IonContent>
</IonPage>
);
};
export default ProtectYourself;