Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 3a29993

Browse files
committed
🚧 (createStop) add transition prop
This also renames StopHOC into createStop.
1 parent b1c584f commit 3a29993

5 files changed

Lines changed: 35 additions & 10 deletions

File tree

src/StopValidator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React, { ComponentType } from 'react';
22

3+
import { TransitionType } from './Transitions/Transition';
4+
35
export interface IStop<T extends string> {
46
name: T;
57
Component: ComponentType<any>;
68
isFullScreen?: boolean;
79
onBack?: () => any;
810
props?: object;
11+
transition?: TransitionType;
912
}
1013

1114
export class StopValidator {

src/Transitions/Transition.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type TransitionType = 'slide-right';
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@ import { of } from 'rxjs';
33
import { View } from 'react-native';
44
import TestRenderer from 'react-test-renderer';
55

6-
import { StopHOC } from '../StopHOC';
6+
import { createStop } from '../createStop';
77
import { Navigation } from '../Navigation';
88

9-
describe('StopHOC', () => {
9+
describe('createStop', () => {
1010
it('creates a Component which pipes back events and filter them based on name', () => {
1111
const spy = jest.fn();
1212
const initialEvent = { target: 'myComponent' };
1313
const back$ = of(initialEvent);
14-
const Stop = StopHOC({ back$ }, undefined, 'myComponent', View, undefined);
14+
const Stop = createStop(
15+
{ back$ },
16+
undefined,
17+
'myComponent',
18+
View,
19+
undefined
20+
);
1521
const testRenderer = TestRenderer.create(<Stop />);
1622
testRenderer.root.instance.back$.subscribe(spy);
1723
expect(spy).toHaveBeenCalledWith(initialEvent);
@@ -21,7 +27,13 @@ describe('StopHOC', () => {
2127
const spy = jest.fn();
2228
const initialEvent = { target: 'notMyComponent' };
2329
const back$ = of(initialEvent);
24-
const Stop = StopHOC({ back$ }, undefined, 'myComponent', View, undefined);
30+
const Stop = createStop(
31+
{ back$ },
32+
undefined,
33+
'myComponent',
34+
View,
35+
undefined
36+
);
2537
const testRenderer = TestRenderer.create(<Stop />);
2638
testRenderer.root.instance.back$.subscribe(spy);
2739
expect(spy).not.toHaveBeenCalled();
@@ -35,7 +47,13 @@ describe('StopHOC', () => {
3547
);
3648
const initialEvent = { target: 'myComponent' };
3749
const back$ = of(initialEvent);
38-
const Stop = StopHOC({ back$ }, onBackSpy, 'myComponent', View, undefined);
50+
const Stop = createStop(
51+
{ back$ },
52+
onBackSpy,
53+
'myComponent',
54+
View,
55+
undefined
56+
);
3957
const testRenderer = TestRenderer.create(<Stop />);
4058
testRenderer.root.instance.back$.subscribe();
4159
expect(setOnBackCallbackSpy).toHaveBeenCalledWith(onBackSpy);

src/createCanal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { last } from './utils/Array.last';
1414
import { IBackEvent } from './Navigation/BackHandlerDelegate';
1515
import { withBackContext, WithBackContext } from './withBackContext';
1616
import { StopValidator, IStop } from './StopValidator';
17-
import { StopHOC } from './StopHOC';
17+
import { createStop } from './createStop';
1818

1919
type CanalComponentProps<T> = {
2020
style?: StyleProp<ViewStyle>;
@@ -60,12 +60,13 @@ export const createCanal = <
6060

6161
stopsList = stops.map(stop => ({
6262
...stop,
63-
Component: StopHOC(
63+
Component: createStop(
6464
this,
6565
stop.onBack,
6666
stop.name,
6767
stop.Component,
68-
stop.props
68+
stop.props,
69+
stop.transition
6970
)
7071
}));
7172
authorizations$ = new Subject<Authorizations>();

src/StopHOC.tsx renamed to src/createStop.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { View, StyleSheet } from 'react-native';
88
import { filter, share, tap } from 'rxjs/operators';
99
import { Navigation } from './Navigation';
1010
import { ICanal } from './createCanal';
11+
import { TransitionType } from './Transitions/Transition';
1112

12-
export const StopHOC = (
13+
export const createStop = (
1314
canal: ICanal,
1415
onBack: (() => any) | undefined,
1516
name: string,
1617
Component: ComponentType,
17-
props: object | undefined
18+
props: object | undefined,
19+
transition: TransitionType | undefined
1820
) => {
1921
/**
2022
* @TODO 2019-07-26 Update @types/react once https://github.com/DefinitelyTyped/DefinitelyTyped/pull is merged.

0 commit comments

Comments
 (0)