Fakultas Ilmu Komputer UI

index.tsx 1.59 KB
Newer Older
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
import { useRoute } from '@react-navigation/core';
import { Section } from 'components/layout';
import { BodyMedium, HeadingLarge } from 'components/typography';
import { dietPrograms } from 'constants/dietelaProgram';
import React, { FC } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Icon, ListItem } from 'react-native-elements';
import { ScrollView } from 'react-native-gesture-handler';
import { DietelaProgram } from 'services/cart/models';
import { colors, layoutStyles } from 'styles';

interface IdProgram {
  id: DietelaProgram;
}

const styles = StyleSheet.create({
  padding: { padding: 10 },
});

const ProgramDetail: FC = () => {
  const route = useRoute();
  const { id } = route.params as IdProgram;
  const programTitle = dietPrograms[id].title;
  const programDetail = dietPrograms[id].details;

  return (
    <ScrollView contentContainerStyle={layoutStyles}>
      <HeadingLarge text={programTitle} />

      <Section>
        <BodyMedium text={programDetail.description} />
      </Section>

      {programDetail.details.map((detail, i) => (
        <View key={`details${i}`}>
          <Section>
            <Text>{detail.title}</Text>
          </Section>

          {detail.content.map((item, j) => (
            <ListItem key={`info${j}`} containerStyle={styles.padding}>
              <Icon name="check" color={colors.primary} />
              <ListItem.Content>
                <ListItem.Title>{item}</ListItem.Title>
              </ListItem.Content>
            </ListItem>
          ))}
        </View>
      ))}
    </ScrollView>
  );
};

export default ProgramDetail;