@applicaster/zapp-react-native-ui-components 12.0.0-rc.131 → 12.0.0-rc.133

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,7 @@
1
1
  import * as React from "react";
2
2
  import { isEqual } from "@applicaster/zapp-react-native-utils/equalUtils";
3
3
  import { useFocusable } from "../Focusable/index.android";
4
+ import { useCellState } from "./hooks/useCellState.android";
4
5
 
5
6
  /**
6
7
  * returns parent focus from prop or from context
@@ -29,7 +30,8 @@ const useParentFocus = (
29
30
  );
30
31
 
31
32
  function FocusableChildComponent(props) {
32
- const { setIsFocusable, focused, ...focusableContext } = useFocusable();
33
+ const { setIsFocusable, ...focusableContext } = useFocusable();
34
+ const focused = useCellState(props.id);
33
35
 
34
36
  const parentFocus = useParentFocus(props, focusableContext);
35
37
 
@@ -53,10 +53,9 @@ function resolveColorForProp(entry, style, colorProp) {
53
53
  const colorFromProp = style[colorProp];
54
54
  const nestedEntryValue = R.path(colorFromProp.split("."), entry);
55
55
 
56
- if (
57
- nestedEntryValue === undefined &&
58
- !validateColor(colorFromProp.replace(".00", "")) // https://github.com/dreamyguy/validate-color/issues/44
59
- ) {
56
+ const color = colorFromProp.replace(".00", "").replace(".0", ""); // https://github.com/dreamyguy/validate-color/issues/44
57
+
58
+ if (nestedEntryValue === undefined && !validateColor(color)) {
60
59
  logWarning(colorFromProp, style, entry, nestedEntryValue);
61
60
  }
62
61
 
@@ -45,15 +45,9 @@ export const AnimatedPlayerModalWrapper = (props: Props) => {
45
45
  }
46
46
 
47
47
  React.useEffect(() => {
48
- const translateYListener = translateY.addListener(() => {
49
- (playerAnimationState === PlayerAnimationStateEnum.minimize ||
50
- playerAnimationState === PlayerAnimationStateEnum.maximaze) &&
51
- setStartComponentsAnimation(true);
52
- });
53
-
54
- return () => {
55
- translateYListener && translateY.removeListener(translateYListener);
56
- };
48
+ (playerAnimationState === PlayerAnimationStateEnum.minimize ||
49
+ playerAnimationState === PlayerAnimationStateEnum.maximaze) &&
50
+ setStartComponentsAnimation(true);
57
51
  }, [playerAnimationState]);
58
52
 
59
53
  return (
@@ -66,9 +66,10 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
66
66
  const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
67
67
  useNavigation();
68
68
 
69
- const isMaximazedModal = videoModalState.mode === "MAXIMIZED";
70
- const isMinimizedModal = videoModalState.mode === "MINIMIZED";
71
- const previousItemId = usePrevious(videoModalState.item?.id);
69
+ const { mode: videoModalMode, item: videoModalItem } = videoModalState;
70
+ const isMaximazedModal = videoModalMode === "MAXIMIZED";
71
+ const isMinimizedModal = videoModalMode === "MINIMIZED";
72
+ const previousItemId = usePrevious(videoModalItem?.id);
72
73
 
73
74
  const isNotMinimizeMaximazeAnimation =
74
75
  playerAnimationState !== PlayerAnimationStateEnum.minimize &&
@@ -81,9 +82,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
81
82
 
82
83
  const isAudioItem = React.useMemo(
83
84
  () =>
84
- videoModalState.item?.content?.type?.includes?.("audio") ||
85
- videoModalState.item?.type?.value === "audio",
86
- [videoModalState.item]
85
+ videoModalItem?.content?.type?.includes?.("audio") ||
86
+ videoModalItem?.type?.value === "audio",
87
+ [videoModalItem]
87
88
  );
88
89
 
89
90
  // Refs for components
@@ -114,7 +115,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
114
115
  const preparedTranslationY =
115
116
  Math.abs(translationY) - lastScrollYValue.current;
116
117
 
117
- if (videoModalState.mode === "MAXIMIZED") {
118
+ if (videoModalMode === "MAXIMIZED") {
118
119
  const endOffsetY =
119
120
  lastSnap + preparedTranslationY + dragToss * velocityY + 150;
120
121
 
@@ -161,7 +162,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
161
162
  resetPlayerAnimationState();
162
163
  }
163
164
  },
164
- [lastSnap, modalSnapPoints, playerAnimationState, videoModalState.mode]
165
+ [lastSnap, modalSnapPoints, playerAnimationState, videoModalMode]
165
166
  );
166
167
 
167
168
  const onScroll = React.useCallback(({ nativeEvent }) => {
@@ -196,10 +197,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
196
197
  }, []);
197
198
 
198
199
  React.useEffect(() => {
199
- if (
200
- videoModalState.mode === "MINIMIZED" &&
201
- videoModalState.previousMode === "MAXIMIZED"
202
- ) {
200
+ const { mode, previousMode, item } = videoModalState;
201
+
202
+ if (mode === "MINIMIZED" && previousMode === "MAXIMIZED") {
203
203
  // set animation to the minimize values if moving from the player to another screen
204
204
  if (playerAnimationState === null) {
205
205
  setScrollModalAnimatedValue(
@@ -214,22 +214,17 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
214
214
  dragScrollY,
215
215
  dragVideoPlayerY
216
216
  );
217
- } else {
218
- resetPlayerAnimationState();
219
217
  }
220
- }
221
-
222
- if (
223
- (videoModalState.mode === "MAXIMIZED" &&
224
- videoModalState.previousMode === "MINIMIZED" &&
225
- previousItemId === videoModalState.item?.id) ||
226
- (previousItemId !== videoModalState.item?.id &&
227
- videoModalState.mode !== "FULLSCREEN")
218
+ } else if (
219
+ playerAnimationState === null &&
220
+ ((previousItemId === item?.id &&
221
+ mode === "MAXIMIZED" &&
222
+ (previousMode === "MINIMIZED" || previousMode === "MAXIMIZED")) ||
223
+ (previousItemId !== item?.id && mode !== "FULLSCREEN"))
228
224
  ) {
229
225
  setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
230
- setTimeout(() => resetPlayerAnimationState());
231
226
  }
232
- }, [videoModalState, previousItemId]);
227
+ }, [videoModalState]);
233
228
 
234
229
  React.useEffect(() => {
235
230
  if (playerAnimationState === PlayerAnimationStateEnum.minimize) {
@@ -254,22 +249,22 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
254
249
  translateYOffset,
255
250
  getAnimatedConfig(modalSnapPoints[1])
256
251
  ).start(() => {
257
- setTimeout(() => {
258
- minimiseVideoModal();
259
-
260
- setScrollModalAnimatedValue(
261
- translateYOffset,
262
- modalSnapPoints[1],
263
- setLastSnap
264
- );
265
-
266
- resetScrollAnimatedValues(
267
- lastScrollY,
268
- lastScrollYValue,
269
- dragScrollY,
270
- dragVideoPlayerY
271
- );
272
- }, 150);
252
+ minimiseVideoModal();
253
+
254
+ setScrollModalAnimatedValue(
255
+ translateYOffset,
256
+ modalSnapPoints[1],
257
+ setLastSnap
258
+ );
259
+
260
+ resetScrollAnimatedValues(
261
+ lastScrollY,
262
+ lastScrollYValue,
263
+ dragScrollY,
264
+ dragVideoPlayerY
265
+ );
266
+
267
+ resetPlayerAnimationState();
273
268
  });
274
269
  } else if (playerAnimationState === PlayerAnimationStateEnum.maximaze) {
275
270
  Animated.timing(translateYOffset, getAnimatedConfig(0)).start(() => {
@@ -286,7 +281,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
286
281
  resetPlayerAnimationState();
287
282
  });
288
283
  }
284
+ }, [playerAnimationState]);
289
285
 
286
+ React.useEffect(() => {
290
287
  const lastScrollYListenerId = lastScrollY.addListener(({ value }) => {
291
288
  lastScrollYValue.current = value;
292
289
  });
@@ -312,7 +309,7 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
312
309
  lastScrollY.removeListener(lastScrollYListenerId);
313
310
  dragScrollY.removeListener(dragListenerId);
314
311
  };
315
- }, [playerAnimationState, isAudioItem, modalSnapPoints, isMinimizedModal]);
312
+ }, [playerAnimationState, isAudioItem, isMinimizedModal]);
316
313
 
317
314
  const Wrapper = React.useMemo(
318
315
  () => (Platform.OS === "android" ? GestureHandlerRootView : View),
@@ -37,11 +37,14 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
37
37
  setStartComponentsAnimation,
38
38
  } = useModalAnimationContext();
39
39
 
40
- const { videoModalState } = useNavigation();
40
+ const {
41
+ videoModalState: { mode: videoModalMode },
42
+ } = useNavigation();
43
+
41
44
  const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
42
45
 
43
- const isMaximazedModal = videoModalState.mode === "MAXIMIZED";
44
- const isMinimizedModal = videoModalState.mode === "MINIMIZED";
46
+ const isMaximazedModal = videoModalMode === "MAXIMIZED";
47
+ const isMinimizedModal = videoModalMode === "MINIMIZED";
45
48
 
46
49
  const isEnablePanGesture =
47
50
  !isLanguageOverlayVisible && (isMaximazedModal || isMinimizedModal);
@@ -59,7 +62,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
59
62
  const preparedTranslationY = Math.abs(translationY);
60
63
  const dragToss = 0.05;
61
64
 
62
- if (videoModalState.mode === "MAXIMIZED") {
65
+ if (videoModalMode === "MAXIMIZED") {
63
66
  if (translationY > 0) {
64
67
  const endOffsetY =
65
68
  lastSnap + preparedTranslationY + dragToss * velocityY + 200;
@@ -84,7 +87,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
84
87
  setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
85
88
  }
86
89
  }
87
- } else if (videoModalState.mode === "MINIMIZED") {
90
+ } else if (videoModalMode === "MINIMIZED") {
88
91
  if (translationY < 0) {
89
92
  // from mini to full
90
93
  setLastSnap(modalSnapPoints[0]);
@@ -100,7 +103,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
100
103
  }
101
104
  }
102
105
  },
103
- [lastSnap, modalSnapPoints, videoModalState.mode]
106
+ [lastSnap, modalSnapPoints, videoModalMode]
104
107
  );
105
108
 
106
109
  React.useEffect(() => {
@@ -66,6 +66,8 @@ export const AnimationView = ({
66
66
  });
67
67
 
68
68
  const { videoModalState } = useNavigation();
69
+ const { mode: videoModalMode, item: videoModalItem } = videoModalState;
70
+
69
71
  const insets = useSafeAreaInsets();
70
72
  const bottomTabBarHeight = useGetBottomTabBarHeight() + (insets.bottom || 0);
71
73
  const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
@@ -88,9 +90,9 @@ export const AnimationView = ({
88
90
 
89
91
  const isAudioItem = React.useMemo(
90
92
  () =>
91
- videoModalState.item?.content?.type?.includes?.("audio") ||
92
- videoModalState.item?.type?.value === "audio",
93
- [videoModalState.item]
93
+ videoModalItem?.content?.type?.includes?.("audio") ||
94
+ videoModalItem?.type?.value === "audio",
95
+ [videoModalItem]
94
96
  );
95
97
 
96
98
  const inlineAudioPlayer = additionalData.inlineAudioPlayer;
@@ -229,10 +231,8 @@ export const AnimationView = ({
229
231
  );
230
232
 
231
233
  const getInitialValue = React.useCallback(() => {
232
- const mode =
233
- videoModalState.mode === "PIP"
234
- ? videoModalState.previousMode
235
- : videoModalState.mode;
234
+ const { mode: videoModalMode, previousMode } = videoModalState;
235
+ const mode = videoModalMode === "PIP" ? previousMode : videoModalMode;
236
236
 
237
237
  switch (mode) {
238
238
  case "MINIMIZED":
@@ -266,7 +266,7 @@ export const AnimationView = ({
266
266
  isTablet,
267
267
  isTabletLandscape,
268
268
  isRTL,
269
- fromMiniPlayer: videoModalState.mode === "MINIMIZED",
269
+ fromMiniPlayer: videoModalMode === "MINIMIZED",
270
270
  inlineAudioPlayer,
271
271
  }),
272
272
  [
@@ -276,7 +276,7 @@ export const AnimationView = ({
276
276
  defaultValue,
277
277
  moveUpValue,
278
278
  moveComponentHorizontalValue,
279
- videoModalState.mode,
279
+ videoModalMode,
280
280
  ]
281
281
  );
282
282
 
@@ -305,7 +305,7 @@ export const AnimationView = ({
305
305
  }
306
306
 
307
307
  if (
308
- videoModalState.mode === "MAXIMIZED" &&
308
+ videoModalMode === "MAXIMIZED" &&
309
309
  defaultValue.x !== screenWidth &&
310
310
  width &&
311
311
  height
@@ -318,10 +318,9 @@ export const AnimationView = ({
318
318
  }, [screenWidth]);
319
319
 
320
320
  React.useEffect(() => {
321
- if (
322
- videoModalState.mode === "MINIMIZED" &&
323
- videoModalState.previousMode === "MAXIMIZED"
324
- ) {
321
+ const { mode, previousMode } = videoModalState;
322
+
323
+ if (mode === "MINIMIZED" && previousMode === "MAXIMIZED") {
325
324
  // set animation to the minimize values if moving from the player to another screen
326
325
  if (playerAnimationState === null) {
327
326
  const value = getAnimationValue(
@@ -338,7 +337,7 @@ export const AnimationView = ({
338
337
  if (
339
338
  playerAnimationState === PlayerAnimationStateEnum.minimize &&
340
339
  startComponentsAnimation &&
341
- videoModalState.mode === "MAXIMIZED"
340
+ videoModalMode === "MAXIMIZED"
342
341
  ) {
343
342
  Animated.timing(
344
343
  animatedValue,
@@ -347,12 +346,7 @@ export const AnimationView = ({
347
346
  } else if (playerAnimationState === PlayerAnimationStateEnum.maximaze) {
348
347
  animatedValue.setValue(defaultValue);
349
348
  }
350
- }, [
351
- playerAnimationState,
352
- startComponentsAnimation,
353
- videoModalState.mode,
354
- defaultValue,
355
- ]);
349
+ }, [playerAnimationState, startComponentsAnimation, defaultValue]);
356
350
 
357
351
  React.useEffect(() => {
358
352
  const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
@@ -414,9 +408,9 @@ export const AnimationView = ({
414
408
  ref={animationComponentRef}
415
409
  style={[
416
410
  ...preparedStyles,
417
- (videoModalState.mode === "MAXIMIZED" ||
418
- videoModalState.mode === "MINIMIZED" ||
419
- (videoModalState.mode === "PIP" && isAppActive)) &&
411
+ (videoModalMode === "MAXIMIZED" ||
412
+ videoModalMode === "MINIMIZED" ||
413
+ (videoModalMode === "PIP" && isAppActive)) &&
420
414
  getAnimationStyle(animationType, animatedValue),
421
415
  ]}
422
416
  >
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.131",
3
+ "version": "12.0.0-rc.133",
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.131",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.131",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.131",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.131",
37
+ "@applicaster/applicaster-types": "12.0.0-rc.133",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-rc.133",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-rc.133",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-rc.133",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",