@applicaster/zapp-react-native-ui-components 15.0.0-alpha.3242245332 → 15.0.0-alpha.3248453012
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/Cell/Cell.tsx +8 -3
- package/Components/Cell/TvOSCellComponent.tsx +12 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +36 -2
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +12 -6
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/Tabs/TV/Tabs.tsx +20 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +120 -27
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/utils.ts +7 -0
- package/index.d.ts +7 -0
- package/package.json +5 -5
package/Components/Cell/Cell.tsx
CHANGED
|
@@ -208,14 +208,14 @@ export class CellComponent extends React.Component<Props, State> {
|
|
|
208
208
|
this.accessibilityManager.readText({
|
|
209
209
|
text: " ",
|
|
210
210
|
});
|
|
211
|
-
} else {
|
|
211
|
+
} else if (this.state.cellFocused) {
|
|
212
212
|
this.accessibilityManager.readText({
|
|
213
213
|
text: `${positionLabel}`,
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
componentDidUpdate(prevProps: Readonly<Props>) {
|
|
218
|
+
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>) {
|
|
219
219
|
if (prevProps.item !== this.props.item) {
|
|
220
220
|
this.setState({
|
|
221
221
|
hasFocusableInside: this.props.CellRenderer.hasFocusableInside?.(
|
|
@@ -224,7 +224,12 @@ export class CellComponent extends React.Component<Props, State> {
|
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
if (
|
|
228
|
+
prevState.cellFocused !== this.state.cellFocused ||
|
|
229
|
+
this.state.hasFocusableInside
|
|
230
|
+
) {
|
|
231
|
+
this.handleAccessibilityFocus(this.props.index, this.props.dataLength);
|
|
232
|
+
}
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
render() {
|
|
@@ -17,6 +17,7 @@ import { CellWithFocusable } from "./CellWithFocusable";
|
|
|
17
17
|
import { FocusableWrapper } from "./FocusableWrapper";
|
|
18
18
|
|
|
19
19
|
import { focusableButtonsRegistration$ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
|
|
20
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
20
21
|
|
|
21
22
|
type Props = {
|
|
22
23
|
item: ZappEntry;
|
|
@@ -37,6 +38,9 @@ type Props = {
|
|
|
37
38
|
component: {
|
|
38
39
|
id: number | string;
|
|
39
40
|
component_type: string;
|
|
41
|
+
styles?: {
|
|
42
|
+
component_margin_top?: number;
|
|
43
|
+
};
|
|
40
44
|
};
|
|
41
45
|
selected: boolean;
|
|
42
46
|
CellRenderer: React.FunctionComponent<any> & {
|
|
@@ -204,11 +208,16 @@ class TvOSCell extends React.Component<Props, State> {
|
|
|
204
208
|
const extraAnchorPointYOffset =
|
|
205
209
|
screenLayout?.extraAnchorPointYOffset || 0;
|
|
206
210
|
|
|
211
|
+
const componentMarginTop = toNumberWithDefaultZero(
|
|
212
|
+
component?.styles?.component_margin_top
|
|
213
|
+
);
|
|
214
|
+
|
|
207
215
|
const totalOffset =
|
|
208
216
|
headerOffset +
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
217
|
+
(componentAnchorPointY || 0) +
|
|
218
|
+
extraAnchorPointYOffset -
|
|
219
|
+
(componentsMapOffset || 0) +
|
|
220
|
+
componentMarginTop;
|
|
212
221
|
|
|
213
222
|
mainOffsetUpdater?.(
|
|
214
223
|
{ tag: this.target },
|
package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import {
|
|
2
3
|
BorderContainerView,
|
|
3
4
|
getBorderPadding, // Export for testing (using a double underscore prefix is a common convention)
|
|
4
5
|
} from "../index";
|
|
5
|
-
import * as React from "react";
|
|
6
6
|
import { render } from "@testing-library/react-native";
|
|
7
7
|
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
8
8
|
import { View } from "react-native";
|
|
@@ -11,6 +11,15 @@ jest.mock("@applicaster/zapp-react-native-utils/numberUtils", () => ({
|
|
|
11
11
|
toNumberWithDefaultZero: jest.fn((value) => Number(value) || 0),
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
|
+
jest.mock(
|
|
15
|
+
"@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
|
|
16
|
+
() => ({
|
|
17
|
+
useAccessibilityManager: jest.fn(() => ({
|
|
18
|
+
addHeading: jest.fn(),
|
|
19
|
+
})),
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
|
|
14
23
|
describe("BorderContainerView", () => {
|
|
15
24
|
describe("getBorderPadding", () => {
|
|
16
25
|
it("returns 0 for inside", () => {
|
|
@@ -42,6 +51,8 @@ describe("BorderContainerView", () => {
|
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
const borderPosition = null;
|
|
54
|
+
const mockEntry = { id: "test-entry" } as ZappEntry;
|
|
55
|
+
const mockHasFocusableInside = jest.fn(() => false);
|
|
45
56
|
|
|
46
57
|
const { queryByTestId } = render(
|
|
47
58
|
<BorderContainerView
|
|
@@ -52,6 +63,10 @@ describe("BorderContainerView", () => {
|
|
|
52
63
|
borderPaddingRight={toNumberWithDefaultZero(padding.paddingRight)}
|
|
53
64
|
borderPaddingBottom={toNumberWithDefaultZero(padding.paddingBottom)}
|
|
54
65
|
borderPaddingLeft={toNumberWithDefaultZero(padding.paddingLeft)}
|
|
66
|
+
hasFocusableInside={mockHasFocusableInside}
|
|
67
|
+
entry={mockEntry}
|
|
68
|
+
state="focused"
|
|
69
|
+
hasTextLabels={false}
|
|
55
70
|
>
|
|
56
71
|
<View testID="child" />
|
|
57
72
|
</BorderContainerView>
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as React from "react";
|
|
1
|
+
import React, { useMemo, useContext, useEffect } from "react";
|
|
3
2
|
import { ImageStyle, StyleSheet, View, ViewStyle } from "react-native";
|
|
3
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
4
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
5
|
+
import { MeasurementPortalContext } from "../../../MeasurmentsPortal/MeasurementsPortal";
|
|
4
6
|
|
|
5
7
|
type BorderPosition = "inside" | "outside" | "center";
|
|
6
8
|
|
|
7
9
|
interface Props {
|
|
10
|
+
hasFocusableInside: (entry: ZappEntry) => boolean;
|
|
11
|
+
entry: ZappEntry;
|
|
12
|
+
state: CellState;
|
|
13
|
+
hasTextLabels: boolean;
|
|
8
14
|
style: ImageStyle | ViewStyle;
|
|
9
15
|
borderPosition: BorderPosition;
|
|
10
16
|
borderPaddingTop: number;
|
|
@@ -118,8 +124,36 @@ export const BorderContainerView = (props: Props) => {
|
|
|
118
124
|
borderPaddingLeft,
|
|
119
125
|
style,
|
|
120
126
|
children,
|
|
127
|
+
hasFocusableInside,
|
|
128
|
+
entry,
|
|
129
|
+
state,
|
|
130
|
+
hasTextLabels,
|
|
121
131
|
} = props;
|
|
122
132
|
|
|
133
|
+
const accessibilityManager = useAccessibilityManager();
|
|
134
|
+
const isMeasurement = useContext(MeasurementPortalContext);
|
|
135
|
+
|
|
136
|
+
const isImageOnlyCell = useMemo(
|
|
137
|
+
() =>
|
|
138
|
+
!hasFocusableInside(entry) &&
|
|
139
|
+
!hasTextLabels &&
|
|
140
|
+
state === "focused" &&
|
|
141
|
+
!isMeasurement?.measuringInProgress,
|
|
142
|
+
[
|
|
143
|
+
hasFocusableInside,
|
|
144
|
+
entry,
|
|
145
|
+
hasTextLabels,
|
|
146
|
+
state,
|
|
147
|
+
isMeasurement?.measuringInProgress,
|
|
148
|
+
]
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (isImageOnlyCell && entry?.title) {
|
|
153
|
+
accessibilityManager.addHeading(String(entry.title));
|
|
154
|
+
}
|
|
155
|
+
}, [isImageOnlyCell, entry?.title]);
|
|
156
|
+
|
|
123
157
|
const padding =
|
|
124
158
|
borderPosition === "outside"
|
|
125
159
|
? {
|
|
@@ -9,6 +9,7 @@ import { useTrackCurrentAutoScrollingElement } from "@applicaster/zapp-react-nat
|
|
|
9
9
|
import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
10
10
|
import { getPropComponentType } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
11
11
|
import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
12
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
12
13
|
|
|
13
14
|
type LiveImageProps = {
|
|
14
15
|
item: ZappEntry;
|
|
@@ -108,8 +109,7 @@ const prepareEntry = (entry) => {
|
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
const previewPlayback =
|
|
112
|
-
entry.extensions?.["brightcove"]?.["preview_playback"];
|
|
112
|
+
const previewPlayback = entry.extensions?.brightcove?.preview_playback;
|
|
113
113
|
|
|
114
114
|
if (previewPlayback) {
|
|
115
115
|
return {
|
|
@@ -117,14 +117,14 @@ const prepareEntry = (entry) => {
|
|
|
117
117
|
extensions: {
|
|
118
118
|
...entry.extensions,
|
|
119
119
|
brightcove: {
|
|
120
|
-
...entry?.extensions?.
|
|
120
|
+
...entry?.extensions?.brightcove,
|
|
121
121
|
video_id: previewPlayback,
|
|
122
122
|
},
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
if (entry.extensions?.
|
|
127
|
+
if (entry.extensions?.brightcove?.video_id) {
|
|
128
128
|
return entry;
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -174,7 +174,7 @@ const getPlayerConfig = (player_screen_id, actionIdentifier) => {
|
|
|
174
174
|
// TODO: Add more dict if needed from the screen component, styles, data etc
|
|
175
175
|
return {
|
|
176
176
|
playerPluginId: playerScreen?.type ?? DEFAULT_PLAYER_IDENTIFIER,
|
|
177
|
-
screenConfig: playerScreen?.
|
|
177
|
+
screenConfig: playerScreen?.general,
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -206,6 +206,11 @@ const LiveImageComponent = (props: LiveImageProps) => {
|
|
|
206
206
|
state,
|
|
207
207
|
} = props;
|
|
208
208
|
|
|
209
|
+
const accessibilityManager = useAccessibilityManager();
|
|
210
|
+
|
|
211
|
+
const isScreenReaderEnabled =
|
|
212
|
+
accessibilityManager.accessibilityManagerState.screenReaderEnabled;
|
|
213
|
+
|
|
209
214
|
const component = useUIComponentContext();
|
|
210
215
|
|
|
211
216
|
// Fix for blinking on state change
|
|
@@ -239,7 +244,8 @@ const LiveImageComponent = (props: LiveImageProps) => {
|
|
|
239
244
|
getFocusedState(state, componentType, isCurrentlyFocused) &&
|
|
240
245
|
playableEntry &&
|
|
241
246
|
cellUUID &&
|
|
242
|
-
isSupportedTVForLiveImage()
|
|
247
|
+
isSupportedTVForLiveImage() &&
|
|
248
|
+
!isScreenReaderEnabled;
|
|
243
249
|
|
|
244
250
|
return (
|
|
245
251
|
<>
|
|
@@ -52,14 +52,14 @@ const _Text = ({
|
|
|
52
52
|
: textTransform(transformText, _label);
|
|
53
53
|
|
|
54
54
|
React.useLayoutEffect(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
if (cellFocused) {
|
|
56
|
+
switch (otherProps.state) {
|
|
57
|
+
case "focused":
|
|
58
|
+
accessibilityManager.addHeading(textLabel);
|
|
59
|
+
break;
|
|
60
|
+
case "focused_selected":
|
|
61
|
+
accessibilityManager.addHeading(`${textLabel}, Selected`);
|
|
62
|
+
break;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}, [cellFocused, otherProps.state, textLabel]);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { makeListOf } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
2
2
|
import { isFirstComponentGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
3
|
-
import {
|
|
3
|
+
import { race, Subject, Subscription } from "rxjs";
|
|
4
|
+
import { first } from "rxjs/operators";
|
|
5
|
+
|
|
6
|
+
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
7
|
+
|
|
8
|
+
const MAX_TIMEOUT_TO_WAIT_COMPONENTS_TO_LOAD = 2000; // 2 seconds
|
|
4
9
|
|
|
5
10
|
const INITIAL_NUMBER_TO_LOAD = 3;
|
|
6
11
|
|
|
@@ -34,7 +39,8 @@ const getNumberOfComponentsWaitToLoadBeforePresent = (
|
|
|
34
39
|
export class ScreenRevealManager {
|
|
35
40
|
public numberOfComponentsWaitToLoadBeforePresent: number;
|
|
36
41
|
private renderingState: Array<ComponentLoadingState>;
|
|
37
|
-
private
|
|
42
|
+
private subject$ = new Subject<void>();
|
|
43
|
+
private subscription: Subscription;
|
|
38
44
|
|
|
39
45
|
constructor(componentsToRender: ZappUIComponent[], callback: Callback) {
|
|
40
46
|
this.numberOfComponentsWaitToLoadBeforePresent =
|
|
@@ -45,32 +51,58 @@ export class ScreenRevealManager {
|
|
|
45
51
|
this.numberOfComponentsWaitToLoadBeforePresent
|
|
46
52
|
);
|
|
47
53
|
|
|
48
|
-
this.
|
|
54
|
+
this.subscription = race(
|
|
55
|
+
withTimeout$(MAX_TIMEOUT_TO_WAIT_COMPONENTS_TO_LOAD),
|
|
56
|
+
this.subject$
|
|
57
|
+
)
|
|
58
|
+
.pipe(first())
|
|
59
|
+
.subscribe(callback);
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
onLoadFinished = (index: number): void => {
|
|
63
|
+
const currentState = this.renderingState[index];
|
|
64
|
+
|
|
65
|
+
if (
|
|
66
|
+
COMPONENT_LOADING_STATE.LOADED_WITH_SUCCESS === currentState ||
|
|
67
|
+
COMPONENT_LOADING_STATE.LOADED_WITH_FAILURE === currentState
|
|
68
|
+
) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
52
72
|
this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_SUCCESS;
|
|
53
73
|
|
|
54
74
|
if (
|
|
55
75
|
getNumberOfLoaded(this.renderingState) >=
|
|
56
76
|
this.numberOfComponentsWaitToLoadBeforePresent
|
|
57
77
|
) {
|
|
58
|
-
this.
|
|
78
|
+
this.subject$.next();
|
|
79
|
+
this.subject$.complete();
|
|
59
80
|
}
|
|
60
81
|
};
|
|
61
82
|
|
|
62
83
|
onLoadFailed = (index: number): void => {
|
|
84
|
+
const currentState = this.renderingState[index];
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
COMPONENT_LOADING_STATE.LOADED_WITH_SUCCESS === currentState ||
|
|
88
|
+
COMPONENT_LOADING_STATE.LOADED_WITH_FAILURE === currentState
|
|
89
|
+
) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
63
93
|
this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_FAILURE;
|
|
64
94
|
|
|
65
95
|
if (
|
|
66
96
|
getNumberOfLoaded(this.renderingState) >=
|
|
67
97
|
this.numberOfComponentsWaitToLoadBeforePresent
|
|
68
98
|
) {
|
|
69
|
-
this.
|
|
99
|
+
this.subject$.next();
|
|
100
|
+
this.subject$.complete();
|
|
70
101
|
}
|
|
71
102
|
};
|
|
72
103
|
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
|
|
104
|
+
dispose(): void {
|
|
105
|
+
this.subscription?.unsubscribe();
|
|
106
|
+
this.subject$.complete();
|
|
107
|
+
}
|
|
76
108
|
}
|
|
@@ -2,106 +2,123 @@ import {
|
|
|
2
2
|
ScreenRevealManager,
|
|
3
3
|
COMPONENT_LOADING_STATE,
|
|
4
4
|
} from "../ScreenRevealManager";
|
|
5
|
+
import { Subject } from "rxjs";
|
|
6
|
+
|
|
7
|
+
jest.mock("@applicaster/zapp-react-native-utils/arrayUtils", () => ({
|
|
8
|
+
makeListOf: jest.fn((value: any, length: number) =>
|
|
9
|
+
Array(length).fill(value)
|
|
10
|
+
),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("@applicaster/zapp-react-native-utils/componentsUtils", () => ({
|
|
14
|
+
isFirstComponentGallery: jest.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock("@applicaster/zapp-react-native-utils/idleUtils", () => ({
|
|
18
|
+
withTimeout$: jest.fn(),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
import { makeListOf } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
22
|
+
import { isFirstComponentGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
23
|
+
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
5
24
|
|
|
6
25
|
describe("ScreenRevealManager", () => {
|
|
7
|
-
|
|
26
|
+
let mockCallback: jest.Mock;
|
|
27
|
+
let timeout$: Subject<void>;
|
|
8
28
|
|
|
9
29
|
beforeEach(() => {
|
|
10
|
-
jest.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
it("should initialize with the correct number of components to wait for", () => {
|
|
14
|
-
const componentsToRender: ZappUIComponent[] = [
|
|
15
|
-
{ component_type: "component1" },
|
|
16
|
-
{ component_type: "component2" },
|
|
17
|
-
{ component_type: "component3" },
|
|
18
|
-
];
|
|
30
|
+
jest.useFakeTimers();
|
|
31
|
+
mockCallback = jest.fn();
|
|
32
|
+
timeout$ = new Subject();
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
(withTimeout$ as jest.Mock).mockReturnValue(timeout$);
|
|
35
|
+
(isFirstComponentGallery as jest.Mock).mockReturnValue(false);
|
|
21
36
|
|
|
22
|
-
|
|
37
|
+
(makeListOf as jest.Mock).mockImplementation((value, length) =>
|
|
38
|
+
Array(length).fill(value)
|
|
39
|
+
);
|
|
40
|
+
});
|
|
23
41
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]);
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
jest.clearAllTimers();
|
|
44
|
+
jest.useRealTimers();
|
|
45
|
+
jest.resetAllMocks();
|
|
29
46
|
});
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{ component_type: "component3" },
|
|
36
|
-
];
|
|
48
|
+
// ────────────────────────────────────────────────
|
|
49
|
+
it("should initialize with correct number of components and UNKNOWN state", () => {
|
|
50
|
+
const components = new Array(5).fill({});
|
|
51
|
+
const mgr = new ScreenRevealManager(components, mockCallback);
|
|
37
52
|
|
|
38
|
-
|
|
53
|
+
expect(mgr.numberOfComponentsWaitToLoadBeforePresent).toBe(3);
|
|
54
|
+
expect(makeListOf).toHaveBeenCalledWith(COMPONENT_LOADING_STATE.UNKNOWN, 3);
|
|
55
|
+
});
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
// ────────────────────────────────────────────────
|
|
58
|
+
it("should set numberOfComponentsWaitToLoadBeforePresent to 1 if first component is gallery", () => {
|
|
59
|
+
(isFirstComponentGallery as jest.Mock).mockReturnValue(true);
|
|
43
60
|
|
|
44
|
-
|
|
61
|
+
const components = new Array(5).fill({});
|
|
62
|
+
const mgr = new ScreenRevealManager(components, mockCallback);
|
|
63
|
+
|
|
64
|
+
expect(mgr.numberOfComponentsWaitToLoadBeforePresent).toBe(1);
|
|
45
65
|
});
|
|
46
66
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{ component_type: "component3" },
|
|
52
|
-
];
|
|
67
|
+
// ────────────────────────────────────────────────
|
|
68
|
+
it("should trigger callback after all components load successfully", () => {
|
|
69
|
+
const components = new Array(3).fill({});
|
|
70
|
+
const mgr = new ScreenRevealManager(components, mockCallback);
|
|
53
71
|
|
|
54
|
-
|
|
72
|
+
mgr.onLoadFinished(0);
|
|
73
|
+
expect(mockCallback).not.toHaveBeenCalled();
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
manager.onLoadFailed(2);
|
|
75
|
+
mgr.onLoadFinished(1);
|
|
76
|
+
expect(mockCallback).not.toHaveBeenCalled();
|
|
59
77
|
|
|
78
|
+
mgr.onLoadFinished(2);
|
|
60
79
|
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
61
80
|
});
|
|
62
81
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{ component_type: "component3" },
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
82
|
+
// ────────────────────────────────────────────────
|
|
83
|
+
it("should trigger callback after some components fail to load but all finished", () => {
|
|
84
|
+
const components = new Array(3).fill({});
|
|
85
|
+
const mgr = new ScreenRevealManager(components, mockCallback);
|
|
71
86
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
mgr.onLoadFinished(0);
|
|
88
|
+
mgr.onLoadFailed(1);
|
|
89
|
+
mgr.onLoadFailed(2);
|
|
75
90
|
|
|
76
91
|
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
77
92
|
});
|
|
78
93
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{ component_type: "component3" },
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
const manager = new ScreenRevealManager(componentsToRender, mockCallback);
|
|
94
|
+
// ────────────────────────────────────────────────
|
|
95
|
+
it("should not trigger callback twice when same component finishes twice", () => {
|
|
96
|
+
const components = new Array(3).fill({});
|
|
97
|
+
const mgr = new ScreenRevealManager(components, mockCallback);
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
mgr.onLoadFinished(0);
|
|
100
|
+
mgr.onLoadFinished(0); // duplicate
|
|
101
|
+
mgr.onLoadFinished(1);
|
|
102
|
+
mgr.onLoadFinished(2);
|
|
90
103
|
|
|
91
|
-
expect(mockCallback).
|
|
104
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
92
105
|
});
|
|
93
106
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{ component_type: "component3" },
|
|
99
|
-
];
|
|
107
|
+
// ────────────────────────────────────────────────
|
|
108
|
+
it("should trigger callback when timeout$ emits before all loaded", () => {
|
|
109
|
+
const components = new Array(3).fill({});
|
|
110
|
+
new ScreenRevealManager(components, mockCallback);
|
|
100
111
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
manager.onLoadFinished(0);
|
|
112
|
+
timeout$.next(); // simulate timeout event from withTimeout$
|
|
104
113
|
|
|
105
114
|
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
106
115
|
});
|
|
116
|
+
|
|
117
|
+
// ────────────────────────────────────────────────
|
|
118
|
+
it("should not call callback if nothing loads and no timeout emitted", () => {
|
|
119
|
+
const components = new Array(3).fill({});
|
|
120
|
+
new ScreenRevealManager(components, mockCallback);
|
|
121
|
+
|
|
122
|
+
expect(mockCallback).not.toHaveBeenCalled();
|
|
123
|
+
});
|
|
107
124
|
});
|
|
@@ -8,6 +8,7 @@ import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
|
8
8
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
9
9
|
import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
|
|
10
10
|
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
|
|
11
|
+
import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
|
|
11
12
|
import { Gutter } from "../Gutter";
|
|
12
13
|
import Tab from "./Tab";
|
|
13
14
|
import { getStyles } from "./styles";
|
|
@@ -28,11 +29,14 @@ const TabsComponent = ({
|
|
|
28
29
|
style,
|
|
29
30
|
selectedEntryIndex,
|
|
30
31
|
setSelectedEntry,
|
|
32
|
+
accessibility,
|
|
31
33
|
}: TabsProps & Partial<TabsSelectionContextType>) => {
|
|
32
34
|
const configuration = useConfiguration();
|
|
33
35
|
const config = applyFontConfig(configuration);
|
|
34
36
|
const styles = useMemo(() => getStyles(config), [config]);
|
|
35
37
|
|
|
38
|
+
const accessibilityManager = useAccessibilityManager({});
|
|
39
|
+
|
|
36
40
|
const {
|
|
37
41
|
tab_bar_gutter: horizontalGutter,
|
|
38
42
|
tab_bar_background_image: bgImage,
|
|
@@ -60,10 +64,20 @@ const TabsComponent = ({
|
|
|
60
64
|
);
|
|
61
65
|
|
|
62
66
|
const onListElementFocus = useCallback(
|
|
63
|
-
(index) => {
|
|
67
|
+
(index, isSelected: boolean, item: ZappEntry) => {
|
|
68
|
+
if (isSelected) {
|
|
69
|
+
accessibilityManager.readText({
|
|
70
|
+
text: `${accessibility?.selectedHint} ${item.title}`,
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
accessibilityManager.readText({
|
|
74
|
+
text: `${accessibility?.hint} ${item.title}`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
scrollToSelectedIndex(index, VIEW_POSITION);
|
|
65
79
|
},
|
|
66
|
-
[scrollToSelectedIndex]
|
|
80
|
+
[scrollToSelectedIndex, accessibility]
|
|
67
81
|
);
|
|
68
82
|
|
|
69
83
|
const renderItem = useCallback(
|
|
@@ -94,7 +108,7 @@ const TabsComponent = ({
|
|
|
94
108
|
id={itemId}
|
|
95
109
|
testID={itemId}
|
|
96
110
|
preferredFocus={isSelected}
|
|
97
|
-
onFocus={() => onListElementFocus(index)}
|
|
111
|
+
onFocus={() => onListElementFocus(index, isSelected, item)}
|
|
98
112
|
onPress={() => setSelectedEntry && setSelectedEntry(item)}
|
|
99
113
|
style={style}
|
|
100
114
|
>
|
|
@@ -149,6 +163,9 @@ const TabsComponent = ({
|
|
|
149
163
|
shouldUsePreferredFocus
|
|
150
164
|
isWithMemory={false}
|
|
151
165
|
nextFocusDown={parentFocus?.nextFocusDown}
|
|
166
|
+
onFocus={() => {
|
|
167
|
+
accessibilityManager.addHeading(accessibility?.announcement);
|
|
168
|
+
}}
|
|
152
169
|
>
|
|
153
170
|
<View style={tabs}>
|
|
154
171
|
<ImageBackground
|
|
@@ -1,62 +1,155 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import { Animated, Dimensions } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
|
|
6
6
|
import { useConfiguration } from "../utils";
|
|
7
|
-
import {
|
|
7
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
|
+
import { isMenuVisible } from "../../Screen/navigationHandler";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
useSafeAreaFrame,
|
|
12
|
+
useSafeAreaInsets,
|
|
13
|
+
} from "react-native-safe-area-context";
|
|
14
|
+
import {
|
|
15
|
+
isAndroidPlatform,
|
|
16
|
+
isAndroidVersionAtLeast,
|
|
17
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
|
+
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
19
|
+
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
20
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
21
|
+
import { useAppSelector } from "@applicaster/zapp-react-native-redux";
|
|
8
22
|
|
|
9
23
|
export type ModalAnimationContextT = {
|
|
10
|
-
yTranslate: React.MutableRefObject<Animated.
|
|
24
|
+
yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
|
|
25
|
+
offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
|
|
26
|
+
offset: React.MutableRefObject<number>;
|
|
27
|
+
heightAboveMinimised: number;
|
|
28
|
+
gestureTranslationRef: React.MutableRefObject<Animated.Value>;
|
|
11
29
|
minimisedHeight: number;
|
|
12
30
|
};
|
|
13
31
|
|
|
14
32
|
export const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
15
33
|
yTranslate: React.createRef<Animated.Value | null>(),
|
|
34
|
+
offsetAnimatedValueRef: React.createRef<Animated.Value>(),
|
|
35
|
+
offset: React.createRef<number>(),
|
|
36
|
+
heightAboveMinimised: 0,
|
|
37
|
+
gestureTranslationRef: React.createRef<Animated.Value>(),
|
|
16
38
|
minimisedHeight: 60,
|
|
17
39
|
});
|
|
18
40
|
|
|
41
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
42
|
+
|
|
43
|
+
export const isOldAndroidDevice =
|
|
44
|
+
isAndroidPlatform() &&
|
|
45
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
46
|
+
|
|
47
|
+
const bottomTabBarHeight = getTabBarHeight();
|
|
48
|
+
|
|
19
49
|
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
50
|
+
const { height } = Dimensions.get("window");
|
|
51
|
+
|
|
20
52
|
const yTranslate = React.useRef(
|
|
21
|
-
new Animated.Value(
|
|
53
|
+
new Animated.Value(height).interpolate<number>({
|
|
54
|
+
inputRange: [0, height],
|
|
55
|
+
outputRange: [0, height],
|
|
56
|
+
})
|
|
22
57
|
);
|
|
23
58
|
|
|
59
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
60
|
+
|
|
24
61
|
const {
|
|
25
|
-
videoModalState: { visible },
|
|
62
|
+
videoModalState: { visible, mode },
|
|
63
|
+
currentRoute,
|
|
64
|
+
screenData,
|
|
26
65
|
} = useNavigation();
|
|
27
66
|
|
|
28
|
-
const
|
|
67
|
+
const isTabletPortrait = useAppSelector(
|
|
68
|
+
(state) => state.appData.isTabletPortrait
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const plugins = usePlugins();
|
|
72
|
+
|
|
73
|
+
const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
|
|
74
|
+
|
|
75
|
+
const frame = useSafeAreaFrame();
|
|
76
|
+
const insets = useSafeAreaInsets();
|
|
77
|
+
|
|
78
|
+
const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
|
|
79
|
+
|
|
80
|
+
// memoizing heightAboveMinimised value
|
|
81
|
+
const offset = React.useRef(heightAboveMinimised);
|
|
82
|
+
|
|
83
|
+
// Used for memoizing modal y position after start/end of transition
|
|
84
|
+
const offsetAnimatedValueRef = React.useRef(
|
|
85
|
+
new Animated.Value(-offset.current)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Used for gesture handling
|
|
89
|
+
const gestureTranslationRef = React.useRef(new Animated.Value(0));
|
|
90
|
+
|
|
91
|
+
const videoModalStateRef = React.useRef({ visible, mode });
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
videoModalStateRef.current = { visible, mode };
|
|
95
|
+
}, [visible, mode]);
|
|
96
|
+
|
|
97
|
+
const translateY = useMemo(() => {
|
|
98
|
+
const maxRange = heightAboveMinimised;
|
|
99
|
+
|
|
100
|
+
const combined: Animated.AnimatedAddition<number> = Animated.add(
|
|
101
|
+
offsetAnimatedValueRef.current,
|
|
102
|
+
gestureTranslationRef.current
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return combined.interpolate({
|
|
106
|
+
inputRange: [0, maxRange],
|
|
107
|
+
outputRange: [0, maxRange],
|
|
108
|
+
extrapolate: "clamp",
|
|
109
|
+
});
|
|
110
|
+
}, [visible, heightAboveMinimised]);
|
|
111
|
+
|
|
112
|
+
offset.current = heightAboveMinimised;
|
|
113
|
+
yTranslate.current = translateY;
|
|
114
|
+
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
const collapsedHeight =
|
|
117
|
+
minimisedHeight +
|
|
118
|
+
(menuVisible ? bottomTabBarHeight : 0) +
|
|
119
|
+
(isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
|
|
120
|
+
PROGRESS_BAR_HEIGHT;
|
|
121
|
+
|
|
122
|
+
const heightAboveMinimised = frame.height - collapsedHeight;
|
|
123
|
+
|
|
124
|
+
const isLandscape = frame.width > frame.height;
|
|
125
|
+
|
|
126
|
+
const isTablet = getIsTablet();
|
|
127
|
+
|
|
128
|
+
const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
|
|
29
129
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (windowDimensions.height > windowDimensions.width) {
|
|
39
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
43
|
-
}
|
|
130
|
+
if (
|
|
131
|
+
heightAboveMinimised !== offset.current &&
|
|
132
|
+
videoModalStateRef.current.mode !== "PIP" &&
|
|
133
|
+
videoModalStateRef.current.mode !== "FULLSCREEN"
|
|
134
|
+
) {
|
|
135
|
+
if (isLandscape && shouldIgnoreLandscape) return;
|
|
136
|
+
setHeightAboveMinimised(heightAboveMinimised);
|
|
137
|
+
offset.current = heightAboveMinimised;
|
|
44
138
|
}
|
|
45
|
-
}, [
|
|
46
|
-
visible,
|
|
47
|
-
windowDimensions.height,
|
|
48
|
-
isTabletLandscape,
|
|
49
|
-
windowDimensions.width,
|
|
50
|
-
]);
|
|
139
|
+
}, [frame.height, insets.bottom, menuVisible, minimisedHeight]);
|
|
51
140
|
|
|
52
141
|
return (
|
|
53
142
|
<ReactContext.Provider
|
|
54
143
|
value={useMemo(
|
|
55
144
|
() => ({
|
|
56
145
|
yTranslate,
|
|
146
|
+
offsetAnimatedValueRef,
|
|
147
|
+
offset,
|
|
148
|
+
heightAboveMinimised,
|
|
57
149
|
minimisedHeight,
|
|
150
|
+
gestureTranslationRef,
|
|
58
151
|
}),
|
|
59
|
-
[minimisedHeight]
|
|
152
|
+
[minimisedHeight, heightAboveMinimised]
|
|
60
153
|
)}
|
|
61
154
|
>
|
|
62
155
|
{children}
|
|
@@ -139,11 +139,7 @@ const VideoModalComponent = () => {
|
|
|
139
139
|
|
|
140
140
|
{itemIdHooksFinished === item?.id ? (
|
|
141
141
|
<View pointerEvents="box-none" style={styles.container}>
|
|
142
|
-
<HandlePlayable
|
|
143
|
-
item={item}
|
|
144
|
-
isModal={mode !== "PIP"}
|
|
145
|
-
mode={mode}
|
|
146
|
-
/>
|
|
142
|
+
<HandlePlayable item={item} isModal mode={mode} />
|
|
147
143
|
</View>
|
|
148
144
|
) : (
|
|
149
145
|
<View style={styles.loaderContainer}>
|
|
@@ -4,6 +4,7 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
|
|
6
6
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
7
|
+
import { create } from "zustand";
|
|
7
8
|
|
|
8
9
|
export const useConfiguration = () => {
|
|
9
10
|
const {
|
|
@@ -52,6 +53,12 @@ export const useConfiguration = () => {
|
|
|
52
53
|
};
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
export const useAnimationStateStore = create<{
|
|
57
|
+
isAnimationInProgress: boolean;
|
|
58
|
+
}>(() => ({
|
|
59
|
+
isAnimationInProgress: false,
|
|
60
|
+
}));
|
|
61
|
+
|
|
55
62
|
const fullSize = {
|
|
56
63
|
width: "100%",
|
|
57
64
|
height: "100%",
|
package/index.d.ts
CHANGED
|
@@ -228,6 +228,12 @@ declare type TabsSelectionContextType = {
|
|
|
228
228
|
selectedEntryIndex: number;
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
+
declare type TabsAccessibility = {
|
|
232
|
+
announcement?: string;
|
|
233
|
+
selectedHint?: string;
|
|
234
|
+
hint?: string;
|
|
235
|
+
};
|
|
236
|
+
|
|
231
237
|
declare type TabsProps = {
|
|
232
238
|
entry: ZappEntry[];
|
|
233
239
|
groupId: string;
|
|
@@ -235,6 +241,7 @@ declare type TabsProps = {
|
|
|
235
241
|
focused?: boolean;
|
|
236
242
|
parentFocus?: ParentFocus;
|
|
237
243
|
style?: ReactViewStyle;
|
|
244
|
+
accessibility?: TabsAccessibility;
|
|
238
245
|
};
|
|
239
246
|
|
|
240
247
|
declare type TabContentProps = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.3248453012",
|
|
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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.3248453012",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.3248453012",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.3248453012",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.3248453012",
|
|
35
35
|
"promise": "^8.3.0",
|
|
36
36
|
"url": "^0.11.0",
|
|
37
37
|
"uuid": "^3.3.2"
|