@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 15.0.0-alpha.1351496011
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 +22 -21
- 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 +49 -43
- package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
- package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
- 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 +3 -0
- 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 -0
- package/Components/River/__tests__/river.test.js +12 -26
- package/Components/River/index.tsx +1 -1
- package/Components/Screen/TV/hooks/useInitialFocus.ts +16 -4
- package/Components/Screen/__tests__/Screen.test.tsx +28 -29
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
- package/Components/Screen/index.tsx +22 -5
- package/Components/Screen/navigationHandler.ts +20 -2
- package/Components/ScreenResolver/index.tsx +22 -1
- 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/utils/index.ts +25 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +91 -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 +6 -10
- 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 +29 -7
- 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 -240
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
- package/Components/VideoModal/hooks/index.ts +0 -2
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
- 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/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- 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/getDatasourceUrl.ts +6 -10
- 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
|
@@ -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,25 @@
|
|
|
1
|
+
import { ReplaySubject } from "rxjs";
|
|
2
|
+
import { pairwise, filter, first } from "rxjs/operators";
|
|
3
|
+
|
|
4
|
+
// we are interested in last 2 events, because we wait transition from <false> to <true>
|
|
5
|
+
const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
|
|
6
|
+
|
|
7
|
+
export const emitScreenRevealManagerIsReadyToShow = () => {
|
|
8
|
+
console.log("debug_2", "is_ready");
|
|
9
|
+
screenRevealManagerSubject$.next(true);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const emitScreenRevealManagerIsNotReadyToShow = () => {
|
|
13
|
+
console.log("debug_2", "is_not_ready");
|
|
14
|
+
screenRevealManagerSubject$.next(false);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const waitUntilScreenRevealManagerIsReady = () => {
|
|
18
|
+
return screenRevealManagerSubject$.pipe(
|
|
19
|
+
pairwise(), // emit consecutive pairs: [prev, curr]
|
|
20
|
+
filter(
|
|
21
|
+
([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady
|
|
22
|
+
), // detect transition from not_ready to ready
|
|
23
|
+
first()
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
import {
|
|
9
|
+
emitScreenRevealManagerIsReadyToShow,
|
|
10
|
+
emitScreenRevealManagerIsNotReadyToShow,
|
|
11
|
+
} from "./utils";
|
|
12
|
+
|
|
13
|
+
const flex = platformSelect({
|
|
14
|
+
tvos: 1,
|
|
15
|
+
android_tv: 1,
|
|
16
|
+
web: undefined,
|
|
17
|
+
samsung_tv: undefined,
|
|
18
|
+
lg_tv: undefined,
|
|
19
|
+
default: undefined,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const TIMEOUT = 500; // 500 ms
|
|
23
|
+
|
|
24
|
+
const HIDDEN = 0; // opacity = 0
|
|
25
|
+
|
|
26
|
+
export const SHOWN = 1; // opacity = 1
|
|
27
|
+
|
|
28
|
+
type Props = {
|
|
29
|
+
componentsToRender: ZappUIComponent[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const withScreenRevealManager = (Component) => {
|
|
33
|
+
return function WithScreenRevealManager(props: Props) {
|
|
34
|
+
const { componentsToRender } = props;
|
|
35
|
+
|
|
36
|
+
const [isReadyToShow, setIsReadyToShow] = React.useState(false);
|
|
37
|
+
|
|
38
|
+
const handleSetIsReadyToShow = React.useCallback(() => {
|
|
39
|
+
setIsReadyToShow(true);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
const managerRef = useRefWithInitialValue<ScreenRevealManager>(
|
|
43
|
+
() => new ScreenRevealManager(componentsToRender, handleSetIsReadyToShow)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const opacityRef = useRefWithInitialValue<Animated.Value>(
|
|
47
|
+
() => new Animated.Value(HIDDEN)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!isReadyToShow) {
|
|
52
|
+
emitScreenRevealManagerIsNotReadyToShow();
|
|
53
|
+
} else {
|
|
54
|
+
emitScreenRevealManagerIsReadyToShow();
|
|
55
|
+
}
|
|
56
|
+
}, [isReadyToShow]);
|
|
57
|
+
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (isReadyToShow) {
|
|
60
|
+
Animated.timing(opacityRef.current, {
|
|
61
|
+
toValue: SHOWN,
|
|
62
|
+
duration: TIMEOUT,
|
|
63
|
+
useNativeDriver: true,
|
|
64
|
+
}).start();
|
|
65
|
+
}
|
|
66
|
+
}, [isReadyToShow]);
|
|
67
|
+
|
|
68
|
+
if (isFirstComponentScreenPicker(componentsToRender)) {
|
|
69
|
+
// for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
|
|
70
|
+
return <Component {...props} />;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Animated.View
|
|
75
|
+
style={{ opacity: opacityRef.current, flex }}
|
|
76
|
+
testID="animated-component"
|
|
77
|
+
>
|
|
78
|
+
<Component
|
|
79
|
+
{...props}
|
|
80
|
+
initialNumberToLoad={
|
|
81
|
+
managerRef.current.numberOfComponentsWaitToLoadBeforePresent
|
|
82
|
+
}
|
|
83
|
+
onLoadFinishedFromScreenRevealManager={
|
|
84
|
+
managerRef.current.onLoadFinished
|
|
85
|
+
}
|
|
86
|
+
onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
|
|
87
|
+
/>
|
|
88
|
+
</Animated.View>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
};
|
|
@@ -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 {
|
|
@@ -63,7 +62,7 @@ const TabsComponent = ({
|
|
|
63
62
|
);
|
|
64
63
|
|
|
65
64
|
const renderItem = useCallback(
|
|
66
|
-
({ item, index, focused }) => {
|
|
65
|
+
({ item, index, focused }: { item: any; index: any; focused?: any }) => {
|
|
67
66
|
const itemId = generateFocusableId(getId(item));
|
|
68
67
|
|
|
69
68
|
const isSelected = R.equals(index, selectedEntryIndex);
|
|
@@ -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}
|
package/Components/Tabs/Tabs.tsx
CHANGED
|
@@ -158,12 +158,11 @@ const TabsComponent = ({
|
|
|
158
158
|
|
|
159
159
|
const renderItem = React.useCallback(
|
|
160
160
|
({ item, index, item: { id } }: RenderItemProps) => (
|
|
161
|
-
|
|
161
|
+
<React.Fragment key={id}>
|
|
162
162
|
<Tab
|
|
163
163
|
ref={(ref) => {
|
|
164
164
|
tabRefs.current[index] = ref;
|
|
165
165
|
}}
|
|
166
|
-
key={id}
|
|
167
166
|
{...{
|
|
168
167
|
title: getTitle(item),
|
|
169
168
|
id,
|
|
@@ -177,7 +176,7 @@ const TabsComponent = ({
|
|
|
177
176
|
{display_mode === "fractional" &&
|
|
178
177
|
index !== tabs?.length - 1 &&
|
|
179
178
|
renderGutter()}
|
|
180
|
-
|
|
179
|
+
</React.Fragment>
|
|
181
180
|
),
|
|
182
181
|
[tabs, display_mode, configuration, onTabPress, getTitle, getSelectedItem]
|
|
183
182
|
);
|
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<TextInputTv /> renders 1`] = `
|
|
4
4
|
<input
|
|
5
|
+
accessibilityProps={
|
|
6
|
+
{
|
|
7
|
+
"accessibilityHint": "Enter text into Search",
|
|
8
|
+
"accessibilityLabel": "Search",
|
|
9
|
+
"accessibilityRole": "searchbox",
|
|
10
|
+
"accessible": true,
|
|
11
|
+
"aria-description": "Enter text into Search",
|
|
12
|
+
"aria-label": "Search",
|
|
13
|
+
"aria-role": "searchbox",
|
|
14
|
+
"role": "searchbox",
|
|
15
|
+
"tabindex": 0,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
5
18
|
testID="TextInput-tv"
|
|
6
19
|
/>
|
|
7
20
|
`;
|
|
@@ -4,6 +4,7 @@ import { Appearance, Platform, StyleSheet, TextInput } from "react-native";
|
|
|
4
4
|
import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
5
5
|
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
6
6
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
7
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
7
8
|
|
|
8
9
|
type Props = Partial<{
|
|
9
10
|
style: any;
|
|
@@ -42,6 +43,8 @@ function TextInputTV(props: Props, ref) {
|
|
|
42
43
|
const [colorScheme, setColorScheme] = useState(getInitialColorScheme());
|
|
43
44
|
const isRTL = useIsRTL();
|
|
44
45
|
|
|
46
|
+
const accessibilityManager = useAccessibilityManager({});
|
|
47
|
+
|
|
45
48
|
const onColorChange = useCallback(
|
|
46
49
|
({ colorScheme: color }) => {
|
|
47
50
|
if (color !== colorScheme) {
|
|
@@ -153,6 +156,13 @@ function TextInputTV(props: Props, ref) {
|
|
|
153
156
|
])
|
|
154
157
|
)(props);
|
|
155
158
|
|
|
159
|
+
const getAccessibilityProps = () => {
|
|
160
|
+
return {
|
|
161
|
+
accessibilityProps:
|
|
162
|
+
accessibilityManager.getInputAccessibilityProps("Search"),
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
156
166
|
const inputProps = {
|
|
157
167
|
...getProps(),
|
|
158
168
|
...getStyle(),
|
|
@@ -161,6 +171,7 @@ function TextInputTV(props: Props, ref) {
|
|
|
161
171
|
...getSecureTextEntry(),
|
|
162
172
|
...getOnEndEditing(),
|
|
163
173
|
...getOnPress(),
|
|
174
|
+
...getAccessibilityProps(),
|
|
164
175
|
};
|
|
165
176
|
|
|
166
177
|
if (
|
|
@@ -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}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, TouchableOpacity } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
|
|
5
5
|
import { Touchable } from "..";
|
|
6
6
|
|
|
@@ -23,38 +23,31 @@ describe("<Touchable />", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("has accessible flag set to false", () => {
|
|
26
|
-
|
|
26
|
+
const { toJSON, UNSAFE_getByType } = render(<Touchable {...props} />);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const touchableWrapper = wrapper.root.findByType(TouchableOpacity);
|
|
33
|
-
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
28
|
+
const touchableWrapper = UNSAFE_getByType(TouchableOpacity);
|
|
29
|
+
expect(toJSON()).toMatchSnapshot();
|
|
34
30
|
expect(touchableWrapper.props).toHaveProperty("accessible", false);
|
|
35
31
|
});
|
|
36
32
|
});
|
|
37
33
|
|
|
38
34
|
describe("when not running in automated tests environment", () => {
|
|
39
|
-
let wrapper;
|
|
40
|
-
|
|
41
|
-
act(() => {
|
|
42
|
-
wrapper = create(<Touchable {...props} />);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const touchableWrapper = wrapper.root.findByType(TouchableOpacity);
|
|
46
|
-
|
|
47
35
|
beforeEach(props.onPress.mockClear);
|
|
48
36
|
|
|
49
37
|
it("renders correctly", () => {
|
|
50
|
-
|
|
38
|
+
const { toJSON } = render(<Touchable {...props} />);
|
|
39
|
+
expect(toJSON()).toMatchSnapshot();
|
|
51
40
|
});
|
|
52
41
|
|
|
53
42
|
it("has accessible flag set to true", () => {
|
|
43
|
+
const { UNSAFE_getByType } = render(<Touchable {...props} />);
|
|
44
|
+
const touchableWrapper = UNSAFE_getByType(TouchableOpacity);
|
|
54
45
|
expect(touchableWrapper.props).toHaveProperty("accessible", true);
|
|
55
46
|
});
|
|
56
47
|
|
|
57
48
|
it("assigns testID and accessibilityLabel props correctly", () => {
|
|
49
|
+
const { UNSAFE_getByType } = render(<Touchable {...props} />);
|
|
50
|
+
const touchableWrapper = UNSAFE_getByType(TouchableOpacity);
|
|
58
51
|
expect(touchableWrapper.props).toHaveProperty("testID", props.testID);
|
|
59
52
|
|
|
60
53
|
expect(touchableWrapper.props).toHaveProperty(
|
|
@@ -64,6 +57,8 @@ describe("<Touchable />", () => {
|
|
|
64
57
|
});
|
|
65
58
|
|
|
66
59
|
it("calls the onPress event when it is pressed", () => {
|
|
60
|
+
const { UNSAFE_getByType } = render(<Touchable {...props} />);
|
|
61
|
+
const touchableWrapper = UNSAFE_getByType(TouchableOpacity);
|
|
67
62
|
touchableWrapper.props.onPress();
|
|
68
63
|
expect(props.onPress).toHaveBeenCalledTimes(1);
|
|
69
64
|
});
|
|
@@ -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],
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Animated,
|
|
2
|
+
import { Animated, StyleSheet, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
5
|
import {
|
|
6
|
-
GestureHandlerRootView,
|
|
7
6
|
NativeViewGestureHandler,
|
|
8
7
|
PanGestureHandler,
|
|
9
8
|
State,
|
|
@@ -43,6 +42,8 @@ type Props = {
|
|
|
43
42
|
children: React.ReactNode;
|
|
44
43
|
};
|
|
45
44
|
|
|
45
|
+
const activeOffsetY = [-5, 5] as [number, number];
|
|
46
|
+
|
|
46
47
|
export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
47
48
|
const {
|
|
48
49
|
isActiveGesture,
|
|
@@ -357,15 +358,10 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
357
358
|
};
|
|
358
359
|
}, [playerAnimationState, isAudioItem, isMinimizedModal]);
|
|
359
360
|
|
|
360
|
-
const Wrapper = React.useMemo(
|
|
361
|
-
() => (Platform.OS === "android" ? GestureHandlerRootView : View),
|
|
362
|
-
[]
|
|
363
|
-
);
|
|
364
|
-
|
|
365
361
|
const scrollEnabled = isMaximizedModal && isNotMinimizeMaximazeAnimation;
|
|
366
362
|
|
|
367
363
|
return (
|
|
368
|
-
<
|
|
364
|
+
<View style={generalStyles.container}>
|
|
369
365
|
<TapGestureHandler
|
|
370
366
|
maxDurationMs={100000}
|
|
371
367
|
ref={tapHandlerRef}
|
|
@@ -378,9 +374,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
378
374
|
ref={panHandlerRef}
|
|
379
375
|
simultaneousHandlers={[scrollRef, tapHandlerRef]}
|
|
380
376
|
shouldCancelWhenOutside={isMaximizedModal}
|
|
377
|
+
activeOffsetY={activeOffsetY}
|
|
381
378
|
onGestureEvent={onGestureEvent}
|
|
382
379
|
onHandlerStateChange={onHandlerStateChange}
|
|
383
|
-
activeOffsetY={[-5, 5]}
|
|
384
380
|
>
|
|
385
381
|
<Animated.View>
|
|
386
382
|
<NativeViewGestureHandler
|
|
@@ -405,7 +401,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
|
|
|
405
401
|
</PanGestureHandler>
|
|
406
402
|
</View>
|
|
407
403
|
</TapGestureHandler>
|
|
408
|
-
</
|
|
404
|
+
</View>
|
|
409
405
|
);
|
|
410
406
|
};
|
|
411
407
|
|