@applicaster/zapp-react-native-ui-components 14.0.17 → 14.0.18-alpha.5740764222

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.
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`componentsMap renders renders components map correctly 1`] = `
3
+ exports[`componentsMap renders components map correctly 1`] = `
4
4
  <View
5
5
  style={
6
6
  {
@@ -13,6 +13,7 @@ jest.mock(
13
13
 
14
14
  jest.mock("react-native-safe-area-context", () => ({
15
15
  useSafeAreaInsets: () => ({ top: 50 }),
16
+ useSafeAreaFrame: () => ({ x: 0, y: 0, width: 375, height: 812 }),
16
17
  }));
17
18
 
18
19
  jest.mock("react-native", () => {
@@ -177,7 +178,7 @@ describe("componentsMap", () => {
177
178
  cleanup();
178
179
  });
179
180
 
180
- it("renders renders components map correctly", () => {
181
+ it("renders components map correctly", () => {
181
182
  themeSpy = jest
182
183
  .spyOn(themeUtils, "useTheme")
183
184
  .mockImplementation(() => () => theme);
@@ -99,9 +99,14 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
99
99
  useCurrentScreenData: jest.fn(() => ({
100
100
  id: "testId",
101
101
  })),
102
+ useIsScreenActive: jest.fn(() => true),
102
103
  useNavbarState: jest.fn(() => ({
103
104
  title: "Test Title",
104
105
  })),
106
+ useRoute: jest.fn(() => ({
107
+ pathname: "/river/testId",
108
+ screenData: { id: "testId" },
109
+ })),
105
110
  useScreenData: jest.fn(() => ({
106
111
  id: "testId",
107
112
  navigations: [{ id: "testId", category: "nav_bar" }],
@@ -125,7 +130,11 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => {
125
130
  identifier: "offline-experience",
126
131
  type: "general",
127
132
  module: {
128
- OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
133
+ OfflineFallbackScreen: ({
134
+ children,
135
+ }: {
136
+ children: React.ReactNode;
137
+ }) => <View>{children}</View>, // eslint-disable-line
129
138
  },
130
139
  },
131
140
  ],
@@ -160,14 +169,14 @@ describe("<Screen Component />", () => {
160
169
  });
161
170
 
162
171
  describe("when the navbar should show", () => {
163
- it("renders correctly", () => {
172
+ it("renders correctly with navbar", () => {
164
173
  const { toJSON } = render(<Screen {...screenProps} />);
165
174
  expect(toJSON()).toMatchSnapshot();
166
175
  });
167
176
  });
168
177
 
169
178
  describe("when the navbar should be hidden", () => {
170
- it("renders correctly", () => {
179
+ it("renders correctly without navbar", () => {
171
180
  const { toJSON } = render(<Screen {...screenProps} />);
172
181
  expect(toJSON()).toMatchSnapshot();
173
182
  });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
3
+ exports[`<Screen Component /> when the navbar should be hidden renders correctly without navbar 1`] = `
4
4
  <View
5
5
  importantForAccessibility="yes"
6
6
  style={
@@ -33,7 +33,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
33
33
  </View>
34
34
  `;
35
35
 
36
- exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
36
+ exports[`<Screen Component /> when the navbar should show renders correctly with navbar 1`] = `
37
37
  <View
38
38
  importantForAccessibility="yes"
39
39
  style={
@@ -117,7 +117,7 @@ export const useWaitForValidOrientation = () => {
117
117
  if (isReadyForDisplay && !readyState) {
118
118
  setReadyState(true);
119
119
  }
120
- }, [readyState, orientation, layoutData]);
120
+ }, [readyState, orientation, layoutData, isReadyForDisplay]);
121
121
 
122
122
  return readyState;
123
123
  };
@@ -4,6 +4,13 @@ import { Animated, ViewProps, ViewStyle } from "react-native";
4
4
 
5
5
  import { useScreenOrientationHandler } from "@applicaster/zapp-react-native-ui-components/Components/Screen/orientationHandler";
6
6
  import { useMemoizedSafeAreaFrameWithActiveState } from "@applicaster/zapp-react-native-ui-components/Components/Screen/hooks";
7
+ import {
8
+ getScreenOrientation,
9
+ isOrientationCompatible,
10
+ } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
11
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
12
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
13
+ import { useSafeAreaFrame } from "react-native-safe-area-context";
7
14
 
8
15
  import { PathnameContext } from "../../Contexts/PathnameContext";
9
16
  import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
@@ -14,6 +21,55 @@ const fullWidthDimensions = {
14
21
  width: "100%",
15
22
  };
16
23
 
24
+ function useSceneDimensions({
25
+ screenData,
26
+ isActive,
27
+ animating,
28
+ overlayStyle,
29
+ }: {
30
+ screenData: NavigationScreenData;
31
+ isActive: boolean;
32
+ animating: boolean;
33
+ overlayStyle: ViewStyle;
34
+ }) {
35
+ const rawFrame = useSafeAreaFrame();
36
+ const isTablet = useIsTablet();
37
+ const { appData } = usePickFromState(["appData"]);
38
+ const isTabletPortrait = appData?.isTabletPortrait;
39
+
40
+ const orientation = getScreenOrientation({
41
+ screenData,
42
+ layoutData: { isTablet, isTabletPortrait },
43
+ });
44
+
45
+ const isFrameOrientationValid = isOrientationCompatible({
46
+ orientation,
47
+ layoutData: {
48
+ isTablet,
49
+ isTabletPortrait,
50
+ width: rawFrame.width,
51
+ height: rawFrame.height,
52
+ },
53
+ });
54
+
55
+ const memoFrame = useMemoizedSafeAreaFrameWithActiveState({
56
+ updateForInactiveScreens: false,
57
+ isActive: isActive && isFrameOrientationValid,
58
+ });
59
+
60
+ const isAnimating = animating && overlayStyle;
61
+
62
+ // When orientation is in transition (frame doesn't match target orientation),
63
+ // use fullWidthDimensions so the scene fills its container rather than
64
+ // rendering with stale dimensions (e.g. portrait dims on a landscape player)
65
+ const isOrientationTransitioning = isActive && !isFrameOrientationValid;
66
+
67
+ const dimensions =
68
+ isAnimating || isOrientationTransitioning ? fullWidthDimensions : memoFrame;
69
+
70
+ return dimensions;
71
+ }
72
+
17
73
  type Props = {
18
74
  children: any;
19
75
  style: any;
@@ -94,18 +150,15 @@ function SceneComponent({
94
150
  isActive,
95
151
  });
96
152
 
97
- // Use shared memoized frame hook - synchronized with useWaitForValidOrientation
98
- // to prevent race conditions during orientation changes
99
- // Pass isActive from props since Scene knows its active state from Transitioner
100
- const memoFrame = useMemoizedSafeAreaFrameWithActiveState({
101
- updateForInactiveScreens: false,
153
+ const dimensions = useSceneDimensions({
154
+ screenData,
102
155
  isActive,
156
+ animating,
157
+ overlayStyle,
103
158
  });
104
159
 
105
160
  const isAnimating = animating && overlayStyle;
106
161
 
107
- const dimensions = isAnimating ? fullWidthDimensions : memoFrame;
108
-
109
162
  return (
110
163
  <Animated.View
111
164
  pointerEvents={pointerEvents}
@@ -24,6 +24,23 @@ jest.mock(
24
24
  })
25
25
  );
26
26
 
27
+ jest.mock(
28
+ "@applicaster/zapp-react-native-utils/appUtils/orientationHelper",
29
+ () => ({
30
+ getScreenOrientation: jest.fn(() => 1),
31
+ isOrientationCompatible: jest.fn(() => true),
32
+ })
33
+ );
34
+
35
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
36
+ useIsTablet: jest.fn(() => false),
37
+ useRoute: jest.fn(() => ({ screenData: {} })),
38
+ }));
39
+
40
+ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
41
+ usePickFromState: jest.fn(() => ({ appData: {} })),
42
+ }));
43
+
27
44
  jest.mock("../../../Contexts/PathnameContext", () => ({
28
45
  PathnameContext: jest.requireActual("react").createContext({ pathname: "" }),
29
46
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.17",
3
+ "version": "14.0.18-alpha.5740764222",
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.17",
32
- "@applicaster/zapp-react-native-bridge": "14.0.17",
33
- "@applicaster/zapp-react-native-redux": "14.0.17",
34
- "@applicaster/zapp-react-native-utils": "14.0.17",
31
+ "@applicaster/applicaster-types": "14.0.18-alpha.5740764222",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.18-alpha.5740764222",
33
+ "@applicaster/zapp-react-native-redux": "14.0.18-alpha.5740764222",
34
+ "@applicaster/zapp-react-native-utils": "14.0.18-alpha.5740764222",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",