Skip to content

Commit

Permalink
Add information about the skipped step
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro committed Aug 11, 2018
1 parent 07795e7 commit 08d0017
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Along with `this.props.start()`, `copilot` HOC passes `copilotEvents` function t
List of available events is:

- `start` — Copilot tutorial has started.
- `stop` — Copilot tutorial has ended or skipped.
- `stop` — Copilot tutorial has ended.
- `stepChange` — Next step is triggered. Passes [`Step`](https://github.com/okgrow/react-native-copilot/blob/master/src/types.js#L2) instance as event handler argument.


Expand Down
6 changes: 4 additions & 2 deletions src/components/CopilotModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ class CopilotModal extends Component<Props, State> {
this.props.prev();
}

handleStop = () => {
handleStop = (wasSkipped?: boolean) => {
wasSkipped = typeof wasSkipped !== "boolean" ? false : wasSkipped;

this.reset();
this.props.stop();
this.props.stop(wasSkipped);
}

renderMask() {
Expand Down
14 changes: 12 additions & 2 deletions src/hocs/copilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,19 @@ const copilot = ({
}
}

stop = async (): void => {
stop = async (wasSkipped: boolean): void => {
await this.setVisibility(false);
this.eventEmitter.emit('stop');
this.eventEmitter.emit('stop', wasSkipped
? {
wasSkipped: true,
skippedStep: this.state.currentStep,
nextStep: this.getNextStep()
}
: {
wasSkipped: false,
skippedStep: null,
nextStep: null
});
}

async moveToCurrentStep(): void {
Expand Down

0 comments on commit 08d0017

Please sign in to comment.