@applicaster/zapp-react-native-ui-components 12.0.0-rc.111 → 12.0.0-rc.113

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.
@@ -128,7 +128,7 @@ export const BorderContainerView = (props: Props) => {
128
128
  : {};
129
129
 
130
130
  return (
131
- <View {...props} style={[style, styles.container]}>
131
+ <View {...props} style={[style, styles.container]} pointerEvents="box-none">
132
132
  <Border style={style} padding={padding} borderPosition={borderPosition} />
133
133
  {children}
134
134
  </View>
@@ -5,6 +5,7 @@ import * as R from "ramda";
5
5
 
6
6
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
7
7
  import { normalizeProgressValue } from "./utils";
8
+ import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
8
9
 
9
10
  const ACTION_NAME = "continue-watching";
10
11
  const DEFAULT_FILL = 0;
@@ -27,6 +28,7 @@ const getProgressValue = (
27
28
 
28
29
  export const useFillInPercent = (entry: ZappEntry): number => {
29
30
  const action = useActions(ACTION_NAME);
31
+ const isActive = useIsScreenActive();
30
32
 
31
33
  const [fillInPercent, setFillInPercent] =
32
34
  React.useState<number>(DEFAULT_FILL);
@@ -39,6 +41,10 @@ export const useFillInPercent = (entry: ZappEntry): number => {
39
41
  }, []);
40
42
 
41
43
  React.useEffect(() => {
44
+ if (!isActive) {
45
+ return;
46
+ }
47
+
42
48
  // refresh progress in UI when it was changed in CW
43
49
  const unsubscribe = action?.addDataSourceListener?.(() => {
44
50
  getProgressValue(action, entry, (progress) => {
@@ -49,7 +55,7 @@ export const useFillInPercent = (entry: ZappEntry): number => {
49
55
  return () => {
50
56
  unsubscribe?.();
51
57
  };
52
- }, []);
58
+ }, [isActive]);
53
59
 
54
60
  return fillInPercent;
55
61
  };
@@ -99,14 +99,6 @@ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
99
99
  }),
100
100
  }));
101
101
 
102
- const {
103
- ORIENTATIONS,
104
- } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
105
-
106
- const {
107
- useCurrentScreenData,
108
- } = require("@applicaster/zapp-react-native-utils/reactHooks/screen");
109
-
110
102
  const {
111
103
  allowedOrientationsForScreen,
112
104
  getOrientation,
@@ -158,45 +150,4 @@ describe("<Screen Component />", () => {
158
150
  expect(wrapper.toJSON()).toMatchSnapshot();
159
151
  });
160
152
  });
161
-
162
- it("invokes the orientation hook when the route changes", () => {
163
- act(() => {
164
- wrapper = create(<Screen {...screenProps} />);
165
- });
166
-
167
- // @ts-ignore
168
- useCurrentScreenData.mockReturnValue({
169
- id: "player-testId",
170
- general: { screen_orientation: ORIENTATIONS.landscapeSensor },
171
- plugin_type: "player",
172
- });
173
-
174
- act(() => {
175
- wrapper.update(
176
- <Screen
177
- {...screenProps}
178
- pathname="/playable"
179
- screenData={{
180
- id: "player-testId",
181
- general: { screen_orientation: ORIENTATIONS.landscapeSensor },
182
- plugin_type: "player",
183
- }}
184
- />
185
- );
186
- });
187
-
188
- useCurrentScreenData.mockReturnValue({
189
- id: "player-testId",
190
- general: { screen_orientation: ORIENTATIONS.landscapeSensor },
191
- });
192
-
193
- act(() => {
194
- wrapper.update(<Screen {...screenProps} />);
195
- });
196
-
197
- expect(allowedOrientationsForScreen).toHaveBeenNthCalledWith(
198
- 1,
199
- ORIENTATIONS.landscapeSensor
200
- );
201
- });
202
153
  });
@@ -1,6 +1,5 @@
1
1
  /// <reference types="@applicaster/applicaster-types" />
2
2
  import React from "react";
3
- import * as R from "ramda";
4
3
  import { View } from "react-native";
5
4
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
5
  import {
@@ -27,7 +26,7 @@ import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/Ap
27
26
 
28
27
  import { RouteManager } from "../RouteManager";
29
28
  import { useScreenConfiguration } from "../River/useScreenConfiguration";
30
- import { useScreenOrientationHandler } from "./orientationHandler";
29
+ import { isValidColor } from "./utils";
31
30
 
32
31
  const screenStyles = {
33
32
  flex: 1,
@@ -37,21 +36,6 @@ const screenStyles = {
37
36
  // paddingRight: insets.right, // Should be applied directly by UI plugin
38
37
  };
39
38
 
40
- function colorIsNotTransparent(color) {
41
- const layers = R.compose(
42
- R.map(R.trim),
43
- R.split(","),
44
- R.replace(")", ""),
45
- R.replace("rgba(", "")
46
- )(color);
47
-
48
- return Number(layers?.[3]) > 0;
49
- }
50
-
51
- function isValidColor(string) {
52
- return string && string !== "transparent" && colorIsNotTransparent(string);
53
- }
54
-
55
39
  type Props = {
56
40
  pathname: unknown;
57
41
  screenData: unknown;
@@ -127,8 +111,6 @@ export function Screen(_props: Props) {
127
111
  const targetScreenData =
128
112
  currentScreenData || (screenData as any)?.targetScreen || screenData;
129
113
 
130
- useScreenOrientationHandler({ screenData: targetScreenData });
131
-
132
114
  const orientation = useGetScreenOrientation(targetScreenData);
133
115
 
134
116
  // We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
@@ -26,9 +26,7 @@ export function isMenuVisible(route, screenData) {
26
26
  if (screenData?.hookPlugin) {
27
27
  const hookPlugin = screenData?.hookPlugin?.module;
28
28
 
29
- return (
30
- hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true || false
31
- );
29
+ return hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true;
32
30
  }
33
31
 
34
32
  if (
@@ -1,14 +1,16 @@
1
1
  import React, { useLayoutEffect } from "react";
2
+
2
3
  import {
3
4
  allowedOrientationsForScreen,
4
5
  ORIENTATIONS,
5
6
  getOrientation,
6
7
  useGetScreenOrientation,
7
8
  } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
8
-
9
+ import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
9
10
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
10
11
  import { findPluginByType } from "@applicaster/zapp-react-native-utils/pluginUtils";
11
12
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
13
+
12
14
  import { ZappHookModalContext } from "../../Contexts";
13
15
  import { HookModalContextT } from "../../Contexts/ZappHookModalContext";
14
16
 
@@ -79,14 +81,23 @@ export function useNewOrientationForScreenData({
79
81
  screenOrientation;
80
82
  }
81
83
 
82
- export function useScreenOrientationHandler({
83
- screenData,
84
- }: OrientationHookArgs) {
84
+ type Props = {
85
+ screenData: {
86
+ screen: {};
87
+ };
88
+ isActive: boolean;
89
+ };
90
+
91
+ export function useScreenOrientationHandler({ screenData, isActive }: Props) {
85
92
  const { isHooksExecutionInProgress } = React.useContext<HookModalContextT>(
86
93
  ZappHookModalContext.ReactContext
87
94
  );
88
95
 
89
- const newOrientation = useNewOrientationForScreenData({ screenData });
96
+ const prevIsActive = usePrevious(isActive);
97
+
98
+ const newOrientation = useNewOrientationForScreenData({
99
+ screenData: screenData.screen,
100
+ });
90
101
 
91
102
  useLayoutEffect(() => {
92
103
  // Null means screen does not have orientation preference, so we can skip rotate
@@ -100,12 +111,12 @@ export function useScreenOrientationHandler({
100
111
  return;
101
112
  }
102
113
 
103
- if (newOrientation !== current) {
114
+ if (!prevIsActive && isActive && newOrientation !== current) {
104
115
  current = newOrientation;
105
116
 
106
117
  setOrientation(newOrientation);
107
118
  }
108
- }, [newOrientation, isHooksExecutionInProgress]);
119
+ }, [newOrientation, isHooksExecutionInProgress, prevIsActive, isActive]);
109
120
  }
110
121
 
111
122
  export function useOrientationHandler({ screenData }: OrientationHookArgs) {
@@ -0,0 +1,16 @@
1
+ import { map, split, replace, compose, trim } from "ramda";
2
+
3
+ function colorIsNotTransparent(color) {
4
+ const layers = compose(
5
+ map(trim),
6
+ split(","),
7
+ replace(")", ""),
8
+ replace("rgba(", "")
9
+ )(color);
10
+
11
+ return Number(layers?.[3]) > 0;
12
+ }
13
+
14
+ export function isValidColor(string) {
15
+ return string && string !== "transparent" && colorIsNotTransparent(string);
16
+ }
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  import { Animated, ViewProps, ViewStyle } from "react-native";
3
3
  import { useSafeAreaFrame } from "react-native-safe-area-context";
4
+
5
+ import { useScreenOrientationHandler } from "@applicaster/zapp-react-native-ui-components/Components/Screen/orientationHandler";
6
+
4
7
  import { PathnameContext } from "../../Contexts/PathnameContext";
5
8
  import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
6
9
  import { ScreenContextProvider } from "../../Contexts/ScreenContext";
@@ -42,6 +45,11 @@ export function Scene({
42
45
  }: Props) {
43
46
  const [initialScreenData, setInitialScreenData] = React.useState(screenData);
44
47
 
48
+ useScreenOrientationHandler({
49
+ screenData,
50
+ isActive,
51
+ });
52
+
45
53
  React.useLayoutEffect(() => {
46
54
  if (isActive) {
47
55
  setInitialScreenData(screenData);
@@ -49,13 +57,12 @@ export function Scene({
49
57
  }, [screenData, isActive]);
50
58
 
51
59
  const frame = useSafeAreaFrame();
52
-
53
60
  const isAnimating = animating && overlayStyle;
54
61
 
55
62
  const dimensions = isAnimating
56
63
  ? {
57
- height: "100%",
58
64
  width: "100%",
65
+ height: "100%",
59
66
  }
60
67
  : frame;
61
68
 
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import * as R from "ramda";
3
+ import { update, compose, tail, append, take, identity } from "ramda";
4
4
 
5
5
  import { AnimationManager } from "./AnimationManager";
6
6
  import { Scene } from "./Scene";
@@ -46,7 +46,7 @@ function prepareScene(children) {
46
46
  */
47
47
  function scenesForBackTransition(props: SceneProps, { scenes }) {
48
48
  return scenes.length > 1
49
- ? R.identity(scenes)
49
+ ? identity(scenes)
50
50
  : [prepareScene(props.children), scenes[0]];
51
51
  }
52
52
 
@@ -110,7 +110,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
110
110
  pushTransitionStart() {
111
111
  this.setState(
112
112
  {
113
- scenes: R.append(prepareScene(this.props.children), this.state.scenes),
113
+ scenes: append(prepareScene(this.props.children), this.state.scenes),
114
114
  ...this.animationManager.stateForAction(this.state, NAV_ACTION_PUSH),
115
115
  },
116
116
  () => {
@@ -177,10 +177,10 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
177
177
  to: { index: 0 },
178
178
  };
179
179
  } else if (isLastSceneHook || scenes.length === 1) {
180
- newState = { scenes: R.update(scenes.length - 1, newScene, scenes) };
180
+ newState = { scenes: update(scenes.length - 1, newScene, scenes) };
181
181
  } else {
182
182
  newState = {
183
- scenes: R.compose(R.tail, R.append(newScene))(scenes),
183
+ scenes: compose(tail, append(newScene))(scenes),
184
184
  };
185
185
  }
186
186
 
@@ -225,7 +225,10 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
225
225
  this.shouldSkipAnimationForRoute(previousRoute) ||
226
226
  this.shouldSkipAnimationForRoute(currentRoute)
227
227
  ) {
228
- return this.transitionWithoutAnimation();
228
+ // we are going back, in this case we need to have only one scene using resetState
229
+ const resetState = isGoingBack ? true : undefined;
230
+
231
+ return this.transitionWithoutAnimation(resetState);
229
232
  }
230
233
 
231
234
  switch (this.props.navigator.previousAction) {
@@ -268,7 +271,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
268
271
  backTransitionEnd(stepsBack) {
269
272
  this.setState({
270
273
  animating: false,
271
- scenes: R.take(this.state.scenes.length - stepsBack, this.state.scenes),
274
+ scenes: take(this.state.scenes.length - stepsBack, this.state.scenes),
272
275
  });
273
276
  }
274
277
 
@@ -284,7 +287,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
284
287
  <View style={styles.container}>
285
288
  {scenes[to.index] && (
286
289
  <Scene
287
- {...{ style: to.style }}
290
+ {...{ style: to?.style || {} }}
288
291
  pathname={pathname}
289
292
  isActive={pathname === this.props.navigator.currentRoute}
290
293
  contentStyle={contentStyle}
@@ -16,6 +16,13 @@ jest.mock("react-native-safe-area-context", () => ({
16
16
  })),
17
17
  }));
18
18
 
19
+ jest.mock(
20
+ "@applicaster/zapp-react-native-ui-components/Components/Screen/orientationHandler",
21
+ () => ({
22
+ useScreenOrientationHandler: jest.fn(),
23
+ })
24
+ );
25
+
19
26
  const { Scene } = require("../Scene");
20
27
 
21
28
  const wrapper = shallow(
@@ -12,6 +12,7 @@ exports[`<TransitionerComponent /> renders correctly 1`] = `
12
12
  <Scene
13
13
  isActive={true}
14
14
  screenUniqueId="mocked-uuid"
15
+ style={Object {}}
15
16
  >
16
17
  <View
17
18
  foo="bar"
@@ -200,7 +200,23 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
200
200
  videoModalState.mode === "MINIMIZED" &&
201
201
  videoModalState.previousMode === "MAXIMIZED"
202
202
  ) {
203
- resetPlayerAnimationState();
203
+ // set animation to the minimize values if moving from the player to another screen
204
+ if (playerAnimationState === null) {
205
+ setScrollModalAnimatedValue(
206
+ translateYOffset,
207
+ modalSnapPoints[1],
208
+ setLastSnap
209
+ );
210
+
211
+ resetScrollAnimatedValues(
212
+ lastScrollY,
213
+ lastScrollYValue,
214
+ dragScrollY,
215
+ dragVideoPlayerY
216
+ );
217
+ } else {
218
+ resetPlayerAnimationState();
219
+ }
204
220
  }
205
221
 
206
222
  if (
@@ -309,6 +309,23 @@ export const AnimationView = ({
309
309
  }
310
310
  }, [additionalData, screenWidth]);
311
311
 
312
+ React.useEffect(() => {
313
+ if (
314
+ videoModalState.mode === "MINIMIZED" &&
315
+ videoModalState.previousMode === "MAXIMIZED"
316
+ ) {
317
+ // set animation to the minimize values if moving from the player to another screen
318
+ if (playerAnimationState === null) {
319
+ const value = getAnimationValue(
320
+ animationType,
321
+ PlayerAnimationStateEnum.minimize
322
+ ).toValue;
323
+
324
+ animatedValue.setValue(value);
325
+ }
326
+ }
327
+ }, [videoModalState]);
328
+
312
329
  React.useEffect(() => {
313
330
  if (
314
331
  playerAnimationState === PlayerAnimationStateEnum.minimize &&
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.0-rc.111",
3
+ "version": "12.0.0-rc.113",
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-rc.111",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.111",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.111",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.111",
37
+ "@applicaster/applicaster-types": "12.0.0-rc.113",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-rc.113",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-rc.113",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-rc.113",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",