1.0.11 • Published 4 years ago

react-native-swiper-hook v1.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-native-swiper-hook

an improvement for react-native-swiper for better swipe handling. For more info about swiperProps visit react-native-swiper page.

install with yarn add react-native-swiper-hook

How to use

import React, { FC, ReactNode } from 'react';
import styled from 'styled-components/native';
import { useSwipeableView } from 'react-native-swiper-hook';
import { View, Button } from 'react-native';
import { SlideIndicator } from '../../atoms/SlideIndicator';

export const OnboardingStoryTemplate: FC = () => {
  const onLastSwipe = () => {
    //Do something on last swipe
  };
  const slidesTexts = ['text1', 'text2', 'text3', 'text4'];
  const slides = (slidesTexts: string[]): ReactNode[] =>
    slidesTexts.map((text) => (
      <>
        <ImagePlaceholder />
        <Paragraph>{text}</Paragraph>
      </>
    ));

  const { SwipeableViews, increaseIndex } = useSwipeableView({
    slides: slides(slidesTexts),
    onLastSwipe,
    swiperProps: {
      dot: <SlideIndicator />,
      activeDot: <SlideIndicator active />,
    },
  });
  return (
    <>
      <PageWrapper>
        <SwipeableViews />
        <View>
          <Button title="CONTINUE" onPress={increaseIndex} />
        </View>
      </PageWrapper>
    </>
  );
};

const ImagePlaceholder = styled.View``;

const Paragraph = styled.Text``;

const PageWrapper = styled.View`
  flex: 1;
`;
1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago