@applicaster/zapp-react-native-ui-components 15.1.0-rc.9 → 16.0.0-alpha.1740103407
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/BackgroundImage/BackgroundImage.tsx +42 -0
- package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +6 -3
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +41 -8
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +13 -8
- package/Components/Layout/FullWidthRow.tsx +38 -0
- package/Components/Layout/TV/NavBarContainer.tsx +1 -10
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +5 -7
- package/Components/Layout/TV/index.web.tsx +5 -7
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/CONFIG_BUILDER_TO_REACT_COMPONENT.md +144 -0
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +165 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +405 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/index.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -10
- package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/components/HorizontalSeparator.tsx +8 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +15 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tv.android.tsx +58 -0
- package/Components/MasterCell/DefaultComponents/{tv/ButtonContainerView/index.tsx → ButtonContainerView/index.tv.tsx} +3 -11
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.web.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +40 -0
- package/Components/MasterCell/DefaultComponents/DataProvider/index.tsx +163 -0
- package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +2 -23
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -22
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +8 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +1 -2
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +34 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +11 -0
- package/Components/MasterCell/DefaultComponents/__tests__/DataProvider.test.tsx +141 -0
- package/Components/MasterCell/DefaultComponents/index.ts +9 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +135 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +33 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +22 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +125 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +37 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +393 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +141 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +343 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +122 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +238 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Asset.ts +4 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Button.ts +24 -73
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TextLabelsContainer.ts +37 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TvActionButton.tsx +27 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +89 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/renderedTree.test.tsx +231 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +47 -48
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +101 -144
- package/Components/MasterCell/MappingFunctions/index.js +3 -2
- package/Components/MasterCell/README.md +4 -0
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +24 -0
- package/Components/MasterCell/__tests__/configInflater.test.js +1 -0
- package/Components/MasterCell/__tests__/elementMapper.test.js +46 -0
- package/Components/MasterCell/dataAdapter.ts +4 -1
- package/Components/MasterCell/elementMapper.tsx +52 -7
- package/Components/MasterCell/utils/__tests__/cloneChildrenWithIds.test.tsx +43 -0
- package/Components/MasterCell/utils/__tests__/useFilterChildren.test.tsx +80 -0
- package/Components/MasterCell/utils/index.ts +85 -15
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
- package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -5
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +188 -118
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
- package/Components/River/RefreshControl.tsx +19 -88
- package/Components/River/River.tsx +9 -82
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -22
- package/Components/River/__tests__/componentsMap.test.js +38 -0
- package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
- package/Components/River/hooks/index.ts +1 -0
- package/Components/River/hooks/usePullToRefresh.ts +51 -0
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +65 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
- package/Components/Screen/hooks.ts +2 -3
- package/Components/Screen/index.tsx +2 -3
- package/Components/Screen/orientationHandler.ts +3 -3
- package/Components/ScreenResolver/index.tsx +9 -5
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +9 -20
- package/Components/Tabs/TabContent.tsx +7 -4
- package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +201 -0
- package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
- package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
- package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
- package/Components/TopCutoffOverlay/index.tsx +55 -0
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +5 -5
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
- package/Components/VideoModal/utils.ts +12 -10
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
- package/Components/Viewport/ViewportAware/index.tsx +16 -7
- package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
- package/Contexts/ScreenContext/index.tsx +25 -18
- package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/Helpers/index.js +7 -1
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -28
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +0 -135
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/types.ts +0 -25
- package/Components/River/TV/withTVEventHandler.tsx +0 -36
- package/Helpers/DataSourceHelper/index.js +0 -19
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
import { useMarginTop } from "../useMarginTop";
|
|
3
|
+
|
|
4
|
+
// Mocks
|
|
5
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
6
|
+
useTheme: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
10
|
+
useCurrentScreenData: jest.fn(),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("@applicaster/zapp-react-native-utils/componentsUtils", () => ({
|
|
14
|
+
isFirstComponentScreenPicker: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
// Imports after mocks
|
|
18
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
19
|
+
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
20
|
+
import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
21
|
+
|
|
22
|
+
describe("useMarginTop", () => {
|
|
23
|
+
const mockTheme = {
|
|
24
|
+
screen_margin_top: 10,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
|
|
30
|
+
(useTheme as jest.Mock).mockReturnValue(mockTheme);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("returns 0 when ScreenPicker is first component", () => {
|
|
34
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
35
|
+
ui_components: [],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(true);
|
|
39
|
+
|
|
40
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
41
|
+
|
|
42
|
+
expect(result.current).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("returns 0 for player screen", () => {
|
|
46
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
47
|
+
plugin_type: "player",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
51
|
+
|
|
52
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
53
|
+
|
|
54
|
+
expect(result.current).toBe(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("returns theme value when margin is empty string", () => {
|
|
58
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
59
|
+
styles: {
|
|
60
|
+
screen_margin_top: "",
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
65
|
+
|
|
66
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
67
|
+
|
|
68
|
+
expect(result.current).toBe(10);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("returns theme value when undefined and general content screen", () => {
|
|
72
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
73
|
+
plugin_type: "general_content",
|
|
74
|
+
styles: {
|
|
75
|
+
screen_margin_top: undefined,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
80
|
+
|
|
81
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
82
|
+
|
|
83
|
+
expect(result.current).toBe(10);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("returns theme value when undefined and supports ui_components", () => {
|
|
87
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
88
|
+
ui_components: ["something"],
|
|
89
|
+
styles: {
|
|
90
|
+
screen_margin_top: undefined,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
95
|
+
|
|
96
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
97
|
+
|
|
98
|
+
expect(result.current).toBe(10);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("returns 0 when undefined and not general content and no ui_components", () => {
|
|
102
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
103
|
+
plugin_type: "other",
|
|
104
|
+
ui_components: null,
|
|
105
|
+
styles: {
|
|
106
|
+
screen_margin_top: undefined,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
111
|
+
|
|
112
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
113
|
+
|
|
114
|
+
expect(result.current).toBe(0);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("returns value from screenData when defined", () => {
|
|
118
|
+
(useCurrentScreenData as jest.Mock).mockReturnValue({
|
|
119
|
+
styles: {
|
|
120
|
+
screen_margin_top: 25,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
(isFirstComponentScreenPicker as jest.Mock).mockReturnValue(false);
|
|
125
|
+
|
|
126
|
+
const { result } = renderHook(() => useMarginTop("screen1"));
|
|
127
|
+
|
|
128
|
+
expect(result.current).toBe(25);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useMarginTop } from "./useMarginTop";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
2
|
+
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
3
|
+
import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
4
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MarginTop is essentially a feature used for managing the visibility of components on your screen.
|
|
8
|
+
* A more accurate term for this might be something like a 'component visibility threshold' or 'cut-off point'.
|
|
9
|
+
* In practical terms, MarginTop determines a specific vertical position (given in the 'y' coordinate)
|
|
10
|
+
* on your screen above which components aren't shown.
|
|
11
|
+
* You might visualize this as a horizontal line across your screen, and any component crossing this line becomes invisible.
|
|
12
|
+
*
|
|
13
|
+
* Classic use case for this feature is making sure that component aren't displayed underneath the navigation bar.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const useMarginTop = (targetScreenId: string): number => {
|
|
17
|
+
const theme = useTheme<BaseThemePropertiesTV>();
|
|
18
|
+
const screenData = useCurrentScreenData(targetScreenId);
|
|
19
|
+
const isGeneralContentScreen = screenData?.plugin_type === "general_content";
|
|
20
|
+
const supportsUiComponents = screenData?.ui_components;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ScreenPicker is a component but should really be a screen.
|
|
24
|
+
* We need to skip margin top for it as it's already applied to the target screen
|
|
25
|
+
**/
|
|
26
|
+
|
|
27
|
+
// ignore margin on screenPicker
|
|
28
|
+
if (isFirstComponentScreenPicker(screenData?.ui_components)) {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const isPlayer = screenData?.plugin_type === "player";
|
|
33
|
+
|
|
34
|
+
// ignore margin on inlinePlayer (remove if better way of identifying cases for plugins that don't have marginTop)
|
|
35
|
+
if (isPlayer) {
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Empty string means that value is blank in the CMS. Fallback to theme
|
|
40
|
+
if (String(screenData?.styles?.screen_margin_top) === "") {
|
|
41
|
+
return toNumberWithDefaultZero(theme.screen_margin_top);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If value is undefined it means one of three things
|
|
46
|
+
* 1. Screen is not a general content screen and it doesn't handle ui components (return 0)
|
|
47
|
+
* 2. Screen is a general content screen but it doesn't have a margin top value (return theme value)
|
|
48
|
+
* 3. Screen isn't general content screen but it handles the ui components (return theme value)
|
|
49
|
+
*/
|
|
50
|
+
if (screenData?.styles?.screen_margin_top === undefined) {
|
|
51
|
+
if (isGeneralContentScreen || supportsUiComponents) {
|
|
52
|
+
return toNumberWithDefaultZero(theme.screen_margin_top);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return toNumberWithDefaultZero(screenData?.styles?.screen_margin_top);
|
|
59
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
4
|
+
import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
|
|
5
|
+
|
|
6
|
+
import { useMarginTop } from "./hooks";
|
|
7
|
+
|
|
8
|
+
interface IProps {
|
|
9
|
+
targetScreenId?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
applyTopCutoff?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const styles = StyleSheet.create({
|
|
15
|
+
container: {
|
|
16
|
+
flex: 1,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const TopCutoffOverlay: React.FC<IProps> = ({
|
|
21
|
+
targetScreenId,
|
|
22
|
+
children,
|
|
23
|
+
applyTopCutoff = true,
|
|
24
|
+
}: IProps) => {
|
|
25
|
+
const cutoffHeight = useMarginTop(targetScreenId);
|
|
26
|
+
|
|
27
|
+
const { backgroundColor: screenBackgroundColor } =
|
|
28
|
+
useScreenConfiguration(targetScreenId);
|
|
29
|
+
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const themeBackgroundColor = theme?.app_background_color;
|
|
32
|
+
|
|
33
|
+
if (!applyTopCutoff) {
|
|
34
|
+
return children;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={styles.container}>
|
|
39
|
+
{children}
|
|
40
|
+
|
|
41
|
+
<View
|
|
42
|
+
style={{
|
|
43
|
+
position: "absolute",
|
|
44
|
+
top: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
right: 0,
|
|
47
|
+
height: cutoffHeight,
|
|
48
|
+
|
|
49
|
+
backgroundColor:
|
|
50
|
+
screenBackgroundColor || themeBackgroundColor || "transparent",
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
3
3
|
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
|
|
4
|
-
import {
|
|
4
|
+
import { useAppData } from "@applicaster/zapp-react-native-redux";
|
|
5
|
+
|
|
5
6
|
import { TransitionerComponent } from "./Transitioner";
|
|
6
7
|
|
|
7
8
|
export const Transitioner = (props) => {
|
|
@@ -16,8 +17,7 @@ export const Transitioner = (props) => {
|
|
|
16
17
|
deviceInfo: true,
|
|
17
18
|
});
|
|
18
19
|
|
|
19
|
-
const {
|
|
20
|
-
const isTabletPortrait = appData?.isTabletPortrait;
|
|
20
|
+
const { isTabletPortrait } = useAppData();
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<TransitionerComponent
|
|
@@ -4,7 +4,10 @@ import { Animated, Dimensions } from "react-native";
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
|
|
6
6
|
import { useConfiguration } from "../utils";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useAppData,
|
|
9
|
+
usePlugins,
|
|
10
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
11
|
import { isBottomTabVisible } from "../../Screen/navigationHandler";
|
|
9
12
|
|
|
10
13
|
import {
|
|
@@ -18,7 +21,6 @@ import {
|
|
|
18
21
|
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
19
22
|
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
20
23
|
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
21
|
-
import { useAppSelector } from "@applicaster/zapp-react-native-redux";
|
|
22
24
|
|
|
23
25
|
export type ModalAnimationContextT = {
|
|
24
26
|
yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
|
|
@@ -64,9 +66,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
|
64
66
|
screenData,
|
|
65
67
|
} = useNavigation();
|
|
66
68
|
|
|
67
|
-
const isTabletPortrait =
|
|
68
|
-
(state) => state.appData.isTabletPortrait
|
|
69
|
-
);
|
|
69
|
+
const { isTabletPortrait } = useAppData();
|
|
70
70
|
|
|
71
71
|
const plugins = usePlugins();
|
|
72
72
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react-
|
|
1
|
+
import { act, renderHook, waitFor } from "@testing-library/react-native";
|
|
2
2
|
import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
|
|
3
3
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
4
4
|
|
|
@@ -13,16 +13,20 @@ describe("useDelayedPlayerDetails", () => {
|
|
|
13
13
|
jest.clearAllMocks();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it("should return false initially, that changes after 1 second", () => {
|
|
16
|
+
it("should return false initially, that changes after 1 second", async () => {
|
|
17
17
|
const { result } = renderHook(() =>
|
|
18
18
|
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
expect(result.current).toBe(false);
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
act(() => {
|
|
24
|
+
jest.advanceTimersByTime(1000);
|
|
25
|
+
});
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
await waitFor(() => {
|
|
28
|
+
expect(result.current).toBe(true);
|
|
29
|
+
});
|
|
26
30
|
});
|
|
27
31
|
|
|
28
32
|
it("should return false when isPip is true", () => {
|
|
@@ -41,7 +45,7 @@ describe("useDelayedPlayerDetails", () => {
|
|
|
41
45
|
expect(result.current).toBe(false);
|
|
42
46
|
});
|
|
43
47
|
|
|
44
|
-
it("should return true for tablet regardless of other flags", () => {
|
|
48
|
+
it("should return true for tablet regardless of other flags", async () => {
|
|
45
49
|
(useIsTablet as jest.Mock).mockReturnValue(true);
|
|
46
50
|
|
|
47
51
|
const { result } = renderHook(() =>
|
|
@@ -52,8 +56,12 @@ describe("useDelayedPlayerDetails", () => {
|
|
|
52
56
|
})
|
|
53
57
|
);
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
act(() => {
|
|
60
|
+
jest.advanceTimersByTime(1000);
|
|
61
|
+
});
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
expect(result.current).toBe(true);
|
|
65
|
+
});
|
|
58
66
|
});
|
|
59
67
|
});
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { mergeRight } from "ramda";
|
|
2
2
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useAppSelector,
|
|
5
|
+
useContentTypes,
|
|
6
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
7
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
8
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
|
|
6
9
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
7
10
|
import { create } from "zustand";
|
|
11
|
+
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
|
|
8
13
|
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
9
14
|
|
|
10
15
|
export const useConfiguration = () => {
|
|
@@ -12,19 +17,16 @@ export const useConfiguration = () => {
|
|
|
12
17
|
videoModalState: { item },
|
|
13
18
|
} = useNavigation();
|
|
14
19
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
"contentTypes",
|
|
18
|
-
"pluginConfigurations",
|
|
19
|
-
]);
|
|
20
|
-
|
|
20
|
+
const rivers = useRivers();
|
|
21
|
+
const contentTypes = useContentTypes();
|
|
21
22
|
const player = usePlayer();
|
|
22
23
|
|
|
23
24
|
const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
|
|
24
25
|
const targetScreenConfiguration = rivers?.[targetScreenId];
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
-
|
|
27
|
+
const { configuration_json } = useAppSelector((state) =>
|
|
28
|
+
selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
|
|
29
|
+
);
|
|
28
30
|
|
|
29
31
|
const playerPluginConfig =
|
|
30
32
|
player?.getPluginConfiguration() ??
|
|
@@ -32,7 +34,7 @@ export const useConfiguration = () => {
|
|
|
32
34
|
{};
|
|
33
35
|
|
|
34
36
|
const config = mergeRight(playerPluginConfig, {
|
|
35
|
-
...
|
|
37
|
+
...configuration_json,
|
|
36
38
|
...targetScreenConfiguration?.general,
|
|
37
39
|
...targetScreenConfiguration?.styles,
|
|
38
40
|
});
|
|
@@ -32,7 +32,7 @@ function getTestDimensions(testDimensions) {
|
|
|
32
32
|
return (process.env.NODE_ENV === "test" && testDimensions) || null;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function ViewportAwareComponent(props: Props,
|
|
35
|
+
function ViewportAwareComponent(props: Props, forwardedRef) {
|
|
36
36
|
const viewportEvents = useViewportEventsContext();
|
|
37
37
|
|
|
38
38
|
const {
|
|
@@ -47,13 +47,22 @@ function ViewportAwareComponent(props: Props, ref) {
|
|
|
47
47
|
getTestDimensions(testDimensions) || initialDimensions
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
+
const localRef = React.useRef(null);
|
|
51
|
+
|
|
50
52
|
const [viewportChangeEvent, setViewportChangeEvent] = React.useState(null);
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const assignRef = React.useCallback(
|
|
55
|
+
(_ref) => {
|
|
56
|
+
localRef.current = _ref;
|
|
57
|
+
|
|
58
|
+
if (typeof forwardedRef === "function") {
|
|
59
|
+
forwardedRef(_ref);
|
|
60
|
+
} else if (forwardedRef) {
|
|
61
|
+
forwardedRef.current = _ref;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[forwardedRef]
|
|
65
|
+
);
|
|
57
66
|
|
|
58
67
|
const checkInViewport = (viewportChangeEvent, layoutEvent) => {
|
|
59
68
|
const inVerticalViewport = Utils.isInViewport(
|
|
@@ -94,7 +103,7 @@ function ViewportAwareComponent(props: Props, ref) {
|
|
|
94
103
|
const onViewportChange = (viewportChangeEvent) => {
|
|
95
104
|
setViewportChangeEvent(viewportChangeEvent);
|
|
96
105
|
|
|
97
|
-
const nodeHandle = findNodeHandle(
|
|
106
|
+
const nodeHandle = findNodeHandle(localRef.current);
|
|
98
107
|
|
|
99
108
|
if (!nodeHandle) {
|
|
100
109
|
return;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
4
3
|
|
|
5
4
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
6
5
|
import CloseButton from "./Buttons/CloseButton";
|
|
@@ -45,15 +44,14 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
|
-
<
|
|
49
|
-
edges={["top", "left", "right"]}
|
|
47
|
+
<View
|
|
50
48
|
style={[style.view, isRTL ? style.rtlStyle : {}]}
|
|
51
|
-
testID="BarView-
|
|
49
|
+
testID="BarView-Container"
|
|
52
50
|
>
|
|
53
51
|
{backButton}
|
|
54
52
|
<BarTitle title={barState.title} screenStyles={screenStyles} />
|
|
55
53
|
{closeButton}
|
|
56
|
-
</
|
|
54
|
+
</View>
|
|
57
55
|
);
|
|
58
56
|
};
|
|
59
57
|
|
|
@@ -46,7 +46,7 @@ describe("BarView", () => {
|
|
|
46
46
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
expect(getByTestId("BarView-
|
|
49
|
+
expect(getByTestId("BarView-Container").props.style).toContainEqual({
|
|
50
50
|
transform: [{ scaleX: -1 }],
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ describe("BarView", () => {
|
|
|
58
58
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
expect(getByTestId("BarView-
|
|
61
|
+
expect(getByTestId("BarView-Container").props.style).not.toContainEqual({
|
|
62
62
|
transform: [{ scaleX: -1 }],
|
|
63
63
|
});
|
|
64
64
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DefaultCell } from "./DefaultCell";
|
|
2
2
|
import { GridCell } from "./GridCell";
|
|
3
3
|
import { HeroCell } from "./HeroCell";
|
|
4
|
-
// import { ScreenSelectorLabel } from "./ScreenSelectorLabel";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Return a view tree ready to be injected with styles etc. Mapping is done
|
|
@@ -15,8 +14,6 @@ export function viewTreeResolver({ component_type }) {
|
|
|
15
14
|
switch (component_type) {
|
|
16
15
|
case "hero":
|
|
17
16
|
return HeroCell;
|
|
18
|
-
// case "screen_picker":
|
|
19
|
-
// return ScreenSelectorLabel;
|
|
20
17
|
case "grid":
|
|
21
18
|
return GridCell;
|
|
22
19
|
case "horizontal_list":
|
|
@@ -16,6 +16,7 @@ import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-co
|
|
|
16
16
|
import { create } from "zustand";
|
|
17
17
|
import { subscribeWithSelector } from "zustand/middleware";
|
|
18
18
|
import { useShallow } from "zustand/react/shallow";
|
|
19
|
+
|
|
19
20
|
import { Animated } from "react-native";
|
|
20
21
|
|
|
21
22
|
interface NavBarStoreState {
|
|
@@ -29,6 +30,8 @@ interface NavBarStoreState {
|
|
|
29
30
|
scrollState: number;
|
|
30
31
|
contentPosition: string;
|
|
31
32
|
scrollYAnimated: Animated.Value;
|
|
33
|
+
hideOnScrollAnimated: Animated.Value;
|
|
34
|
+
hideOnScroll: boolean;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
interface NavBarState {
|
|
@@ -62,24 +65,28 @@ const createStateStore = () =>
|
|
|
62
65
|
);
|
|
63
66
|
|
|
64
67
|
const createStore = () =>
|
|
65
|
-
create
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
create(
|
|
69
|
+
subscribeWithSelector<NavBarStoreState>((set) => ({
|
|
70
|
+
title: "",
|
|
71
|
+
summary: "",
|
|
72
|
+
visible: true,
|
|
73
|
+
height: 0,
|
|
74
|
+
scrollState: 0,
|
|
75
|
+
contentPosition: "",
|
|
76
|
+
scrollYAnimated: new Animated.Value(0),
|
|
77
|
+
hideOnScrollAnimated: new Animated.Value(0),
|
|
78
|
+
hideOnScroll: false,
|
|
79
|
+
setTitle(title) {
|
|
80
|
+
set({ title });
|
|
81
|
+
},
|
|
82
|
+
setSummary(summary) {
|
|
83
|
+
set({ summary });
|
|
84
|
+
},
|
|
85
|
+
setVisible(visible) {
|
|
86
|
+
set({ visible });
|
|
87
|
+
},
|
|
88
|
+
}))
|
|
89
|
+
);
|
|
83
90
|
|
|
84
91
|
const createScreenComponentsStore = () =>
|
|
85
92
|
create(subscribeWithSelector<Record<string, unknown>>((_) => ({})));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { getAnalyticsFunctions } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
4
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
4
|
|
|
6
5
|
type ComponentProps = {
|
|
7
6
|
component: {
|
|
@@ -21,11 +20,13 @@ type ComponentProps = {
|
|
|
21
20
|
|
|
22
21
|
function withAnalytics(Component) {
|
|
23
22
|
return function WithAnalytics(props: ComponentProps) {
|
|
24
|
-
const { appData } = usePickFromState(["appData"]);
|
|
25
|
-
|
|
26
23
|
const analyticsFunctions = React.useMemo(
|
|
27
|
-
() =>
|
|
28
|
-
|
|
24
|
+
() =>
|
|
25
|
+
getAnalyticsFunctions({
|
|
26
|
+
component: props.component,
|
|
27
|
+
zappPipesData: props.zappPipesData,
|
|
28
|
+
} as any),
|
|
29
|
+
[props.component, props.zappPipesData]
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
return (
|
|
@@ -88,6 +88,7 @@ exports[`withConfigurationProvider correctly passes all the configuration keys c
|
|
|
88
88
|
tab_cell_padding_right={10}
|
|
89
89
|
tab_cell_padding_top={14}
|
|
90
90
|
tablet_theme={false}
|
|
91
|
+
tabs_screen_background_color="transparent"
|
|
91
92
|
target={false}
|
|
92
93
|
target_screen_switch={false}
|
|
93
94
|
text_label_active_font_color="rgba(239, 239, 239, 0.5)"
|
|
@@ -208,4 +208,5 @@ export const keysMap: Record<string, Function> = {
|
|
|
208
208
|
tab_bar_item_margin_right: castOrDefaultValue(Number, 0),
|
|
209
209
|
tab_bar_item_margin_bottom: castOrDefaultValue(Number, 0),
|
|
210
210
|
tab_bar_item_margin_left: castOrDefaultValue(Number, 0),
|
|
211
|
+
tabs_screen_background_color: castOrDefaultValue(R.identity, "transparent"),
|
|
211
212
|
};
|