IntroductionContainer.js 1.51 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
import React, {useEffect, useState} from 'react';
import IntroScreen from './IntroductionScreen';
import RootNavigation from '../../../navigation/RootNavigation';
import {APP_NAVIGATE_SCREEN} from '../../../utils/constant';
import {useTranslation} from 'react-i18next';
const IntroductionContainer = props => {
  // console.log("props: ", props)
  const {t, i18n} = useTranslation();

  const [indexSwiper, setIndex] = useState(0);
  const [showsPagination, setShowPagination] = useState(true);
  const [scroll, setScrollEnabled] = useState(true);

  const nextView = () => {
    setIndex(indexSwiper + 1);
  };
  const preView = () => {
    setIndex(indexSwiper - 1);
  };

  const hidePagination = () => {
    //console.log("hidePagination")
    setShowPagination(false);
  };
  const showPagination = () => {
    //console.log("hidePagination")
    setShowPagination(true);
  };
  const scrollEnabled = () => {
    setScrollEnabled(true);
  };
  const disableScroll = () => {
    setScrollEnabled(false);
  };
  const onSwiper = index => {
    //console.log(index)
    setIndex(index);
    if (index >= 3) {
      hidePagination();
      disableScroll();
    } else {
      showPagination();
      scrollEnabled();
    }
  };
  const navigateToDomain = () => {
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
47 48
    RootNavigation.navigate(APP_NAVIGATE_SCREEN.LOGIN);
  };
49 50 51 52 53 54 55
  const introProps = {
    indexSwiper,
    showsPagination,
    scroll,
    nextView,
    preView,
    onSwiper,
quynhquang400@gmail.com's avatar
quynhquang400@gmail.com committed
56
    navigateToDomain,
57 58 59 60 61
  };
  return <IntroScreen {...introProps} />;
};

export default IntroductionContainer;