@applicaster/zapp-react-native-ui-components 14.0.0-rc.8 → 15.0.0-rc.1
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/index.tsx +15 -0
- package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
- package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
- package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
- package/Components/AudioPlayer/mobile/index.tsx +18 -0
- package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
- package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
- package/Components/AudioPlayer/tv/Layout.tsx +168 -0
- package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
- package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
- package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
- package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
- package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
- package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
- package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
- package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
- package/Components/AudioPlayer/types.ts +40 -0
- package/Components/BaseFocusable/index.tsx +23 -12
- package/Components/Cell/Cell.tsx +91 -64
- package/Components/Cell/CellWithFocusable.tsx +3 -0
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
- package/Components/Cell/index.js +7 -3
- package/Components/ComponentResolver/index.ts +1 -1
- package/Components/FeedLoader/FeedLoader.tsx +7 -16
- package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
- package/Components/FeedLoader/index.js +2 -8
- package/Components/Focusable/Focusable.tsx +12 -3
- package/Components/Focusable/FocusableTvOS.tsx +5 -5
- package/Components/Focusable/FocusableiOS.tsx +2 -2
- package/Components/Focusable/Touchable.tsx +5 -3
- package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
- package/Components/Focusable/index.android.tsx +19 -11
- package/Components/Focusable/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
- package/Components/FocusableList/FocusableItem.tsx +4 -3
- package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
- package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
- package/Components/FocusableList/index.tsx +20 -9
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -10
- package/Components/HandlePlayable/HandlePlayable.tsx +25 -9
- package/Components/HookRenderer/HookRenderer.tsx +5 -1
- package/Components/Layout/TV/LayoutBackground.tsx +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
- package/Components/MasterCell/elementMapper.tsx +1 -2
- package/Components/MasterCell/index.tsx +1 -1
- package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
- package/Components/MasterCell/utils/index.ts +11 -5
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
- package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +46 -33
- package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
- package/Components/PlayerContainer/index.ts +1 -1
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +1 -6
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
- package/Components/River/RefreshControl.tsx +11 -17
- package/Components/River/RiverItem.tsx +11 -8
- package/Components/River/TV/River.tsx +2 -17
- package/Components/River/TV/index.tsx +3 -1
- package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
- package/Components/River/TV/withRiverDataLoader.tsx +17 -0
- package/Components/River/TV/withTVEventHandler.tsx +1 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -6
- package/Components/River/__tests__/river.test.js +12 -26
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +28 -29
- package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
- package/Components/Screen/navigationHandler.ts +20 -2
- package/Components/ScreenResolver/index.tsx +15 -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 +1 -3
- package/Components/Tabs/Tabs.tsx +2 -3
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
- package/Components/TextInputTv/index.tsx +11 -0
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
- package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
- package/Components/VideoLive/animationUtils.ts +3 -3
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -9
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +73 -29
- package/Components/VideoModal/PlayerDetails.tsx +24 -2
- package/Components/VideoModal/PlayerWrapper.tsx +26 -142
- package/Components/VideoModal/VideoModal.tsx +3 -17
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -180
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +21 -51
- package/Components/VideoModal/hooks/index.ts +0 -2
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +15 -1
- package/Components/VideoModal/hooks/useModalSize.ts +18 -2
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
- package/Components/VideoModal/hooks/utils/index.ts +4 -0
- package/Components/VideoModal/utils.ts +6 -0
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
- package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
- package/Contexts/CellFocusedStateContext/index.tsx +27 -0
- package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
- package/Contexts/ScreenContext/index.tsx +46 -6
- package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
- package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
- package/Decorators/RiverFeedLoader/index.tsx +22 -4
- package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
- package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
- package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
- package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
- package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
- package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
- package/Decorators/ZappPipesDataConnector/types.ts +29 -0
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
- package/events/index.ts +3 -0
- package/package.json +5 -10
- package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
- package/Components/AudioPlayer/index.ts +0 -1
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
- package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
- /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +0 -0
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react-hooks";
|
|
2
2
|
import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
|
|
3
|
-
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
4
|
-
import { showDetails } from "../utils";
|
|
5
3
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
4
|
|
|
7
|
-
jest.
|
|
8
|
-
withTimeout$: jest.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock("../utils", () => ({
|
|
12
|
-
showDetails: jest.fn(),
|
|
13
|
-
}));
|
|
5
|
+
jest.useFakeTimers();
|
|
14
6
|
|
|
15
7
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
16
|
-
useIsTablet: jest.fn(),
|
|
8
|
+
useIsTablet: jest.fn().mockReturnValue(false),
|
|
17
9
|
}));
|
|
18
10
|
|
|
19
11
|
describe("useDelayedPlayerDetails", () => {
|
|
@@ -21,69 +13,47 @@ describe("useDelayedPlayerDetails", () => {
|
|
|
21
13
|
jest.clearAllMocks();
|
|
22
14
|
});
|
|
23
15
|
|
|
24
|
-
it("should return false initially", () => {
|
|
25
|
-
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
26
|
-
subscribe: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
|
|
27
|
-
});
|
|
28
|
-
|
|
16
|
+
it("should return false initially, that changes after 1 second", () => {
|
|
29
17
|
const { result } = renderHook(() =>
|
|
30
18
|
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
31
19
|
);
|
|
32
20
|
|
|
33
21
|
expect(result.current).toBe(false);
|
|
34
|
-
});
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
38
|
-
subscribe: (callback) => {
|
|
39
|
-
callback.next();
|
|
23
|
+
jest.advanceTimersByTime(1000);
|
|
40
24
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
(showDetails as jest.Mock).mockReturnValue(true);
|
|
46
|
-
(useIsTablet as jest.Mock).mockReturnValue(false);
|
|
25
|
+
expect(result.current).toBe(true);
|
|
26
|
+
});
|
|
47
27
|
|
|
28
|
+
it("should return false when isPip is true", () => {
|
|
48
29
|
const { result } = renderHook(() =>
|
|
49
|
-
useDelayedPlayerDetails({ isInline: true, isDocked:
|
|
30
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: true })
|
|
50
31
|
);
|
|
51
32
|
|
|
52
|
-
expect(result.current).toBe(
|
|
33
|
+
expect(result.current).toBe(false);
|
|
53
34
|
});
|
|
54
35
|
|
|
55
|
-
it("should return false
|
|
56
|
-
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
57
|
-
subscribe: (callback) => {
|
|
58
|
-
callback.next();
|
|
59
|
-
|
|
60
|
-
return { unsubscribe: jest.fn() };
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
(showDetails as jest.Mock).mockReturnValue(false);
|
|
65
|
-
(useIsTablet as jest.Mock).mockReturnValue(false);
|
|
66
|
-
|
|
36
|
+
it("should return false when isDocked is true", () => {
|
|
67
37
|
const { result } = renderHook(() =>
|
|
68
|
-
useDelayedPlayerDetails({ isInline: true, isDocked:
|
|
38
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: true, isPip: false })
|
|
69
39
|
);
|
|
70
40
|
|
|
71
41
|
expect(result.current).toBe(false);
|
|
72
42
|
});
|
|
73
43
|
|
|
74
|
-
it("should
|
|
75
|
-
|
|
44
|
+
it("should return true for tablet regardless of other flags", () => {
|
|
45
|
+
(useIsTablet as jest.Mock).mockReturnValue(true);
|
|
76
46
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
47
|
+
const { result } = renderHook(() =>
|
|
48
|
+
useDelayedPlayerDetails({
|
|
49
|
+
isInline: false,
|
|
50
|
+
isDocked: false,
|
|
51
|
+
isPip: false,
|
|
52
|
+
})
|
|
83
53
|
);
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
jest.advanceTimersByTime(1000);
|
|
86
56
|
|
|
87
|
-
expect(
|
|
57
|
+
expect(result.current).toBe(true);
|
|
88
58
|
});
|
|
89
59
|
});
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
// const showPlayerDetails = (
|
|
2
|
+
// isInline: boolean,
|
|
3
|
+
// isDocked: boolean,
|
|
4
|
+
// isPip: boolean,
|
|
5
|
+
// isTablet: boolean
|
|
6
|
+
// ) => {
|
|
7
|
+
// return showDetails({
|
|
8
|
+
// isMobile: !isTablet,
|
|
9
|
+
// isInline,
|
|
10
|
+
// isDocked,
|
|
11
|
+
// isPip,
|
|
12
|
+
// });
|
|
13
|
+
// };
|
|
14
|
+
|
|
1
15
|
import * as React from "react";
|
|
2
16
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
3
17
|
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
4
18
|
|
|
5
19
|
import { showDetails } from "./utils";
|
|
6
20
|
|
|
7
|
-
const TIMEOUT =
|
|
21
|
+
const TIMEOUT = 1000; // ms
|
|
8
22
|
|
|
9
23
|
type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
|
|
10
24
|
|
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import { getXray } from "@applicaster/zapp-react-native-utils/logger";
|
|
11
11
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
12
|
+
import {
|
|
13
|
+
isAndroidPlatform,
|
|
14
|
+
isAndroidVersionAtLeast,
|
|
15
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
16
|
+
import { StatusBar } from "react-native";
|
|
17
|
+
import { isAndroidTablet } from "@applicaster/zapp-react-native-utils/reactHooks/layout/isTablet";
|
|
12
18
|
|
|
13
19
|
const { Logger } = getXray();
|
|
14
20
|
|
|
@@ -27,12 +33,17 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
|
|
|
27
33
|
height: "100%",
|
|
28
34
|
};
|
|
29
35
|
|
|
36
|
+
const isOldAndroidDevice =
|
|
37
|
+
isAndroidPlatform() && !isAndroidVersionAtLeast(35) && !isAndroidTablet();
|
|
38
|
+
|
|
30
39
|
export const useModalSize = (): Size => {
|
|
31
40
|
const frame = useSafeAreaFrame();
|
|
32
41
|
|
|
33
42
|
const [modalSize, setModalSize] = React.useState<Size>({
|
|
34
43
|
width: frame.width,
|
|
35
|
-
height:
|
|
44
|
+
height: isOldAndroidDevice
|
|
45
|
+
? frame.height + StatusBar.currentHeight
|
|
46
|
+
: frame.height,
|
|
36
47
|
});
|
|
37
48
|
|
|
38
49
|
const setNewModalSize = React.useCallback((newSize, log) => {
|
|
@@ -44,7 +55,12 @@ export const useModalSize = (): Size => {
|
|
|
44
55
|
return oldSize;
|
|
45
56
|
}
|
|
46
57
|
|
|
47
|
-
return
|
|
58
|
+
return {
|
|
59
|
+
width: newSize.width,
|
|
60
|
+
height: isOldAndroidDevice
|
|
61
|
+
? newSize.height + StatusBar.currentHeight
|
|
62
|
+
: newSize.height,
|
|
63
|
+
};
|
|
48
64
|
});
|
|
49
65
|
|
|
50
66
|
logger.debug({
|
|
@@ -12,7 +12,7 @@ describe("showDetails", () => {
|
|
|
12
12
|
expect(result).toBe(false);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it("should return
|
|
15
|
+
it("should return true if isDocked & mobile", () => {
|
|
16
16
|
const result = showDetails({
|
|
17
17
|
isMobile: true,
|
|
18
18
|
isInline: true,
|
|
@@ -20,7 +20,7 @@ describe("showDetails", () => {
|
|
|
20
20
|
isPip: false,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
expect(result).toBe(
|
|
23
|
+
expect(result).toBe(true);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it("should return true if isMobile is true and isInline is true", () => {
|
|
@@ -34,6 +34,9 @@ export const useConfiguration = () => {
|
|
|
34
34
|
minimised_height = 0,
|
|
35
35
|
minimised_height_tablet = 0,
|
|
36
36
|
modal_background_color,
|
|
37
|
+
tablet_landscape_player_container_background_color,
|
|
38
|
+
screen_background_color,
|
|
39
|
+
audio_player_background_color,
|
|
37
40
|
} = config;
|
|
38
41
|
|
|
39
42
|
const minimisedHeight = useIsTablet()
|
|
@@ -43,6 +46,9 @@ export const useConfiguration = () => {
|
|
|
43
46
|
return {
|
|
44
47
|
minimised_height: Number(minimisedHeight),
|
|
45
48
|
modal_background_color,
|
|
49
|
+
tablet_landscape_player_container_background_color,
|
|
50
|
+
audio_player_background_color,
|
|
51
|
+
screen_background_color,
|
|
46
52
|
};
|
|
47
53
|
};
|
|
48
54
|
|
|
@@ -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
|
});
|
|
@@ -4,8 +4,8 @@ which helps in detecting whether a given component is visible within the viewpor
|
|
|
4
4
|
It is useful for implementing lazy loading or triggering specific actions when a component comes into view.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React, {
|
|
8
|
-
import {
|
|
7
|
+
import React, { FC, ReactNode, useEffect, useRef, useState } from "react";
|
|
8
|
+
import { Dimensions, View } from "react-native";
|
|
9
9
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
10
10
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
11
11
|
|
|
@@ -78,7 +78,7 @@ const VisibilitySensorComponent: FC<Props> = ({
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
const stopWatching = () => {
|
|
81
|
-
|
|
81
|
+
clearInterval(interval);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const isInViewPort = () => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export const CellFocusedStateContext = React.createContext<boolean>(false);
|
|
4
|
+
|
|
5
|
+
export const CellFocusedStateContextProvider = ({
|
|
6
|
+
cellFocused,
|
|
7
|
+
children,
|
|
8
|
+
}: {
|
|
9
|
+
cellFocused: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<CellFocusedStateContext.Provider value={cellFocused}>
|
|
14
|
+
{children}
|
|
15
|
+
</CellFocusedStateContext.Provider>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function withCellFocusedStateContext(
|
|
20
|
+
Component: React.ComponentType<any>
|
|
21
|
+
) {
|
|
22
|
+
return function WithCellFocusedStateContextWrapper(props) {
|
|
23
|
+
const cellFocusedState = React.useContext(CellFocusedStateContext);
|
|
24
|
+
|
|
25
|
+
return <Component {...props} cellFocusedState={cellFocusedState} />;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
|
|
5
5
|
|
|
@@ -14,12 +14,12 @@ describe("withConfigurationProvider", () => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
it("provides configuration to children", () => {
|
|
17
|
-
const
|
|
17
|
+
const { toJSON } = render(
|
|
18
18
|
<ConfigurationProvider configuration={{ target: "foobar" }}>
|
|
19
19
|
<TestComponent />
|
|
20
20
|
</ConfigurationProvider>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
expect(
|
|
23
|
+
expect(toJSON()).toMatchSnapshot();
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
14
14
|
import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
|
|
15
15
|
import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
|
|
16
|
-
import { create
|
|
16
|
+
import { create } from "zustand";
|
|
17
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
17
18
|
import { useShallow } from "zustand/react/shallow";
|
|
18
19
|
import { Animated } from "react-native";
|
|
19
20
|
|
|
@@ -39,11 +40,26 @@ interface NavBarState {
|
|
|
39
40
|
setSummary: (subtitle: string) => void;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const createStateStore = () =>
|
|
44
|
+
create(
|
|
45
|
+
subscribeWithSelector<ScreenStateStore>((set) => ({
|
|
46
|
+
data: {},
|
|
47
|
+
setValue: (key, value) =>
|
|
48
|
+
set((state) => ({
|
|
49
|
+
data: {
|
|
50
|
+
...state.data,
|
|
51
|
+
[key]: value,
|
|
52
|
+
},
|
|
53
|
+
})),
|
|
54
|
+
removeValue: (key) =>
|
|
55
|
+
set((state) => {
|
|
56
|
+
const newData = { ...state.data };
|
|
57
|
+
delete newData[key];
|
|
58
|
+
|
|
59
|
+
return { data: newData };
|
|
60
|
+
}),
|
|
61
|
+
}))
|
|
62
|
+
);
|
|
47
63
|
|
|
48
64
|
const createStore = () =>
|
|
49
65
|
create<NavBarStoreState>((set) => ({
|
|
@@ -65,7 +81,15 @@ const createStore = () =>
|
|
|
65
81
|
},
|
|
66
82
|
}));
|
|
67
83
|
|
|
84
|
+
type ScreenContextType = {
|
|
85
|
+
_navBarStore: ReturnType<typeof createStore>;
|
|
86
|
+
_stateStore: ReturnType<typeof createStateStore>;
|
|
87
|
+
navBar: NavBarState;
|
|
88
|
+
legacyFormatScreenData: LegacyNavigationScreenData | null;
|
|
89
|
+
};
|
|
90
|
+
|
|
68
91
|
export const ScreenContext = createContext<ScreenContextType>({
|
|
92
|
+
_stateStore: createStateStore(),
|
|
69
93
|
_navBarStore: createStore(),
|
|
70
94
|
navBar: {
|
|
71
95
|
visible: true,
|
|
@@ -103,6 +127,21 @@ export function ScreenContextProvider({
|
|
|
103
127
|
null
|
|
104
128
|
);
|
|
105
129
|
|
|
130
|
+
const screenStateRef = useRef<null | ReturnType<typeof createStateStore>>(
|
|
131
|
+
null
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const getScreenState = useCallback(() => {
|
|
135
|
+
if (screenStateRef.current !== null) {
|
|
136
|
+
return screenStateRef.current;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const stateStore = createStateStore();
|
|
140
|
+
screenStateRef.current = stateStore;
|
|
141
|
+
|
|
142
|
+
return stateStore;
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
106
145
|
const getScreenNavBarState = useCallback(() => {
|
|
107
146
|
if (screenNavBarStateRef.current !== null) {
|
|
108
147
|
return screenNavBarStateRef.current;
|
|
@@ -163,6 +202,7 @@ export function ScreenContextProvider({
|
|
|
163
202
|
value={useMemo(
|
|
164
203
|
() => ({
|
|
165
204
|
_navBarStore: getScreenNavBarState(),
|
|
205
|
+
_stateStore: getScreenState(),
|
|
166
206
|
navBar: navBarState,
|
|
167
207
|
legacyFormatScreenData: routeScreenData,
|
|
168
208
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
|
|
4
4
|
import { View } from "react-native";
|
|
5
5
|
import { withConfigurationProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ConfigurationWrapper";
|
|
@@ -15,12 +15,12 @@ describe("withConfigurationProvider", () => {
|
|
|
15
15
|
it("correctly passes all the configuration keys child component", () => {
|
|
16
16
|
const Component = withConfigurationProvider(TestComponent);
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const { toJSON } = render(
|
|
19
19
|
<Component
|
|
20
20
|
screenData={{ styles: {}, general: {}, data: { source: "test" } }}
|
|
21
21
|
/>
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
expect(
|
|
24
|
+
expect(toJSON()).toMatchSnapshot();
|
|
25
25
|
});
|
|
26
26
|
});
|
|
@@ -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
|
[]
|