@applicaster/zapp-react-native-ui-components 12.0.0-rc.10 → 12.0.0-rc.101

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.
Files changed (150) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  3. package/Components/AudioPlayer/helpers.tsx +1 -0
  4. package/Components/BaseFocusable/index.tsx +3 -3
  5. package/Components/Cell/Cell.tsx +32 -11
  6. package/Components/Cell/CellWithFocusable.tsx +40 -19
  7. package/Components/Cell/TvOSCellComponent.tsx +5 -9
  8. package/Components/ErrorScreen/index.tsx +1 -1
  9. package/Components/Focusable/Focusable.tsx +6 -1
  10. package/Components/FocusableCell/index.tsx +7 -7
  11. package/Components/FocusableGroup/index.tsx +11 -2
  12. package/Components/FocusableList/FocusableChild.ts +24 -14
  13. package/Components/FocusableList/FocusableItem.tsx +1 -1
  14. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  15. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  16. package/Components/FocusableList/index.tsx +26 -25
  17. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  18. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  19. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  20. package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
  21. package/Components/HookRenderer/index.tsx +1 -6
  22. package/Components/Image/Image.android.tsx +3 -26
  23. package/Components/Image/Image.tsx +18 -2
  24. package/Components/Image/utils/index.ts +39 -0
  25. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  26. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  27. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  28. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  29. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  30. package/Components/Layout/TV/__tests__/index.test.tsx +20 -108
  31. package/Components/Layout/TV/index.tsx +15 -84
  32. package/Components/Layout/TV/index.web.tsx +33 -0
  33. package/Components/Layout/index.tsx +15 -11
  34. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
  35. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -113
  36. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  37. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  38. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
  39. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  40. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  41. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  42. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  43. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +37 -2
  44. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  45. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  46. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  47. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  48. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  49. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  50. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
  51. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  52. package/Components/MasterCell/dataAdapter.ts +21 -7
  53. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  54. package/Components/MasterCell/index.tsx +3 -1
  55. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  56. package/Components/MasterCell/utils/index.ts +33 -35
  57. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  58. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  59. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  60. package/Components/ModalComponent/Button/Item.tsx +82 -0
  61. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  62. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  63. package/Components/ModalComponent/Button/assets.ts +4 -0
  64. package/Components/ModalComponent/Button/index.tsx +111 -0
  65. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  66. package/Components/ModalComponent/Header/Title.tsx +70 -0
  67. package/Components/ModalComponent/Header/assets.ts +4 -0
  68. package/Components/ModalComponent/Header/index.tsx +71 -0
  69. package/Components/ModalComponent/Header/utils.ts +79 -0
  70. package/Components/ModalComponent/index.tsx +38 -0
  71. package/Components/ModalComponent/utils.ts +126 -0
  72. package/Components/Navigator/StackNavigator.tsx +57 -0
  73. package/Components/Navigator/index.ts +1 -0
  74. package/Components/PlayerContainer/PlayerContainer.tsx +66 -31
  75. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  76. package/Components/PlayerImageBackground/index.tsx +34 -8
  77. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  78. package/Components/River/RefreshControl.tsx +55 -1
  79. package/Components/River/River.tsx +8 -5
  80. package/Components/River/TV/River.tsx +2 -25
  81. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  82. package/Components/River/__tests__/componentsMap.test.js +7 -0
  83. package/Components/River/useScreenConfiguration.ts +2 -2
  84. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  85. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  86. package/Components/RouteManager/index.tsx +4 -2
  87. package/Components/Screen/TV/hooks/index.ts +3 -0
  88. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  89. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  90. package/Components/Screen/TV/index.web.tsx +165 -0
  91. package/Components/Screen/__tests__/Screen.test.tsx +91 -74
  92. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  93. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  94. package/Components/Screen/index.tsx +110 -54
  95. package/Components/Screen/navigationHandler.ts +5 -82
  96. package/Components/ScreenResolver/index.tsx +10 -13
  97. package/Components/Tabs/TV/styles.ts +1 -1
  98. package/Components/TrackedView/index.tsx +6 -3
  99. package/Components/Transitioner/Scene.tsx +32 -26
  100. package/Components/Transitioner/Transitioner.tsx +21 -28
  101. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
  102. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  103. package/Components/VideoLive/LiveImageManager.ts +70 -14
  104. package/Components/VideoLive/PlayerLiveImageComponent.tsx +132 -95
  105. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  106. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +21 -29
  107. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +66 -0
  108. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +355 -0
  109. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +161 -0
  110. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +456 -0
  111. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +182 -0
  112. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  113. package/Components/VideoModal/ModalAnimation/utils.ts +302 -0
  114. package/Components/VideoModal/PlayerDetails.tsx +6 -3
  115. package/Components/VideoModal/PlayerWrapper.tsx +81 -49
  116. package/Components/VideoModal/VideoModal.tsx +23 -40
  117. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  118. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
  119. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +266 -166
  120. package/Components/VideoModal/hooks/useModalSize.ts +10 -12
  121. package/Components/VideoModal/utils.ts +8 -5
  122. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  123. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  124. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  125. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  126. package/Components/Viewport/utils.js +1 -1
  127. package/Components/ZappUIComponent/index.tsx +22 -12
  128. package/Components/index.js +2 -0
  129. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  130. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  131. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  132. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  133. package/Contexts/FocusableGroupContext/index.ts +7 -0
  134. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  135. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  136. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  137. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  138. package/Contexts/ScreenContext/index.tsx +95 -29
  139. package/Contexts/ScreenDataContext/index.tsx +20 -0
  140. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  141. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  142. package/Decorators/RiverResolver/index.tsx +0 -4
  143. package/Decorators/index.tsx +0 -4
  144. package/events/index.ts +1 -0
  145. package/package.json +5 -6
  146. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  147. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  148. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  149. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
  150. /package/Contexts/{index.js → index.ts} +0 -0
@@ -1,183 +1,6 @@
1
- import { isNavBarVisible, isMenuVisible } from "../navigationHandler";
1
+ import { isMenuVisible } from "../navigationHandler";
2
2
 
3
3
  describe("NavigationHandler", () => {
4
- describe("isNavBarVisible", () => {
5
- it("returns false when the route is a player route", () => {
6
- const navBarVisible = isNavBarVisible(
7
- "/playable/some_vod_item",
8
- {},
9
- undefined,
10
- false
11
- );
12
-
13
- expect(navBarVisible).toBe(false);
14
- });
15
-
16
- it("returns false when the next screen is the QB search screen", () => {
17
- const navBarVisible = isNavBarVisible(
18
- "/river/A1234",
19
- {
20
- type: "qb_search_screen",
21
- },
22
- undefined,
23
- false
24
- );
25
-
26
- expect(navBarVisible).toBe(false);
27
- });
28
-
29
- describe("when screen is a hook", () => {
30
- it("returns true if the `showNavBar` flag is set to true", () => {
31
- const navBarVisible = isNavBarVisible(
32
- "",
33
- {
34
- hookPlugin: {
35
- module: {
36
- showNavBar: true,
37
- },
38
- },
39
- },
40
- undefined,
41
- false
42
- );
43
-
44
- expect(navBarVisible).toBe(true);
45
- });
46
-
47
- it("returns true if presentFullScreen flag is set to false", () => {
48
- const navBarVisible = isNavBarVisible(
49
- "",
50
- {
51
- hookPlugin: {
52
- module: {
53
- presentFullScreen: false,
54
- },
55
- },
56
- },
57
- undefined,
58
- false
59
- );
60
-
61
- expect(navBarVisible).toBe(true);
62
- });
63
-
64
- it("returns false if presentFullScreen flag is set to true", () => {
65
- const navBarVisible = isNavBarVisible(
66
- "",
67
- {
68
- hookPlugin: {
69
- module: {
70
- presentFullScreen: true,
71
- },
72
- },
73
- },
74
- undefined,
75
- false
76
- );
77
-
78
- expect(navBarVisible).toBe(false);
79
- });
80
- });
81
-
82
- it("returns false if the screen's general settings allow screen presentation", () => {
83
- const navBarVisible = isNavBarVisible(
84
- "",
85
- {
86
- general: {
87
- allow_screen_plugin_presentation: true,
88
- },
89
- },
90
- undefined,
91
- false
92
- );
93
-
94
- expect(navBarVisible).toBe(false);
95
- });
96
-
97
- it("returns false if the screen's general settings hide app nav bar", () => {
98
- const navBarVisible = isNavBarVisible(
99
- "",
100
- {
101
- general: {
102
- hide_app_nav_bar: true,
103
- },
104
- },
105
- undefined,
106
- false
107
- );
108
-
109
- expect(navBarVisible).toBe(false);
110
- });
111
-
112
- it("returns false if it's secondary nav bar and hide_secondary_level_menu is true", () => {
113
- const navBarVisible = isNavBarVisible(
114
- "",
115
- {
116
- navigations: [
117
- {
118
- styles: {
119
- hide_secondary_level_menu: true,
120
- },
121
- },
122
- ],
123
- },
124
- undefined,
125
- true
126
- );
127
-
128
- expect(navBarVisible).toBe(false);
129
- });
130
-
131
- it("returns true if it's secondary nav bar and hide_secondary_level_menu is false", () => {
132
- const navBarVisible = isNavBarVisible(
133
- "",
134
- {
135
- navigations: [
136
- {
137
- styles: {
138
- hide_secondary_level_menu: false,
139
- },
140
- },
141
- ],
142
- },
143
- undefined,
144
- true
145
- );
146
-
147
- expect(navBarVisible).toBe(true);
148
- });
149
-
150
- it("returns true if it's first level menu and hide_secondary_level_menu is true", () => {
151
- const navBarVisible = isNavBarVisible(
152
- "",
153
- {
154
- navigations: [
155
- {
156
- styles: {
157
- hide_secondary_level_menu: false,
158
- },
159
- },
160
- ],
161
- },
162
- undefined,
163
- false
164
- );
165
-
166
- expect(navBarVisible).toBe(true);
167
- });
168
-
169
- it("returns true otherwise", () => {
170
- const navBarVisible = isNavBarVisible(
171
- "",
172
- { navigations: [] },
173
- undefined,
174
- false
175
- );
176
-
177
- expect(navBarVisible).toBe(true);
178
- });
179
- });
180
-
181
4
  describe("isMenuVisible", () => {
182
5
  it("returns false when the route is a player route", () => {
183
6
  const menuVisible = isMenuVisible("/playable/some_vod_item", {});
@@ -1,36 +1,40 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
- import React, { useMemo } from "react";
2
+ import React from "react";
3
3
  import * as R from "ramda";
4
4
  import { View } from "react-native";
5
- import { RouteManager } from "../RouteManager";
5
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
+ import {
7
+ isOrientationCompatible,
8
+ useGetScreenOrientation,
9
+ } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
10
+
6
11
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
- import { useScreenOrientationHandler } from "./orientationHandler";
12
+ import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
13
+ import {
14
+ shouldNavBarDisplayMenu,
15
+ getNavBarProps,
16
+ getScreenId,
17
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
18
+ import {
19
+ useDimensions,
20
+ useRoute,
21
+ useCurrentScreenData,
22
+ useNavbarState,
23
+ useScreenData,
24
+ useNavigation,
25
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
26
+ import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
27
+
28
+ import { RouteManager } from "../RouteManager";
8
29
  import { useScreenConfiguration } from "../River/useScreenConfiguration";
9
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
10
- import type { ZappNavigationProps } from "@applicaster/zapp-react-native-flow-types/index";
11
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
12
- import { ScreenContextProvider } from "../../Contexts/ScreenContext";
30
+ import { useScreenOrientationHandler } from "./orientationHandler";
13
31
 
14
- type Props = {
15
- pathname: string;
16
- screenData: Record<string, any>;
17
- NavBar: ZappPlugin;
18
- Menu: ZappPlugin;
19
- navBarProps: Record<string, any>;
20
- isNavBarVisible: boolean;
21
- menuProps: {
22
- setToggleMenu: () => void;
23
- toggleMenu: () => void;
24
- openMenu: () => void;
25
- setOpenMenu: () => void;
26
- closeMenu: () => void;
27
- setCloseMenu: () => void;
28
- dimensions: { window: number };
29
- navigator: ZappNavigationProps;
30
- bottomTabBarHeight: number;
31
- isRTL: boolean;
32
- category: string;
33
- } & QuickBrickAppNavigator;
32
+ const screenStyles = {
33
+ flex: 1,
34
+ paddingTop: 0,
35
+ // paddingBottom: insets.bottom, // Should be applied directly by UI plugin
36
+ // paddingLeft: insets.left, // Should be applied directly by UI plugin
37
+ // paddingRight: insets.right, // Should be applied directly by UI plugin
34
38
  };
35
39
 
36
40
  function colorIsNotTransparent(color) {
@@ -41,38 +45,78 @@ function colorIsNotTransparent(color) {
41
45
  R.replace("rgba(", "")
42
46
  )(color);
43
47
 
44
- const alpha = Number(layers?.[3]);
45
-
46
- return alpha > 0;
48
+ return Number(layers?.[3]) > 0;
47
49
  }
48
50
 
49
51
  function isValidColor(string) {
50
52
  return string && string !== "transparent" && colorIsNotTransparent(string);
51
53
  }
52
54
 
53
- export function Screen(props: Props) {
54
- const { pathname, screenData, NavBar } = props;
55
+ type Props = {
56
+ pathname: unknown;
57
+ screenData: unknown;
58
+ };
59
+
60
+ export function Screen(_props: Props) {
61
+ const theme = useTheme<BaseThemePropertiesMobile>();
62
+ const navigation = useNavigation();
55
63
  const { plugins } = usePickFromState(["plugins"]);
56
64
 
57
- const offlinePlugin = useMemo(
65
+ // Gets the data for the current screen configuration
66
+ const currentScreenData = useCurrentScreenData();
67
+ const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
68
+
69
+ const {
70
+ width: screenWidth,
71
+ height,
72
+ deviceInfo,
73
+ } = useDimensions("screen", {
74
+ fullDimensions: true,
75
+ });
76
+
77
+ const { screenData, pathname } = useRoute();
78
+
79
+ const currentRiver = useScreenData(
80
+ getScreenId(screenData, navigation.activeRiver)
81
+ );
82
+
83
+ const { title } = useNavbarState();
84
+
85
+ const isTablet = deviceInfo?.isTablet;
86
+
87
+ const { appData } = usePickFromState(["appData"]);
88
+ const isTabletPortrait = appData?.isTabletPortrait;
89
+
90
+ const layoutData = { isTablet, isTabletPortrait, width: screenWidth, height };
91
+
92
+ const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
93
+
94
+ const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
95
+ getNavBarProps(currentRiver, pathname, title),
96
+ [currentRiver, pathname]
97
+ );
98
+
99
+ const NavBar = React.useMemo(
58
100
  () =>
59
- R.compose(
60
- R.prop("module"),
61
- R.find(R.propEq("identifier", "offline-experience"))
62
- )(plugins),
63
- [plugins]
101
+ getNavigationPluginModule(
102
+ "nav_bar",
103
+ currentRiver,
104
+ plugins
105
+ ) as React.ComponentType<MobileNavBarPluginProps & { hasMenu: boolean }>,
106
+ []
64
107
  );
65
108
 
66
- const { OfflineFallbackScreen } = offlinePlugin;
109
+ const offlinePlugin = getComponentModule({
110
+ plugins,
111
+ components: {},
112
+ componentType: "offline-experience",
113
+ });
67
114
 
68
- // Gets the data for the current screen configuration
69
- const currentScreenData = useCurrentScreenData();
70
- const theme = useTheme();
71
- const { backgroundColor } = useScreenConfiguration(currentScreenData.id);
115
+ const { OfflineFallbackScreen } = offlinePlugin;
72
116
 
73
117
  const style = React.useMemo(
74
118
  () => ({
75
- flex: 1,
119
+ ...screenStyles,
76
120
  backgroundColor: isValidColor(backgroundColor)
77
121
  ? backgroundColor
78
122
  : theme.app_background_color,
@@ -81,19 +125,31 @@ export function Screen(props: Props) {
81
125
  );
82
126
 
83
127
  const targetScreenData =
84
- currentScreenData || screenData?.targetScreen || screenData;
128
+ currentScreenData || (screenData as any)?.targetScreen || screenData;
85
129
 
86
130
  useScreenOrientationHandler({ screenData: targetScreenData });
87
131
 
132
+ const orientation = useGetScreenOrientation(targetScreenData);
133
+
134
+ // We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
135
+ // This saves unnecessary re-renders and user will not see distorted aspect screen.
136
+ if (
137
+ !isOrientationCompatible({
138
+ orientation,
139
+ layoutData,
140
+ })
141
+ ) {
142
+ return <View style={style} />;
143
+ }
144
+
88
145
  return (
89
- <ScreenContextProvider pathname={pathname}>
90
- <View style={style}>
91
- <NavBar key={pathname} {...props.navBarProps} />
92
-
93
- <OfflineFallbackScreen screenData={screenData}>
94
- <RouteManager pathname={pathname} screenData={screenData} />
95
- </OfflineFallbackScreen>
96
- </View>
97
- </ScreenContextProvider>
146
+ <View style={style}>
147
+ {navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
148
+
149
+ <OfflineFallbackScreen screenData={targetScreenData}>
150
+ {/* @TODO RouteManager doesn't use props, can they be removed ? */}
151
+ <RouteManager pathname={pathname} screenData={screenData} />
152
+ </OfflineFallbackScreen>
153
+ </View>
98
154
  );
99
155
  }
@@ -1,85 +1,3 @@
1
- import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
2
-
3
- /**
4
- * This function helps to decide wether the navbar should be presented on the screen
5
- * based on route and / or screen Data
6
- *
7
- * Currently the scenarios include
8
- * - players => false
9
- * - search screen plugin => false
10
- * - hooks with `showNavBar: true` or `presentFullScreen` not set to true, defaults to no navbar for hook screens
11
- * - screens with `allow_screen_plugin_presentation` in general property => false
12
- *
13
- * @param {String} route current route of the screen
14
- * @param {Object} screenData payload associated with the currently presented screen
15
- * @returns {Boolean}
16
- */
17
- export function isNavBarVisible(
18
- route,
19
- screenData,
20
- showNavBar,
21
- canGoBack,
22
- videoModalState: QuickBrickVideoModalState | null = null
23
- ) {
24
- /* screenData is not actual navigator.data
25
- * or navigator.screenData,
26
- * but navigator.data.screen */
27
- if (route.includes("playable")) {
28
- return false;
29
- }
30
-
31
- if (
32
- videoModalState?.mode === "FULLSCREEN" &&
33
- videoModalState?.visible === true
34
- ) {
35
- return false;
36
- }
37
-
38
- if (screenData?.type === "qb_search_screen" && !isTV()) {
39
- return false;
40
- }
41
-
42
- /* Match if screen is Hook */
43
- if (route.startsWith("/hooks/")) {
44
- const module = screenData?.module;
45
-
46
- if (module?.presentFullScreen) {
47
- return false;
48
- }
49
-
50
- return module?.showNavBar ?? false;
51
- }
52
-
53
- if (screenData?.hookPlugin) {
54
- const hookPlugin = screenData?.hookPlugin?.module;
55
-
56
- return (
57
- hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true || false
58
- );
59
- }
60
-
61
- if (
62
- screenData?.general?.allow_screen_plugin_presentation ||
63
- screenData?.general?.hide_app_nav_bar
64
- ) {
65
- return false;
66
- }
67
-
68
- const hideSecondaryLevel = screenData?.navigations?.some(
69
- (navigation) => navigation.styles?.hide_secondary_level_menu
70
- );
71
-
72
- if (canGoBack && hideSecondaryLevel) {
73
- return false;
74
- }
75
-
76
- if (typeof showNavBar === "boolean" && !showNavBar) {
77
- return false;
78
- }
79
-
80
- return true;
81
- }
82
-
83
1
  /**
84
2
  * This function helps to decide wether the menu should be presented on the screen
85
3
  * based on route and / or screen Data
@@ -87,6 +5,11 @@ export function isNavBarVisible(
87
5
  * is similar to the navbar, except that it covers scenarios where only the navbar (and not)
88
6
  * the menu, will be hidden
89
7
  *
8
+ * - playable screens
9
+ * - qb_search_screen
10
+ * - screen hooks that specify showNavBar or presentFullScreen
11
+ * - screens or nested screens that have allow_screen_plugin_presentation set to true
12
+ *
90
13
  * @param {String} route current route of the screen
91
14
  * @param {Object} screenData payload associated with the currently presented screen
92
15
  * @returns {Boolean}
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import * as R from "ramda";
3
- import { useDispatch } from "react-redux";
2
+ import { path, prop } from "ramda";
4
3
  import {
5
4
  findPluginByType,
6
5
  findPluginByIdentifier,
@@ -15,7 +14,6 @@ import { componentsLogger } from "../../Helpers/logger";
15
14
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
16
15
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
17
16
  import { useScreenAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
18
- import { setAppStateHasFinishedTransitioning } from "@applicaster/zapp-react-native-redux/appState";
19
17
 
20
18
  const logger = componentsLogger.addSubsystem("ScreenResolver");
21
19
 
@@ -32,12 +30,13 @@ type Props = {
32
30
  nextFocusLeft?: React.Ref<any>;
33
31
  nextFocusUp?: React.Ref<any>;
34
32
  };
33
+ groupId?: string;
35
34
  };
36
35
 
37
36
  export function ScreenResolverComponent(props: Props) {
38
37
  useScreenAnalytics(props);
39
38
 
40
- const { screenType, screenId, screenData } = props;
39
+ const { screenType, screenId, screenData, groupId } = props;
41
40
 
42
41
  const { hookPlugin } = screenData || {};
43
42
 
@@ -53,11 +52,8 @@ export function ScreenResolverComponent(props: Props) {
53
52
 
54
53
  const [, setScreenContext] = ZappPipesScreenContext.useZappPipesContext();
55
54
 
56
- const dispatch = useDispatch();
57
-
58
55
  React.useEffect(() => {
59
56
  setScreenContext(rivers[screenId]);
60
- dispatch(setAppStateHasFinishedTransitioning());
61
57
  }, [screenId]);
62
58
 
63
59
  const ScreenPlugin =
@@ -81,6 +77,7 @@ export function ScreenResolverComponent(props: Props) {
81
77
  item={screenData}
82
78
  mode={mode === "PIP" ? "PIP" : "FULLSCREEN"}
83
79
  isModal={false}
80
+ groupId={groupId}
84
81
  />
85
82
  );
86
83
  }
@@ -91,21 +88,21 @@ export function ScreenResolverComponent(props: Props) {
91
88
  <HookRenderer
92
89
  screenData={screenData}
93
90
  focused={props.focused}
94
- parentFocus={props.parentFocus}
91
+ parentFocus={props.parentFocus as ParentFocus}
95
92
  />
96
93
  )
97
94
  );
98
95
  }
99
96
 
100
97
  const ScreenComponent =
101
- R.path(["module", "Component"], ScreenPlugin) ||
102
- R.prop("module", ScreenPlugin) ||
103
- R.prop("Component", ScreenPlugin) ||
98
+ path(["module", "Component"], ScreenPlugin) ||
99
+ prop("module", ScreenPlugin) ||
100
+ prop("Component", ScreenPlugin) ||
104
101
  ScreenPlugin;
105
102
 
106
103
  const configuration =
107
- R.prop("configuration", ScreenPlugin) ||
108
- R.prop("__plugin_configuration", ScreenComponent);
104
+ prop("configuration", ScreenPlugin) ||
105
+ prop("__plugin_configuration", ScreenComponent);
109
106
 
110
107
  if (ScreenComponent) {
111
108
  return (
@@ -78,7 +78,7 @@ export const getStyles = (config): Partial<TVTabsStyles> => {
78
78
  },
79
79
  tvos: {
80
80
  marginTop: -1,
81
- }
81
+ },
82
82
  }),
83
83
  },
84
84
  tabsBackground: {
@@ -17,9 +17,12 @@ type TrackedViewProps = {
17
17
  export const TrackedView = memo(function TrackedView(props: TrackedViewProps) {
18
18
  const children = props.children;
19
19
 
20
- const onPositionUpdated = useCallback((event: TrackedViewNativeProps) => {
21
- props?.onPositionUpdated(event.nativeEvent);
22
- }, []);
20
+ const onPositionUpdated = useCallback(
21
+ (event: TrackedViewNativeProps) => {
22
+ props.onPositionUpdated(event.nativeEvent);
23
+ },
24
+ [props.onPositionUpdated]
25
+ );
23
26
 
24
27
  if (isTV()) {
25
28
  return <View {...(props as any)}>{children}</View>;
@@ -1,12 +1,9 @@
1
1
  import React from "react";
2
- import {
3
- Animated,
4
- useWindowDimensions,
5
- ViewProps,
6
- ViewStyle,
7
- } from "react-native";
2
+ import { Animated, ViewProps, ViewStyle } from "react-native";
8
3
  import { useSafeAreaFrame } from "react-native-safe-area-context";
9
4
  import { PathnameContext } from "../../Contexts/PathnameContext";
5
+ import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
6
+ import { ScreenContextProvider } from "../../Contexts/ScreenContext";
10
7
 
11
8
  type Props = {
12
9
  children: any;
@@ -16,6 +13,8 @@ type Props = {
16
13
  animating: boolean;
17
14
  contentStyle: ViewStyle;
18
15
  pathname: string;
16
+ isActive: boolean;
17
+ screenData: NavigationScreenData;
19
18
  };
20
19
 
21
20
  /**
@@ -38,34 +37,41 @@ export function Scene({
38
37
  animating,
39
38
  contentStyle,
40
39
  pathname,
40
+ isActive = false,
41
+ screenData,
41
42
  }: Props) {
43
+ const [initialScreenData, setInitialScreenData] = React.useState(screenData);
44
+
45
+ React.useLayoutEffect(() => {
46
+ if (isActive) {
47
+ setInitialScreenData(screenData);
48
+ }
49
+ }, [screenData, isActive]);
50
+
42
51
  const frame = useSafeAreaFrame();
43
- const { height, width } = useWindowDimensions();
44
52
 
45
- if (overlayStyle && animating) {
46
- // Safe frame takes too long to update,
47
- // so we can not rely on it there, and use height and width instead.
48
- return (
49
- <Animated.View
50
- pointerEvents={pointerEvents}
51
- style={[style, contentStyle, { height, width }]}
52
- >
53
- <PathnameContext.Provider value={pathname}>
54
- {children}
55
- </PathnameContext.Provider>
56
- <Animated.View style={overlayStyle} />
57
- </Animated.View>
58
- );
59
- }
53
+ const isAnimating = animating && overlayStyle;
54
+
55
+ const dimensions = isAnimating
56
+ ? {
57
+ height: "100%",
58
+ width: "100%",
59
+ }
60
+ : frame;
60
61
 
61
62
  return (
62
63
  <Animated.View
63
64
  pointerEvents={pointerEvents}
64
- style={[style, contentStyle, frame]}
65
+ style={[style, contentStyle, dimensions]}
65
66
  >
66
- <PathnameContext.Provider value={pathname}>
67
- {children}
68
- </PathnameContext.Provider>
67
+ <ScreenDataContext.Provider value={initialScreenData}>
68
+ <PathnameContext.Provider value={pathname}>
69
+ <ScreenContextProvider pathname={pathname}>
70
+ {children}
71
+ </ScreenContextProvider>
72
+ </PathnameContext.Provider>
73
+ </ScreenDataContext.Provider>
74
+ {isAnimating && <Animated.View style={overlayStyle} />}
69
75
  </Animated.View>
70
76
  );
71
77
  }