Skip to content

Commit 7f7ca95

Browse files
author
Pedro
committed
Add information about skipped step
1 parent 7bbeefc commit 7f7ca95

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ Along with `this.props.start()`, `copilot` HOC passes `copilotEvents` function t
184184
List of available events is:
185185

186186
- `start` — Copilot tutorial has started.
187-
- `skip` — Copilot tutorial has skipped. Passes and object with currentStep and nextStep information. Both are instances of [`Step`](https://github.com/okgrow/react-native-copilot/blob/master/src/types.js#L2)
188187
- `stop` — Copilot tutorial has ended.
189188
- `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.
190189

src/components/CopilotModal.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type Props = {
99
stop: () => void,
1010
next: () => void,
1111
prev: () => void,
12-
skip: () => void,
1312
currentStepNumber: number,
1413
currentStep: ?Step,
1514
visible: boolean,
@@ -213,14 +212,11 @@ class CopilotModal extends Component<Props, State> {
213212
this.props.prev();
214213
}
215214

216-
handleStop = () => {
217-
this.reset();
218-
this.props.stop();
219-
}
215+
handleStop = (wasSkipped?: boolean) => {
216+
wasSkipped = typeof wasSkipped !== "boolean" ? false : wasSkipped;
220217

221-
handleSkip = () => {
222218
this.reset();
223-
this.props.skip();
219+
this.props.stop(wasSkipped);
224220
}
225221

226222
renderMask() {

src/hocs/copilot.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,21 @@ const copilot = ({
148148
}
149149
}
150150

151-
skip = async (): void => {
151+
stop = async (wasSkipped: boolean): void => {
152152
await this.setVisibility(false);
153-
this.eventEmitter.emit('skip', {
154-
currentStep: this.state.currentStep,
155-
nextStep: this.getNextStep()
153+
this.eventEmitter.emit('stop', wasSkipped
154+
? {
155+
wasSkipped: true,
156+
skippedStep: this.state.currentStep,
157+
nextStep: this.getNextStep()
158+
}
159+
: {
160+
wasSkipped: false,
161+
skippedStep: null,
162+
nextStep: null
156163
});
157164
}
158165

159-
stop = async (): void => {
160-
await this.setVisibility(false);
161-
this.eventEmitter.emit('stop');
162-
}
163-
164166
async moveToCurrentStep(): void {
165167
const size = await this.state.currentStep.target.measure();
166168

@@ -186,7 +188,6 @@ const copilot = ({
186188
next={this.next}
187189
prev={this.prev}
188190
stop={this.stop}
189-
skip={this.skip}
190191
visible={this.state.visible}
191192
isFirstStep={this.isFirstStep()}
192193
isLastStep={this.isLastStep()}

0 commit comments

Comments
 (0)