@applicaster/zapp-react-native-ui-components 12.0.0-rc.5 → 12.0.0-rc.6
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.
- package/Components/AnimatedInOut/index.tsx +18 -10
- package/Components/Image/Image.android.tsx +4 -0
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
- package/Components/VideoModal/PlayerWrapper.tsx +63 -64
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +3 -2
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +8 -12
- package/package.json +5 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Animated, EasingFunction, StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
|
|
3
|
+
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
4
|
+
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
4
5
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
5
6
|
|
|
6
7
|
type AnimatedInterpolatedStyle =
|
|
@@ -35,11 +36,16 @@ function getAnimation(config: AnimatedInConfig, phase: "in" | "out") {
|
|
|
35
36
|
return config[phase] || config;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
export function AnimatedInOut(
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
export function AnimatedInOut({
|
|
40
|
+
visible,
|
|
41
|
+
animationConfig,
|
|
42
|
+
staticStyles = {},
|
|
43
|
+
children,
|
|
44
|
+
}: Props) {
|
|
41
45
|
const [animatedValue] = React.useState(new Animated.Value(visible ? 1 : 0));
|
|
42
|
-
const [animating, setAnimating] = React.useState(
|
|
46
|
+
const [animating, setAnimating] = React.useState(undefined);
|
|
47
|
+
|
|
48
|
+
const previousVisible = usePrevious(toBooleanWithDefaultFalse(visible));
|
|
43
49
|
|
|
44
50
|
function startAnimation(toValue, config) {
|
|
45
51
|
if (animating) {
|
|
@@ -55,7 +61,7 @@ export function AnimatedInOut(props: Props) {
|
|
|
55
61
|
delay,
|
|
56
62
|
useNativeDriver: true,
|
|
57
63
|
}).start(() => {
|
|
58
|
-
setAnimating(
|
|
64
|
+
setAnimating(undefined);
|
|
59
65
|
onAnimationEnd();
|
|
60
66
|
});
|
|
61
67
|
|
|
@@ -63,12 +69,14 @@ export function AnimatedInOut(props: Props) {
|
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
React.useEffect(() => {
|
|
66
|
-
if (visible) {
|
|
72
|
+
if (!previousVisible && visible) {
|
|
67
73
|
startAnimation(1.0, getAnimation(animationConfig, "in"));
|
|
68
|
-
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (previousVisible && !visible) {
|
|
69
77
|
startAnimation(0.0, getAnimation(animationConfig, "out"));
|
|
70
78
|
}
|
|
71
|
-
}, [visible,
|
|
79
|
+
}, [visible, previousVisible]);
|
|
72
80
|
|
|
73
81
|
const styles = visible
|
|
74
82
|
? getAnimation(animationConfig, "in").styles
|
|
@@ -77,7 +85,7 @@ export function AnimatedInOut(props: Props) {
|
|
|
77
85
|
return (
|
|
78
86
|
<Animated.View
|
|
79
87
|
renderToHardwareTextureAndroid={animating}
|
|
80
|
-
style={[styles(animatedValue),
|
|
88
|
+
style={[styles(animatedValue), staticStyles]}
|
|
81
89
|
>
|
|
82
90
|
{children}
|
|
83
91
|
</Animated.View>
|
|
@@ -15,6 +15,8 @@ export const QBImage = (props: FastImageProps) => {
|
|
|
15
15
|
headers: props.source.headers,
|
|
16
16
|
priority: props.source.priority,
|
|
17
17
|
cache: props.source.cache,
|
|
18
|
+
maxWidth: props.source.maxWidth,
|
|
19
|
+
maxHeight: props.source.maxHeight,
|
|
18
20
|
};
|
|
19
21
|
}, [
|
|
20
22
|
...(typeof props.source === "object"
|
|
@@ -23,6 +25,8 @@ export const QBImage = (props: FastImageProps) => {
|
|
|
23
25
|
props.source?.priority,
|
|
24
26
|
props.source?.cache,
|
|
25
27
|
props.source?.headers,
|
|
28
|
+
props.source?.maxWidth,
|
|
29
|
+
props.source?.maxHeight,
|
|
26
30
|
]
|
|
27
31
|
: []),
|
|
28
32
|
]);
|
|
@@ -4,7 +4,6 @@ import { Text, TextStyle, View, ViewStyle } from "react-native";
|
|
|
4
4
|
|
|
5
5
|
import { getLocalizations } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
6
6
|
import { getAppStylesColor } from "@applicaster/zapp-react-native-utils/stylesUtils";
|
|
7
|
-
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks/layout";
|
|
8
7
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
9
8
|
import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
|
|
10
9
|
|
|
@@ -26,10 +25,10 @@ const textStyles = (appStyles = defaultAppStyles): TextStyle => ({
|
|
|
26
25
|
textAlign: "center",
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
const errorStyles = ({
|
|
28
|
+
const errorStyles = ({ backgroundColor }): ViewStyle => ({
|
|
30
29
|
flex: 1,
|
|
31
|
-
width,
|
|
32
|
-
height,
|
|
30
|
+
width: "100%",
|
|
31
|
+
height: "100%",
|
|
33
32
|
justifyContent: "center",
|
|
34
33
|
alignItems: "center",
|
|
35
34
|
position: "absolute",
|
|
@@ -41,8 +40,6 @@ export function ErrorDisplayComponent({
|
|
|
41
40
|
styles,
|
|
42
41
|
remoteConfigurations: { localizations },
|
|
43
42
|
}: Props) {
|
|
44
|
-
const { width, height } = useDimensions("window");
|
|
45
|
-
|
|
46
43
|
const theme = useTheme();
|
|
47
44
|
const backgroundColor = theme?.app_background_color;
|
|
48
45
|
|
|
@@ -53,7 +50,7 @@ export function ErrorDisplayComponent({
|
|
|
53
50
|
const appStyles = R.prop(styleKeys.style_namespace, styles);
|
|
54
51
|
|
|
55
52
|
return (
|
|
56
|
-
<View style={errorStyles({
|
|
53
|
+
<View style={errorStyles({ backgroundColor })}>
|
|
57
54
|
<Text style={textStyles(appStyles)}>{stream_error_message}</Text>
|
|
58
55
|
</View>
|
|
59
56
|
);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Platform,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
3
9
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
4
10
|
|
|
5
11
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
@@ -7,12 +13,12 @@ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/dev
|
|
|
7
13
|
import { PlayerDetails } from "./PlayerDetails";
|
|
8
14
|
import { playerDimesionsHack } from "./utils";
|
|
9
15
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
10
|
-
import { useDimensions } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
11
16
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
12
17
|
|
|
13
|
-
type
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
18
|
+
type DimensionsT = {
|
|
19
|
+
width: number | string;
|
|
20
|
+
height: number | string;
|
|
21
|
+
aspectRatio?: number;
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
type Configuration = {
|
|
@@ -23,25 +29,20 @@ type Configuration = {
|
|
|
23
29
|
|
|
24
30
|
type Props = {
|
|
25
31
|
entry: ZappEntry;
|
|
26
|
-
style: ViewStyle &
|
|
32
|
+
style: ViewStyle & DimensionsT;
|
|
27
33
|
containerStyle?: ViewStyle;
|
|
28
34
|
inline?: boolean;
|
|
29
35
|
docked?: boolean;
|
|
30
36
|
isModal?: boolean;
|
|
31
37
|
fullscreen?: boolean;
|
|
32
38
|
isTabletPortrait?: boolean;
|
|
33
|
-
children: (playerDimensions:
|
|
39
|
+
children: (playerDimensions: DimensionsT) => React.ReactNode;
|
|
34
40
|
configuration: Configuration;
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
const defaultStyles = StyleSheet.create({
|
|
38
44
|
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
39
45
|
playerDetails: { flex: 1, paddingTop: 20 },
|
|
40
|
-
inlinePlayerContainerDimensions: {
|
|
41
|
-
aspectRatio: 16 / 9,
|
|
42
|
-
width: "100%",
|
|
43
|
-
height: undefined,
|
|
44
|
-
},
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
const orientationStyles = StyleSheet.create({
|
|
@@ -57,6 +58,15 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
|
|
|
57
58
|
return orientationStyles.portrait;
|
|
58
59
|
};
|
|
59
60
|
|
|
61
|
+
const getScreenAspectRatio = () => {
|
|
62
|
+
const { width, height } = Dimensions.get("screen");
|
|
63
|
+
|
|
64
|
+
const longEdge = Math.max(width, height);
|
|
65
|
+
const shortEdge = Math.min(width, height);
|
|
66
|
+
|
|
67
|
+
return longEdge / shortEdge;
|
|
68
|
+
};
|
|
69
|
+
|
|
60
70
|
const safeAreaStyles = (
|
|
61
71
|
configuration: Configuration,
|
|
62
72
|
isTablet: boolean
|
|
@@ -71,34 +81,6 @@ const safeAreaStyles = (
|
|
|
71
81
|
};
|
|
72
82
|
};
|
|
73
83
|
|
|
74
|
-
const getTabletWidth = (
|
|
75
|
-
configuration: Configuration,
|
|
76
|
-
dimensions: Dimensions
|
|
77
|
-
) => {
|
|
78
|
-
const tablet_landscape_sidebar_width =
|
|
79
|
-
configuration?.tablet_landscape_sidebar_width;
|
|
80
|
-
|
|
81
|
-
const { width } = dimensions;
|
|
82
|
-
|
|
83
|
-
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
84
|
-
|
|
85
|
-
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
86
|
-
return width * (1 - sidebarWidth / 100);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (Number.isNaN(sidebarWidth)) {
|
|
90
|
-
return width * 0.65;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return width - sidebarWidth;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const defaultAspectRatioHeight = (width: number): number =>
|
|
97
|
-
(width / 16) * 9;
|
|
98
|
-
|
|
99
|
-
export const defaultAspectRatioWidth = (height: number): number =>
|
|
100
|
-
(height / 9) * 16;
|
|
101
|
-
|
|
102
84
|
const getEdges = (
|
|
103
85
|
isTablet: boolean,
|
|
104
86
|
docked: boolean,
|
|
@@ -120,6 +102,28 @@ const getEdges = (
|
|
|
120
102
|
return ["top"];
|
|
121
103
|
};
|
|
122
104
|
|
|
105
|
+
const getTabletWidth = (
|
|
106
|
+
configuration: Configuration,
|
|
107
|
+
dimensions: DimensionsT
|
|
108
|
+
) => {
|
|
109
|
+
const tablet_landscape_sidebar_width =
|
|
110
|
+
configuration?.tablet_landscape_sidebar_width;
|
|
111
|
+
|
|
112
|
+
const { width } = dimensions;
|
|
113
|
+
|
|
114
|
+
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
115
|
+
|
|
116
|
+
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
117
|
+
return Number(width) * (1 - sidebarWidth / 100);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (Number.isNaN(sidebarWidth)) {
|
|
121
|
+
return Number(width) * 0.65;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return Number(width) - sidebarWidth;
|
|
125
|
+
};
|
|
126
|
+
|
|
123
127
|
export const PlayerWrapper = (props: Props) => {
|
|
124
128
|
const {
|
|
125
129
|
entry,
|
|
@@ -141,40 +145,38 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
141
145
|
|
|
142
146
|
const tabletWidth = getTabletWidth(configuration, style);
|
|
143
147
|
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
const containerDimensions: Dimensions = React.useMemo(
|
|
148
|
+
const baseDimensions: DimensionsT = React.useMemo(
|
|
147
149
|
() => ({
|
|
148
150
|
width:
|
|
149
|
-
isInlineModal && !docked && isTabletLandscape
|
|
150
|
-
|
|
151
|
-
: style.width,
|
|
152
|
-
height:
|
|
153
|
-
isInlineModal && !docked
|
|
154
|
-
? defaultAspectRatioHeight(
|
|
155
|
-
isTabletLandscape ? tabletWidth : screenWidth
|
|
156
|
-
)
|
|
157
|
-
: style.height,
|
|
151
|
+
isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
|
|
152
|
+
height: isInlineModal && docked ? style.height : undefined,
|
|
158
153
|
}),
|
|
159
|
-
[isInlineModal,
|
|
154
|
+
[isInlineModal, tabletWidth, style.height, docked]
|
|
160
155
|
);
|
|
161
156
|
|
|
162
|
-
const playerDimensions:
|
|
157
|
+
const playerDimensions: DimensionsT = React.useMemo(
|
|
163
158
|
() => ({
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
...baseDimensions,
|
|
160
|
+
width: isInlineModal && docked ? undefined : baseDimensions.width,
|
|
161
|
+
aspectRatio: !isInlineModal ? getScreenAspectRatio() : 16 / 9,
|
|
162
|
+
}),
|
|
163
|
+
[baseDimensions, isInlineModal]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const containerDimensions: DimensionsT = React.useMemo(
|
|
167
|
+
() => ({
|
|
168
|
+
...baseDimensions,
|
|
169
|
+
aspectRatio:
|
|
170
|
+
isInlineModal && docked ? undefined : playerDimensions.aspectRatio,
|
|
169
171
|
}),
|
|
170
|
-
[isInlineModal, docked,
|
|
172
|
+
[baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
|
|
171
173
|
);
|
|
172
174
|
|
|
173
175
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
174
176
|
|
|
175
177
|
const childrenStyles = React.useMemo(
|
|
176
178
|
() => ({ ...playerDimensions, ...playerDimesionsHack }),
|
|
177
|
-
[
|
|
179
|
+
[containerDimensions, playerDimesionsHack]
|
|
178
180
|
);
|
|
179
181
|
|
|
180
182
|
return (
|
|
@@ -195,9 +197,6 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
195
197
|
defaultStyles.playerContainer,
|
|
196
198
|
containerDimensions,
|
|
197
199
|
containerStyle,
|
|
198
|
-
isInlineModal && !docked && !isTabletLandscape
|
|
199
|
-
? defaultStyles.inlinePlayerContainerDimensions
|
|
200
|
-
: {},
|
|
201
200
|
playerDimesionsHack,
|
|
202
201
|
]}
|
|
203
202
|
>
|
|
@@ -50,7 +50,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
50
50
|
|
|
51
51
|
jest.mock("../utils", () => ({ playerDimesionsHack: {} }));
|
|
52
52
|
|
|
53
|
-
const { PlayerWrapper
|
|
53
|
+
const { PlayerWrapper } = require("../PlayerWrapper");
|
|
54
54
|
|
|
55
55
|
jest.useFakeTimers();
|
|
56
56
|
const children = jest.fn(() => {});
|
|
@@ -110,7 +110,8 @@ describe("PlayerWrapper", () => {
|
|
|
110
110
|
|
|
111
111
|
const expectDimensions = {
|
|
112
112
|
...dimensions,
|
|
113
|
-
width:
|
|
113
|
+
width: undefined,
|
|
114
|
+
aspectRatio: 16 / 9,
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
expect(element).toMatchSnapshot();
|
|
@@ -34,17 +34,13 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
34
34
|
"position": "relative",
|
|
35
35
|
"zIndex": 200,
|
|
36
36
|
},
|
|
37
|
-
Object {
|
|
38
|
-
"height": 421.875,
|
|
39
|
-
"width": 300,
|
|
40
|
-
},
|
|
41
|
-
Object {},
|
|
42
37
|
Object {
|
|
43
38
|
"aspectRatio": 1.7777777777777777,
|
|
44
39
|
"height": undefined,
|
|
45
40
|
"width": "100%",
|
|
46
41
|
},
|
|
47
42
|
Object {},
|
|
43
|
+
Object {},
|
|
48
44
|
]
|
|
49
45
|
}
|
|
50
46
|
testID="test-player-container"
|
|
@@ -107,12 +103,12 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
107
103
|
"zIndex": 200,
|
|
108
104
|
},
|
|
109
105
|
Object {
|
|
106
|
+
"aspectRatio": undefined,
|
|
110
107
|
"height": 50,
|
|
111
|
-
"width":
|
|
108
|
+
"width": "100%",
|
|
112
109
|
},
|
|
113
110
|
Object {},
|
|
114
111
|
Object {},
|
|
115
|
-
Object {},
|
|
116
112
|
]
|
|
117
113
|
}
|
|
118
114
|
testID="test-player-container"
|
|
@@ -163,12 +159,12 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
|
163
159
|
"zIndex": 200,
|
|
164
160
|
},
|
|
165
161
|
Object {
|
|
166
|
-
"
|
|
162
|
+
"aspectRatio": 1.7777777777777777,
|
|
163
|
+
"height": undefined,
|
|
167
164
|
"width": 195,
|
|
168
165
|
},
|
|
169
166
|
Object {},
|
|
170
167
|
Object {},
|
|
171
|
-
Object {},
|
|
172
168
|
]
|
|
173
169
|
}
|
|
174
170
|
testID="test-player-container"
|
|
@@ -231,12 +227,12 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
231
227
|
"zIndex": 200,
|
|
232
228
|
},
|
|
233
229
|
Object {
|
|
234
|
-
"
|
|
235
|
-
"
|
|
230
|
+
"aspectRatio": 1.7786666666666666,
|
|
231
|
+
"height": undefined,
|
|
232
|
+
"width": "100%",
|
|
236
233
|
},
|
|
237
234
|
Object {},
|
|
238
235
|
Object {},
|
|
239
|
-
Object {},
|
|
240
236
|
]
|
|
241
237
|
}
|
|
242
238
|
testID="test-player-container"
|
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.
|
|
3
|
+
"version": "12.0.0-rc.6",
|
|
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",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"redux-mock-store": "^1.5.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
39
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.
|
|
40
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
38
|
+
"@applicaster/applicaster-types": "12.0.0-rc.6",
|
|
39
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.6",
|
|
40
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-rc.6",
|
|
41
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.6",
|
|
42
42
|
"promise": "^8.3.0",
|
|
43
43
|
"react-router-native": "^5.1.2",
|
|
44
44
|
"url": "^0.11.0",
|