import _ from 'lodash'; import React, {Component} from 'react'; import {StyleSheet, ScrollView} from 'react-native'; import {View, Button, Wizard, Text, RadioGroup, RadioButton, TextField, Toast} from 'react-native-ui-lib'; const flavors = ['Chocolate', 'Vanilla']; const initialFlavor = flavors[0]; const stepTypes = _.map(Wizard.States, state => { return {state}; }); interface State { activeIndex: number; completedStepIndex?: number; allTypesIndex: number; selectedFlavor: string; customerName?: string; toastMessage?: string; } export default class WizardScreen extends Component<{}, State> { state = { activeIndex: 0, completedStepIndex: undefined, allTypesIndex: 0, selectedFlavor: initialFlavor, customerName: undefined, toastMessage: undefined }; onActiveIndexChanged = (activeIndex: number) => { this.setState({activeIndex}); }; onAllTypesIndexChanged = (allTypesIndex: number) => { this.setState({allTypesIndex}); }; closeToast = () => { setTimeout(() => { this.setState({toastMessage: undefined}); }, 2000); }; reset = () => { const {customerName, selectedFlavor} = this.state; this.setState({ activeIndex: 0, completedStepIndex: undefined, selectedFlavor: initialFlavor, customerName: undefined, toastMessage: `${customerName}, you bought some ${selectedFlavor.toLowerCase()}` }, this.closeToast); }; goToPrevStep = () => { const {activeIndex: prevActiveIndex} = this.state; const activeIndex = prevActiveIndex === 0 ? 0 : prevActiveIndex - 1; this.setState({activeIndex}); }; renderPrevButton = () => { return (