@applicaster/zapp-react-native-ui-components 12.0.0-alpha.9388848580 → 12.0.0-alpha.9417984401
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/FreezeWithCallback/Freeze.tsx +31 -0
- package/Components/FreezeWithCallback/LICENSE +21 -0
- package/Components/FreezeWithCallback/Suspender.tsx +17 -0
- package/Components/FreezeWithCallback/__tests__/index.test.tsx +170 -0
- package/Components/FreezeWithCallback/index.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +1 -7
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +12 -0
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -5
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +71 -0
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +7 -1
- package/Components/MasterCell/index.tsx +2 -2
- package/Components/PlayerContainer/PlayerContainer.tsx +11 -3
- package/Components/Screen/TV/hooks/index.ts +0 -2
- package/Components/Screen/TV/index.web.tsx +32 -19
- package/Components/Screen/__tests__/Screen.test.tsx +0 -49
- package/Components/Screen/index.tsx +1 -19
- package/Components/Screen/navigationHandler.ts +1 -3
- package/Components/Screen/orientationHandler.ts +18 -7
- package/Components/Screen/utils.ts +16 -0
- package/Components/Transitioner/Scene.tsx +9 -2
- package/Components/Transitioner/Transitioner.tsx +23 -10
- package/Components/Transitioner/__tests__/Scene.test.js +7 -0
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -0
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +23 -2
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +17 -0
- package/Components/VideoModal/PlayerDetails.tsx +16 -2
- package/Components/VideoModal/PlayerWrapper.tsx +40 -10
- package/Components/VideoModal/VideoModal.tsx +33 -27
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +102 -10
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -3
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
- package/Contexts/ConfirmDialogState/index.ts +1 -1
- package/const.ts +6 -0
- package/index.js +3 -0
- package/package.json +5 -5
- package/Components/Screen/TV/hooks/useRestoreFocus.ts +0 -22
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
|
|
2
|
+
import React, { Suspense, useEffect } from "react";
|
|
3
|
+
import { Suspender } from "./Suspender";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
freeze: boolean;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
placeholder?: React.ReactNode;
|
|
9
|
+
onRelease?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Freeze({
|
|
13
|
+
freeze,
|
|
14
|
+
children,
|
|
15
|
+
placeholder = null,
|
|
16
|
+
onRelease,
|
|
17
|
+
}: Props) {
|
|
18
|
+
const prevFreeze = usePrevious(freeze);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (prevFreeze && !freeze && onRelease) {
|
|
22
|
+
onRelease();
|
|
23
|
+
}
|
|
24
|
+
}, [freeze, onRelease, prevFreeze]);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Suspense fallback={placeholder}>
|
|
28
|
+
<Suspender freeze={freeze}>{children}</Suspender>
|
|
29
|
+
</Suspense>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Software Mansion
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
|
|
3
|
+
const infiniteThenable = { then() {} };
|
|
4
|
+
|
|
5
|
+
export const Suspender = ({
|
|
6
|
+
freeze,
|
|
7
|
+
children,
|
|
8
|
+
}: {
|
|
9
|
+
freeze: boolean;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}) => {
|
|
12
|
+
if (freeze) {
|
|
13
|
+
throw infiniteThenable;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return <Fragment>{children}</Fragment>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import React, { Dispatch, useEffect, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
act,
|
|
4
|
+
create,
|
|
5
|
+
ReactTestRenderer,
|
|
6
|
+
ReactTestRendererJSON,
|
|
7
|
+
} from "react-test-renderer";
|
|
8
|
+
import { FreezeWithCallback } from "../index";
|
|
9
|
+
|
|
10
|
+
const SimpleContent = () => <div />;
|
|
11
|
+
|
|
12
|
+
interface InnerProps {
|
|
13
|
+
value: number;
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
16
|
+
const Inner = ({ value }: InnerProps) => <div />;
|
|
17
|
+
|
|
18
|
+
interface TestSubscriber {
|
|
19
|
+
renderCount: number;
|
|
20
|
+
subscription: Dispatch<number>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function createSubscriberComponent(): [React.FC, TestSubscriber] {
|
|
24
|
+
const testState: TestSubscriber = {
|
|
25
|
+
renderCount: 0,
|
|
26
|
+
subscription: () => {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const Subscriber: React.FC = () => {
|
|
30
|
+
const [value, setValue] = useState(0);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
testState.subscription = setValue;
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
testState.renderCount += 1;
|
|
37
|
+
|
|
38
|
+
return <Inner value={value} />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return [Subscriber, testState];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface ContainerProps {
|
|
45
|
+
freeze: boolean;
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Container = ({ freeze, children }: ContainerProps) => (
|
|
50
|
+
<FreezeWithCallback freeze={freeze}>{children}</FreezeWithCallback>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
function setupTest(initialFreeze: boolean = false) {
|
|
54
|
+
let testRenderer: ReactTestRenderer | undefined;
|
|
55
|
+
const [Subscriber, subscriberState] = createSubscriberComponent();
|
|
56
|
+
|
|
57
|
+
act(() => {
|
|
58
|
+
testRenderer = create(
|
|
59
|
+
<Container freeze={initialFreeze}>
|
|
60
|
+
<Subscriber />
|
|
61
|
+
</Container>
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
testRenderer,
|
|
67
|
+
testInstance: testRenderer?.root,
|
|
68
|
+
subscriberState,
|
|
69
|
+
updateFreeze: (freeze: boolean) => {
|
|
70
|
+
act(() =>
|
|
71
|
+
testRenderer?.update(
|
|
72
|
+
<Container freeze={freeze}>
|
|
73
|
+
<Subscriber />
|
|
74
|
+
</Container>
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe("FreezeWithCallback", () => {
|
|
82
|
+
test("Renders stuff not frozen", () => {
|
|
83
|
+
const testRenderer = create(
|
|
84
|
+
<Container freeze={false}>
|
|
85
|
+
<SimpleContent />
|
|
86
|
+
</Container>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("Does not render stuff when frozen", () => {
|
|
93
|
+
const testRenderer = create(
|
|
94
|
+
<Container freeze>
|
|
95
|
+
<SimpleContent />
|
|
96
|
+
</Container>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(testRenderer.root.findAllByType(SimpleContent)).toHaveLength(0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("Stuff is gone after freeze", () => {
|
|
103
|
+
const testRenderer = create(
|
|
104
|
+
<Container freeze={false}>
|
|
105
|
+
<SimpleContent />
|
|
106
|
+
</Container>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
|
|
110
|
+
|
|
111
|
+
act(() =>
|
|
112
|
+
testRenderer.update(
|
|
113
|
+
<Container freeze>
|
|
114
|
+
<SimpleContent />
|
|
115
|
+
</Container>
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(testRenderer.toJSON()).toBe(null);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("Updates work when not frozen", () => {
|
|
123
|
+
const { testInstance, subscriberState } = setupTest();
|
|
124
|
+
|
|
125
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
126
|
+
act(() => subscriberState.subscription(1));
|
|
127
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(1);
|
|
128
|
+
expect(subscriberState.renderCount).toBe(2);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("Updates does not propagate when frozen", () => {
|
|
132
|
+
const { testInstance, subscriberState, updateFreeze } = setupTest();
|
|
133
|
+
|
|
134
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
135
|
+
updateFreeze(true);
|
|
136
|
+
act(() => subscriberState.subscription(1));
|
|
137
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
138
|
+
expect(subscriberState.renderCount).toBe(1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("State persists after defrost", () => {
|
|
142
|
+
const { testInstance, subscriberState, updateFreeze, testRenderer } =
|
|
143
|
+
setupTest();
|
|
144
|
+
|
|
145
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
146
|
+
act(() => subscriberState.subscription(1));
|
|
147
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(1);
|
|
148
|
+
|
|
149
|
+
updateFreeze(true);
|
|
150
|
+
expect(testRenderer?.toJSON()).toBe(null);
|
|
151
|
+
|
|
152
|
+
updateFreeze(false);
|
|
153
|
+
expect((testRenderer?.toJSON() as ReactTestRendererJSON).type).toBe("div");
|
|
154
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(1);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("Update propagate after defrost", () => {
|
|
158
|
+
const { testInstance, subscriberState, updateFreeze } = setupTest();
|
|
159
|
+
|
|
160
|
+
updateFreeze(true);
|
|
161
|
+
act(() => subscriberState.subscription(1));
|
|
162
|
+
act(() => subscriberState.subscription(2));
|
|
163
|
+
act(() => subscriberState.subscription(3));
|
|
164
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(0);
|
|
165
|
+
|
|
166
|
+
updateFreeze(false);
|
|
167
|
+
expect(testInstance?.findByType(Inner).props.value).toEqual(3);
|
|
168
|
+
expect(subscriberState.renderCount).toBe(2);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -117,9 +117,6 @@ export const BorderContainerView = (props: Props) => {
|
|
|
117
117
|
children,
|
|
118
118
|
} = props;
|
|
119
119
|
|
|
120
|
-
const borderStyleForMissingBorder =
|
|
121
|
-
style?.borderWidth === 0 || !style?.borderColor ? { borderRadius: 0 } : {};
|
|
122
|
-
|
|
123
120
|
const padding =
|
|
124
121
|
borderPosition === "outside"
|
|
125
122
|
? {
|
|
@@ -131,10 +128,7 @@ export const BorderContainerView = (props: Props) => {
|
|
|
131
128
|
: {};
|
|
132
129
|
|
|
133
130
|
return (
|
|
134
|
-
<View
|
|
135
|
-
{...props}
|
|
136
|
-
style={[style, styles.container, borderStyleForMissingBorder]}
|
|
137
|
-
>
|
|
131
|
+
<View pointerEvents="box-none" {...props} style={[style, styles.container]}>
|
|
138
132
|
<Border style={style} padding={padding} borderPosition={borderPosition} />
|
|
139
133
|
{children}
|
|
140
134
|
</View>
|
|
@@ -5,6 +5,7 @@ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/acti
|
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
import { getXray } from "@applicaster/zapp-react-native-utils/logger";
|
|
7
7
|
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
8
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
8
9
|
|
|
9
10
|
const { Logger } = getXray();
|
|
10
11
|
|
|
@@ -44,6 +45,11 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
|
|
|
44
45
|
|
|
45
46
|
const actionContext = useActions(pluginIdentifier);
|
|
46
47
|
|
|
48
|
+
const accessibilityManager = useAccessibilityManager({});
|
|
49
|
+
|
|
50
|
+
const { ttsLabel = "" } =
|
|
51
|
+
actionContext?.initialEntryState(item)?.getAccessibility?.(item) || {};
|
|
52
|
+
|
|
47
53
|
const onPress = (event) => {
|
|
48
54
|
event?.preventDefault?.();
|
|
49
55
|
|
|
@@ -88,6 +94,12 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
|
|
|
88
94
|
mouse: focusable.mouse,
|
|
89
95
|
});
|
|
90
96
|
});
|
|
97
|
+
|
|
98
|
+
if (ttsLabel) {
|
|
99
|
+
accessibilityManager.readText({
|
|
100
|
+
text: ttsLabel,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
91
103
|
};
|
|
92
104
|
|
|
93
105
|
const handleBlur = (_focusable, _direction) => {
|
|
@@ -38,21 +38,22 @@ function Image({
|
|
|
38
38
|
|
|
39
39
|
const shouldRenderImg = source && !error;
|
|
40
40
|
|
|
41
|
+
// Default placeholder image fallback is empty string because it won't rerender
|
|
42
|
+
// in case of undefined or {uri: undefined} source
|
|
43
|
+
// https://github.com/facebook/react-native/issues/9195
|
|
41
44
|
const defaultPlaceHolderImage = React.useMemo(
|
|
42
45
|
() => ({ uri: placeholderImage || "" }),
|
|
43
46
|
[source, error]
|
|
44
47
|
);
|
|
45
48
|
|
|
46
|
-
const _source = shouldRenderImg
|
|
47
|
-
? withDimensions(source)
|
|
48
|
-
: defaultPlaceHolderImage;
|
|
49
|
-
|
|
50
49
|
return (
|
|
51
50
|
// @ts-ignore
|
|
52
51
|
<MemoizedImage
|
|
53
52
|
style={style as ImageStyle}
|
|
54
53
|
onError={() => setErrorState(true)}
|
|
55
|
-
source={
|
|
54
|
+
source={
|
|
55
|
+
shouldRenderImg ? withDimensions(source) : defaultPlaceHolderImage
|
|
56
|
+
}
|
|
56
57
|
{...R.omit(["source"], otherProps)}
|
|
57
58
|
/>
|
|
58
59
|
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ImageStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getImageContainerMarginStyles,
|
|
5
|
+
ifElseFocusedSelected,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
7
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
8
|
+
|
|
9
|
+
export const ImageBorderContainer = ({
|
|
10
|
+
value,
|
|
11
|
+
state,
|
|
12
|
+
imageStyles,
|
|
13
|
+
}: {
|
|
14
|
+
value: (key: string) => string;
|
|
15
|
+
state: CellState;
|
|
16
|
+
imageStyles: ImageStyle;
|
|
17
|
+
}) => {
|
|
18
|
+
const imageMargins = getImageContainerMarginStyles({ value });
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
type: "BorderContainerView",
|
|
22
|
+
style: {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
// Image border now separated from the image, so cell padding affects the border position
|
|
25
|
+
marginTop:
|
|
26
|
+
toNumberWithDefaultZero(imageMargins.marginTop) +
|
|
27
|
+
toNumberWithDefaultZero(value("cell_padding_top")),
|
|
28
|
+
marginLeft:
|
|
29
|
+
toNumberWithDefaultZero(imageMargins.marginLeft) +
|
|
30
|
+
toNumberWithDefaultZero(value("cell_padding_left")),
|
|
31
|
+
marginRight:
|
|
32
|
+
toNumberWithDefaultZero(imageMargins.marginRight) +
|
|
33
|
+
toNumberWithDefaultZero(value("cell_padding_right")),
|
|
34
|
+
marginBottom:
|
|
35
|
+
toNumberWithDefaultZero(imageMargins.marginBottom) +
|
|
36
|
+
toNumberWithDefaultZero(value("cell_padding_bottom")),
|
|
37
|
+
zIndex: 1,
|
|
38
|
+
borderWidth: value("image_border_size"),
|
|
39
|
+
borderColor: ifElseFocusedSelected(
|
|
40
|
+
state,
|
|
41
|
+
value("image_focused_border_color"),
|
|
42
|
+
value("image_selected_border_color"),
|
|
43
|
+
value("image_focused_selected_border_color"),
|
|
44
|
+
value("image_border_color")
|
|
45
|
+
),
|
|
46
|
+
borderRadius: toNumberWithDefaultZero(value("image_corner_radius")),
|
|
47
|
+
},
|
|
48
|
+
additionalProps: {
|
|
49
|
+
pointerEvents: "none",
|
|
50
|
+
borderPosition: value("image_border_position"),
|
|
51
|
+
borderPaddingTop: toNumberWithDefaultZero(
|
|
52
|
+
value("image_border_padding_top")
|
|
53
|
+
),
|
|
54
|
+
borderPaddingRight: toNumberWithDefaultZero(
|
|
55
|
+
value("image_border_padding_right")
|
|
56
|
+
),
|
|
57
|
+
borderPaddingBottom: toNumberWithDefaultZero(
|
|
58
|
+
value("image_border_padding_bottom")
|
|
59
|
+
),
|
|
60
|
+
borderPaddingLeft: toNumberWithDefaultZero(
|
|
61
|
+
value("image_border_padding_left")
|
|
62
|
+
),
|
|
63
|
+
},
|
|
64
|
+
elements: [
|
|
65
|
+
{
|
|
66
|
+
type: "View",
|
|
67
|
+
style: imageStyles,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -15,6 +15,7 @@ import { BorderContainerView } from "./BorderContainerView";
|
|
|
15
15
|
import { CellBadge } from "./CellBadge";
|
|
16
16
|
import { TvActionButtons } from "./tv/TvActionButtons";
|
|
17
17
|
import { ButtonContainerView } from "./tv/ButtonContainerView";
|
|
18
|
+
import { ImageBorderContainer } from "./ImageBorderContainer";
|
|
18
19
|
|
|
19
20
|
export const defaultComponents = {
|
|
20
21
|
View,
|
|
@@ -28,6 +29,7 @@ export const defaultComponents = {
|
|
|
28
29
|
ProgressBar,
|
|
29
30
|
Toggle,
|
|
30
31
|
LiveImage,
|
|
32
|
+
ImageBorderContainer,
|
|
31
33
|
BorderContainerView,
|
|
32
34
|
DynamicBadge,
|
|
33
35
|
SecondaryImage,
|
|
@@ -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
|
};
|
|
@@ -76,8 +76,8 @@ export function masterCellBuilder({
|
|
|
76
76
|
const selectedState = screen?.selectedEntry;
|
|
77
77
|
|
|
78
78
|
const entryIsSelected = React.useMemo(
|
|
79
|
-
() => selectedState?.id === item?.id,
|
|
80
|
-
[selectedState?.id]
|
|
79
|
+
() => !!(selectedState?.id && selectedState?.id === item?.id),
|
|
80
|
+
[selectedState?.id, item?.id]
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
const elements = React.useMemo(
|
|
@@ -363,11 +363,19 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
363
363
|
const { fullscreen = false } = event || {};
|
|
364
364
|
|
|
365
365
|
if (fullscreen) {
|
|
366
|
-
|
|
366
|
+
// in order to avoid UI glitches with player we have to start re-render ealier and then start real rotation
|
|
367
367
|
navigator.fullscreenVideoModal();
|
|
368
|
+
|
|
369
|
+
setTimeout(() => {
|
|
370
|
+
playerEvent("onFullscreenPlayerWillPresent");
|
|
371
|
+
});
|
|
368
372
|
} else {
|
|
369
|
-
|
|
373
|
+
// in order to avoid UI glitches with player we have to start re-render ealier and then start real rotation
|
|
370
374
|
navigator.maximiseVideoModal();
|
|
375
|
+
|
|
376
|
+
setTimeout(() => {
|
|
377
|
+
playerEvent("onFullscreenPlayerWillDismiss");
|
|
378
|
+
});
|
|
371
379
|
}
|
|
372
380
|
};
|
|
373
381
|
|
|
@@ -519,7 +527,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
519
527
|
}
|
|
520
528
|
|
|
521
529
|
return () => {
|
|
522
|
-
playerEvent("player_did_close");
|
|
530
|
+
playerEvent("player_did_close", { item });
|
|
523
531
|
|
|
524
532
|
if (!isModal) {
|
|
525
533
|
showNavBar(true);
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { last } from "ramda";
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import {
|
|
5
5
|
findMenuPlugin,
|
|
6
6
|
getNavigationProps,
|
|
7
7
|
getPathAttributes,
|
|
8
8
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useIsScreenActive,
|
|
11
|
+
useNavigation,
|
|
12
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
10
13
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
11
14
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
12
15
|
import {
|
|
@@ -17,8 +20,10 @@ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/he
|
|
|
17
20
|
|
|
18
21
|
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
19
22
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
20
|
-
import { useInitialFocus
|
|
23
|
+
import { useInitialFocus } from "./hooks";
|
|
21
24
|
import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
25
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
26
|
+
import { FreezeWithCallback } from "../../FreezeWithCallback";
|
|
22
27
|
|
|
23
28
|
const styles = StyleSheet.create({
|
|
24
29
|
container: {
|
|
@@ -103,7 +108,6 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
103
108
|
const backgroundColor = useScreenBackgroundColor(screenId);
|
|
104
109
|
|
|
105
110
|
useInitialFocus();
|
|
106
|
-
useRestoreFocus();
|
|
107
111
|
|
|
108
112
|
const activeRiver = getActiveRiver({
|
|
109
113
|
screenId,
|
|
@@ -145,21 +149,30 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
145
149
|
? routeState?.state?.entry
|
|
146
150
|
: routeState?.state?.screen;
|
|
147
151
|
|
|
152
|
+
const isScreenActive = useIsScreenActive();
|
|
153
|
+
|
|
148
154
|
return (
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
<FreezeWithCallback
|
|
156
|
+
freeze={!isScreenActive}
|
|
157
|
+
onRelease={() => {
|
|
158
|
+
focusManager.setInitialFocus();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
162
|
+
<NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
|
|
163
|
+
<NavBar
|
|
164
|
+
isVisible={isNavBarVisible}
|
|
165
|
+
menuPlugin={menuPlugin}
|
|
166
|
+
navigationProps={navigationProps}
|
|
167
|
+
/>
|
|
168
|
+
</NavBarContainer>
|
|
169
|
+
<ScreenResolver
|
|
170
|
+
screenType={screenType}
|
|
171
|
+
screenId={screenId}
|
|
172
|
+
screenData={screenData}
|
|
173
|
+
groupId={route}
|
|
155
174
|
/>
|
|
156
|
-
</
|
|
157
|
-
|
|
158
|
-
screenType={screenType}
|
|
159
|
-
screenId={screenId}
|
|
160
|
-
screenData={screenData}
|
|
161
|
-
groupId={route}
|
|
162
|
-
/>
|
|
163
|
-
</View>
|
|
175
|
+
</View>
|
|
176
|
+
</FreezeWithCallback>
|
|
164
177
|
);
|
|
165
178
|
};
|
|
@@ -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
|
});
|