Fakultas Ilmu Komputer UI

index.tsx 1.38 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
import { CarouselPagination } from 'components/core';
import React, { FC, useState } from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import Carousel from 'react-native-snap-carousel';
import WeeklyReportPage from './components/WeeklyReportPage';
import { page1 } from './pages/Page1';
import { page2 } from './pages/Page2';
import { page3 } from './pages/Page3';
import { page4 } from './pages/Page4';

const ReadOnlyWeeklyReport: FC = () => {
  const [activeSlide, setActiveSlide] = useState(0);
  const pageComponents = [
    <WeeklyReportPage questions={page1} title="Laporan Diet Anda" />,
    <WeeklyReportPage questions={page2} />,
    <WeeklyReportPage
      questions={page3}
      title="Selama 1 minggu terakhir, berapa rata-rata Anda mengonsumsi jenis makanan dibawah ini selama seharian?"
    />,
    <WeeklyReportPage questions={page4} />,
  ];

  return (
    <>
      <View style={[styles.flexContainer]}>
        <Carousel
          data={pageComponents}
          renderItem={({ item }: any) => item}
          sliderWidth={Dimensions.get('window').width}
          itemWidth={Dimensions.get('window').width}
          onSnapToItem={setActiveSlide}
        />
      </View>
      <CarouselPagination index={activeSlide} length={4} />
    </>
  );
};

const styles = StyleSheet.create({
  flexContainer: {
    flex: 1,
  },
});

export default ReadOnlyWeeklyReport;