@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4462655310 → 12.0.0-alpha.4484269996

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 (66) hide show
  1. package/Components/BaseFocusable/index.tsx +2 -2
  2. package/Components/Cell/Cell.tsx +26 -5
  3. package/Components/Cell/CellWithFocusable.tsx +6 -4
  4. package/Components/Cell/TvOSCellComponent.tsx +3 -7
  5. package/Components/Focusable/Focusable.tsx +6 -1
  6. package/Components/FocusableGroup/index.tsx +10 -2
  7. package/Components/FreezeWithCallback/Freeze.tsx +31 -0
  8. package/Components/FreezeWithCallback/LICENSE +21 -0
  9. package/Components/FreezeWithCallback/Suspender.tsx +17 -0
  10. package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
  11. package/Components/FreezeWithCallback/index.tsx +3 -0
  12. package/Components/Layout/TV/ScreenContainer.tsx +79 -5
  13. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
  14. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
  15. package/Components/Layout/TV/__tests__/index.test.tsx +2 -1
  16. package/Components/Layout/TV/index.tsx +11 -65
  17. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -1
  18. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +1 -7
  19. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
  20. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
  21. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
  22. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  23. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +6 -1
  24. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
  25. package/Components/MasterCell/dataAdapter.ts +21 -7
  26. package/Components/MasterCell/index.tsx +5 -3
  27. package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
  28. package/Components/Navigator/StackNavigator.tsx +14 -5
  29. package/Components/PlayerContainer/PlayerContainer.tsx +2 -5
  30. package/Components/Screen/TV/hooks/index.ts +0 -2
  31. package/Components/Screen/TV/index.web.tsx +40 -41
  32. package/Components/Screen/__tests__/Screen.test.tsx +0 -49
  33. package/Components/Screen/index.tsx +28 -77
  34. package/Components/Screen/navigationHandler.ts +6 -3
  35. package/Components/Screen/orientationHandler.ts +18 -7
  36. package/Components/Screen/utils.ts +16 -0
  37. package/Components/ScreenResolver/index.tsx +6 -11
  38. package/Components/Transitioner/Scene.tsx +20 -12
  39. package/Components/Transitioner/Transitioner.tsx +26 -21
  40. package/Components/Transitioner/__tests__/Scene.test.js +7 -0
  41. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +8 -4
  42. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  43. package/Components/VideoLive/LiveImageManager.ts +10 -0
  44. package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
  45. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
  46. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
  47. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +31 -7
  48. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +9 -2
  49. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +27 -15
  50. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -4
  51. package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
  52. package/Components/VideoModal/PlayerWrapper.tsx +2 -2
  53. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +80 -14
  54. package/Components/VideoModal/hooks/useModalSize.ts +10 -12
  55. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
  56. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
  57. package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
  58. package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
  59. package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
  60. package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
  61. package/Contexts/FocusableGroupContext/index.ts +7 -0
  62. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
  63. package/package.json +5 -5
  64. package/Components/Screen/TV/hooks/useRestoreFocus.ts +0 -22
  65. /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
  66. /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
@@ -42,9 +42,14 @@ exports[`PlayerWrapper renders inline 1`] = `
42
42
  }
43
43
  animationType="moveUpComponent"
44
44
  style={
45
- Object {
46
- "flexDirection": "column",
47
- }
45
+ Array [
46
+ Object {
47
+ "flexDirection": "column",
48
+ },
49
+ Object {
50
+ "flex": 1,
51
+ },
52
+ ]
48
53
  }
49
54
  >
50
55
  <View
@@ -67,12 +72,34 @@ exports[`PlayerWrapper renders inline 1`] = `
67
72
  testID="test-player-container"
68
73
  />
69
74
  <View
75
+ animationType="componentFade"
70
76
  style={
71
77
  Object {
72
78
  "flex": 1,
73
79
  }
74
80
  }
75
- />
81
+ >
82
+ <View
83
+ configuration={
84
+ Object {
85
+ "tablet_landscape_player_container_background_color": "red",
86
+ "tablet_landscape_sidebar_width": "35%",
87
+ }
88
+ }
89
+ entry={
90
+ Object {
91
+ "id": "test",
92
+ }
93
+ }
94
+ isTabletLandscape={false}
95
+ style={
96
+ Object {
97
+ "flex": 1,
98
+ "paddingTop": 20,
99
+ }
100
+ }
101
+ />
102
+ </View>
76
103
  </View>
77
104
  </RNCSafeAreaView>
78
105
  </RNCSafeAreaProvider>
@@ -120,9 +147,14 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
120
147
  }
121
148
  animationType="moveUpComponent"
122
149
  style={
123
- Object {
124
- "flexDirection": "column",
125
- }
150
+ Array [
151
+ Object {
152
+ "flexDirection": "column",
153
+ },
154
+ Object {
155
+ "flex": 1,
156
+ },
157
+ ]
126
158
  }
127
159
  >
128
160
  <View
@@ -148,6 +180,7 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
148
180
  style={
149
181
  Object {
150
182
  "flex": 1,
183
+ "paddingTop": 20,
151
184
  }
152
185
  }
153
186
  />
@@ -198,9 +231,14 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
198
231
  }
199
232
  animationType="moveUpComponent"
200
233
  style={
201
- Object {
202
- "flexDirection": "row",
203
- }
234
+ Array [
235
+ Object {
236
+ "flexDirection": "row",
237
+ },
238
+ Object {
239
+ "flex": 1,
240
+ },
241
+ ]
204
242
  }
205
243
  >
206
244
  <View
@@ -239,12 +277,34 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
239
277
  />
240
278
  </View>
241
279
  <View
280
+ animationType="componentFade"
242
281
  style={
243
282
  Object {
244
283
  "flex": 1,
245
284
  }
246
285
  }
247
- />
286
+ >
287
+ <View
288
+ configuration={
289
+ Object {
290
+ "tablet_landscape_player_container_background_color": "red",
291
+ "tablet_landscape_sidebar_width": "35%",
292
+ }
293
+ }
294
+ entry={
295
+ Object {
296
+ "id": "test",
297
+ }
298
+ }
299
+ isTabletLandscape={true}
300
+ style={
301
+ Object {
302
+ "flex": 1,
303
+ "paddingTop": 20,
304
+ }
305
+ }
306
+ />
307
+ </View>
248
308
  </View>
249
309
  </RNCSafeAreaView>
250
310
  </RNCSafeAreaProvider>
@@ -292,9 +352,14 @@ exports[`PlayerWrapper renders properly 1`] = `
292
352
  }
293
353
  animationType="moveUpComponent"
294
354
  style={
295
- Object {
296
- "flexDirection": "column",
297
- }
355
+ Array [
356
+ Object {
357
+ "flexDirection": "column",
358
+ },
359
+ Object {
360
+ "flex": 1,
361
+ },
362
+ ]
298
363
  }
299
364
  >
300
365
  <View
@@ -320,6 +385,7 @@ exports[`PlayerWrapper renders properly 1`] = `
320
385
  style={
321
386
  Object {
322
387
  "flex": 1,
388
+ "paddingTop": 20,
323
389
  }
324
390
  }
325
391
  />
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import { Dimensions } from "react-native";
3
2
  import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
4
3
  import {
5
4
  addOrientationChangeListener,
@@ -9,11 +8,10 @@ import {
9
8
  } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
10
9
 
11
10
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
11
+ import { useSafeAreaFrame } from "react-native-safe-area-context";
12
12
 
13
13
  const { Logger } = getXray();
14
14
 
15
- const { width: WIDTH, height: HEIGHT } = Dimensions.get("window");
16
-
17
15
  const logger = new Logger(
18
16
  "hooks",
19
17
  "zapp-react-native-ui-components/Components/VideoModal"
@@ -24,20 +22,18 @@ type Size = {
24
22
  height: number | string;
25
23
  };
26
24
 
27
- const MODAL_SIZE_FOR_PORTRAIT: Size = {
28
- width: WIDTH,
29
- height: HEIGHT,
30
- };
31
-
32
25
  const MODAL_SIZE_FOR_LANDSCAPE: Size = {
33
26
  width: "100%",
34
27
  height: "100%",
35
28
  };
36
29
 
37
30
  export const useModalSize = (): Size => {
38
- const [modalSize, setModalSize] = React.useState<Size>(
39
- MODAL_SIZE_FOR_PORTRAIT
40
- );
31
+ const frame = useSafeAreaFrame();
32
+
33
+ const [modalSize, setModalSize] = React.useState<Size>({
34
+ width: frame.width,
35
+ height: frame.height,
36
+ });
41
37
 
42
38
  const setNewModalSize = React.useCallback((newSize, log) => {
43
39
  setModalSize((oldSize) => {
@@ -90,7 +86,9 @@ export const useModalSize = (): Size => {
90
86
  toOrientation === ORIENTATIONS.landscapeSensor;
91
87
 
92
88
  setNewModalSize(
93
- isLandscape ? MODAL_SIZE_FOR_LANDSCAPE : MODAL_SIZE_FOR_PORTRAIT,
89
+ isLandscape
90
+ ? MODAL_SIZE_FOR_LANDSCAPE
91
+ : { width: frame.width, height: frame.height },
94
92
  `useModalSize: set modal size ${
95
93
  isLandscape ? "landscape" : "portrait"
96
94
  } for orientation: ${to}`
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, StyleSheet } from "react-native";
2
+ import { StyleSheet } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
3
4
 
4
5
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
5
6
  import CloseButton from "./Buttons/CloseButton";
@@ -44,11 +45,11 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
44
45
  );
45
46
 
46
47
  return (
47
- <View style={[style.view, isRTL ? style.rtlStyle : {}]}>
48
+ <SafeAreaView style={[style.view, isRTL ? style.rtlStyle : {}]}>
48
49
  {backButton}
49
50
  <BarTitle title={barState.title} screenStyles={screenStyles} />
50
51
  {closeButton}
51
- </View>
52
+ </SafeAreaView>
52
53
  );
53
54
  };
54
55
 
@@ -16,9 +16,9 @@ exports[`DefaultCellRenderer returns a react component and it renders correctly
16
16
  store={null}
17
17
  style={
18
18
  Object {
19
- "backgroundColor": "#CCC",
19
+ "backgroundColor": "transparent",
20
20
  "margin": 12,
21
- "opacity": 0.6,
21
+ "opacity": 1,
22
22
  "width": 169,
23
23
  }
24
24
  }
@@ -105,7 +105,7 @@ exports[`DefaultCellRenderer returns a react component for LG TVs 1`] = `
105
105
  store={null}
106
106
  style={
107
107
  Object {
108
- "backgroundColor": "rgba(252,70,27,1.0)",
108
+ "backgroundColor": "rgba(47,47,47,1.0)",
109
109
  "borderRadius": 4,
110
110
  "flex": 1,
111
111
  "overflow": "hidden",
@@ -238,7 +238,7 @@ exports[`DefaultCellRenderer returns a react component for Samsung TVs 1`] = `
238
238
  store={null}
239
239
  style={
240
240
  Object {
241
- "backgroundColor": "rgba(252,70,27,1.0)",
241
+ "backgroundColor": "rgba(47,47,47,1.0)",
242
242
  "borderRadius": 4,
243
243
  "flex": 1,
244
244
  "overflow": "hidden",
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+
3
+ export const FocusableGroupContext = React.createContext<string | null>(null);
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import { FocusableGroupContext } from "./FocusableGroupContext";
3
+
4
+ type ProviderArgs = {
5
+ id: string;
6
+ children: React.ReactNode;
7
+ };
8
+
9
+ export const FocusableGroupContextProvider = ({
10
+ id,
11
+ children,
12
+ }: ProviderArgs) => (
13
+ <FocusableGroupContext.Provider value={id}>
14
+ {children}
15
+ </FocusableGroupContext.Provider>
16
+ );
@@ -0,0 +1,22 @@
1
+ import React, { useContext } from "react";
2
+ import { Text } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+ import { FocusableGroupContextProvider, FocusableGroupContext } from "../";
5
+
6
+ const MockComponent = () => {
7
+ const focusableContext = useContext(FocusableGroupContext) || "default";
8
+
9
+ return <Text testID={focusableContext} />;
10
+ };
11
+
12
+ describe("FocusableGroupContextProvider", () => {
13
+ it("should provide focusable context to the wrapped component", () => {
14
+ const { getByTestId } = render(
15
+ <FocusableGroupContextProvider id="testId">
16
+ <MockComponent />
17
+ </FocusableGroupContextProvider>
18
+ );
19
+
20
+ expect(getByTestId("testId")).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { Text } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+ import { withFocusableContext } from "../withFocusableContext";
5
+ import { FocusableGroupContext } from "../FocusableGroupContext";
6
+
7
+ const MockComponent = ({ groupId }: { groupId: string }) => (
8
+ <Text testID={groupId} />
9
+ );
10
+
11
+ const WrappedComponent = withFocusableContext(MockComponent);
12
+
13
+ describe("withFocusableContext HOC", () => {
14
+ it("should provide focusable context to the wrapped component", () => {
15
+ const { getByTestId } = render(<WrappedComponent />, {
16
+ // eslint-disable-next-line react/display-name
17
+ wrapper: ({ children }: { children: React.ReactElement }) => (
18
+ <FocusableGroupContext.Provider value="test">
19
+ {children}
20
+ </FocusableGroupContext.Provider>
21
+ ),
22
+ });
23
+
24
+ expect(getByTestId("test")).toBeTruthy();
25
+ });
26
+ });
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { FocusableGroupContext } from "./FocusableGroupContext";
3
+ import { FocusableGroupContextProvider } from "./FocusableGroupContextProvider";
4
+
5
+ export { FocusableGroupContext, FocusableGroupContextProvider };
6
+
7
+ export const useGroupId = () => React.useContext(FocusableGroupContext);
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { FocusableGroupContext } from "./FocusableGroupContext";
3
+
4
+ export const withFocusableContext = (Component) => {
5
+ // eslint-disable-next-line react/display-name
6
+ return ({ groupId, ...props }: Record<string, any>) => (
7
+ <FocusableGroupContext.Consumer>
8
+ {(groupIdContext: string) => {
9
+ // eslint-disable-next-line react/display-name
10
+ const propsGroupId = groupId || null;
11
+ const providedGroupId = propsGroupId || groupIdContext;
12
+
13
+ return <Component {...props} groupId={providedGroupId} />;
14
+ }}
15
+ </FocusableGroupContext.Consumer>
16
+ );
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.0-alpha.4462655310",
3
+ "version": "12.0.0-alpha.4484269996",
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",
@@ -34,10 +34,10 @@
34
34
  "redux-mock-store": "^1.5.3"
35
35
  },
36
36
  "dependencies": {
37
- "@applicaster/applicaster-types": "12.0.0-alpha.4462655310",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4462655310",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.4462655310",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.4462655310",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.4484269996",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4484269996",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.4484269996",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.4484269996",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",
@@ -1,22 +0,0 @@
1
- import * as React from "react";
2
- import { isNil } from "ramda";
3
- import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
- import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
5
- import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
6
-
7
- export const useRestoreFocus = (): void => {
8
- const isScreenActive = useIsScreenActive();
9
- const previousIsScreenActive = usePrevious(isScreenActive);
10
-
11
- React.useEffect(() => {
12
- if (isNil(previousIsScreenActive)) {
13
- // it's initial mounting of the screen, do nothing here
14
- return;
15
- }
16
-
17
- if (!previousIsScreenActive && isScreenActive) {
18
- // restore focus when we go back from next screen
19
- focusManager.setInitialFocus();
20
- }
21
- }, [previousIsScreenActive, isScreenActive]);
22
- };