1.0.6 • Published 4 years ago

react-native-wiz v1.0.6

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

React Native Wiz

A beautiful Wizard for React Native because every app needs a proper introduction.

React Native Wiz Preview

React Native Wiz is in early development stage and has been tested exclusively on iOS. Use at your own risk.

Installation


  • npm: npm install react-native-wiz
  • yarn: yarn add react-native-wiz

Add to the top of each component accessing the Wiz library.

import Wiz from 'react-native-wiz'

Usage

1. Creating the Provider

Wrap your wizard(s) or whole application inside the Wiz provider e.g. inside App.js

<Wiz.Provider>
  <View style={{ flex: 1 }}>
    <Text>My Amazing App</Text>
  </View>
</Wiz.Provider>

2. Adding your actions

Start wrapping each of the elements you want to be part of the wizard inside a Wiz.View. Make sure to provide a unique ID for each view.

<Wiz.View
  id="example"
  autoPlay={true}
  completed={false}>
  <TouchableOpacity>
    <Text>My Button</Text>
  </TouchableOpacity>
</Wiz.View>

3. Handling completion

In order to complete an action, all you have to do is change the completed prop to true. Alternatively, you can use the complete() method.

export default function MyComponent() {

  const [ completed, setCompleted ] = React.useState(false)

  const handlePress = () => {
    // Do something here
    setCompleted(true)
  }

  return (
    <Wiz.View  
      id="example"
      completed={completed}>
      <TouchableOpacity onPress={handlePress}>
        <Text>My Button</Text>
      </TouchableOpacity>
    </Wiz.View>
  )

}

Props

PropDescription
wizID of the wizard this action belongs to (optional). Use when you need multiple wizards
idA unique ID, required for each action
enabledEnable or disable the action. Defaults to true
autoPlayBoolean determining whether or not the wizards should start by itself. Use with care and only on the first action in a wizard. Defaults to false
queuePosition in queue. Use this to configure the playing order. Defaults to 0
completedAfter setting this prop to true the next action will appear
textText describing your action
textOffsetOffset from component position (object) { x: int, y: int }
textStyleStyling for Text component (object)
imageDescription image source (optional)
imageHeightHeight of the image. Defaults to 100
imageWidthWidth of the image. Defaults to 100
imageOffsetOffset from component position (object) { x: int, y: int }
customComponentCustom component to render
customComponentOffsetOffset from component position (object) { x: int, y: int }
delayTime in ms after which the action should appear. Defaults to 0
onActiveFunction. Runs when the action becomes active
onCompleteFunction. Runs when the action has completed
styleInherited from View (object)

Methods

show()

Shows the Wiz.View.

complete()

Same funcionality as the completed prop. Running this method will mark the action as complete and show the next action in queue.