Code Monkey home page Code Monkey logo

react-native-copilot's Introduction

React Native Copilot

Step-by-step walkthrough for your react native app!

React Native Copilot

Demo

Installation

yarn add react-native-copilot

# or with npm:

npm install --save react-native-copilot

Optional: If you want to have the smooth SVG animation, you should install and link react-native-svg.

Usage

Wrap the portion of your app that you want to use copilot with inside <CopilotProvider>:

import { CopilotProvider } from "react-native-copilot";

const AppWithCopilot = () => {
  return (
    <CopilotProvider>
      <HomeScreen />
    </CopilotProvider>
  );
};

NOTE: The old way of using copilot with the copilot() HOC maker is deprecated in v3. It will continue to work but it's not recommended and may be removed in the future.

Before defining walkthrough steps for your react elements, you must make them walkthroughable. The easiest way to do that for built-in react native components, is using the walkthroughable HOC. Then you must wrap the element with CopilotStep.

import {
  CopilotProvider,
  CopilotStep,
  walkthroughable,
} from "react-native-copilot";

const CopilotText = walkthroughable(Text);

const HomeScreen = () => {
  return (
    <View>
      <CopilotStep text="This is a hello world example!" order={1} name="hello">
        <CopilotText>Hello world!</CopilotText>
      </CopilotStep>
    </View>
  );
};

Every CopilotStep must have these props:

  1. name: A unique name for the walkthrough step.
  2. order: A positive number indicating the order of the step in the entire walkthrough.
  3. text: The text shown as the description for the step.

Additionally, a step may set the active prop, a boolean that controls whether the step is used or skipped.

In order to start the tutorial, you can call the start function from the useCopilot hook:

const HomeScreen = () => {
  return (
    <View>
      <Button title="Start tutorial" onPress={() => start()} />
    </View>
  );
};

If you are looking for a working example, please check out this link.

Overlays and animation

The overlay in react-native-copilot is the component that draws the dark transparent over the screen. React-native-copilot comes with two overlay options: view and svg.

The view overlay uses 4 rectangles drawn around the target element using the <View /> component. We don't recommend using animation with this overlay since it's sluggish on some devices specially on Android.

The svg overlay uses an SVG path component for drawing the overlay. It offers a nice and smooth animation but it depends on react-native-svg. If you are using expo, you can install it using:

expo install react-native-svg

Or if you are using react-native-cli:

yarn add react-native-svg

# or with npm

npm install --save react-native-svg

cd ios && pod install

You can specify the overlay by passing the overlay prop to the <CopilotProvider /> component:

<CopilotProvider overlay="svg" {/* or "view" */}>
  <App />
</CopilotProvider>

By default, if overlay is not explicitly specified, the svg overlay will be used if react-native-svg is installed, otherwise the view overlay will be used.

Custom tooltip and step number UI components

You can customize the tooltip and the step number components by passing a component to the CopilotProvider component. If you are looking for an example tooltip component, take a look at the default ui implementations.

const TooltipComponent = () => {
  const {
    isFirstStep,
    isLastStep,
    handleNext,
    handleNth,
    handlePrev,
    handleStop,
    currentStep,
  } = useCopilot();

  return (
    // ...
  )
};


<CopilotProvider tooltipComponent={TooltipComponent} stepNumberComponent={StepComponent}>
  <App />
</CopilotProvider>

Navigating through the tour

The above code snippet shows the functions passed to the tooltip. These are your primary navigation functions. Some notes on navigation:

  • handleNext and handlePrev will move the mask from the current wrapped component immediately to the next.

  • You can use handleStop in conjunction with handleNth to effectively "pause" a tour, allowing for user input, animations or any other interaction that shouldn't have the mask applied. Once you want to pick the tour back up, call handleNth on the next tour step.

Note that handleNth is 1-indexed, which is in line with what your step orders should look like.

Custom tooltip styling

You can customize tooltip's wrapper style:

const style = {
  backgroundColor: "#9FA8DA",
  borderRadius: 10,
  paddingTop: 5,
};

<CopilotProvider tooltipStyle={style}>
  <App />
</CopilotProvider>;

Manage tooltip width

By default, the tooltip width is calculated dynamically. You can make it fixed-size by overriding both width and maxWidth, check the example bellow:

const MARGIN = 8;
const WIDTH = Dimensions.get("window").width - 2 * MARGIN;

<CopioltProvider tooltipStyle={{ width: WIDTH, maxWidth: WIDTH, left: MARGIN }}>
  <App />
</CopilotProvider>;

Custom tooltip arrow color

You can customize the tooltip's arrow color:

<CopilotProvider arrowColor="#9FA8DA">
  <App />
</CopilotProvider>

Custom overlay color

You can customize the mask color - default is rgba(0, 0, 0, 0.4), by passing a color string to the CopilotProvider component.

<CopilotProvider backdropColor="rgba(50, 50, 100, 0.9)">
  <App />
</CopilotProvider>

Custom svg mask Path

You can customize the mask svg path by passing a function to the CopilotProvider component.

function SvgMaskPathFn(args: {
  size: Animated.valueXY;
  position: Animated.valueXY;
  canvasSize: {
    x: number;
    y: number;
  };
  step: Step;
}): string;

Example with circle:

const circleSvgPath = ({ position, canvasSize }) =>
  `M0,0H${canvasSize.x}V${canvasSize.y}H0V0ZM${position.x._value},${position.y._value}Za50 50 0 1 0 100 0 50 50 0 1 0-100 0`;

<CopilotProvider svgMaskPath={circleSvgPath}>
  <App />
</CopilotProvider>;

Example with different overlay for specific step:

Give name prop for the step

<CopilotStep text="This is a hello world example!" order={1} name="hello">
  <CopilotText>Hello world!</CopilotText>
</CopilotStep>

Now you can return different svg path depending on step name

const customSvgPath = (args) => {
  if (args.step?.name === "hello") {
    return `M0,0H${canvasSize.x}V${canvasSize.y}H0V0ZM${position.x._value},${position.y._value}Za50 50 0 1 0 100 0 50 50 0 1 0-100 0`;
  } else {
    return `M0,0H${canvasSize.x}V${canvasSize.y}H0V0ZM${position.x._value},${
      position.y._value
    }H${position.x._value + size.x._value}V${
      position.y._value + size.y._value
    }H${position.x._value}V${position.y._value}Z`;
  }
};

<CopilotProvider svgMaskPath={customSvgPath}>
  <App />
</CopilotProvider>;

Custom components as steps

The components wrapped inside CopilotStep, will receive a copilot prop with a mutable ref and onLayou which the outermost rendered element of the component or the element that you want the tooltip be shown around, must extend.

import { CopilotStep } from "react-native-copilot";

const CustomComponent = ({ copilot }) => (
  <View {...copilot}>
    <Text>Hello world!</Text>
  </View>
);

const HomeScreen = () => {
  return (
    <View>
      <CopilotStep text="This is a hello world example!" order={1} name="hello">
        <CustomComponent />
      </CopilotStep>
    </View>
  );
};

Custom labels (for i18n)

You can localize labels:

<CopilotProvider
  labels={{
    previous: "Vorheriger",
    next: "Nächster",
    skip: "Überspringen",
    finish: "Beenden"
  }}
>

Adjust vertical position

In order to adjust vertical position pass verticalOffset to the CopilotProvider component.

<CopilotProvider verticalOffset={36}>

Triggering the tutorial

Use const {start} = useCopilot() to trigger the tutorial. You can either invoke it with a touch event or in useEffect to start after the comopnent mounts. Note that the component and all its descendants must be mounted before starting the tutorial since the CopilotSteps need to be registered first.

Usage inside a ScrollView

Pass the ScrollView reference as the second argument to the start() function. eg start(undefined, scrollViewRef)

import { ScrollView } from "react-native";

class HomeScreen {
  componentDidMount() {
    // Starting the tutorial and passing the scrollview reference.
    this.props.start(false, this.scrollView);
  }

  componentWillUnmount() {
    // Don't forget to disable event handlers to prevent errors
    this.props.copilotEvents.off("stop");
  }

  render() {
    <ScrollView ref={(ref) => (this.scrollView = ref)}>// ...</ScrollView>;
  }
}

Listening to the events

useCopilot provides a copilotEvents function prop to allow you to track the progress of the tutorial. It utilizes mitt under the hood.

List of available events is:

  • start — Copilot tutorial has started.
  • stop — Copilot tutorial has ended or skipped.
  • stepChange — Next step is triggered. Passes Step instance as event handler argument.

Example:

import { useCopilot } from "react-native-copilot";

const HomeScreen = () => {
  const { copilotEvents } = useCopilot();

  useEffect(() => {
    const listener = () => {
      // Copilot tutorial finished!
    };

    copilotEvents.on("stop", listener);

    return () => {
      copilotEvents.off("stop", listener)
    };
  }, []);

  return (
    // ...
  );
}

Contributing

Issues and Pull Requests are always welcome.

If you are interested in becoming a maintainer, get in touch with us by sending an email or opening an issue. You should already have code merged into the project. Active contributors are encouraged to get in touch.

Creation of this project was sponsored by OK GROW!

react-native-copilot's People

Contributors

arrygoo avatar bdomantas avatar beaur avatar cfnelson avatar computerjazz avatar cooperwalter avatar cryptolab1023 avatar czystyl avatar danielang avatar dependabot[bot] avatar downanddoerrty avatar ghsdh3409 avatar github-actions[bot] avatar jakequade avatar jguix avatar jparksecurity avatar jzabala avatar klapperkopp avatar lindboe avatar lklepner avatar mloureiro avatar mohebifar avatar naffiq avatar ohtangza avatar prayuditb avatar richardlitt avatar spencer-evans-pnt avatar terreb avatar xavxyz avatar yoavprat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-copilot's Issues

Customizing Modal Dialog size and Highlighted Step

Copilot has been working great off the bat, but I need some guidance on how I am able to customize the size of the modal window that's being generated and the highlighted step. When there's a spot highlighted, there seems to be a few pixels added making the highlight not exact to my tabs.

Also, is there some options or some way I can determine the size of the modal. This comes an issue when I have a middle tab button highlighted, and my modal window is much smaller size it draws the modal to the right.

test

Unable to edit number components in the CoPilot Modal

Hey,
I'm trying to edit the stepNumber style in the CoPilot modal so it suits my app's theme better. The only way currently I know how to do this is to edit the modules style directly. I figured since this is a new module changes will be made frequently so a fork would be less than ideal. Any solutions to this?

The Code below is in CopilotModal.js, it references the style I would like to have the ability to edit.

renderTooltip() {
    const { tooltipComponent: TooltipComponent } = this.props;

    return [
      <Animated.View
        key="stepNumber"
        style={[
          styles.stepNumber,
          {
            left: this.state.animatedValues.stepNumberLeft,
            top: Animated.add(this.state.animatedValues.top, -STEP_NUMBER_RADIUS),
          },
        ]}
      >```

Can you support i18n ?

Hi,
I would really like to use this package but i need to use it with different language.
Will it be possible to make the few words that are hard coded ( next,skip,previous ) to be props ?

Thanks,
Yaniv

Is there a way to make the element of the current CopilotStep touchable/pressable?

Hi is it possible for me to be able to allow the users to click on touchable elements in the current CopilotStep? Right now even though it has a white background while everywhere else on the screen is black, it is still not possible to click on that element. I have tried both 'view' and 'svg' overlay's.

Would greatly appreciate your help!

Use CoPilot in a FlatList

Hello, I wish to use copilot on a ListItem in FlatList, and I think that if I used it, the steps will be repeated in all ListItems when the FlatList Render... Someone, have a Idea how to used it in a FlatList?

Thanks!!

Undefined is not an object

screen_shot

import {
  copilot,
  walkthroughable,
  CopilotStep
} from '@okgrow/react-native-copilot';

...

const Step1 = ({ copilot }) => <View {...copilot}><Text>Step 1</Text></View>;

...

<CopilotStep text="This is a hello world example!" order={1} name="hello">
  <Step1 />
</CopilotStep>
"dependencies": {
    "@okgrow/react-native-copilot": "^1.0.0",
    "expo": "24.0.2",
    "react": "^16.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz",
  },

Change Arrow Color and backdrop color

Current Behavior
The top arrow color cannot be changed
backdrop color also don't work

I tried this for backdrop and it didn't work
Input Code

export default copilot({
  animated: true, // Can be true or false
  overlay: 'svg', // Can be either view or svg
  backdropColor:"rgb(0, 0, 0, 0.9)",
  stepNumberComponent: StepNumber1,
  tooltipComponent:TooltipComponent1
})(Homepage);

Expected behavior/code
There should be some way to customise arrow color and backdrop color,
Arrow color is hard-coded here in CopilotModal.js :

 if (verticalPosition === 'bottom') {
      tooltip.top = obj.top + obj.height + MARGIN;
      arrow.borderBottomColor = '#fff';
      arrow.top = tooltip.top - (ARROW_SIZE * 2);
    } else {
      tooltip.bottom = layout.height - (obj.top - MARGIN);
      arrow.borderTopColor = '#fff';
      arrow.bottom = tooltip.bottom - (ARROW_SIZE * 2);
    }

and backdrop color is here:

 <Svg pointerEvents="none" width={this.state.canvasSize.x} height={this.state.canvasSize.y}>
   <AnimatedSvgPath
      ref={(ref) => { this.mask = ref; }}
      fill="rgba(0, 0, 0, 0.4)"
      fillRule="evenodd"
      strokeWidth={1}
      d={path(this.state.size, this.state.position, this.state.canvasSize)}
    />
 </Svg>

Environment

  • Device: iPhone 6s Simulator
  • OS:iOS12
  • react-native-copilot: v2.4.1
  • react-native: v0.57
  • react-native-svg: v7.1.0

Problem in RTL apps

react-native-copilot completely renders mirror of what it should be rendering in RTL projects.
Here I've made a CopilotView around the heart ❤️ icon like this:

const CopilotView = walkthroughable(View);
...
<CopilotView>
  <HeartIcon/>
</CopilotView>

As you can see it's completely mirrored.
If you point me to the right direction I'll fix it myself.
Thank you for your efforts.

When tour guide, can't we interact with real UI?

I think in your version when we tour, only modal seems to be working, not real UI component working
People can interact with real UI even when tour guide mode so that they can experience really

Enhancement request: allow passing of custom props to currentStep from CopilotStep.

Hey ya'll

I'd like to suggest an enhancement to the currentStep object/prop that gets passed to custom components like tooltipComponent and stepNumberComponent.

It would be great if we could allow passing in custom props from CopilotStep. A situation where this would be useful is when you have a customizable custom tooltip component like so:

const CustomToolTipComponent = ({
  isFirstStep,
  isLastStep,
  handleNext,
  handlePrev,
  handleStop,
  currentStep,
}) => (
  // ...
  <Button>{currentStep.toolTipButtonText}</Button>
);
// ...
copilot({
  tooltipComponent: TooltipComponent
})(RootComponent)
<CopilotStep
  order={1}
  name="hello"
  text="Custom button text"
  toolTipButtonText="Cool btn txt right"
>
...
</CopilotStep>

Looking at the source, I think a simple update to ConnectedCopilotStep when registering steps could allow a enhancement like this. Perphaps passing along the rest of the props like this would be a bad idea:

this.props._copilot.registerStep({
  name: this.props.name,
  text: this.props.text,
  order: this.props.order,
  target: this,
  wrapper: this.wrapper,
  ...this.props,
});

We could add a dedicated prop to CopilotStep named something like options woul d do the trick:

<CopilotStep
  order={1}
  name="hello"
  text="Custom button text"
  options={{ toolTipButtonText: "Cool btn txt" }}
>
this.props._copilot.registerStep({
  name: this.props.name,
  text: this.props.text,
  order: this.props.order,
  target: this,
  wrapper: this.wrapper,
  options: this.props.options,
});

Let me know what ya'll think and if ya'll are 👍 on this I'd be glad to put a PR together.

First Step Highlight frame not visible on start()

Hi,
I have this issue that even with the example app, it does not behave as it does in the screenshot in the readme.md. The first step elment never gets highlighted on a start().

Expected behavior:
First Step Element gets highlighted.

Actual behavior:
First element does not get highlighted. It only does, when you go one step further and then go back to previous.

bug

Suggested solution:
I looked into it and found that if you change the following line 143 in copilot.js, it works:

old line:
await this.setCurrentStep(currentStep, false);

changed to:
await this.setCurrentStep(currentStep, true);

Questions: are there any drawbacks on triggering the moveToCurrentStep() also on start()? Or why was is this not done at the moment?

Update: I added a pull request for this. Just in case. :)

Improve the documentation

There are 5 parameters in the copilot() HOC function, but only overlay and animated are documented.
Can you explain how to use other parameters?

I use this library on Android device, and I follow the example to create the tour guide.
But I found if I don't add androidStatusBarVisible: false into copliot(), the Modal will have some offset so that part of view will be cut.
In fact, the statusBar is visible on my screen, I don't understand why I should pass androidStatusBarVisible as false.

backdropColor is not working in iOS

  render() {
    return (
      <View style={styles.container}>
        <CopilotStep text="Hey! This is the first step of the tour!" order={1} name="openApp">
          <WalkthroughableText style={styles.title}>
            {'Welcome to the demo of\n"React Native Copilot"'}
          </WalkthroughableText>
        </CopilotStep>
        <View style={styles.middleView}>
          <CopilotStep active={this.state.secondStepActive} text="Here goes your profile picture!" order={2} name="secondText">
            <WalkthroughableImage
              source={{ uri: 'https://pbs.twimg.com/profile_images/527584017189982208/l3wwN-l-_400x400.jpeg' }}
              style={styles.profilePhoto}
            />
          </CopilotStep>
          <View style={styles.activeSwitchContainer}>
            <Text>Profile photo step activated?</Text>
            <View style={{ flexGrow: 1 }} />
            <Switch
              onValueChange={secondStepActive => this.setState({ secondStepActive })}
              value={this.state.secondStepActive}
            />
          </View>

          <TouchableOpacity style={styles.button} onPress={() => this.props.start()}>
            <Text style={styles.buttonText}>START THE TUTORIAL!</Text>
          </TouchableOpacity>
        </View>
        <View style={styles.row}>
          <CopilotStep text="Here is an item in the corner of the screen." order={3} name="thirdText">
            <WalkthroughableText style={styles.tabItem}>
            </WalkthroughableText>
          </CopilotStep>
        </View>
      </View>
    );
  }
}

export default copilot({
    backdropColor:"rgb(30, 70, 10, 1)",
     animated: true, // Can be true or false
    overlay: 'svg', // Can be either view or svg
})(WalkThrough);

Use copilot in a ScrollView

We are currently using copilot in one of our project, we needed to add some features:

  • be able to highlight an element that is in a scrollView but not in visible on the screen (cf screenshot)
    ios - scroll on highlighted elements
  • customize the style of the CopilotStep

We have worked on an implementation of those features on a fork: https://github.com/bamlab/react-native-copilot

Could you look at it and tell us if we can make a Pull Request on your repo?

overlay not covering component completely

Current Behavior
overlay is not covering whole component.

Input Code

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, Text, Image, View, TouchableOpacity, Switch } from 'react-native';
import { Ionicons } from 'react-native-vector-icons';

import { copilot, walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';

const WalkthroughableText = walkthroughable(Text);
const WalkthroughableImage = walkthroughable(Image);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    paddingTop: 40,
  },
  title: {
    fontSize: 24,
    textAlign: 'center',
  },
  profilePhoto: {
    width: 140,
    height: 140,
    borderRadius: 70,
    marginVertical: 20,
  },
  middleView: {
    flex: 1,
    alignItems: 'center',
  },
  button: {
    backgroundColor: '#2980b9',
    paddingVertical: 10,
    paddingHorizontal: 15,
  },
  buttonText: {
    color: 'white',
    fontSize: 16,
  },
  row: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  tabItem: {
    flex: 1,
    textAlign: 'center',
  },
  activeSwitchContainer: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    marginBottom: 20,
    alignItems: 'center',
    paddingHorizontal: 40,
  },
});

class AppNew extends Component {
  static propTypes = {
    start: PropTypes.func.isRequired,
    copilotEvents: PropTypes.shape({
      on: PropTypes.func.isRequired,
    }).isRequired,
  };

  state = {
    secondStepActive: true,
  };

  componentDidMount() {
    this.props.copilotEvents.on('stepChange', this.handleStepChange);
    this.props.start();
  }

  handleStepChange = (step) => {
    console.log(`Current step is: ${step.name}`);
  }

  render() {
    return (
      <View style={styles.container}>
        <CopilotStep text="Hey! This is the first step of the tour!" order={1} name="openApp">
          <WalkthroughableText style={styles.title}>
            {'Welcome to the demo of\n"React Native Copilot"'}
          </WalkthroughableText>
        </CopilotStep>
        <View style={styles.middleView}>
          <CopilotStep active={this.state.secondStepActive} text="Here goes your profile picture!" order={2} name="secondText">
            <WalkthroughableImage
              source={{ uri: 'https://pbs.twimg.com/profile_images/527584017189982208/l3wwN-l-_400x400.jpeg' }}
              style={styles.profilePhoto}
            />
          </CopilotStep>
          <View style={styles.activeSwitchContainer}>
            <Text>Profile photo step activated?</Text>
            <View style={{ flexGrow: 1 }} />
            <Switch
              onValueChange={secondStepActive => this.setState({ secondStepActive })}
              value={this.state.secondStepActive}
            />
          </View>

          <TouchableOpacity style={styles.button} onPress={() => this.props.start()}>
            <Text style={styles.buttonText}>START THE TUTORIAL!</Text>
          </TouchableOpacity>
        </View>

      </View>
    );
  }
}

export default copilot({
  animated: true, // Can be true or false
  overlay: 'svg', // Can be either view or svg
})(AppNew);

Expected behavior/code
it should cover component completely

Environment

  • Device: Android Nexus simulator
  • OS: Android 8.0 Oreo
  • react-native-copilot: "^2.4.1",
  • react-native: 0.55.4
  • react-native-svg: 6.5.2

Additional context/Screenshots
screenshot_1542446826

Copilot steps doesn't display in the screen

This is my code, what should I do to see Copilot steps which will show hints one by one?
I saw that in example there is props.start() to start the tutorial, however, how to make it work, if Copilot steps inside the render function?

import { copilot,walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';
const CopilotText = walkthroughable(Text);

class Home extends Component {

render() {
return (
  <View>     
    <CopilotStep text="Hint 1" order={1} name="openApp">
       <CopilotText>Step 1 !</CopilotText>
    </CopilotStep>
    </View>
    <View>
      <CopilotStep text="Hint 2" order={2} name="openApp2">
       <CopilotText>Step 2!</CopilotText>
    </CopilotStep>
    </View>
    <View>
    <CopilotStep text="Hint 3!" order={3} name="openApp3">
       <CopilotText>Step 3</CopilotText>
    </CopilotStep>
    </View>
)}
}

export default copilot()(Home);

How to use custom class as copilot component

If I use copilot component as a variable it works:

CustomComponent = ({ copilot }) => <View {...copilot}><Text>Hello world!</Text></View>;

But if I want to export it to class it doesn't work:

const CustomComponent = ({ copilot }) => <Custom {...copilot}/>;

class Custom extends PureComponent {
  render() {
    return <View {...this.props}><Text>Hello world!</Text></View>;
  }
}

So what I have to do if I want to use copilot with my own class?

Can't install via YARN or NPM

Hi,

I can't install this package via YARN:

yarn add react-native-copilot
yarn add v1.3.2
[1/4] 🔍  Resolving packages...
error Couldn't find package "react-native-copilot" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

or NPM:

npm install --save react-native-copilot
npm ERR! code E404
npm ERR! 404 Not Found: react-native-copilot@latest

When I run npm info I get:

npm info react-native-copilot
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/react-native-copilot
npm ERR! 404 
npm ERR! 404  'react-native-copilot' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

System Info:

node --version
v8.9.1
npm --version
5.2.0

Is it currently not on NPM?

Need more tutorial! help wanted

I followed your tutorial but couldn't see any tour guide both on android and ios.
It would be grateful if more detailed tutorial

Detecting end of bubble tutorial

I want to detect the end of the bubble tutorial in the app so that I can perform other operations. Is there any way to detect.

Use copilot with custom native-base components

It seems not possible to highlight buttons in the walkthrough.
I call this.props.start(); so that shouldn't be the problem. It might have to do with the custom components in native-base. If we are using the normal components it works perfectly, but with the custom components, it won't.
image

How can I make copilot work with custom native-base components?

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

Hi, im using clojurescript to develop a react-native app.
This is my code:

(def joy (.joyride JoyRide))
(def JoyrideStep  (r/adapt-react-class (.-JoyrideStep JoyRide)))
(def JoyrideText (r/adapt-react-class (.joyridable JoyRide (r/reactify-component (.-Text ReactNative)))) )

(defn ^:export joyride-page []
  [view
   [JoyrideStep (clj->js {:text  "Hey! This is the first step of the tour!"
                          :order 1
                          :name "openApp"})
    [JoyrideText "Welcome to the demo of joyride library"]])

(defn m-joyride-page []
  (let [m (-> joyride-page
              r/reactify-component
              joy
              r/adapt-react-class)]
    [m]))

I am getting the following issue:

whatsapp image 2017-10-12 at 3 06 42 pm

What am i doing wrong?

Is there is any way to style Tooltip?

Hi,

Please refer the attached screenshot where I want to change the Tooltip text, Tooltip backgroundColor, Next & Skip button styling, and Order number styling.

screen shot 2018-09-18 at 8 08 17 pm

Not Opening

Added all the things as mentioned but not working. It is not showing anything .

Could not use Android Back Button when in walkthrough?

Hi! First of all, many thanks for developing such a convenient and powerful walkthrough tool for RN. I have finished developing the walkthrough for our app right now and I am considering utilizing the back button on Android to act as the "Previous" button. However, when in walkthrough, pressing the back button on android does not trigger the function. And after the walkthrough has been finished by tapping the "Finish" or "Skip" button, the handler can be successfully called. I am not usre how to handle it or is it intended? My codes for this functionality is as followed.

import { BackHandler } from 'react-native'
componentWillUnmount () {
    BackHandler.removeEventListener('androidBackButtonPress', this.handleBackPress)
  }

  handleBackPress = () => {
    console.log('test')
    return true
  }
  componentDidMount () {
    BackHandler.addEventListener('androidBackButtonPress', this.handleBackPress)
  }

App shows all steps together, instead of showing them step by step

I have added 3 steps, I thought that they will display one by one, however, they all displayed together at the same time. Why is that?

import { copilot,walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';
const CopilotText = walkthroughable(Text);

class Home extends Component {

render() {
return (
  <View>     
    <CopilotStep text="step 1" order={1} name="openApp">
       <CopilotText>Step 1 !</CopilotText>
    </CopilotStep>
    </View>
    <View>
      <CopilotStep text="Step 2" order={2} name="openApp2">
       <CopilotText>Step 2!</CopilotText>
    </CopilotStep>
    </View>
    <View>
    <CopilotStep text="Step 3!" order={3} name="openApp3">
       <CopilotText>Step 3</CopilotText>
    </CopilotStep>
    </View>
)}
}


export default copilot()(Home);



Has any one tried to use this library along with react navigation

Hi
This library fits my use case very well ,unfortunately some of the views that i need highlighted are on different screens/routes/navigators/components . They are not a single component . One of the views that i need to highlight is in side drawer . The first screenshot contains the top tab bar in which i want to highlight all the individual items and the second screen shot contains the drawer which i want to high light . We are using react navigation . Kindly help please

screen shot 2018-09-14 at 7 32 39 pm

screen shot 2018-09-14 at 7 33 11 pm

Copilot not showing when there is active alert

@okgrow/react-native-copilot 2.4.1
react-native: 0.56.0
react-native-navigation: 2.0.2641 (this is likely not relevant, just in case)
native-base: 2.8.1(this is likely not relevant, just in case)
Xcode 10.1
iOS simulator iPhone6 - 12.1

When there is an active alert on screen (usual RN alert, not 3rd party). this.props.start() doesn't initiate showing steps, when no active alerts it works as expected.

Stateless function components cannot be given refs

"react-native": "0.56.0",
"@okgrow/react-native-copilot": "^2.4.1",
simulator iPhone 6 with iOS 12.1

I get the warning "Stateless function components cannot be given refs. Attempts to access this ref will fail" when trying to wrap my custom functional component with walkthroughable. I haven't found any mentioning in the docs that react-native-copilot requires only stateful components to work with. Is there a way to highlight a stateless (functional) component?

Two Default Export Problem

Hello

I have a problem for react native copilot. My js file has export like
export default connect(
(state) => {
return {
selectedCategories: state.mainMenu.items,
user: state.user
}
}
)(NewSelectTopic);

Because of these i don't added export default copilot(NewSelectTopic) .
how can i do a solution here?

Thanks.

Cannot read property "text" of null (CopilotModal.render)

So I have such code, when I'm running it I get the error: "Cannot read property text of null. Why is that? What should I change in the code, in order to run it without error?

import { copilot,walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';
const CopilotText = walkthroughable(Text);

class Home extends Component {

componentWillMount(){
 this.props.start();
}

render() {
return (
  <View>     
    <CopilotStep text="Hint 1" order={1} name="openApp">
       <CopilotText>Step 1 !</CopilotText>
    </CopilotStep>
    </View>
    <View>
      <CopilotStep text="Hint 2" order={2} name="openApp2">
       <CopilotText>Step 2!</CopilotText>
    </CopilotStep>
    </View>
    <View>
    <CopilotStep text="Hint 3!" order={3} name="openApp3">
       <CopilotText>Step 3</CopilotText>
    </CopilotStep>
    </View>
)}
}

export default copilot()(Home); 

screen shot 2018-02-09 at 14 40 30

Add skip event listener to return current step and next step information

We are currently using copilot in one of our project, we needed to add some features:

. Be able to differentiate the skip action from the stop action.

screenshot_1532811468

I need to be able to visit the feature by pressing "Go now" and when i go back to the root tab the walkthrough journey should focus the next step.

We have worked on an implementation of those features on a fork: https://github.com/PedroLourenco/react-native-copilot/tree/add_skip_event_listener

Could you look at it and tell us if we can make a Pull Request on your repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.