@applicaster/zapp-react-native-ui-components 12.0.0-alpha.9834532023 → 12.0.0-alpha.9903765553

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 (77) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +5 -5
  3. package/Components/Cell/CellWithFocusable.tsx +17 -5
  4. package/Components/FocusableGroup/index.tsx +1 -0
  5. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  6. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  7. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  8. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  9. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  10. package/Components/Layout/TV/__tests__/index.test.tsx +18 -74
  11. package/Components/Layout/TV/index.tsx +9 -105
  12. package/Components/Layout/index.tsx +1 -9
  13. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  14. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -109
  15. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  16. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  17. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  18. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
  19. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  20. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  21. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  22. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  23. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  24. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  25. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  26. package/Components/MasterCell/utils/index.ts +16 -5
  27. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  28. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  29. package/Components/Navigator/StackNavigator.tsx +48 -0
  30. package/Components/Navigator/index.ts +1 -0
  31. package/Components/PlayerContainer/PlayerContainer.tsx +18 -3
  32. package/Components/PlayerImageBackground/index.tsx +34 -8
  33. package/Components/River/ComponentsMap/ComponentsMap.tsx +92 -41
  34. package/Components/River/RefreshControl.tsx +55 -1
  35. package/Components/River/TV/River.tsx +0 -23
  36. package/Components/River/__tests__/componentsMap.test.js +6 -0
  37. package/Components/RouteManager/index.tsx +2 -2
  38. package/Components/Screen/TV/hooks/index.ts +3 -0
  39. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  40. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  41. package/Components/Screen/TV/index.web.tsx +179 -0
  42. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  43. package/Components/ScreenResolver/index.tsx +3 -1
  44. package/Components/Transitioner/Scene.tsx +24 -19
  45. package/Components/Transitioner/Transitioner.tsx +9 -2
  46. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  47. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  48. package/Components/VideoLive/LiveImageManager.ts +18 -1
  49. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +20 -5
  50. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  51. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  52. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  53. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  54. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  55. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  56. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  57. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  58. package/Components/VideoModal/PlayerDetails.tsx +3 -3
  59. package/Components/VideoModal/PlayerWrapper.tsx +77 -47
  60. package/Components/VideoModal/VideoModal.tsx +23 -40
  61. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -1
  62. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +151 -119
  63. package/Components/VideoModal/utils.ts +3 -3
  64. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  65. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  66. package/Components/Viewport/utils.js +1 -1
  67. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  68. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  69. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  70. package/Contexts/ScreenContext/index.tsx +100 -25
  71. package/Contexts/ScreenDataContext/index.ts +3 -0
  72. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  73. package/events/index.ts +1 -0
  74. package/package.json +5 -5
  75. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  76. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  77. /package/Contexts/{index.js → index.ts} +0 -0
@@ -1,4 +1,11 @@
1
- import React, { createContext, ReactNode, useMemo, useState } from "react";
1
+ import React, {
2
+ createContext,
3
+ ReactNode,
4
+ useCallback,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ } from "react";
2
9
  import {
3
10
  useCurrentScreenData,
4
11
  useNavigation,
@@ -7,27 +14,67 @@ import {
7
14
  } from "@applicaster/zapp-react-native-utils/reactHooks";
8
15
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
9
16
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
17
+ import { create, StoreApi, UseBoundStore } from "zustand";
18
+ import { useShallow } from "zustand/react/shallow";
19
+ import { Animated } from "react-native";
20
+
21
+ interface NavBarStoreState {
22
+ visible: boolean;
23
+ title: string;
24
+ summary: string;
25
+ setVisible: (state: boolean) => void;
26
+ setTitle: (title: string) => void;
27
+ setSummary: (subtitle: string) => void;
28
+ height: number;
29
+ scrollState: number;
30
+ contentPosition: string;
31
+ scrollYAnimated: Animated.Value;
32
+ }
33
+
34
+ interface NavBarState {
35
+ visible: boolean;
36
+ title: string;
37
+ summary: string;
38
+ setVisible: (state: boolean) => void;
39
+ setTitle: (title: string) => void;
40
+ setSummary: (subtitle: string) => void;
41
+ }
10
42
 
11
43
  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
- };
44
+ _navBarStore: UseBoundStore<StoreApi<NavBarStoreState>>;
45
+ navBar: NavBarState;
20
46
  legacyFormatScreenData: LegacyNavigationScreenData | null;
21
47
  };
22
48
 
49
+ const createStore = () =>
50
+ create<NavBarStoreState>((set) => ({
51
+ title: "",
52
+ summary: "",
53
+ visible: true,
54
+ height: 0,
55
+ scrollState: 0,
56
+ contentPosition: "",
57
+ scrollYAnimated: new Animated.Value(0),
58
+ setTitle(title) {
59
+ set({ title });
60
+ },
61
+ setSummary(summary) {
62
+ set({ summary });
63
+ },
64
+ setVisible(visible) {
65
+ set({ visible });
66
+ },
67
+ }));
68
+
23
69
  export const ScreenContext = createContext<ScreenContextType>({
70
+ _navBarStore: createStore(),
24
71
  navBar: {
25
72
  visible: true,
26
73
  title: "",
27
74
  summary: "",
28
- setVisible: (_state) => {},
29
- setTitle: (_title) => {},
30
- setSummary: (_subtitle) => {},
75
+ setVisible: (_state) => void 0,
76
+ setTitle: (_title) => void 0,
77
+ setSummary: (_subtitle) => void 0,
31
78
  },
32
79
  legacyFormatScreenData: {} as LegacyNavigationScreenData,
33
80
  });
@@ -53,9 +100,35 @@ export function ScreenContextProvider({
53
100
  const isNested = useNestedNavigationContext();
54
101
  const currentScreenScreenData = useCurrentScreenData();
55
102
 
56
- const [navBarTitle, setNavBarTitle] = useState("");
57
- const [navBarSummary, setNavBarSummary] = useState("");
58
- const [navBarVisible, setNavBarVisible] = useState(true);
103
+ const screenNavBarStateRef =
104
+ useRef<null | ReturnType<typeof createStore>>(null);
105
+
106
+ const getScreenNavBarState = useCallback(() => {
107
+ if (screenNavBarStateRef.current !== null) {
108
+ return screenNavBarStateRef.current;
109
+ }
110
+
111
+ const navBarState = createStore();
112
+ screenNavBarStateRef.current = navBarState;
113
+
114
+ return navBarState;
115
+ }, []);
116
+
117
+ useEffect(() => {
118
+ // purge the getScreenNavBarState store when the pathname changes
119
+ screenNavBarStateRef.current = null;
120
+ }, [pathname]);
121
+
122
+ const screenNavBarState = getScreenNavBarState()(
123
+ useShallow((state) => ({
124
+ visible: state.visible,
125
+ title: state.title,
126
+ summary: state.summary,
127
+ setTitle: state.setTitle,
128
+ setSummary: state.setSummary,
129
+ setVisible: state.setVisible,
130
+ }))
131
+ );
59
132
 
60
133
  const isHook = pathname.includes("hook");
61
134
 
@@ -73,26 +146,28 @@ export function ScreenContextProvider({
73
146
  const isVisible = isNavBarVisible(
74
147
  pathname,
75
148
  currentScreenScreenData, // what fallback should be if currentScreenData is not available?
76
- navBarVisible,
149
+ screenNavBarState.visible,
77
150
  canGoBack(isHook, pathname),
78
151
  videoModalState
79
152
  );
80
153
 
81
- const navBarState = useMemo(() => {
82
- return {
83
- title: navBarTitle,
84
- summary: navBarSummary,
154
+ const navBarState = useMemo(
155
+ () => ({
156
+ title: screenNavBarState.title,
157
+ summary: screenNavBarState.summary,
85
158
  visible: isVisible,
86
- setTitle: setNavBarTitle,
87
- setSummary: setNavBarSummary,
88
- setVisible: setNavBarVisible,
89
- };
90
- }, [isVisible, navBarTitle, navBarSummary]);
159
+ setTitle: screenNavBarState.setTitle,
160
+ setSummary: screenNavBarState.setSummary,
161
+ setVisible: screenNavBarState.setVisible,
162
+ }),
163
+ [isVisible, screenNavBarState.title, screenNavBarState.summary]
164
+ );
91
165
 
92
166
  return (
93
167
  <ScreenContext.Provider
94
168
  value={useMemo(
95
169
  () => ({
170
+ _navBarStore: getScreenNavBarState(),
96
171
  navBar: navBarState,
97
172
  legacyFormatScreenData: routeScreenData,
98
173
  }),
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+
3
+ export const ScreenDataContext = React.createContext<any>(null);
@@ -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;
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.9834532023",
3
+ "version": "12.0.0-alpha.9903765553",
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.9834532023",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.9834532023",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.9834532023",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.9834532023",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.9903765553",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.9903765553",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.9903765553",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.9903765553",
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