@applicaster/zapp-react-native-ui-components 14.0.0-alpha.9119252693 → 14.0.0-alpha.9203091422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/AnimatedInOut/index.tsx +5 -3
- package/Components/AudioPlayer/mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap +0 -6
- package/Components/Focusable/Focusable.tsx +5 -3
- package/Components/Focusable/FocusableTvOS.tsx +3 -3
- package/Components/Focusable/FocusableiOS.tsx +1 -1
- package/Components/FocusableList/index.tsx +4 -0
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -8
- package/Components/MasterCell/elementMapper.tsx +1 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
- package/Components/MasterCell/utils/index.ts +23 -3
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +26 -22
- package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
- package/Components/River/TV/withTVEventHandler.tsx +1 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
- package/Components/ScreenRevealManager/index.ts +1 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
- package/Components/Tabs/TV/Tabs.android.tsx +0 -2
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
- package/Components/Transitioner/Scene.tsx +1 -0
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
- package/Components/VideoLive/animationUtils.ts +3 -3
- package/Components/VideoModal/hooks/useModalSize.ts +3 -1
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
- package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
- package/Decorators/RiverFeedLoader/index.tsx +8 -2
- package/Decorators/RiverFeedLoader/utils/index.ts +7 -2
- package/Decorators/ZappPipesDataConnector/index.tsx +20 -2
- package/package.json +5 -6
- package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ScreenRevealManager,
|
|
3
|
+
COMPONENT_LOADING_STATE,
|
|
4
|
+
} from "../ScreenRevealManager";
|
|
5
|
+
|
|
6
|
+
describe("ScreenRevealManager", () => {
|
|
7
|
+
const mockCallback = jest.fn();
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
jest.clearAllMocks();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should initialize with the correct number of components to wait for", () => {
|
|
14
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
15
|
+
{ component_type: "component1" },
|
|
16
|
+
{ component_type: "component2" },
|
|
17
|
+
{ component_type: "component3" },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
21
|
+
|
|
22
|
+
expect(manager["numberOfComponentsWaitToLoadBeforePresent"]).toBe(3);
|
|
23
|
+
|
|
24
|
+
expect(manager["renderingState"]).toEqual([
|
|
25
|
+
COMPONENT_LOADING_STATE.UNKNOWN,
|
|
26
|
+
COMPONENT_LOADING_STATE.UNKNOWN,
|
|
27
|
+
COMPONENT_LOADING_STATE.UNKNOWN,
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should call the callback when the required number of components are loaded successfully", () => {
|
|
32
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
33
|
+
{ component_type: "component1" },
|
|
34
|
+
{ component_type: "component2" },
|
|
35
|
+
{ component_type: "component3" },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
39
|
+
|
|
40
|
+
manager.onLoadFinished(0);
|
|
41
|
+
manager.onLoadFinished(1);
|
|
42
|
+
manager.onLoadFinished(2);
|
|
43
|
+
|
|
44
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should call the callback when the required number of components fail to load", () => {
|
|
48
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
49
|
+
{ component_type: "component1" },
|
|
50
|
+
{ component_type: "component2" },
|
|
51
|
+
{ component_type: "component3" },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
55
|
+
|
|
56
|
+
manager.onLoadFailed(0);
|
|
57
|
+
manager.onLoadFailed(1);
|
|
58
|
+
manager.onLoadFailed(2);
|
|
59
|
+
|
|
60
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should call the callback when a mix of successful and failed loads meet the required number", () => {
|
|
64
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
65
|
+
{ component_type: "component1" },
|
|
66
|
+
{ component_type: "component2" },
|
|
67
|
+
{ component_type: "component3" },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
71
|
+
|
|
72
|
+
manager.onLoadFinished(0);
|
|
73
|
+
manager.onLoadFailed(1);
|
|
74
|
+
manager.onLoadFinished(2);
|
|
75
|
+
|
|
76
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should not call the callback if the required number of components are not loaded", () => {
|
|
80
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
81
|
+
{ component_type: "component1" },
|
|
82
|
+
{ component_type: "component2" },
|
|
83
|
+
{ component_type: "component3" },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
87
|
+
|
|
88
|
+
manager.onLoadFinished(0);
|
|
89
|
+
manager.onLoadFailed(1);
|
|
90
|
+
|
|
91
|
+
expect(mockCallback).not.toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("should call the callback when the when first component is gallery and it was loaded successfully", () => {
|
|
95
|
+
const componentsToRender: ZappUIComponent[] = [
|
|
96
|
+
{ component_type: "gallery-qb" },
|
|
97
|
+
{ component_type: "component2" },
|
|
98
|
+
{ component_type: "component3" },
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
102
|
+
|
|
103
|
+
manager.onLoadFinished(0);
|
|
104
|
+
|
|
105
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { render, screen, act } from "@testing-library/react-native";
|
|
5
|
+
import { View } from "react-native";
|
|
6
|
+
import {
|
|
7
|
+
withScreenRevealManager,
|
|
8
|
+
SHOWN,
|
|
9
|
+
TIMEOUT,
|
|
10
|
+
} from "../withScreenRevealManager";
|
|
11
|
+
|
|
12
|
+
// jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
|
|
13
|
+
|
|
14
|
+
const MockComponent = ({
|
|
15
|
+
initialNumberToLoad,
|
|
16
|
+
onLoadFinishedFromScreenRevealManager,
|
|
17
|
+
onLoadFailedFromScreenRevealManager,
|
|
18
|
+
}) => {
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
// Simulate loading components
|
|
21
|
+
for (let i = 0; i < initialNumberToLoad; i++) {
|
|
22
|
+
onLoadFinishedFromScreenRevealManager(i);
|
|
23
|
+
}
|
|
24
|
+
}, [initialNumberToLoad, onLoadFinishedFromScreenRevealManager]);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View
|
|
28
|
+
testID="mock-component"
|
|
29
|
+
initialNumberToLoad={initialNumberToLoad}
|
|
30
|
+
onLoadFinishedFromScreenRevealManager={
|
|
31
|
+
onLoadFinishedFromScreenRevealManager
|
|
32
|
+
}
|
|
33
|
+
onLoadFailedFromScreenRevealManager={onLoadFailedFromScreenRevealManager}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const WrappedComponent = withScreenRevealManager(MockComponent);
|
|
39
|
+
|
|
40
|
+
describe.skip("withScreenRevealManager", () => {
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
jest.clearAllMocks();
|
|
43
|
+
jest.useFakeTimers();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
jest.runOnlyPendingTimers();
|
|
48
|
+
jest.useRealTimers();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should render the wrapped component", () => {
|
|
52
|
+
render(
|
|
53
|
+
<WrappedComponent
|
|
54
|
+
componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(screen.getByTestId("mock-component")).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should animate opacity when ready to show", () => {
|
|
62
|
+
render(
|
|
63
|
+
<WrappedComponent
|
|
64
|
+
componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const animatedView = screen.getByTestId("animated-component");
|
|
69
|
+
|
|
70
|
+
act(() => {
|
|
71
|
+
jest.advanceTimersByTime(TIMEOUT + 100);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(animatedView.props.style.opacity).toBe(SHOWN);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("should pass initialNumberToLoad, onLoadFinishedFromScreenRevealManager, and onLoadFailedFromScreenRevealManager to the wrapped component", () => {
|
|
78
|
+
render(
|
|
79
|
+
<WrappedComponent
|
|
80
|
+
componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const mockComponent = screen.getByTestId("mock-component");
|
|
85
|
+
|
|
86
|
+
expect(mockComponent.props.initialNumberToLoad).toBe(3);
|
|
87
|
+
|
|
88
|
+
expect(
|
|
89
|
+
mockComponent.props.onLoadFinishedFromScreenRevealManager
|
|
90
|
+
).toBeInstanceOf(Function);
|
|
91
|
+
|
|
92
|
+
expect(
|
|
93
|
+
mockComponent.props.onLoadFailedFromScreenRevealManager
|
|
94
|
+
).toBeInstanceOf(Function);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { withScreenRevealManager } from "./withScreenRevealManager";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
4
|
+
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
|
+
import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
|
|
6
|
+
|
|
7
|
+
import { ScreenRevealManager } from "./ScreenRevealManager";
|
|
8
|
+
|
|
9
|
+
const flex = platformSelect({
|
|
10
|
+
tvos: 1,
|
|
11
|
+
android_tv: 1,
|
|
12
|
+
web: undefined,
|
|
13
|
+
samsung_tv: undefined,
|
|
14
|
+
lg_tv: undefined,
|
|
15
|
+
default: undefined,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const TIMEOUT = 500; // 500 ms
|
|
19
|
+
|
|
20
|
+
const HIDDEN = 0; // opacity = 0
|
|
21
|
+
|
|
22
|
+
export const SHOWN = 1; // opacity = 1
|
|
23
|
+
|
|
24
|
+
type Props = {
|
|
25
|
+
componentsToRender: ZappUIComponent[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const withScreenRevealManager = (Component) => {
|
|
29
|
+
return function WithScreenRevealManager(props: Props) {
|
|
30
|
+
const { componentsToRender } = props;
|
|
31
|
+
|
|
32
|
+
const [isReadyToShow, setIsReadyToShow] = React.useState(false);
|
|
33
|
+
|
|
34
|
+
const handleSetIsReadyToShow = React.useCallback(() => {
|
|
35
|
+
setIsReadyToShow(true);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const managerRef = useRefWithInitialValue<ScreenRevealManager>(
|
|
39
|
+
() => new ScreenRevealManager(componentsToRender, handleSetIsReadyToShow)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const opacityRef = useRefWithInitialValue<Animated.Value>(
|
|
43
|
+
() => new Animated.Value(HIDDEN)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (isReadyToShow) {
|
|
48
|
+
Animated.timing(opacityRef.current, {
|
|
49
|
+
toValue: SHOWN,
|
|
50
|
+
duration: TIMEOUT,
|
|
51
|
+
useNativeDriver: true,
|
|
52
|
+
}).start();
|
|
53
|
+
}
|
|
54
|
+
}, [isReadyToShow]);
|
|
55
|
+
|
|
56
|
+
if (isFirstComponentScreenPicker(componentsToRender)) {
|
|
57
|
+
// for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
|
|
58
|
+
return <Component {...props} />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Animated.View
|
|
63
|
+
style={{ opacity: opacityRef.current, flex }}
|
|
64
|
+
testID="animated-component"
|
|
65
|
+
>
|
|
66
|
+
<Component
|
|
67
|
+
{...props}
|
|
68
|
+
initialNumberToLoad={
|
|
69
|
+
managerRef.current.numberOfComponentsWaitToLoadBeforePresent
|
|
70
|
+
}
|
|
71
|
+
onLoadFinishedFromScreenRevealManager={
|
|
72
|
+
managerRef.current.onLoadFinished
|
|
73
|
+
}
|
|
74
|
+
onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
|
|
75
|
+
/>
|
|
76
|
+
</Animated.View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -7,7 +7,6 @@ import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
|
7
7
|
|
|
8
8
|
import Tab from "./Tab";
|
|
9
9
|
import { Gutter } from "../Gutter";
|
|
10
|
-
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
11
10
|
import { ImageBackground, View } from "react-native";
|
|
12
11
|
import { getStyles } from "./styles";
|
|
13
12
|
import {
|
|
@@ -100,7 +99,6 @@ const TabsComponent = ({
|
|
|
100
99
|
>
|
|
101
100
|
<FocusableList
|
|
102
101
|
horizontal
|
|
103
|
-
onScrollToIndexFailed={noop}
|
|
104
102
|
onLayout={onLayoutChange}
|
|
105
103
|
contentContainerStyle={tabsListContentContainer}
|
|
106
104
|
ref={flatListRef}
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
exports[`<Touchable /> when not running in automated tests environment renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
accessibilityLabel="some-test-id"
|
|
6
|
+
accessibilityState={
|
|
7
|
+
{
|
|
8
|
+
"busy": undefined,
|
|
9
|
+
"checked": undefined,
|
|
10
|
+
"disabled": undefined,
|
|
11
|
+
"expanded": undefined,
|
|
12
|
+
"selected": undefined,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
accessibilityValue={
|
|
16
|
+
{
|
|
17
|
+
"max": undefined,
|
|
18
|
+
"min": undefined,
|
|
19
|
+
"now": undefined,
|
|
20
|
+
"text": undefined,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
6
23
|
accessible={true}
|
|
7
24
|
collapsable={false}
|
|
8
25
|
focusable={true}
|
|
@@ -29,6 +46,23 @@ exports[`<Touchable /> when not running in automated tests environment renders c
|
|
|
29
46
|
exports[`<Touchable /> when running in automated tests environment has accessible flag set to false 1`] = `
|
|
30
47
|
<View
|
|
31
48
|
accessibilityLabel="some-test-id"
|
|
49
|
+
accessibilityState={
|
|
50
|
+
{
|
|
51
|
+
"busy": undefined,
|
|
52
|
+
"checked": undefined,
|
|
53
|
+
"disabled": undefined,
|
|
54
|
+
"expanded": undefined,
|
|
55
|
+
"selected": undefined,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
accessibilityValue={
|
|
59
|
+
{
|
|
60
|
+
"max": undefined,
|
|
61
|
+
"min": undefined,
|
|
62
|
+
"now": undefined,
|
|
63
|
+
"text": undefined,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
32
66
|
accessible={false}
|
|
33
67
|
collapsable={false}
|
|
34
68
|
focusable={true}
|
|
@@ -36,6 +36,7 @@ export function CurrentScreenContextProvider({
|
|
|
36
36
|
screenData: NavigationScreenData;
|
|
37
37
|
}) {
|
|
38
38
|
const { pathname, isActive = false, screenData } = props;
|
|
39
|
+
console.log("CurrentScreenContextProvider", { screenData });
|
|
39
40
|
|
|
40
41
|
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
41
42
|
|
|
@@ -6,15 +6,21 @@ exports[`<Scene /> renders correctly 1`] = `
|
|
|
6
6
|
collapsable={false}
|
|
7
7
|
pointerEvents="auto"
|
|
8
8
|
style={
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
"flex": 1,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"paddingBottom": 49,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"fontScale": 2,
|
|
18
|
+
"height": 1334,
|
|
19
|
+
"scale": 2,
|
|
20
|
+
"statusBarHeight": null,
|
|
21
|
+
"width": 750,
|
|
22
|
+
},
|
|
23
|
+
]
|
|
18
24
|
}
|
|
19
25
|
/>
|
|
20
26
|
</View>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Animated, Easing, EasingFunction, StyleProp } from "react-native";
|
|
2
2
|
|
|
3
3
|
type AnimatedInterpolatedStyle =
|
|
4
|
-
| Animated.AnimatedInterpolation
|
|
5
|
-
| [{ [Key: string]: Animated.AnimatedInterpolation }];
|
|
4
|
+
| Animated.AnimatedInterpolation<number>
|
|
5
|
+
| [{ [Key: string]: Animated.AnimatedInterpolation<number> }];
|
|
6
6
|
|
|
7
7
|
type AnimationConfig = {
|
|
8
8
|
duration: number;
|
|
@@ -31,7 +31,7 @@ const interpolate = (
|
|
|
31
31
|
animatedValue: Animated.Value,
|
|
32
32
|
from: number = 0,
|
|
33
33
|
to: number = 1
|
|
34
|
-
): Animated.AnimatedInterpolation =>
|
|
34
|
+
): Animated.AnimatedInterpolation<number> =>
|
|
35
35
|
animatedValue.interpolate({
|
|
36
36
|
inputRange: [0, 1],
|
|
37
37
|
outputRange: [from, to],
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isAndroidVersionAtLeast,
|
|
15
15
|
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
16
16
|
import { StatusBar } from "react-native";
|
|
17
|
+
import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
|
|
17
18
|
|
|
18
19
|
const { Logger } = getXray();
|
|
19
20
|
|
|
@@ -32,7 +33,8 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
|
|
|
32
33
|
height: "100%",
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const isOldAndroidDevice =
|
|
36
|
+
const isOldAndroidDevice =
|
|
37
|
+
isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
|
|
36
38
|
|
|
37
39
|
export const useModalSize = (): Size => {
|
|
38
40
|
const frame = useSafeAreaFrame();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
|
-
import { act,
|
|
5
|
+
import { act, render } from "@testing-library/react-native";
|
|
6
6
|
|
|
7
7
|
import { ViewportAware } from "../";
|
|
8
8
|
import { ViewportTracker } from "../../ViewportTracker";
|
|
@@ -12,21 +12,17 @@ import ReactNative from "react-native";
|
|
|
12
12
|
|
|
13
13
|
jest.useFakeTimers();
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
...jest.requireActual("react-native/Libraries/ReactNative/NativeUIManager"),
|
|
18
|
-
measureLayout: (handle, parent, error, success) => {
|
|
19
|
-
success(100, 100, 400, 400);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
});
|
|
15
|
+
const { ScrollView } = ReactNative;
|
|
23
16
|
|
|
24
|
-
jest.
|
|
25
|
-
...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
|
|
26
|
-
findNodeHandle: () => 1234,
|
|
27
|
-
}));
|
|
17
|
+
jest.spyOn(ReactNative, "findNodeHandle").mockImplementation(() => 1234);
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
ReactNative.UIManager.measureLayout = jest.fn(
|
|
20
|
+
(handle, parent, error, success) => {
|
|
21
|
+
success(100, 100, 400, 400);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
ReactNative.findNodeHandle = () => 1234;
|
|
30
26
|
|
|
31
27
|
const viewportEventsManager = new ViewportEvents(true);
|
|
32
28
|
|
|
@@ -138,7 +134,7 @@ describe("<ViewportAware />", () => {
|
|
|
138
134
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
139
135
|
expect(onViewportEnter).toHaveBeenCalled();
|
|
140
136
|
|
|
141
|
-
const scrollviews = wrapper.
|
|
137
|
+
const scrollviews = wrapper.UNSAFE_getAllByType(ScrollView);
|
|
142
138
|
expect(scrollviews).toBeArray();
|
|
143
139
|
expect(scrollviews).toHaveProperty("length", 2);
|
|
144
140
|
|
|
@@ -179,7 +175,7 @@ describe("<ViewportAware />", () => {
|
|
|
179
175
|
|
|
180
176
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
181
177
|
|
|
182
|
-
const scrollviews = wrapper.
|
|
178
|
+
const scrollviews = wrapper.UNSAFE_getAllByType(ScrollView);
|
|
183
179
|
expect(scrollviews).toBeArray();
|
|
184
180
|
expect(scrollviews).toHaveProperty("length", 2);
|
|
185
181
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import TestRenderer, { act } from "react-test-renderer";
|
|
2
|
+
import { act, render } from "@testing-library/react-native";
|
|
4
3
|
import { ViewportEvents } from "../../ViewportEvents";
|
|
4
|
+
import ReactNative from "react-native";
|
|
5
|
+
|
|
6
|
+
const { ScrollView } = ReactNative;
|
|
5
7
|
|
|
6
8
|
const TestComponent = () => <ScrollView />;
|
|
7
9
|
|
|
8
|
-
jest.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
jest.spyOn(ReactNative, "findNodeHandle").mockImplementation(() => 1234);
|
|
11
|
+
|
|
12
|
+
ReactNative.UIManager.measureLayout = jest.fn(
|
|
13
|
+
(handle, parent, error, success) => {
|
|
14
|
+
success(100, 100, 400, 400);
|
|
15
|
+
}
|
|
16
|
+
);
|
|
12
17
|
|
|
13
18
|
const viewportEventsManager = new ViewportEvents(true);
|
|
14
19
|
|
|
@@ -23,32 +28,49 @@ const event = {
|
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
describe("<ViewportTracker />", () => {
|
|
26
|
-
// eslint-disable-next-line react/prop-types
|
|
27
|
-
const ReactWrapper = ({ children }) => (
|
|
28
|
-
<ViewportTracker viewportEventsManager={viewportEventsManager}>
|
|
29
|
-
<ScrollView>{children}</ScrollView>
|
|
30
|
-
</ViewportTracker>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const wrapper = TestRenderer.create(
|
|
34
|
-
<ReactWrapper>
|
|
35
|
-
<TestComponent />
|
|
36
|
-
</ReactWrapper>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const scrollView = wrapper.root.findByType(ScrollView);
|
|
40
|
-
|
|
41
31
|
beforeEach(() => {
|
|
42
32
|
viewportEventSpy.mockClear();
|
|
43
33
|
});
|
|
44
34
|
|
|
45
35
|
it("renders correctly", () => {
|
|
36
|
+
// eslint-disable-next-line react/prop-types
|
|
37
|
+
const ReactWrapper = ({ children }) => (
|
|
38
|
+
<ViewportTracker viewportEventsManager={viewportEventsManager}>
|
|
39
|
+
<ScrollView>{children}</ScrollView>
|
|
40
|
+
</ViewportTracker>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const wrapper = render(
|
|
44
|
+
<ReactWrapper>
|
|
45
|
+
<TestComponent />
|
|
46
|
+
</ReactWrapper>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const scrollView = wrapper.UNSAFE_getByType(ScrollView);
|
|
50
|
+
|
|
46
51
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
47
52
|
expect(scrollView.props).toMatchSnapshot();
|
|
48
53
|
});
|
|
49
54
|
|
|
50
55
|
it("notifies viewport listeners when layout changes", () => {
|
|
51
|
-
|
|
56
|
+
// eslint-disable-next-line react/prop-types
|
|
57
|
+
const ReactWrapper = ({ children }) => (
|
|
58
|
+
<ViewportTracker viewportEventsManager={viewportEventsManager}>
|
|
59
|
+
<ScrollView>{children}</ScrollView>
|
|
60
|
+
</ViewportTracker>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const wrapper = render(
|
|
64
|
+
<ReactWrapper>
|
|
65
|
+
<TestComponent />
|
|
66
|
+
</ReactWrapper>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const scrollView = wrapper.UNSAFE_getByType(ScrollView);
|
|
70
|
+
|
|
71
|
+
act(() => {
|
|
72
|
+
scrollView.props.onLayout(event);
|
|
73
|
+
});
|
|
52
74
|
|
|
53
75
|
expect(viewportEventSpy).toHaveBeenCalledWith(
|
|
54
76
|
expect.objectContaining({
|
|
@@ -63,12 +85,50 @@ describe("<ViewportTracker />", () => {
|
|
|
63
85
|
});
|
|
64
86
|
|
|
65
87
|
it("notifies viewport listeners when content scrolls", () => {
|
|
66
|
-
|
|
88
|
+
// eslint-disable-next-line react/prop-types
|
|
89
|
+
const ReactWrapper = ({ children }) => (
|
|
90
|
+
<ViewportTracker viewportEventsManager={viewportEventsManager}>
|
|
91
|
+
<ScrollView>{children}</ScrollView>
|
|
92
|
+
</ViewportTracker>
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const wrapper = render(
|
|
96
|
+
<ReactWrapper>
|
|
97
|
+
<TestComponent />
|
|
98
|
+
</ReactWrapper>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const scrollView = wrapper.UNSAFE_getByType(ScrollView);
|
|
102
|
+
|
|
103
|
+
act(() => {
|
|
104
|
+
scrollView.props.onLayout(event);
|
|
105
|
+
scrollView.props.onScroll(event);
|
|
106
|
+
});
|
|
107
|
+
|
|
67
108
|
expect(viewportEventSpy).toHaveBeenCalled();
|
|
68
109
|
});
|
|
69
110
|
|
|
70
111
|
it("notifies viewport listeners when content size changes", () => {
|
|
71
|
-
|
|
112
|
+
// eslint-disable-next-line react/prop-types
|
|
113
|
+
const ReactWrapper = ({ children }) => (
|
|
114
|
+
<ViewportTracker viewportEventsManager={viewportEventsManager}>
|
|
115
|
+
<ScrollView>{children}</ScrollView>
|
|
116
|
+
</ViewportTracker>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const wrapper = render(
|
|
120
|
+
<ReactWrapper>
|
|
121
|
+
<TestComponent />
|
|
122
|
+
</ReactWrapper>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const scrollView = wrapper.UNSAFE_getByType(ScrollView);
|
|
126
|
+
|
|
127
|
+
act(() => {
|
|
128
|
+
scrollView.props.onLayout(event);
|
|
129
|
+
scrollView.props.onContentSizeChange(100, 100);
|
|
130
|
+
});
|
|
131
|
+
|
|
72
132
|
expect(viewportEventSpy).toHaveBeenCalled();
|
|
73
133
|
});
|
|
74
134
|
});
|
|
@@ -21,13 +21,13 @@ const prepareConfiguration = (
|
|
|
21
21
|
keys: [string]
|
|
22
22
|
) => R.compose(R.evolve(keysMap), R.pickAll(keys))(configuration);
|
|
23
23
|
|
|
24
|
+
const configurationKeys = R.keys(keysMap);
|
|
25
|
+
|
|
24
26
|
export function withConfigurationProvider(Component: React.ComponentType<any>) {
|
|
25
27
|
return function WithConfigurationProvider(props: Props) {
|
|
26
28
|
const styles = props?.screenData?.styles;
|
|
27
29
|
const general = props?.screenData?.general;
|
|
28
30
|
|
|
29
|
-
const configurationKeys = React.useMemo(() => R.keys(keysMap), []);
|
|
30
|
-
|
|
31
31
|
const configuration = React.useMemo(
|
|
32
32
|
() => prepareConfiguration({ ...general, ...styles }, configurationKeys),
|
|
33
33
|
[]
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
loadDatasources,
|
|
14
14
|
usePipesContexts,
|
|
15
15
|
} from "./utils";
|
|
16
|
+
import { useScreenResolvers } from "@applicaster/zapp-react-native-utils/actionsExecutor/screenResolver";
|
|
16
17
|
|
|
17
18
|
type RiverProps = {
|
|
18
19
|
dispatch: DispatchProp;
|
|
@@ -25,7 +26,7 @@ export function WithRiverFeedLoader(Component: ZappComponent) {
|
|
|
25
26
|
return function WrappedWithRiverFeedLoader(props: RiverProps) {
|
|
26
27
|
const { river } = props;
|
|
27
28
|
const { screenData, pathname } = useRoute();
|
|
28
|
-
|
|
29
|
+
const resolvers = useScreenResolvers();
|
|
29
30
|
const pipesContexts = usePipesContexts(river.id, pathname);
|
|
30
31
|
|
|
31
32
|
const componentsToLoad = ignoreComponentsWithClearCacheFlag(
|
|
@@ -49,7 +50,12 @@ export function WithRiverFeedLoader(Component: ZappComponent) {
|
|
|
49
50
|
item?.filter((item2) => item2 !== undefined)
|
|
50
51
|
);
|
|
51
52
|
|
|
52
|
-
loadDatasources(
|
|
53
|
+
loadDatasources(
|
|
54
|
+
nonEmptyDataSources,
|
|
55
|
+
river?.id,
|
|
56
|
+
props.dispatch,
|
|
57
|
+
resolvers
|
|
58
|
+
);
|
|
53
59
|
}, []);
|
|
54
60
|
|
|
55
61
|
return <Component {...props} />;
|