Socket
Book a DemoInstallSign in
Socket

@nghinv/react-native-app-tour

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nghinv/react-native-app-tour

React Native app tour Library

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
1
Created
Source

@nghinv/react-native-app-tour

React Native App Tour Library

CircleCI Version MIT License

Installation

yarn add @nghinv/react-native-app-tour

or

npm install @nghinv/react-native-app-tour
yarn add react-native-gesture-handler react-native-reanimated react-native-animateable-text react-native-svg

IOS run cd ios && pod install

Usage

  • Wrapper AppTourProvider in the Root Component
import { AppTourProvider } from '@nghinv/react-native-app-tour';

...
render() {
  return (
    <AppTourProvider
      sceneIndex={0}
      scenes={[
        [
          { 
            id: '1',
            nextDelay: 50,
            pressToNext: true,
            enablePressNode: true,
            prevDisable: true,
          }, 
          { id: '2' },
        ],
        [
          { id: '2' }, 
          { id: '1' },
        ],
      ]}
      options={{
        buttonTitleColor: {
          next: 'red',
          prev: 'orange',
        },
        borderRadius: 5,
        colorNodeOnPress: 'tomato',
        ...otherOptionsProps,
      }}
    >
      <Root />
    </AppTourProvider>
  )
}
...
  • Use AppTourStep
import React, { useEffect } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { AppTourStep, useAppTour, AppTour, useEvent } from '@nghinv/react-native-app-tour';

export function App() {
  const { addEventListener, removeEventListener } = useEvent();

  useEffect(() => {
    // Listener AppTour Event
    const id = addEventListener('AppTourEvent', (event) => {
      console.log('AppTourEvent', event.name, event.node?.id);

    return () => {
      removeEventListener(id);
    };
  }, []);

  const onStartAppTour = () => {
    // Start show AppTour
    // Use AppTour.start(step) to jump to step
    AppTour.start();
  };

  return (
    <View style={{flex: 1}}>
      <View style={styles.viewTitle}>
        <AppTourStep
          id='1'
          title='Text welcome'
          describe='This is welcome title app'
        >
          <Text>
            {'Welcome to the demo of\n"React Native AppTour"'}
          </Text>
        </AppTourStep>
      </View>
      <View style={styles.viewAvatar}>
        <AppTourStep
          id='2'
          title='avatar'
          describe='Press here to change your avatar'
        >
          <Image 
            style={styles.avatar} 
            source={require('../assets/avatar.jpg')} 
            resizeMode='cover' 
          />
        </AppTourStep>
      </View>

      <TouchableOpacity 
        onPress={onStartAppTour} 
        style={styles.button}
      >
        <Text>Start App Tour</Text>
      </TouchableOpacity>
    </View>
  )
}

Property

AppTourProvider

PropertyTypeDefaultDescription
sceneIndexnumber0Index of scenes
scenesArray<Array<SceneProperty>>[]Index of scenes
optionsOptionsPropertyundefinedCustom app tour props
  • SceneProperty
PropertyTypeDefaultDescription
idstringID of AppTourStep
nextDelaynumberundefinedunit: ms
prevDelaynumberundefinedunit: ms
pressToNextbooleanfalsePress to Element to next step
enablePressNodebooleanfalse
nextDisablebooleanfalsedisable next step button
prevDisablebooleanfalsedisable prev step button
  • OptionsProperty
PropertyTypeDefaultDescription
nativeModalbooleanfalseUse Modal from react native
backdropOpacitynumber0.8value from 0 to 1
backgroundColorstringundefinedbackgroundColor of content
borderRadiusnumber5borderRadius of content
titleShowbooleantrue
titleStyleTextStyleundefined
describeStyleTextStyleundefined
stepShowbooleantrue
stepTitleColorstringwhite
stepBackgroundColorstringgreen
pathAnimatedbooleantrueDefault set pathAnimated = false on Android
stepHeightnumber20
triangleHeightnumber8
colorNodeOnPressstringrgba(255, 255, 255, 0.8)
backAndroidToSkipbooleanfalseEnable skip AppTour on backAndroid press
debugbooleanfalseShow debug
buttonTitleButtonTitlePropsundefined
buttonTitleColorButtonTitleColorPropsundefined
  • ButtonTitleProps
PropertyTypeDefaultDescription
skipstringSkip
prevstringPrevious
nextstringNext
finishstringFinish
  • ButtonTitleColorProps
PropertyTypeDefaultDescription
skipstringgreen
prevstringgreen
nextstringgreen
finishstringgreen

AppTourStep

PropertyTypeDefaultDescription
idstringID of Element
titlestring
describestring
maskTypecircle | rectrect
scrollToAnimated.SharedValue<ScrollToXY>
  • ScrollToXY
PropertyTypeDefaultDescription
xnumber
ynumber

AppTour

PropertyTypeDefaultDescription
start(step?: number) => voidStart show AppTour
stop(cb?: () => void) => voidStop AppTour
nextStep() => voidNext step AppTour
preStep() => voidPrevious step AppTour
currentStep() => numberGet current step

useAppTour

PropertyTypeDefaultDescription
setSceneIndexReact.Dispatch<React.SetStateAction<number>>Set scenes index

useEvent

PropertyTypeDefaultDescription
addEventListener(eventName: 'AppTourEvent', callback: (data: EventData) => void) => string
removeEventListener(id: string) => boolean
  • EventData
PropertyTypeDefaultDescription
nameonStart|onStop|onFinish|onSkip|onNext|onPrevious| onPressNode
stepnumber
nodeNodeType
sceneSceneType

Credits

Keywords

react native

FAQs

Package last updated on 09 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts