@applicaster/zapp-react-native-ui-components 12.0.0-rc.77 → 12.0.0-rc.79

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,5 +1,6 @@
1
1
  import React, { useEffect, useMemo } from "react";
2
2
  import * as R from "ramda";
3
+ import validateColor from "validate-color";
3
4
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
4
5
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
6
 
@@ -52,7 +53,10 @@ function resolveColorForProp(entry, style, colorProp) {
52
53
  const colorFromProp = style[colorProp];
53
54
  const nestedEntryValue = R.path(colorFromProp.split("."), entry);
54
55
 
55
- if (nestedEntryValue === undefined) {
56
+ if (
57
+ nestedEntryValue === undefined &&
58
+ !validateColor(colorFromProp.replace(".00", "")) // https://github.com/dreamyguy/validate-color/issues/44
59
+ ) {
56
60
  logWarning(colorFromProp, style, entry, nestedEntryValue);
57
61
  }
58
62
 
@@ -100,58 +100,68 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
100
100
  { useNativeDriver: true }
101
101
  );
102
102
 
103
- const onHandlerStateChange = ({ nativeEvent }) => {
104
- if (nativeEvent.oldState === State.ACTIVE && scrollPosition.current === 0) {
105
- // eslint-disable-next-line prefer-const
106
- const { velocityY, translationY } = nativeEvent;
107
- const dragToss = 0.05;
103
+ const onHandlerStateChange = React.useCallback(
104
+ ({ nativeEvent }) => {
105
+ if (
106
+ nativeEvent.oldState === State.ACTIVE &&
107
+ scrollPosition.current === 0
108
+ ) {
109
+ // eslint-disable-next-line prefer-const
110
+ const { velocityY, translationY } = nativeEvent;
111
+ const dragToss = 0.05;
108
112
 
109
- const preparedTranslationY =
110
- Math.abs(translationY) - lastScrollYValue.current;
113
+ const preparedTranslationY =
114
+ Math.abs(translationY) - lastScrollYValue.current;
111
115
 
112
- if (videoModalState.mode === "MAXIMIZED") {
113
- const endOffsetY =
114
- lastSnap + preparedTranslationY + dragToss * velocityY + 150;
116
+ if (videoModalState.mode === "MAXIMIZED") {
117
+ const endOffsetY =
118
+ lastSnap + preparedTranslationY + dragToss * velocityY + 150;
115
119
 
116
- let destSnapPoint = modalSnapPoints[0];
120
+ let destSnapPoint = modalSnapPoints[0];
117
121
 
118
- for (const snapPoint of modalSnapPoints) {
119
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
122
+ for (const snapPoint of modalSnapPoints) {
123
+ const distFromSnap = Math.abs(snapPoint - endOffsetY);
120
124
 
121
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
122
- destSnapPoint = snapPoint;
125
+ if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
126
+ destSnapPoint = snapPoint;
127
+ }
123
128
  }
124
- }
125
129
 
126
- setLastSnap(destSnapPoint);
130
+ setLastSnap(destSnapPoint);
127
131
 
128
- if (destSnapPoint === modalSnapPoints[0]) {
129
- translateYOffset.extractOffset();
130
- translateYOffset.setValue(preparedTranslationY);
131
- translateYOffset.flattenOffset();
132
- dragScrollY.setValue(0);
132
+ if (destSnapPoint === modalSnapPoints[0]) {
133
+ translateYOffset.extractOffset();
134
+ translateYOffset.setValue(preparedTranslationY);
135
+ translateYOffset.flattenOffset();
136
+ dragScrollY.setValue(0);
133
137
 
134
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
138
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
139
+ } else {
140
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
141
+ }
135
142
  } else {
136
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
143
+ if (translationY < 0) {
144
+ // from mini to full
145
+ setLastSnap(modalSnapPoints[0]);
146
+
147
+ translateYOffset.setValue(
148
+ modalSnapPoints[1] - preparedTranslationY
149
+ );
150
+
151
+ dragScrollY.setValue(0);
152
+
153
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
154
+ } else {
155
+ resetPlayerAnimationState();
156
+ }
137
157
  }
138
158
  } else {
139
- if (translationY < 0) {
140
- // from mini to full
141
- setLastSnap(modalSnapPoints[0]);
142
- translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
143
- dragScrollY.setValue(0);
144
-
145
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
146
- } else {
159
+ playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
147
160
  resetPlayerAnimationState();
148
- }
149
161
  }
150
- } else {
151
- playerAnimationState === PlayerAnimationStateEnum.drag_scroll &&
152
- resetPlayerAnimationState();
153
- }
154
- };
162
+ },
163
+ [lastSnap, modalSnapPoints, playerAnimationState, videoModalState.mode]
164
+ );
155
165
 
156
166
  const onScroll = React.useCallback(({ nativeEvent }) => {
157
167
  scrollPosition.current = nativeEvent.contentOffset.y;
@@ -50,50 +50,57 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
50
50
  { useNativeDriver: true }
51
51
  );
52
52
 
53
- const onHandlerStateChange = ({ nativeEvent }) => {
54
- if (nativeEvent.oldState === State.ACTIVE) {
55
- // eslint-disable-next-line prefer-const
56
- const { velocityY, translationY } = nativeEvent;
57
- const preparedTranslationY = Math.abs(translationY);
58
- const dragToss = 0.05;
59
-
60
- if (videoModalState.mode === "MAXIMIZED") {
61
- if (translationY > 0) {
62
- const endOffsetY =
63
- lastSnap + preparedTranslationY + dragToss * velocityY + 200;
64
-
65
- let destSnapPoint = modalSnapPoints[0];
53
+ const onHandlerStateChange = React.useCallback(
54
+ ({ nativeEvent }) => {
55
+ if (nativeEvent.oldState === State.ACTIVE) {
56
+ // eslint-disable-next-line prefer-const
57
+ const { velocityY, translationY } = nativeEvent;
58
+ const preparedTranslationY = Math.abs(translationY);
59
+ const dragToss = 0.05;
60
+
61
+ if (videoModalState.mode === "MAXIMIZED") {
62
+ if (translationY > 0) {
63
+ const endOffsetY =
64
+ lastSnap + preparedTranslationY + dragToss * velocityY + 200;
65
+
66
+ let destSnapPoint = modalSnapPoints[0];
67
+
68
+ for (const snapPoint of modalSnapPoints) {
69
+ const distFromSnap = Math.abs(snapPoint - endOffsetY);
70
+
71
+ if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
72
+ destSnapPoint = snapPoint;
73
+ }
74
+ }
66
75
 
67
- for (const snapPoint of modalSnapPoints) {
68
- const distFromSnap = Math.abs(snapPoint - endOffsetY);
76
+ setLastSnap(destSnapPoint);
69
77
 
70
- if (distFromSnap < Math.abs(destSnapPoint - endOffsetY)) {
71
- destSnapPoint = snapPoint;
78
+ if (destSnapPoint === modalSnapPoints[0]) {
79
+ setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
80
+ } else {
81
+ lastScrollY.setValue(0);
82
+ lastScrollYValue.current = 0;
83
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
72
84
  }
73
85
  }
86
+ } else if (videoModalState.mode === "MINIMIZED") {
87
+ if (translationY < 0) {
88
+ // from mini to full
89
+ setLastSnap(modalSnapPoints[0]);
74
90
 
75
- setLastSnap(destSnapPoint);
91
+ translateYOffset.setValue(
92
+ modalSnapPoints[1] - preparedTranslationY
93
+ );
76
94
 
77
- if (destSnapPoint === modalSnapPoints[0]) {
78
95
  setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
79
96
  } else {
80
- lastScrollY.setValue(0);
81
- lastScrollYValue.current = 0;
82
- setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
97
+ resetPlayerAnimationState();
83
98
  }
84
99
  }
85
- } else if (videoModalState.mode === "MINIMIZED") {
86
- if (translationY < 0) {
87
- // from mini to full
88
- setLastSnap(modalSnapPoints[0]);
89
- translateYOffset.setValue(modalSnapPoints[1] - preparedTranslationY);
90
- setPlayerAnimationState(PlayerAnimationStateEnum.maximaze);
91
- } else {
92
- resetPlayerAnimationState();
93
- }
94
100
  }
95
- }
96
- };
101
+ },
102
+ [lastSnap, modalSnapPoints, videoModalState.mode]
103
+ );
97
104
 
98
105
  React.useEffect(() => {
99
106
  const dragVideoPlayerYListenerId = dragVideoPlayerY.addListener(
@@ -1,10 +1,7 @@
1
1
  import React, { useRef, useState } from "react";
2
2
  import { Animated, View, StyleSheet } from "react-native";
3
3
 
4
- import {
5
- useSafeAreaInsets,
6
- useSafeAreaFrame,
7
- } from "react-native-safe-area-context";
4
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
8
5
 
9
6
  import {
10
7
  useModalAnimationContext,
@@ -18,6 +15,7 @@ import {
18
15
  } from "@applicaster/zapp-react-native-utils/reactHooks";
19
16
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
20
17
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
+ import { useAppState } from "@applicaster/zapp-react-native-utils/reactHooks/app";
21
19
 
22
20
  import {
23
21
  gestureListenerHelper,
@@ -59,18 +57,19 @@ export const AnimationView = ({
59
57
  } = useModalAnimationContext();
60
58
 
61
59
  const isRTL = useIsRTL();
60
+ const isAppActive = useAppState(true);
62
61
 
63
62
  const {
64
63
  height: screenHeight,
64
+ width: screenWidth,
65
65
  deviceInfo: { isTablet, isTabletLandscape },
66
- } = useDimensions("screen", { deviceInfo: true });
66
+ } = useDimensions("window", { deviceInfo: true });
67
67
 
68
68
  const startAnimationDistance = Math.round((screenHeight * 60) / 100);
69
69
  const { videoModalState } = useNavigation();
70
70
  const bottomTabBarHeight = useGetBottomTabBarHeight();
71
71
  const minimisedWidth = defaultAspectRatioWidth(minimisedHeight);
72
72
  const insets = useSafeAreaInsets();
73
- const { width: screenWidth } = useSafeAreaFrame();
74
73
  const animationComponentRef = useRef(null);
75
74
 
76
75
  // retrieving top position of the player for tablet landscape mode
@@ -88,13 +87,6 @@ export const AnimationView = ({
88
87
  getAnimationDefaultValue(animationType, bottomTabBarHeight)
89
88
  );
90
89
 
91
- const animationValueType: string =
92
- animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
93
-
94
- const animatedValue = useRef(
95
- new Animated[animationValueType](defaultValue)
96
- ).current;
97
-
98
90
  const isAudioItem = React.useMemo(
99
91
  () =>
100
92
  videoModalState.item?.content?.type?.includes?.("audio") ||
@@ -118,63 +110,8 @@ export const AnimationView = ({
118
110
  : -additionalData.moveValue
119
111
  : 0;
120
112
 
121
- const calculationData = React.useMemo(
122
- () => ({
123
- isAudioItem,
124
- bottomTabBarHeight,
125
- minimisedHeight,
126
- minimisedWidth,
127
- defaultValue,
128
- moveUpValue,
129
- moveComponentHorizontalValue,
130
- isTablet,
131
- isTabletLandscape,
132
- isRTL,
133
- fromMiniPlayer: videoModalState.mode === "MINIMIZED",
134
- inlineAudioPlayer,
135
- }),
136
- [
137
- bottomTabBarHeight,
138
- minimisedHeight,
139
- minimisedWidth,
140
- defaultValue,
141
- moveUpValue,
142
- moveComponentHorizontalValue,
143
- videoModalState.mode,
144
- ]
145
- );
146
-
147
- React.useEffect(() => {
148
- if (additionalData.resetAnimationValue) {
149
- animatedValue.setValue(0);
150
- }
151
- }, [additionalData.resetAnimationValue]);
152
-
153
- React.useEffect(() => {
154
- if (animationType === ComponentAnimationType.player) {
155
- let width, height;
156
-
157
- if (additionalData.aspectRatio) {
158
- width = isTabletLandscape ? additionalData.width : screenWidth;
159
-
160
- height =
161
- (isTabletLandscape ? additionalData.width : screenWidth) /
162
- additionalData.aspectRatio;
163
- } else {
164
- width =
165
- typeof additionalData.width === "number" && additionalData.width;
166
-
167
- height =
168
- typeof additionalData.height === "number" && additionalData.height;
169
- }
170
-
171
- if (defaultValue.x === 0 && width && height) {
172
- const value = { x: width, y: height };
173
- setDefaultValue(value);
174
- animatedValue.setValue(value);
175
- }
176
- }
177
- }, [additionalData, screenWidth]);
113
+ const animationValueType: string =
114
+ animationType === ComponentAnimationType.player ? "ValueXY" : "Value";
178
115
 
179
116
  const getAnimationValue = React.useCallback(
180
117
  (animationType, state) => {
@@ -292,6 +229,90 @@ export const AnimationView = ({
292
229
  ]
293
230
  );
294
231
 
232
+ const getInitialValue = React.useCallback(() => {
233
+ const mode =
234
+ videoModalState.mode === "PIP"
235
+ ? videoModalState.previousMode
236
+ : videoModalState.mode;
237
+
238
+ switch (mode) {
239
+ case "MINIMIZED":
240
+ return getAnimationValue(
241
+ animationType,
242
+ PlayerAnimationStateEnum.minimize
243
+ ).toValue;
244
+
245
+ case "MAXIMIZED":
246
+ default:
247
+ return getAnimationValue(
248
+ animationType,
249
+ PlayerAnimationStateEnum.maximaze
250
+ ).toValue;
251
+ }
252
+ }, [defaultValue, videoModalState]);
253
+
254
+ const animatedValue = useRef(
255
+ new Animated[animationValueType](getInitialValue())
256
+ ).current;
257
+
258
+ const calculationData = React.useMemo(
259
+ () => ({
260
+ isAudioItem,
261
+ bottomTabBarHeight,
262
+ minimisedHeight,
263
+ minimisedWidth,
264
+ defaultValue,
265
+ moveUpValue,
266
+ moveComponentHorizontalValue,
267
+ isTablet,
268
+ isTabletLandscape,
269
+ isRTL,
270
+ fromMiniPlayer: videoModalState.mode === "MINIMIZED",
271
+ inlineAudioPlayer,
272
+ }),
273
+ [
274
+ bottomTabBarHeight,
275
+ minimisedHeight,
276
+ minimisedWidth,
277
+ defaultValue,
278
+ moveUpValue,
279
+ moveComponentHorizontalValue,
280
+ videoModalState.mode,
281
+ ]
282
+ );
283
+
284
+ React.useEffect(() => {
285
+ if (additionalData.resetAnimationValue) {
286
+ animatedValue.setValue(defaultValue);
287
+ }
288
+ }, [additionalData.resetAnimationValue, defaultValue]);
289
+
290
+ React.useEffect(() => {
291
+ if (animationType === ComponentAnimationType.player) {
292
+ let width, height;
293
+
294
+ if (additionalData.aspectRatio) {
295
+ width = isTabletLandscape ? additionalData.width : screenWidth;
296
+
297
+ height =
298
+ (isTabletLandscape ? additionalData.width : screenWidth) /
299
+ additionalData.aspectRatio;
300
+ } else {
301
+ width =
302
+ typeof additionalData.width === "number" && additionalData.width;
303
+
304
+ height =
305
+ typeof additionalData.height === "number" && additionalData.height;
306
+ }
307
+
308
+ if (defaultValue.x === 0 && width && height) {
309
+ const value = { x: width, y: height };
310
+ setDefaultValue(value);
311
+ animatedValue.setValue(value);
312
+ }
313
+ }
314
+ }, [additionalData, screenWidth]);
315
+
295
316
  React.useEffect(() => {
296
317
  if (
297
318
  playerAnimationState === PlayerAnimationStateEnum.minimize &&
@@ -374,7 +395,8 @@ export const AnimationView = ({
374
395
  ...preparedStyles,
375
396
  additionalData.saveArea ? styles.flex : null,
376
397
  (videoModalState.mode === "MAXIMIZED" ||
377
- videoModalState.mode === "MINIMIZED") &&
398
+ videoModalState.mode === "MINIMIZED" ||
399
+ (videoModalState.mode === "PIP" && isAppActive)) &&
378
400
  getAnimationStyle(animationType, animatedValue),
379
401
  ]}
380
402
  >
@@ -412,6 +434,7 @@ export const AnimationComponent = (props: Props) => {
412
434
  delete additionalData.extraAnimation[animationType];
413
435
 
414
436
  return (
437
+ // @ts-ignore
415
438
  <Component {...(isReactFragment ? null : props)}>
416
439
  <AnimationComponent
417
440
  {...animationProps}
@@ -1,11 +1,11 @@
1
1
  import React, { useContext } from "react";
2
2
  import { Animated } from "react-native";
3
3
 
4
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
5
  import {
5
- useSafeAreaFrame,
6
- useSafeAreaInsets,
7
- } from "react-native-safe-area-context";
8
- import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+ useGetBottomTabBarHeight,
7
+ useDimensions,
8
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
9
9
 
10
10
  import { useConfiguration } from "../utils";
11
11
 
@@ -93,7 +93,7 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
93
93
  const translateYOffset = React.useRef(new Animated.Value(0)).current;
94
94
  const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
95
95
 
96
- const { height } = useSafeAreaFrame();
96
+ const { height } = useDimensions("window", { fullDimensions: true });
97
97
  const { bottom: bottomSafeArea } = useSafeAreaInsets();
98
98
  const bottomTabBarHeight = useGetBottomTabBarHeight();
99
99
 
@@ -33,8 +33,11 @@ export const useConfiguration = () => {
33
33
  ...pluginConfiguration,
34
34
  });
35
35
 
36
- const { minimised_height, minimised_height_tablet, modal_background_color } =
37
- config;
36
+ const {
37
+ minimised_height = 0,
38
+ minimised_height_tablet = 0,
39
+ modal_background_color,
40
+ } = config;
38
41
 
39
42
  const minimisedHeight = useIsTablet()
40
43
  ? minimised_height_tablet
@@ -2,7 +2,6 @@ import React, {
2
2
  createContext,
3
3
  ReactNode,
4
4
  useCallback,
5
- useEffect,
6
5
  useMemo,
7
6
  useRef,
8
7
  } from "react";
@@ -114,11 +113,6 @@ export function ScreenContextProvider({
114
113
  return navBarState;
115
114
  }, []);
116
115
 
117
- useEffect(() => {
118
- // purge the getScreenNavBarState store when the pathname changes
119
- screenNavBarStateRef.current = null;
120
- }, [pathname]);
121
-
122
116
  const screenNavBarState = getScreenNavBarState()(
123
117
  useShallow((state) => ({
124
118
  visible: state.visible,
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.77",
3
+ "version": "12.0.0-rc.79",
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.77",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.77",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.77",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.77",
37
+ "@applicaster/applicaster-types": "12.0.0-rc.79",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-rc.79",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-rc.79",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-rc.79",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",