Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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