@applicaster/zapp-react-native-ui-components 12.0.0-alpha.3977160850 → 12.0.0-alpha.4337072244

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 (82) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +7 -7
  3. package/Components/Cell/CellWithFocusable.tsx +38 -19
  4. package/Components/Cell/TvOSCellComponent.tsx +2 -2
  5. package/Components/ErrorScreen/index.tsx +1 -1
  6. package/Components/FocusableCell/index.tsx +7 -7
  7. package/Components/FocusableGroup/index.tsx +1 -0
  8. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  9. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  10. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  11. package/Components/HookRenderer/index.tsx +1 -3
  12. package/Components/Image/Image.android.tsx +3 -25
  13. package/Components/Image/Image.tsx +18 -2
  14. package/Components/Image/utils/index.ts +39 -0
  15. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  16. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -10
  17. package/Components/Layout/TV/__tests__/index.test.tsx +18 -86
  18. package/Components/Layout/TV/index.tsx +43 -102
  19. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  20. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  21. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  22. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  23. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  24. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
  25. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  26. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  27. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  28. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  29. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  30. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  31. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  32. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  33. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  34. package/Components/MasterCell/utils/index.ts +18 -7
  35. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  36. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  37. package/Components/PlayerContainer/PlayerContainer.tsx +64 -31
  38. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  39. package/Components/PlayerImageBackground/index.tsx +34 -8
  40. package/Components/River/ComponentsMap/ComponentsMap.tsx +86 -22
  41. package/Components/River/RefreshControl.tsx +55 -1
  42. package/Components/River/TV/River.tsx +0 -23
  43. package/Components/River/__tests__/componentsMap.test.js +7 -0
  44. package/Components/RouteManager/index.tsx +2 -2
  45. package/Components/Screen/TV/hooks/index.ts +3 -0
  46. package/Components/Screen/TV/hooks/useInitialFocus.ts +67 -0
  47. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  48. package/Components/Screen/TV/index.web.tsx +174 -0
  49. package/Components/Screen/__tests__/Screen.test.tsx +5 -1
  50. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +14 -0
  51. package/Components/Screen/index.tsx +48 -28
  52. package/Components/ScreenResolver/index.tsx +3 -1
  53. package/Components/Tabs/TV/styles.ts +1 -1
  54. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -28
  55. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  56. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
  57. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  58. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  59. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  60. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  61. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  62. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  63. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  64. package/Components/VideoModal/PlayerWrapper.tsx +66 -43
  65. package/Components/VideoModal/VideoModal.tsx +25 -42
  66. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +6 -1
  67. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +246 -166
  68. package/Components/VideoModal/utils.ts +3 -3
  69. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +1 -1
  70. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  71. package/Components/Viewport/utils.js +1 -1
  72. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  73. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  74. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  75. package/Contexts/ScreenContext/index.tsx +94 -25
  76. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  77. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  78. package/events/index.ts +1 -0
  79. package/package.json +5 -5
  80. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  81. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  82. /package/Contexts/{index.js → index.ts} +0 -0
@@ -1,4 +1,10 @@
1
- import React, { createContext, ReactNode, useMemo, useState } from "react";
1
+ import React, {
2
+ createContext,
3
+ ReactNode,
4
+ useCallback,
5
+ useMemo,
6
+ useRef,
7
+ } from "react";
2
8
  import {
3
9
  useCurrentScreenData,
4
10
  useNavigation,
@@ -7,27 +13,67 @@ import {
7
13
  } from "@applicaster/zapp-react-native-utils/reactHooks";
8
14
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
9
15
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
16
+ import { create, StoreApi, UseBoundStore } from "zustand";
17
+ import { useShallow } from "zustand/react/shallow";
18
+ import { Animated } from "react-native";
19
+
20
+ interface NavBarStoreState {
21
+ visible: boolean;
22
+ title: string;
23
+ summary: string;
24
+ setVisible: (state: boolean) => void;
25
+ setTitle: (title: string) => void;
26
+ setSummary: (subtitle: string) => void;
27
+ height: number;
28
+ scrollState: number;
29
+ contentPosition: string;
30
+ scrollYAnimated: Animated.Value;
31
+ }
32
+
33
+ interface NavBarState {
34
+ visible: boolean;
35
+ title: string;
36
+ summary: string;
37
+ setVisible: (state: boolean) => void;
38
+ setTitle: (title: string) => void;
39
+ setSummary: (subtitle: string) => void;
40
+ }
10
41
 
11
42
  type ScreenContextType = {
12
- navBar: {
13
- visible: boolean;
14
- title: string;
15
- summary: string;
16
- setVisible: (state: boolean) => void;
17
- setTitle: (title: string) => void;
18
- setSummary: (subtitle: string) => void;
19
- };
43
+ _navBarStore: UseBoundStore<StoreApi<NavBarStoreState>>;
44
+ navBar: NavBarState;
20
45
  legacyFormatScreenData: LegacyNavigationScreenData | null;
21
46
  };
22
47
 
48
+ const createStore = () =>
49
+ create<NavBarStoreState>((set) => ({
50
+ title: "",
51
+ summary: "",
52
+ visible: true,
53
+ height: 0,
54
+ scrollState: 0,
55
+ contentPosition: "",
56
+ scrollYAnimated: new Animated.Value(0),
57
+ setTitle(title) {
58
+ set({ title });
59
+ },
60
+ setSummary(summary) {
61
+ set({ summary });
62
+ },
63
+ setVisible(visible) {
64
+ set({ visible });
65
+ },
66
+ }));
67
+
23
68
  export const ScreenContext = createContext<ScreenContextType>({
69
+ _navBarStore: createStore(),
24
70
  navBar: {
25
71
  visible: true,
26
72
  title: "",
27
73
  summary: "",
28
- setVisible: (_state) => {},
29
- setTitle: (_title) => {},
30
- setSummary: (_subtitle) => {},
74
+ setVisible: (_state) => void 0,
75
+ setTitle: (_title) => void 0,
76
+ setSummary: (_subtitle) => void 0,
31
77
  },
32
78
  legacyFormatScreenData: {} as LegacyNavigationScreenData,
33
79
  });
@@ -53,9 +99,30 @@ export function ScreenContextProvider({
53
99
  const isNested = useNestedNavigationContext();
54
100
  const currentScreenScreenData = useCurrentScreenData();
55
101
 
56
- const [navBarTitle, setNavBarTitle] = useState("");
57
- const [navBarSummary, setNavBarSummary] = useState("");
58
- const [navBarVisible, setNavBarVisible] = useState(true);
102
+ const screenNavBarStateRef =
103
+ useRef<null | ReturnType<typeof createStore>>(null);
104
+
105
+ const getScreenNavBarState = useCallback(() => {
106
+ if (screenNavBarStateRef.current !== null) {
107
+ return screenNavBarStateRef.current;
108
+ }
109
+
110
+ const navBarState = createStore();
111
+ screenNavBarStateRef.current = navBarState;
112
+
113
+ return navBarState;
114
+ }, []);
115
+
116
+ const screenNavBarState = getScreenNavBarState()(
117
+ useShallow((state) => ({
118
+ visible: state.visible,
119
+ title: state.title,
120
+ summary: state.summary,
121
+ setTitle: state.setTitle,
122
+ setSummary: state.setSummary,
123
+ setVisible: state.setVisible,
124
+ }))
125
+ );
59
126
 
60
127
  const isHook = pathname.includes("hook");
61
128
 
@@ -73,26 +140,28 @@ export function ScreenContextProvider({
73
140
  const isVisible = isNavBarVisible(
74
141
  pathname,
75
142
  currentScreenScreenData, // what fallback should be if currentScreenData is not available?
76
- navBarVisible,
143
+ screenNavBarState.visible,
77
144
  canGoBack(isHook, pathname),
78
145
  videoModalState
79
146
  );
80
147
 
81
- const navBarState = useMemo(() => {
82
- return {
83
- title: navBarTitle,
84
- summary: navBarSummary,
148
+ const navBarState = useMemo(
149
+ () => ({
150
+ title: screenNavBarState.title,
151
+ summary: screenNavBarState.summary,
85
152
  visible: isVisible,
86
- setTitle: setNavBarTitle,
87
- setSummary: setNavBarSummary,
88
- setVisible: setNavBarVisible,
89
- };
90
- }, [isVisible, navBarTitle, navBarSummary]);
153
+ setTitle: screenNavBarState.setTitle,
154
+ setSummary: screenNavBarState.setSummary,
155
+ setVisible: screenNavBarState.setVisible,
156
+ }),
157
+ [isVisible, screenNavBarState.title, screenNavBarState.summary]
158
+ );
91
159
 
92
160
  return (
93
161
  <ScreenContext.Provider
94
162
  value={useMemo(
95
163
  () => ({
164
+ _navBarStore: getScreenNavBarState(),
96
165
  navBar: navBarState,
97
166
  legacyFormatScreenData: routeScreenData,
98
167
  }),
@@ -63,7 +63,7 @@ function prepareContext(
63
63
  const parent = findParent(currentContext, route, getChildren);
64
64
 
65
65
  const newEntry = {
66
- route: route,
66
+ route,
67
67
  id: uuid(),
68
68
  data: newContext,
69
69
  } as SingleEntry;
@@ -12,11 +12,16 @@ export function withComponentsMapProvider(Component: React.ComponentType<any>) {
12
12
  };
13
13
 
14
14
  const setComponentHeightById = (id: string | number, height: number) => {
15
- componentsHeightMapRef.current = { ...componentsHeightMapRef.current, [id]: height };
15
+ componentsHeightMapRef.current = {
16
+ ...componentsHeightMapRef.current,
17
+ [id]: height,
18
+ };
16
19
  };
17
20
 
18
21
  return (
19
- <ComponentsMapProvider {...{ setComponentHeightById, getComponentHeightById }}>
22
+ <ComponentsMapProvider
23
+ {...{ setComponentHeightById, getComponentHeightById }}
24
+ >
20
25
  <Component {...props} />
21
26
  </ComponentsMapProvider>
22
27
  );
package/events/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export enum QBUIComponentEvents {
2
2
  toggleGradient = "toggleGradient",
3
3
  topMenuBarTV_onFocus = "topMenuBarTV_onFocus",
4
+ navigatorReplaceItem = "navigatorReplaceItem",
4
5
  }
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.3977160850",
3
+ "version": "12.0.0-alpha.4337072244",
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.3977160850",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.3977160850",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.3977160850",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.3977160850",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.4337072244",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4337072244",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.4337072244",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.4337072244",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",
@@ -1,64 +0,0 @@
1
- import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
4
- import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
- import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
7
- import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
8
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
-
10
- import { useScreenConfiguration } from "../../River/useScreenConfiguration";
11
-
12
- const styles = StyleSheet.create({
13
- container: {
14
- position: "absolute",
15
- top: 0,
16
- left: 0,
17
- right: 0,
18
- bottom: 0,
19
-
20
- alignItems: "center",
21
- justifyContent: "center",
22
- },
23
- });
24
-
25
- export const TransitionOverlay = () => {
26
- const screen = useCurrentScreenData();
27
-
28
- const { backgroundColor: screenBackgroundColor } = useScreenConfiguration(
29
- screen?.id
30
- );
31
-
32
- const theme = useTheme();
33
-
34
- const themeBackgroundColor = React.useMemo(
35
- () => theme.app_background_color,
36
- [theme.app_background_color]
37
- );
38
-
39
- const backgroundColor = ifEmptyUseFallback(
40
- screenBackgroundColor,
41
- themeBackgroundColor
42
- );
43
-
44
- const {
45
- appState: { isTransitioning },
46
- } = usePickFromState(["appState"]);
47
-
48
- if (!isWeb() || !isTransitioning) {
49
- return null;
50
- }
51
-
52
- return (
53
- <View
54
- style={[
55
- styles.container,
56
- {
57
- backgroundColor,
58
- },
59
- ]}
60
- >
61
- <Spinner size={"large"} />
62
- </View>
63
- );
64
- };
@@ -1,50 +0,0 @@
1
- import {
2
- useNavigation,
3
- useNavigationType,
4
- MenuTypes,
5
- useGetBottomTabBarHeight,
6
- } from "@applicaster/zapp-react-native-utils/reactHooks";
7
- import { useSafeAreaInsets } from "react-native-safe-area-context";
8
- import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
9
-
10
- import { useConfiguration } from "../utils";
11
-
12
- type Option<T> = T | undefined;
13
-
14
- type Return = {
15
- top: Option<number>;
16
- height: Option<number>;
17
- bottom: Option<number>;
18
- };
19
-
20
- export const usePosition = (): Return => {
21
- const { minimised_height: minimisedHeight } = useConfiguration();
22
- const insets = useSafeAreaInsets();
23
- const bottomTabBarHeight = useGetBottomTabBarHeight();
24
-
25
- const {
26
- videoModalState: { mode },
27
- currentRoute,
28
- screenData,
29
- } = useNavigation();
30
-
31
- const docked = mode === "MINIMIZED";
32
-
33
- const navType = useNavigationType();
34
- const isBottomBarNavigation = navType === MenuTypes.bottomTabBar;
35
-
36
- const minimisedMarginBottom =
37
- isMenuVisible(currentRoute, screenData) && isBottomBarNavigation
38
- ? bottomTabBarHeight
39
- : insets.bottom;
40
-
41
- if (docked) {
42
- return {
43
- top: undefined,
44
- height: minimisedHeight,
45
- bottom: minimisedMarginBottom,
46
- };
47
- }
48
-
49
- return { top: 0, height: undefined, bottom: 0 };
50
- };
File without changes