import React, { useContext, ReactElement } from 'react'; import { StyleSheet, View } from 'react-native'; import { Button } from 'react-native-elements'; import { Col, Row, Alignment } from '@farfarawaylabs/react-native-layout'; import CarouselContext from './CarouselContext'; export interface CarouselNavigationProps { /** The color of a dot represnting a slide. Defaults to '#FFF' */ dotColor?: string; /** The color of the active dot. Defaults to '#232323' */ activeDotColor?: string; /** Event handler to call when the done button is pressed */ onDone?: (currentIndex: number) => void; /** The title of the done button. Defaults to 'Done' */ doneButtonTitle?: string; /** Should the done button be showed on all slides or just on the last one. Defaults to false */ shouldShowDoneButtonOnAllSlides?: boolean; /** Your own custom element to be used as the done button */ doneButton?: ReactElement; } const CarouselNavigation: React.FC = ({ dotColor = '#FFF', activeDotColor = '#232323', onDone, shouldShowDoneButtonOnAllSlides = false, doneButtonTitle = 'Done', doneButton, }) => { const { numberOfSlides, selectedIndex } = useContext(CarouselContext); const dots = []; for (let index = 0; index < numberOfSlides!; index++) { const dotStyles: Array = [styles.dot]; if (index === selectedIndex) { dotStyles.push(styles.selectedDot); dotStyles.push({ backgroundColor: activeDotColor }); } else { dotStyles.push({ backgroundColor: dotColor }); } dots.push(); } const getDoneButton = () => { if (doneButton) { return doneButton; } return (