0.0.1 • Published 3 years ago

digi-rn-wizard v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Digi-RN-Wizard

Create multi-step wizards in React Native applications to guide users through setup or other complex tasks in a simple manner.

Installation

  1. Install:

    • Using npm: npm install digi-rn-wizard --save
    • Using Yarn: yarn add digi-rn-wizard
  2. Import it in your JS:

import {Wizard, Step} from 'digi-rn-wizard';

Basic Usage

import {Wizard, Step, Breadcrumb} from 'digi-rn-wizard';

<Wizard>
  <Breadcrumb />
  <Step title="Start">
    <Text>Each step can contain any content you wish to render.</Text>
  </Step>
  <Step title="Middle">
    <View>
      <Text>It can contain text, controls or other custom components.</Text>
      <TextInput
        onChangeText={onChangeText}
        value={text}
      />
    </View>
  </Step>
  <Step title="Complete">
    <Text>The number of steps is dynamic, but must be contained in a Step component.</Text>
  </Step>
</Wizard>

Advanced Usage

See the example app to understand how to implement more advanced features.

Available Properties

Wizard

PropTypeDefaultDescription
refvoidoptionalReference to use function including next(), prev(), and goto()
styleobjectoptionalStyle object for the main container
currentStepfuncoptionalCallback containing the index and title of the current step as well as number of total steps
isFirstStepfuncoptionalCallback containing boolean value is current step is first step
isLastStepfuncoptionalCallback containing boolean value if current step is last step
transitionstringfadeType of transition between steps
durationnumber300Time for transition to complete

Step

PropTypeDefaultDescription
titlestringoptionalTitle of the step, returned by currentStep

Breadcrumb

PropTypeDefaultDescription
orientationstringhorizontalSet the orientation of the breadcrumb bar, horizontal or vertical
quickNavbooltrueAllow navigation to step by tapping on breadcrumb
onColorstring#FFFFFFColor of breadcrumb when selected
offColorstring#000000Color of breadcrumbs when not selected

The position of the breadcrumb component will determine it's rendering position. Make it the first child under Wizard to render it before the step or make it the last child under Wizard to render it after the step. Combined with the orientation prop you can position and scale the breadcrumb bar on any side of the Wizard's steps.

Reference Functions

DigiWizard provides the following reference functions so you can create custom controls for the wizard to better match the UI of your application. Create a reference to the Wizard using the useRef hook:

import React, {useRef} from 'react'
const wizard = useRef(null)

<Wizard ref={wizard} />

next()

wizard.current.next() This function will advance the wizard to the next step, if available. If additional steps are not available the call will be ignored.

prev()

wizard.current.prev() This function will revert the wizard to the previous step, if available. If additional steps are not available the call will be ignored.

goto(step)

wizard.current.goto(step) This function will change the wizard to the provided step, if available. If the provided step is outside the bounds of the available steps the call will be ignored. step is a 0 based index.