UNPKG

react-native-slider-intro

Version:

A simple and full customizable React Native package which implements a unique slider.

64 lines (63 loc) 1.62 kB
"use strict"; import React, { useContext } from 'react'; import { Animated, StyleSheet, TouchableOpacity, View } from 'react-native'; import { SliderContext } from './SliderProvider'; import { ButtonType } from '../types/Button.types'; import Button from './Button'; import { jsx as _jsx } from "react/jsx-runtime"; const styles = StyleSheet.create({ wrapper: { flex: 1, justifyContent: 'center', alignItems: 'center' } }); const Previous = () => { const { onSkip, leftButtonType, buttonsMaxSize, showLeftButton, renderSkipButton, skipLabel, slide, setDefaultState, goToNewSlide, animations } = useContext(SliderContext); const { _opacityOfSkipButton } = animations; const handlePress = () => { const { active } = slide; if (leftButtonType === ButtonType.Skip) { setDefaultState(); onSkip?.(); return; } goToNewSlide(active - 1); }; const renderDefaultSkipButton = label => /*#__PURE__*/_jsx(Button, { label: label, type: ButtonType.Skip }); return /*#__PURE__*/_jsx(View, { style: [styles.wrapper, { maxWidth: buttonsMaxSize }], children: showLeftButton && /*#__PURE__*/_jsx(TouchableOpacity, { onPress: handlePress, children: /*#__PURE__*/_jsx(Animated.View, { style: { maxWidth: buttonsMaxSize, opacity: _opacityOfSkipButton }, children: renderSkipButton ? renderSkipButton(skipLabel) : renderDefaultSkipButton(skipLabel) }) }) }); }; export default Previous; //# sourceMappingURL=Previous.js.map