@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5035843303 → 12.0.0-alpha.5353184830
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/Cell/CellWithFocusable.tsx +14 -26
- package/Components/Cell/TvOSCellComponent.tsx +9 -4
- package/Components/Image/Image.android.tsx +34 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +1 -4
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +0 -4
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +1 -4
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +2 -10
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +0 -9
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
- package/Components/Screen/__tests__/Screen.test.tsx +71 -60
- package/Components/Screen/orientationHandler.ts +1 -1
- package/Components/VideoLive/LiveImageManager.ts +1 -45
- package/Components/VideoModal/PlayerWrapper.tsx +64 -63
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +3 -2
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +10 -18
- package/Components/VideoModal/hooks/useModalSize.ts +13 -4
- 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>
|
|
@@ -3,8 +3,6 @@ import * as React from "react";
|
|
|
3
3
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
4
4
|
import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
|
|
5
5
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
6
|
-
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
7
|
-
|
|
8
6
|
import { isAppleTV } from "../../Helpers/Platform";
|
|
9
7
|
import { useCellState } from "../MasterCell/utils";
|
|
10
8
|
|
|
@@ -37,19 +35,18 @@ const useCellFocusedState = (groupId: string, id: string) => {
|
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
type Props = {
|
|
40
|
-
item: ZappEntry
|
|
41
|
-
CellRenderer: React.ComponentType<{ item: Object
|
|
42
|
-
id: string
|
|
43
|
-
groupId: string
|
|
44
|
-
onFocus: Function
|
|
45
|
-
index: number
|
|
46
|
-
scrollTo: Function
|
|
47
|
-
preferredFocus?: boolean
|
|
48
|
-
skipFocusManagerRegistration?: boolean
|
|
49
|
-
isFocusable?: boolean
|
|
50
|
-
behavior: Behavior
|
|
51
|
-
selected?: boolean
|
|
52
|
-
focused?: boolean;
|
|
38
|
+
item: ZappEntry,
|
|
39
|
+
CellRenderer: React.ComponentType<{ item: Object, state: string }>,
|
|
40
|
+
id: string,
|
|
41
|
+
groupId: string,
|
|
42
|
+
onFocus: Function,
|
|
43
|
+
index: number,
|
|
44
|
+
scrollTo: Function,
|
|
45
|
+
preferredFocus?: boolean,
|
|
46
|
+
skipFocusManagerRegistration?: boolean,
|
|
47
|
+
isFocusable?: boolean,
|
|
48
|
+
behavior: Behavior,
|
|
49
|
+
selected?: boolean,
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
export function CellWithFocusable(props: Props) {
|
|
@@ -65,19 +62,11 @@ export function CellWithFocusable(props: Props) {
|
|
|
65
62
|
skipFocusManagerRegistration,
|
|
66
63
|
isFocusable,
|
|
67
64
|
behavior,
|
|
68
|
-
selected
|
|
69
|
-
focused,
|
|
65
|
+
selected
|
|
70
66
|
} = props;
|
|
71
67
|
|
|
72
68
|
const isFocused = useCellFocusedState(groupId, id);
|
|
73
|
-
|
|
74
|
-
const state = useCellState({
|
|
75
|
-
id: item.id,
|
|
76
|
-
behavior,
|
|
77
|
-
focused: isFocused || toBooleanWithDefaultFalse(focused),
|
|
78
|
-
selected,
|
|
79
|
-
});
|
|
80
|
-
|
|
69
|
+
const state = useCellState({ id: item.id, behavior, focused: isFocused, selected });
|
|
81
70
|
const [focusedButtonId, setFocusedButtonId] = React.useState(undefined);
|
|
82
71
|
|
|
83
72
|
// for horizontal scrolling
|
|
@@ -106,7 +95,6 @@ export function CellWithFocusable(props: Props) {
|
|
|
106
95
|
preferredFocus={preferredFocus}
|
|
107
96
|
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
108
97
|
isFocusable={isFocusable}
|
|
109
|
-
focused={focused}
|
|
110
98
|
/>
|
|
111
99
|
);
|
|
112
100
|
}
|
|
@@ -226,7 +226,13 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
226
226
|
|
|
227
227
|
hasReceivedFocus() {}
|
|
228
228
|
|
|
229
|
-
scrollTo(index) {
|
|
229
|
+
scrollTo(index) {
|
|
230
|
+
// Workaround for HL autoscroll/autoloop feature, we scroll manually on tvOS.
|
|
231
|
+
// Should be removed after refactoring autoscroll/autoloop feature
|
|
232
|
+
if (this.props.component?.component_type !== "horizontal_list_qb") {
|
|
233
|
+
this.props?.scrollToIndex?.(index);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
230
236
|
|
|
231
237
|
render() {
|
|
232
238
|
const {
|
|
@@ -243,7 +249,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
243
249
|
hasReceivedFocus,
|
|
244
250
|
groupId,
|
|
245
251
|
isFocusable,
|
|
246
|
-
behavior
|
|
252
|
+
behavior
|
|
247
253
|
} = this.props;
|
|
248
254
|
|
|
249
255
|
const { id } = item;
|
|
@@ -273,7 +279,6 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
273
279
|
index={index}
|
|
274
280
|
scrollTo={this.scrollTo}
|
|
275
281
|
preferredFocus={preferredFocus}
|
|
276
|
-
focused={this.props.focused}
|
|
277
282
|
behavior={behavior}
|
|
278
283
|
/>
|
|
279
284
|
</View>
|
|
@@ -305,7 +310,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
305
310
|
item,
|
|
306
311
|
focused: this.props.focused || selectedCell || focused,
|
|
307
312
|
scrollTo: this.scrollTo,
|
|
308
|
-
behavior
|
|
313
|
+
behavior
|
|
309
314
|
}}
|
|
310
315
|
/>
|
|
311
316
|
);
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import FastImage, {
|
|
4
|
+
FastImageProps,
|
|
5
|
+
} from "@applicaster/react-native-fast-image";
|
|
6
|
+
|
|
7
|
+
export const QBImage = (props: FastImageProps) => {
|
|
8
|
+
const source = React.useMemo(() => {
|
|
9
|
+
if (typeof props.source === "number") {
|
|
10
|
+
return props.source;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
uri: props.source.uri,
|
|
15
|
+
headers: props.source.headers,
|
|
16
|
+
priority: props.source.priority,
|
|
17
|
+
cache: props.source.cache,
|
|
18
|
+
maxWidth: props.source.maxWidth,
|
|
19
|
+
maxHeight: props.source.maxHeight,
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
...(typeof props.source === "object"
|
|
23
|
+
? [
|
|
24
|
+
props.source?.uri,
|
|
25
|
+
props.source?.priority,
|
|
26
|
+
props.source?.cache,
|
|
27
|
+
props.source?.headers,
|
|
28
|
+
props.source?.maxWidth,
|
|
29
|
+
props.source?.maxHeight,
|
|
30
|
+
]
|
|
31
|
+
: []),
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
return <FastImage {...props} source={source} />;
|
|
35
|
+
};
|
|
@@ -4,7 +4,6 @@ import { Focusable } from "@applicaster/zapp-react-native-ui-components/Componen
|
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
import { getXray } from "@applicaster/zapp-react-native-utils/logger";
|
|
7
|
-
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
8
7
|
|
|
9
8
|
const { Logger } = getXray();
|
|
10
9
|
|
|
@@ -36,9 +35,7 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
|
|
|
36
35
|
|
|
37
36
|
const focusableId = getFocusableId(prefixId, suffixId);
|
|
38
37
|
|
|
39
|
-
const focused =
|
|
40
|
-
focusableId === focusedButtonId ||
|
|
41
|
-
toBooleanWithDefaultFalse(otherProps.focused);
|
|
38
|
+
const focused = focusableId === focusedButtonId;
|
|
42
39
|
|
|
43
40
|
const additionalStyles = focused ? focusedStyles : normalStyles;
|
|
44
41
|
|
|
@@ -31,10 +31,6 @@ function Image({
|
|
|
31
31
|
|
|
32
32
|
const source = useImageSource({ uri, entry, otherProps });
|
|
33
33
|
|
|
34
|
-
// const source = {
|
|
35
|
-
// uri: `https://placehold.co/392x221/blue/FFFFFF.png?text=${otherProps?.item?.index}`,
|
|
36
|
-
// };
|
|
37
|
-
|
|
38
34
|
React.useEffect(() => {
|
|
39
35
|
// reset error state on URI change as the error is referencing previous uri
|
|
40
36
|
setErrorState(null);
|
|
@@ -61,10 +61,7 @@ export function ButtonContainerView({
|
|
|
61
61
|
<View style={applyRTLStylesIfNeeded(style, isRTL)}>
|
|
62
62
|
{insertBetween(
|
|
63
63
|
(index) => (
|
|
64
|
-
<HorizontalSeparator
|
|
65
|
-
key={`separator_${index}`}
|
|
66
|
-
width={horizontalGutter}
|
|
67
|
-
/>
|
|
64
|
+
<HorizontalSeparator key={index} width={horizontalGutter} />
|
|
68
65
|
),
|
|
69
66
|
cloneElementsWithIds(buttonIds, filteredChildren)
|
|
70
67
|
)}
|
|
@@ -7,10 +7,6 @@ import type {
|
|
|
7
7
|
ContainerProps,
|
|
8
8
|
ContainerChildren,
|
|
9
9
|
} from "./types";
|
|
10
|
-
import {
|
|
11
|
-
useIsRTL,
|
|
12
|
-
applyRTLStylesIfNeeded,
|
|
13
|
-
} from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
14
10
|
|
|
15
11
|
const HorizontalSeparator = ({ width }: HorizontalSeparatorProps) => (
|
|
16
12
|
<View style={{ width }} />
|
|
@@ -21,7 +17,6 @@ export function ButtonContainerView({
|
|
|
21
17
|
children,
|
|
22
18
|
...otherProps
|
|
23
19
|
}: ContainerProps) {
|
|
24
|
-
const isRTL = useIsRTL();
|
|
25
20
|
const horizontalGutter = R.pathOr(0, ["horizontalGutter"], otherProps);
|
|
26
21
|
|
|
27
22
|
const filteredChildren = useFilterChildren<ContainerChildren>(children);
|
|
@@ -31,13 +26,10 @@ export function ButtonContainerView({
|
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
return (
|
|
34
|
-
<View style={
|
|
29
|
+
<View style={style}>
|
|
35
30
|
{insertBetween(
|
|
36
31
|
(index) => (
|
|
37
|
-
<HorizontalSeparator
|
|
38
|
-
key={`separator_${index}`}
|
|
39
|
-
width={horizontalGutter}
|
|
40
|
-
/>
|
|
32
|
+
<HorizontalSeparator key={index} width={horizontalGutter} />
|
|
41
33
|
),
|
|
42
34
|
filteredChildren
|
|
43
35
|
)}
|
|
@@ -9,13 +9,4 @@ describe("insertBetween", () => {
|
|
|
9
9
|
|
|
10
10
|
expect(result).toEqual([1, "|", 2, "|", 3]);
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
it("insertBetween", () => {
|
|
14
|
-
const separator = (index) => `separator:${index}`;
|
|
15
|
-
const items = [1, 2, 3];
|
|
16
|
-
|
|
17
|
-
const result = insertBetween(separator, items);
|
|
18
|
-
|
|
19
|
-
expect(result).toEqual([1, "separator:0", 2, "separator:1", 3]);
|
|
20
|
-
});
|
|
21
12
|
});
|
|
@@ -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,6 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { create, act } from "react-test-renderer";
|
|
4
|
+
import { Provider } from "react-redux";
|
|
5
|
+
import configureStore from "redux-mock-store";
|
|
6
|
+
|
|
7
|
+
const mockStore = configureStore();
|
|
8
|
+
|
|
9
|
+
const plugins = [];
|
|
10
|
+
const store = mockStore({ plugins });
|
|
4
11
|
|
|
5
12
|
import { ORIENTATIONS } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
6
13
|
|
|
@@ -117,71 +124,75 @@ describe("<Screen Component />", () => {
|
|
|
117
124
|
|
|
118
125
|
describe("when the navbar should show", () => {
|
|
119
126
|
act(() => {
|
|
120
|
-
wrapper = create(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe("when the navbar should be hidden", () => {
|
|
129
|
-
beforeEach(() => {
|
|
130
|
-
mock_navBarVisibleFlag = false;
|
|
131
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
afterEach(() => {
|
|
135
|
-
mock_navBarVisibleFlag = true;
|
|
127
|
+
wrapper = create(
|
|
128
|
+
<Provider store={store}>
|
|
129
|
+
<Screen {...screenProps} />{" "}
|
|
130
|
+
</Provider>
|
|
131
|
+
);
|
|
136
132
|
});
|
|
137
133
|
|
|
138
134
|
it("renders correctly", () => {
|
|
139
|
-
act(() => {
|
|
140
|
-
wrapper = create(<Screen {...screenProps} />);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
135
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
144
136
|
});
|
|
145
137
|
});
|
|
146
138
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
139
|
+
// describe("when the navbar should be hidden", () => {
|
|
140
|
+
// beforeEach(() => {
|
|
141
|
+
// mock_navBarVisibleFlag = false;
|
|
142
|
+
// wrapper = create(<Screen {...screenProps} />);
|
|
143
|
+
// });
|
|
144
|
+
|
|
145
|
+
// afterEach(() => {
|
|
146
|
+
// mock_navBarVisibleFlag = true;
|
|
147
|
+
// });
|
|
148
|
+
|
|
149
|
+
// it("renders correctly", () => {
|
|
150
|
+
// act(() => {
|
|
151
|
+
// wrapper = create(<Screen {...screenProps} />);
|
|
152
|
+
// });
|
|
153
|
+
|
|
154
|
+
// expect(wrapper.toJSON()).toMatchSnapshot();
|
|
155
|
+
// });
|
|
156
|
+
// });
|
|
157
|
+
|
|
158
|
+
// it("invokes the orientation hook when the route changes", () => {
|
|
159
|
+
// act(() => {
|
|
160
|
+
// wrapper = create(<Screen {...screenProps} />);
|
|
161
|
+
// });
|
|
162
|
+
|
|
163
|
+
// // @ts-ignore
|
|
164
|
+
// useCurrentScreenData.mockReturnValue({
|
|
165
|
+
// id: "player-testId",
|
|
166
|
+
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
167
|
+
// plugin_type: "player",
|
|
168
|
+
// });
|
|
169
|
+
|
|
170
|
+
// act(() => {
|
|
171
|
+
// wrapper.update(
|
|
172
|
+
// <Screen
|
|
173
|
+
// {...screenProps}
|
|
174
|
+
// pathname="/playable"
|
|
175
|
+
// screenData={{
|
|
176
|
+
// id: "player-testId",
|
|
177
|
+
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
178
|
+
// plugin_type: "player",
|
|
179
|
+
// }}
|
|
180
|
+
// />
|
|
181
|
+
// );
|
|
182
|
+
// });
|
|
183
|
+
|
|
184
|
+
// useCurrentScreenData.mockReturnValue({
|
|
185
|
+
// id: "player-testId",
|
|
186
|
+
// general: { screen_orientation: ORIENTATIONS.landscapeSensor },
|
|
187
|
+
// });
|
|
188
|
+
|
|
189
|
+
// act(() => {
|
|
190
|
+
// wrapper.update(<Screen {...screenProps} />);
|
|
191
|
+
// });
|
|
192
|
+
|
|
193
|
+
// expect(allowedOrientationsForScreen).toHaveBeenNthCalledWith(
|
|
194
|
+
// 1,
|
|
195
|
+
// ORIENTATIONS.landscapeSensor
|
|
196
|
+
// );
|
|
197
|
+
// });
|
|
187
198
|
});
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
10
10
|
import { findPluginByType } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
11
|
-
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks
|
|
11
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
12
|
import { ZappHookModalContext } from "../../Contexts";
|
|
13
13
|
import { HookModalContextT } from "../../Contexts/ZappHookModalContext";
|
|
14
14
|
|
|
@@ -9,12 +9,7 @@ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
9
9
|
|
|
10
10
|
const { log_debug, log_info, log_error } = loggerLiveImageManager;
|
|
11
11
|
|
|
12
|
-
export type LiveImageManagerEvent =
|
|
13
|
-
| "onEnd"
|
|
14
|
-
| "onStart"
|
|
15
|
-
| "onError"
|
|
16
|
-
| "onDestroy"
|
|
17
|
-
| "onPlayerClose";
|
|
12
|
+
export type LiveImageManagerEvent = "onEnd" | "onStart" | "onError";
|
|
18
13
|
|
|
19
14
|
export type LiveImageManagerListenerData = {
|
|
20
15
|
id: string;
|
|
@@ -105,15 +100,6 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
this.items = this.items.filter((i) => i !== item);
|
|
108
|
-
|
|
109
|
-
this.invokeListenersUpdate({
|
|
110
|
-
callbackName: "onDestroy",
|
|
111
|
-
event: {
|
|
112
|
-
item,
|
|
113
|
-
playerId: this.currentlyPlaying?.playerId,
|
|
114
|
-
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
103
|
};
|
|
118
104
|
|
|
119
105
|
public onViewportEnter = (item: LiveImage) => {
|
|
@@ -390,25 +376,6 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
390
376
|
});
|
|
391
377
|
};
|
|
392
378
|
|
|
393
|
-
onLiveImagePlayerClose = (item: LiveImage) => {
|
|
394
|
-
log_debug(
|
|
395
|
-
`onLiveImagePlayerClose: live-image ${playerInfo(
|
|
396
|
-
item.player
|
|
397
|
-
)}, currentPlayingId: ${
|
|
398
|
-
this.currentlyPlaying?.playerId
|
|
399
|
-
}, primaryPlayerId: ${this.primaryPlayer?.playerId}`
|
|
400
|
-
);
|
|
401
|
-
|
|
402
|
-
this.invokeListenersUpdate({
|
|
403
|
-
callbackName: "onPlayerClose",
|
|
404
|
-
event: {
|
|
405
|
-
item,
|
|
406
|
-
playerId: this.currentlyPlaying?.playerId,
|
|
407
|
-
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
408
|
-
},
|
|
409
|
-
});
|
|
410
|
-
};
|
|
411
|
-
|
|
412
379
|
onLiveImageError = (item: LiveImage, error: Error) => {
|
|
413
380
|
item.setMode(LiveImageType.Image);
|
|
414
381
|
|
|
@@ -512,16 +479,6 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
|
|
|
512
479
|
LiveImageManager.instance.onLiveImageError(this, error);
|
|
513
480
|
};
|
|
514
481
|
|
|
515
|
-
onVideoError = (error: Error) => {
|
|
516
|
-
log_error(
|
|
517
|
-
`onVideoError: live-image, fail to play, switching back to image. error: ${
|
|
518
|
-
error?.message
|
|
519
|
-
}, ${playerInfo(this.player)}`
|
|
520
|
-
);
|
|
521
|
-
|
|
522
|
-
LiveImageManager.instance.onLiveImageError(this, error);
|
|
523
|
-
};
|
|
524
|
-
|
|
525
482
|
onVideoEnd = (_event) => {
|
|
526
483
|
log_info(
|
|
527
484
|
`onVideoEnd: live-image, video completed, switching back to image, ${playerInfo(
|
|
@@ -540,7 +497,6 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
|
|
|
540
497
|
);
|
|
541
498
|
|
|
542
499
|
// TODO: we maybe want to add onPlayerClose to separate completion behavior
|
|
543
|
-
LiveImageManager.instance.onLiveImagePlayerClose(this);
|
|
544
500
|
LiveImageManager.instance.onLiveImageEnded(this);
|
|
545
501
|
};
|
|
546
502
|
}
|
|
@@ -1,18 +1,24 @@
|
|
|
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";
|
|
6
|
-
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks
|
|
12
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
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,14 +29,14 @@ 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
|
|
|
@@ -52,6 +58,15 @@ const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
|
|
|
52
58
|
return orientationStyles.portrait;
|
|
53
59
|
};
|
|
54
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
|
+
|
|
55
70
|
const safeAreaStyles = (
|
|
56
71
|
configuration: Configuration,
|
|
57
72
|
isTablet: boolean
|
|
@@ -66,34 +81,6 @@ const safeAreaStyles = (
|
|
|
66
81
|
};
|
|
67
82
|
};
|
|
68
83
|
|
|
69
|
-
const getTabletWidth = (
|
|
70
|
-
configuration: Configuration,
|
|
71
|
-
dimensions: Dimensions
|
|
72
|
-
) => {
|
|
73
|
-
const tablet_landscape_sidebar_width =
|
|
74
|
-
configuration?.tablet_landscape_sidebar_width;
|
|
75
|
-
|
|
76
|
-
const { width } = dimensions;
|
|
77
|
-
|
|
78
|
-
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
79
|
-
|
|
80
|
-
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
81
|
-
return width * (1 - sidebarWidth / 100);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (Number.isNaN(sidebarWidth)) {
|
|
85
|
-
return width * 0.65;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return width - sidebarWidth;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const defaultAspectRatioHeight = (width: number): number =>
|
|
92
|
-
(width / 16) * 9;
|
|
93
|
-
|
|
94
|
-
export const defaultAspectRatioWidth = (height: number): number =>
|
|
95
|
-
(height / 9) * 16;
|
|
96
|
-
|
|
97
84
|
const getEdges = (
|
|
98
85
|
isTablet: boolean,
|
|
99
86
|
docked: boolean,
|
|
@@ -115,6 +102,28 @@ const getEdges = (
|
|
|
115
102
|
return ["top"];
|
|
116
103
|
};
|
|
117
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
|
+
|
|
118
127
|
export const PlayerWrapper = (props: Props) => {
|
|
119
128
|
const {
|
|
120
129
|
entry,
|
|
@@ -136,40 +145,38 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
136
145
|
|
|
137
146
|
const tabletWidth = getTabletWidth(configuration, style);
|
|
138
147
|
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const containerDimensions: Dimensions = React.useMemo(
|
|
148
|
+
const baseDimensions: DimensionsT = React.useMemo(
|
|
142
149
|
() => ({
|
|
143
150
|
width:
|
|
144
|
-
isInlineModal && !docked && isTabletLandscape
|
|
145
|
-
|
|
146
|
-
: style.width,
|
|
147
|
-
height:
|
|
148
|
-
isInlineModal && !docked
|
|
149
|
-
? defaultAspectRatioHeight(
|
|
150
|
-
isTabletLandscape ? tabletWidth : screenWidth
|
|
151
|
-
)
|
|
152
|
-
: style.height,
|
|
151
|
+
isInlineModal && !docked && isTabletLandscape ? tabletWidth : "100%",
|
|
152
|
+
height: isInlineModal && docked ? style.height : undefined,
|
|
153
153
|
}),
|
|
154
|
-
[isInlineModal,
|
|
154
|
+
[isInlineModal, tabletWidth, style.height, docked]
|
|
155
155
|
);
|
|
156
156
|
|
|
157
|
-
const playerDimensions:
|
|
157
|
+
const playerDimensions: DimensionsT = React.useMemo(
|
|
158
158
|
() => ({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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,
|
|
164
171
|
}),
|
|
165
|
-
[isInlineModal, docked,
|
|
172
|
+
[baseDimensions, isInlineModal, docked, playerDimensions.aspectRatio]
|
|
166
173
|
);
|
|
167
174
|
|
|
168
175
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
169
176
|
|
|
170
177
|
const childrenStyles = React.useMemo(
|
|
171
178
|
() => ({ ...playerDimensions, ...playerDimesionsHack }),
|
|
172
|
-
[
|
|
179
|
+
[containerDimensions, playerDimesionsHack]
|
|
173
180
|
);
|
|
174
181
|
|
|
175
182
|
return (
|
|
@@ -190,12 +197,6 @@ export const PlayerWrapper = (props: Props) => {
|
|
|
190
197
|
defaultStyles.playerContainer,
|
|
191
198
|
containerDimensions,
|
|
192
199
|
containerStyle,
|
|
193
|
-
{
|
|
194
|
-
height:
|
|
195
|
-
isInlineModal && !docked
|
|
196
|
-
? containerDimensions.height + 10
|
|
197
|
-
: containerDimensions.height,
|
|
198
|
-
},
|
|
199
200
|
playerDimesionsHack,
|
|
200
201
|
]}
|
|
201
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();
|
|
@@ -35,13 +35,11 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
35
35
|
"zIndex": 200,
|
|
36
36
|
},
|
|
37
37
|
Object {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"aspectRatio": 1.7777777777777777,
|
|
39
|
+
"height": undefined,
|
|
40
|
+
"width": "100%",
|
|
40
41
|
},
|
|
41
42
|
Object {},
|
|
42
|
-
Object {
|
|
43
|
-
"height": 431.875,
|
|
44
|
-
},
|
|
45
43
|
Object {},
|
|
46
44
|
]
|
|
47
45
|
}
|
|
@@ -105,13 +103,11 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
105
103
|
"zIndex": 200,
|
|
106
104
|
},
|
|
107
105
|
Object {
|
|
106
|
+
"aspectRatio": undefined,
|
|
108
107
|
"height": 50,
|
|
109
|
-
"width":
|
|
108
|
+
"width": "100%",
|
|
110
109
|
},
|
|
111
110
|
Object {},
|
|
112
|
-
Object {
|
|
113
|
-
"height": 50,
|
|
114
|
-
},
|
|
115
111
|
Object {},
|
|
116
112
|
]
|
|
117
113
|
}
|
|
@@ -163,13 +159,11 @@ 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
|
-
Object {
|
|
171
|
-
"height": 119.6875,
|
|
172
|
-
},
|
|
173
167
|
Object {},
|
|
174
168
|
]
|
|
175
169
|
}
|
|
@@ -233,13 +227,11 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
233
227
|
"zIndex": 200,
|
|
234
228
|
},
|
|
235
229
|
Object {
|
|
236
|
-
"
|
|
237
|
-
"
|
|
230
|
+
"aspectRatio": 1.7786666666666666,
|
|
231
|
+
"height": undefined,
|
|
232
|
+
"width": "100%",
|
|
238
233
|
},
|
|
239
234
|
Object {},
|
|
240
|
-
Object {
|
|
241
|
-
"height": 800,
|
|
242
|
-
},
|
|
243
235
|
Object {},
|
|
244
236
|
]
|
|
245
237
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { Dimensions } from "react-native";
|
|
3
3
|
import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
|
|
4
4
|
import {
|
|
@@ -39,13 +39,22 @@ export const useModalSize = (): Size => {
|
|
|
39
39
|
MODAL_SIZE_FOR_PORTRAIT
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const setNewModalSize = (
|
|
43
|
-
setModalSize(
|
|
42
|
+
const setNewModalSize = React.useCallback((newSize, log) => {
|
|
43
|
+
setModalSize((oldSize) => {
|
|
44
|
+
if (
|
|
45
|
+
oldSize.height === newSize.height &&
|
|
46
|
+
oldSize.width === newSize.width
|
|
47
|
+
) {
|
|
48
|
+
return oldSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return newSize;
|
|
52
|
+
});
|
|
44
53
|
|
|
45
54
|
logger.debug({
|
|
46
55
|
message: log,
|
|
47
56
|
});
|
|
48
|
-
};
|
|
57
|
+
}, []);
|
|
49
58
|
|
|
50
59
|
const isTabletLandscape = useIsTabletLandscape();
|
|
51
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.5353184830",
|
|
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-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
41
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
38
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.5353184830",
|
|
39
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5353184830",
|
|
40
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.5353184830",
|
|
41
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.5353184830",
|
|
42
42
|
"promise": "^8.3.0",
|
|
43
43
|
"react-router-native": "^5.1.2",
|
|
44
44
|
"url": "^0.11.0",
|