@applicaster/zapp-react-native-ui-components 14.0.0-alpha.3011001369 → 14.0.0-alpha.3065652724

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 (46) hide show
  1. package/Components/Cell/Cell.tsx +91 -64
  2. package/Components/Cell/CellWithFocusable.tsx +3 -0
  3. package/Components/FeedLoader/FeedLoader.tsx +1 -1
  4. package/Components/Focusable/Focusable.tsx +10 -3
  5. package/Components/Focusable/FocusableTvOS.tsx +2 -2
  6. package/Components/Focusable/Touchable.tsx +5 -3
  7. package/Components/Focusable/index.android.tsx +8 -4
  8. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  9. package/Components/FocusableList/FocusableItem.tsx +4 -3
  10. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  11. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  12. package/Components/FocusableList/index.tsx +16 -9
  13. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +9 -11
  14. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +0 -12
  15. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  16. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  17. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  18. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  19. package/Components/PlayerContainer/PlayerContainer.tsx +4 -1
  20. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -42
  21. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  22. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  23. package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
  24. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  25. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  26. package/Components/Screen/index.tsx +22 -5
  27. package/Components/Screen/navigationHandler.ts +20 -2
  28. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +2 -2
  29. package/Components/ScreenRevealManager/utils/index.ts +23 -0
  30. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +12 -0
  31. package/Components/Tabs/TV/Tabs.android.tsx +1 -1
  32. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  33. package/Components/TextInputTv/index.tsx +11 -0
  34. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -1
  35. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
  36. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
  37. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +42 -22
  38. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  39. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  40. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  41. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  42. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  43. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  44. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
  45. package/events/index.ts +2 -0
  46. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, useMemo } from "react";
2
2
  import { Animated, Dimensions } from "react-native";
3
3
 
4
4
  import {
@@ -163,31 +163,51 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
163
163
 
164
164
  return (
165
165
  <ReactContext.Provider
166
- value={{
167
- yTranslate,
168
- startComponentsAnimation,
169
- setStartComponentsAnimation,
170
- isActiveGesture: playerAnimationState !== null,
171
- playerAnimationState,
172
- setPlayerAnimationState,
173
- resetPlayerAnimationState,
174
- minimisedHeight,
175
- animatedValues: {
166
+ value={useMemo(
167
+ () => ({
168
+ yTranslate,
169
+ startComponentsAnimation,
170
+ setStartComponentsAnimation,
171
+ isActiveGesture: playerAnimationState !== null,
172
+ playerAnimationState,
173
+ setPlayerAnimationState,
174
+ resetPlayerAnimationState,
175
+ minimisedHeight,
176
+ animatedValues: {
177
+ lastScrollY,
178
+ dragScrollY,
179
+ dragVideoPlayerY,
180
+ translateYOffset,
181
+ },
182
+ lastScrollYValue,
183
+ scrollPosition,
184
+ modalSnapPoints,
185
+ lastSnap,
186
+ setLastSnap,
187
+ tabletLandscapePlayerTopPosition,
188
+ setTabletLandscapePlayerTopPosition,
189
+ startComponentsAnimationDistance,
190
+ progressBarHeight,
191
+ }),
192
+ // eslint-disable-next-line react-hooks/exhaustive-deps
193
+ [
194
+ startComponentsAnimation,
195
+ playerAnimationState,
196
+ minimisedHeight,
176
197
  lastScrollY,
177
198
  dragScrollY,
178
199
  dragVideoPlayerY,
179
200
  translateYOffset,
180
- },
181
- lastScrollYValue,
182
- scrollPosition,
183
- modalSnapPoints,
184
- lastSnap,
185
- setLastSnap,
186
- tabletLandscapePlayerTopPosition,
187
- setTabletLandscapePlayerTopPosition,
188
- startComponentsAnimationDistance,
189
- progressBarHeight,
190
- }}
201
+ lastSnap,
202
+ modalSnapPoints,
203
+ lastScrollYValue,
204
+ scrollPosition,
205
+ tabletLandscapePlayerTopPosition,
206
+ startComponentsAnimationDistance,
207
+ progressBarHeight,
208
+ isLiveItem,
209
+ ]
210
+ )}
191
211
  >
192
212
  {children}
193
213
  </ReactContext.Provider>
@@ -4,8 +4,8 @@ import {
4
4
  Dimensions,
5
5
  Easing,
6
6
  StyleProp,
7
- ViewStyle,
8
7
  StyleSheet,
8
+ ViewStyle,
9
9
  } from "react-native";
10
10
  import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
11
11
  import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
@@ -69,11 +69,10 @@ export const PlayerDetails = ({
69
69
  const screenData = useTargetScreenData(entry);
70
70
  const insets = useSafeAreaInsets();
71
71
 
72
- const extraTabletStyles = !isAudioPlayer
73
- ? isTabletLandscape
72
+ const extraTabletStyles =
73
+ !isAudioPlayer && isTabletLandscape
74
74
  ? { marginTop: -insets.top, paddingTop: insets.top + 20 }
75
- : { marginTop: -8, paddingTop: -8 }
76
- : {};
75
+ : null;
77
76
 
78
77
  // Animation setup
79
78
  const translateY = useRef(new Animated.Value(50)).current;
@@ -129,6 +128,7 @@ export const PlayerDetails = ({
129
128
  riverId={screenData.id}
130
129
  feed={screenData?.data?.source}
131
130
  riverComponents={screenData.ui_components}
131
+ isScreenWrappedInContainer
132
132
  />
133
133
  ) : null}
134
134
  </Animated.View>
@@ -2,6 +2,8 @@ import { renderHook } from "@testing-library/react-hooks";
2
2
  import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
3
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
4
4
 
5
+ jest.useFakeTimers();
6
+
5
7
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
6
8
  useIsTablet: jest.fn().mockReturnValue(false),
7
9
  }));
@@ -11,11 +13,15 @@ describe("useDelayedPlayerDetails", () => {
11
13
  jest.clearAllMocks();
12
14
  });
13
15
 
14
- it("should return true initially", () => {
16
+ it("should return false initially, that changes after 1 second", () => {
15
17
  const { result } = renderHook(() =>
16
18
  useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
17
19
  );
18
20
 
21
+ expect(result.current).toBe(false);
22
+
23
+ jest.advanceTimersByTime(1000);
24
+
19
25
  expect(result.current).toBe(true);
20
26
  });
21
27
 
@@ -46,6 +52,8 @@ describe("useDelayedPlayerDetails", () => {
46
52
  })
47
53
  );
48
54
 
55
+ jest.advanceTimersByTime(1000);
56
+
49
57
  expect(result.current).toBe(true);
50
58
  });
51
59
  });
@@ -1,22 +1,26 @@
1
+ // const showPlayerDetails = (
2
+ // isInline: boolean,
3
+ // isDocked: boolean,
4
+ // isPip: boolean,
5
+ // isTablet: boolean
6
+ // ) => {
7
+ // return showDetails({
8
+ // isMobile: !isTablet,
9
+ // isInline,
10
+ // isDocked,
11
+ // isPip,
12
+ // });
13
+ // };
14
+
15
+ import * as React from "react";
1
16
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
17
+ import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
2
18
 
3
19
  import { showDetails } from "./utils";
4
20
 
5
- type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
21
+ const TIMEOUT = 1000; // ms
6
22
 
7
- const showPlayerDetails = (
8
- isInline: boolean,
9
- isDocked: boolean,
10
- isPip: boolean,
11
- isTablet: boolean
12
- ) => {
13
- return showDetails({
14
- isMobile: !isTablet,
15
- isInline,
16
- isDocked,
17
- isPip,
18
- });
19
- };
23
+ type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
20
24
 
21
25
  /**
22
26
  * Custom hook to determine whether to show player details with a delay.
@@ -32,7 +36,28 @@ export const useDelayedPlayerDetails = ({
32
36
  isDocked,
33
37
  isPip,
34
38
  }: Props): boolean => {
39
+ const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
40
+
35
41
  const isTablet = useIsTablet();
36
42
 
37
- return showPlayerDetails(isInline, isDocked, isPip, isTablet);
43
+ React.useEffect(() => {
44
+ const subscription = withTimeout$(TIMEOUT).subscribe({
45
+ next: () => {
46
+ setShouldShowDetails(() => {
47
+ return showDetails({
48
+ isMobile: !isTablet,
49
+ isInline,
50
+ isDocked,
51
+ isPip,
52
+ });
53
+ });
54
+ },
55
+ });
56
+
57
+ return () => {
58
+ subscription.unsubscribe();
59
+ };
60
+ }, [isDocked, isTablet, isInline, isPip]);
61
+
62
+ return shouldShowDetails;
38
63
  };
@@ -12,7 +12,7 @@ describe("showDetails", () => {
12
12
  expect(result).toBe(false);
13
13
  });
14
14
 
15
- it("should return false if isDocked is true", () => {
15
+ it("should return true if isDocked & mobile", () => {
16
16
  const result = showDetails({
17
17
  isMobile: true,
18
18
  isInline: true,
@@ -20,7 +20,7 @@ describe("showDetails", () => {
20
20
  isPip: false,
21
21
  });
22
22
 
23
- expect(result).toBe(false);
23
+ expect(result).toBe(true);
24
24
  });
25
25
 
26
26
  it("should return true if isMobile is true and isInline is true", () => {
@@ -52,6 +52,10 @@ export const showDetails = ({
52
52
  }
53
53
 
54
54
  if (isDocked) {
55
+ if (isMobile) {
56
+ return true;
57
+ }
58
+
55
59
  return false;
56
60
  }
57
61
 
@@ -0,0 +1,27 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ export const CellFocusedStateContext = React.createContext<boolean>(false);
4
+
5
+ export const CellFocusedStateContextProvider = ({
6
+ cellFocused,
7
+ children,
8
+ }: {
9
+ cellFocused: boolean;
10
+ children: ReactNode;
11
+ }) => {
12
+ return (
13
+ <CellFocusedStateContext.Provider value={cellFocused}>
14
+ {children}
15
+ </CellFocusedStateContext.Provider>
16
+ );
17
+ };
18
+
19
+ export function withCellFocusedStateContext(
20
+ Component: React.ComponentType<any>
21
+ ) {
22
+ return function WithCellFocusedStateContextWrapper(props) {
23
+ const cellFocusedState = React.useContext(CellFocusedStateContext);
24
+
25
+ return <Component {...props} cellFocusedState={cellFocusedState} />;
26
+ };
27
+ }
@@ -24,16 +24,12 @@ export const getDatasourceUrl: (
24
24
  ) => {
25
25
  const { source, mapping } = R.propOr({}, ["data"], component);
26
26
 
27
- if (mapping) {
28
- const contexts = {
29
- entry: entryContext,
30
- screen: screenContext || screenData,
31
- search: getSearchContext(searchContext, mapping),
32
- };
27
+ const contexts = {
28
+ entry: entryContext,
29
+ screen: screenContext || screenData,
30
+ search: getSearchContext(searchContext, mapping),
31
+ };
33
32
 
34
- return getInflatedDataSourceUrl({ source, mapping, contexts });
35
- }
36
-
37
- return source;
33
+ return getInflatedDataSourceUrl({ source, mapping, contexts });
38
34
  }
39
35
  );
package/events/index.ts CHANGED
@@ -3,4 +3,6 @@ export enum QBUIComponentEvents {
3
3
  topMenuBarTV_onFocus = "topMenuBarTV_onFocus",
4
4
  navigatorReplaceItem = "navigatorReplaceItem",
5
5
  scrollVerticallyToInitialOffset = "scrollVerticallyToInitialOffset",
6
+ focusOnSelectedTab = "focusOnSelectedTab",
7
+ focusOnSelectedTopMenuItem = "focusOnSelectedTopMenuItem",
6
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-alpha.3011001369",
3
+ "version": "14.0.0-alpha.3065652724",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.0-alpha.3011001369",
32
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3011001369",
33
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3011001369",
34
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3011001369",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.3065652724",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.3065652724",
33
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.3065652724",
34
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.3065652724",
35
35
  "promise": "^8.3.0",
36
36
  "url": "^0.11.0",
37
37
  "uuid": "^3.3.2"