@applicaster/zapp-react-native-ui-components 13.0.0-alpha.8532113155 → 13.0.0-alpha.8865612391
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/AppContainer/__tests__/AppContainer.test.js +4 -6
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/BaseFocusable/index.tsx +1 -2
- package/Components/Cell/Cell.tsx +1 -0
- package/Components/Cell/CellWithFocusable.tsx +1 -0
- package/Components/Cell/TvOSCellComponent.tsx +20 -22
- package/Components/Cell/index.js +3 -1
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +6 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/FocusableTvOS.tsx +5 -1
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableList/index.tsx +26 -9
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/ModalComponent/Button/index.tsx +6 -6
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/PlayerContainer/PlayerContainer.tsx +8 -8
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +23 -3
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +8 -6
- package/Components/Screen/index.tsx +4 -4
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +5 -3
- package/Components/TextInputTv/index.tsx +2 -1
- package/Components/Transitioner/Scene.tsx +1 -1
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -68
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +11 -11
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +7 -7
- package/Components/VideoModal/PlayerDetails.tsx +9 -6
- package/Components/VideoModal/PlayerWrapper.tsx +2 -2
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +3 -16
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +1 -1
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/package.json +7 -7
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
import { CellRendererResolver } from "../";
|
|
4
5
|
|
|
5
6
|
jest.mock("../../default-cell-renderer", () => {
|
|
6
7
|
const View = jest.requireActual("react-native").View;
|
|
@@ -8,8 +9,6 @@ jest.mock("../../default-cell-renderer", () => {
|
|
|
8
9
|
return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
const { CellRendererResolver } = require("../index");
|
|
12
|
-
|
|
13
12
|
const component = {
|
|
14
13
|
styles: {
|
|
15
14
|
cell_plugin_configuration_id: "ABCDE-123456",
|
|
@@ -45,17 +44,9 @@ describe("CellRendererResolver", () => {
|
|
|
45
44
|
cellStyles,
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
it("renders correctly", () => {
|
|
49
|
-
const result = shallow(
|
|
50
|
-
getResult({ component, plugins, styles, cellStyles })
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(result).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
47
|
describe("with a default renderer plugin", () => {
|
|
57
48
|
it("renders correctly", () => {
|
|
58
|
-
const
|
|
49
|
+
const { UNSAFE_root } = render(
|
|
59
50
|
getResult({
|
|
60
51
|
component,
|
|
61
52
|
plugins,
|
|
@@ -64,56 +55,63 @@ describe("CellRendererResolver", () => {
|
|
|
64
55
|
})
|
|
65
56
|
);
|
|
66
57
|
|
|
67
|
-
expect(
|
|
58
|
+
expect(UNSAFE_root).toBeDefined();
|
|
68
59
|
});
|
|
69
60
|
|
|
70
61
|
it("returns default plugin if component has no cell_plugin_configuration_id", () => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
const { UNSAFE_getByProps } = render(
|
|
63
|
+
getResult({
|
|
64
|
+
component: {},
|
|
65
|
+
plugins,
|
|
66
|
+
styles,
|
|
67
|
+
cellStyles,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
80
72
|
});
|
|
81
73
|
|
|
82
74
|
it("returns default plugin if requested cell plugin configuration does not exist", () => {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const { UNSAFE_getByProps } = render(
|
|
76
|
+
getResult({
|
|
77
|
+
component: { styles: { cell_plugin_configuration_id: "wrong-id" } },
|
|
78
|
+
plugins,
|
|
79
|
+
styles,
|
|
80
|
+
cellStyles,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
91
85
|
});
|
|
92
86
|
|
|
93
87
|
it("returns default plugin if cellStyles store is empty", () => {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
const { UNSAFE_getByProps } = render(
|
|
89
|
+
getResult({
|
|
90
|
+
component,
|
|
91
|
+
plugins,
|
|
92
|
+
styles,
|
|
93
|
+
cellStyles: {},
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
102
98
|
});
|
|
103
99
|
|
|
104
100
|
it("returns null if requested renderer plugin does not exist", () => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
const { UNSAFE_getByProps } = render(
|
|
102
|
+
getResult({
|
|
103
|
+
component: {
|
|
104
|
+
styles: {
|
|
105
|
+
cell_plugin_configuration_id: "FGHIJ-123456",
|
|
106
|
+
},
|
|
109
107
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
plugins,
|
|
109
|
+
styles,
|
|
110
|
+
cellStyles,
|
|
111
|
+
})
|
|
112
|
+
);
|
|
115
113
|
|
|
116
|
-
expect(
|
|
114
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
});
|
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`ComponentResolver renders correctly 1`] = `
|
|
4
|
-
<ContextProvider
|
|
5
|
-
value={null}
|
|
6
|
-
>
|
|
7
|
-
<Memo(ComponentResolver)
|
|
8
|
-
cellStyles={{}}
|
|
9
|
-
component={
|
|
10
|
-
{
|
|
11
|
-
"component_type": "some_component",
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
components={
|
|
15
|
-
{
|
|
16
|
-
"SomeComponent": [MockFunction],
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
decorators={[MockFunction]}
|
|
20
|
-
dispatch={[Function]}
|
|
21
|
-
plugins={[]}
|
|
22
|
-
store={
|
|
23
|
-
{
|
|
24
|
-
"clearActions": [Function],
|
|
25
|
-
"dispatch": [Function],
|
|
26
|
-
"getActions": [Function],
|
|
27
|
-
"getState": [Function],
|
|
28
|
-
"replaceReducer": [Function],
|
|
29
|
-
"subscribe": [Function],
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/>
|
|
33
|
-
</ContextProvider>
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
3
|
exports[`ComponentResolverComponent initializes the cell renderer plugin module if matching plugin exists 1`] = `
|
|
37
|
-
<
|
|
4
|
+
<View
|
|
38
5
|
rendered={true}
|
|
39
6
|
/>
|
|
40
7
|
`;
|
|
41
|
-
|
|
42
|
-
exports[`ComponentResolverComponent renders the Component if it exists 1`] = `
|
|
43
|
-
<mockConstructor
|
|
44
|
-
rendered={true}
|
|
45
|
-
/>
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
exports[`ComponentResolverComponent returns null if the component doesn't exist 1`] = `""`;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
5
4
|
import configureStore from "redux-mock-store";
|
|
6
5
|
|
|
7
6
|
const mockLogger = {
|
|
@@ -43,37 +42,36 @@ const store = configureStore()({
|
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
const component = { component_type: "some_component" };
|
|
46
|
-
const decorators =
|
|
45
|
+
const decorators = (x) => x;
|
|
47
46
|
const renderFunction = jest.fn((Comp) => <Comp rendered />);
|
|
48
47
|
|
|
49
48
|
function clearAllMocks() {
|
|
50
|
-
|
|
51
|
-
decorators.mockClear();
|
|
52
|
-
renderFunction.mockClear();
|
|
53
|
-
mockLogger.warning.mockClear();
|
|
49
|
+
jest.clearAllMocks();
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
describe("ComponentResolver", () => {
|
|
57
53
|
beforeEach(clearAllMocks);
|
|
58
54
|
|
|
59
55
|
it("renders correctly", () => {
|
|
60
|
-
const
|
|
56
|
+
const { toJSON } = render(
|
|
61
57
|
<ComponentResolver
|
|
62
58
|
component={component}
|
|
63
59
|
decorators={decorators}
|
|
64
60
|
store={store}
|
|
65
|
-
|
|
61
|
+
>
|
|
62
|
+
{() => null}
|
|
63
|
+
</ComponentResolver>
|
|
66
64
|
);
|
|
67
65
|
|
|
68
|
-
expect(
|
|
66
|
+
expect(toJSON()).toBeNull();
|
|
69
67
|
});
|
|
70
68
|
});
|
|
71
69
|
|
|
72
70
|
describe("ComponentResolverComponent", () => {
|
|
73
71
|
beforeEach(clearAllMocks);
|
|
74
72
|
|
|
75
|
-
const
|
|
76
|
-
|
|
73
|
+
const renderComponent = (component, plugins) =>
|
|
74
|
+
render(
|
|
77
75
|
<ComponentResolverComponent
|
|
78
76
|
components={components}
|
|
79
77
|
component={component}
|
|
@@ -87,9 +85,9 @@ describe("ComponentResolverComponent", () => {
|
|
|
87
85
|
);
|
|
88
86
|
|
|
89
87
|
it("renders the Component if it exists", () => {
|
|
90
|
-
const
|
|
88
|
+
const { toJSON } = renderComponent(component, plugins);
|
|
91
89
|
|
|
92
|
-
expect(
|
|
90
|
+
expect(toJSON()).not.toBeNull();
|
|
93
91
|
|
|
94
92
|
expect(renderFunction).toHaveBeenCalledWith(
|
|
95
93
|
SomeComponent,
|
|
@@ -98,14 +96,12 @@ describe("ComponentResolverComponent", () => {
|
|
|
98
96
|
});
|
|
99
97
|
|
|
100
98
|
it("returns null if the component doesn't exist", () => {
|
|
101
|
-
const
|
|
99
|
+
const { UNSAFE_root } = renderComponent({ component_type: "foo" }, plugins);
|
|
102
100
|
|
|
103
101
|
const warningMessage =
|
|
104
102
|
"Component foo cannot be found - it is skipped from rendering";
|
|
105
103
|
|
|
106
|
-
expect(
|
|
107
|
-
expect(wrapper.isEmptyRender()).toBe(true);
|
|
108
|
-
|
|
104
|
+
expect(UNSAFE_root.children.length).toBe(0);
|
|
109
105
|
expect(mockLogger.warning).toHaveBeenCalledTimes(2);
|
|
110
106
|
|
|
111
107
|
expect(mockLogger.warning).toHaveBeenNthCalledWith(
|
|
@@ -124,11 +120,9 @@ describe("ComponentResolverComponent", () => {
|
|
|
124
120
|
});
|
|
125
121
|
|
|
126
122
|
it("initializes the cell renderer plugin module if matching plugin exists", () => {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const wrapper = getWrapper(component, plugins);
|
|
123
|
+
const { toJSON } = renderComponent(component, plugins);
|
|
130
124
|
|
|
131
|
-
expect(
|
|
125
|
+
expect(toJSON()).toMatchSnapshot();
|
|
132
126
|
|
|
133
127
|
expect(renderFunction).toHaveBeenCalledWith(
|
|
134
128
|
SomeComponent,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
|
|
4
|
-
import { ContentScreen } from "../
|
|
4
|
+
import { ContentScreen } from "../";
|
|
5
5
|
|
|
6
6
|
describe("<ContentScreen />", () => {
|
|
7
7
|
it("renders correctly", () => {
|
|
8
|
-
expect(() =>
|
|
8
|
+
expect(() => render(<ContentScreen />)).toThrowErrorMatchingSnapshot();
|
|
9
9
|
});
|
|
10
10
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ImageStyle,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
Text,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
TextStyle,
|
|
9
|
-
ImageStyle,
|
|
10
7
|
TextProps,
|
|
8
|
+
TextStyle,
|
|
9
|
+
View,
|
|
10
|
+
ViewStyle,
|
|
11
11
|
} from "react-native";
|
|
12
12
|
import { defaultAsset } from "./defaultAsset";
|
|
13
13
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
@@ -150,13 +150,13 @@ export function ErrorScreen(props: Props) {
|
|
|
150
150
|
return (
|
|
151
151
|
<View style={[baseStyles.container, styles.screen]}>
|
|
152
152
|
<View style={[baseStyles.container, styles.component]}>
|
|
153
|
-
{assetEnabled
|
|
153
|
+
{assetEnabled ? (
|
|
154
154
|
<Image
|
|
155
155
|
fadeDuration={0}
|
|
156
156
|
source={{ uri: asset }}
|
|
157
157
|
style={styles.asset}
|
|
158
158
|
/>
|
|
159
|
-
)}
|
|
159
|
+
) : null}
|
|
160
160
|
<Text style={styles.title} {...titleProps}>
|
|
161
161
|
{title}
|
|
162
162
|
</Text>
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
focusManager,
|
|
10
10
|
forceFocusableFocus,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
12
|
-
import { findNodeHandle } from "react-native";
|
|
12
|
+
import { findNodeHandle, ViewStyle } from "react-native";
|
|
13
13
|
|
|
14
14
|
function noop() {}
|
|
15
15
|
|
|
@@ -35,6 +35,10 @@ type Props = {
|
|
|
35
35
|
forceFocus?: boolean;
|
|
36
36
|
initialFocus?: boolean;
|
|
37
37
|
onLayout?: (e: any) => void;
|
|
38
|
+
willReceiveFocus: () => void;
|
|
39
|
+
hasReceivedFocus: () => void;
|
|
40
|
+
offsetUpdater: (arg1: string, arg2: number) => number;
|
|
41
|
+
style: ViewStyle;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export class Focusable extends BaseFocusable<Props> {
|
|
@@ -33,6 +33,8 @@ type Props = {
|
|
|
33
33
|
onLongPress?: (ref: FocusManager.FocusableRef) => void;
|
|
34
34
|
onRegister?: () => void;
|
|
35
35
|
isFocusableCell?: boolean;
|
|
36
|
+
/** only for FocusableScrollView */
|
|
37
|
+
onSetIsFocusable?: (isFocusable: boolean) => void;
|
|
36
38
|
} & ParentFocus;
|
|
37
39
|
|
|
38
40
|
export const FocusableContext = React.createContext<
|
|
@@ -67,6 +69,7 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
67
69
|
onLongPress,
|
|
68
70
|
onRegister = noop,
|
|
69
71
|
isFocusableCell = true,
|
|
72
|
+
onSetIsFocusable,
|
|
70
73
|
} = props;
|
|
71
74
|
|
|
72
75
|
const isRTL = useIsRTL();
|
|
@@ -137,9 +140,13 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
137
140
|
[onBlur]
|
|
138
141
|
);
|
|
139
142
|
|
|
140
|
-
const setIsFocusable = React.useCallback(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
const setIsFocusable = React.useCallback(
|
|
144
|
+
(blockFocus) => {
|
|
145
|
+
onSetIsFocusable?.(blockFocus);
|
|
146
|
+
setDisableFocus(!blockFocus);
|
|
147
|
+
},
|
|
148
|
+
[onSetIsFocusable]
|
|
149
|
+
);
|
|
143
150
|
|
|
144
151
|
const parentFocus = React.useMemo(
|
|
145
152
|
() => ({
|
|
@@ -15,6 +15,7 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
|
15
15
|
|
|
16
16
|
import { useParentFocus, useCheckItemIdsForUnique } from "./hooks";
|
|
17
17
|
import { FocusableListItemWrapper } from "./FocusableListItemWrapper";
|
|
18
|
+
import { FocusableScrollView } from "../FocusableScrollView";
|
|
18
19
|
|
|
19
20
|
const mapIndexed = R.addIndex(R.map);
|
|
20
21
|
|
|
@@ -54,6 +55,7 @@ export type Props<ItemT> = FlatListProps<ItemT> & {
|
|
|
54
55
|
disableNextFocusUp?: boolean;
|
|
55
56
|
disableNextFocusLeft?: boolean;
|
|
56
57
|
disableNextFocusRight?: boolean;
|
|
58
|
+
useScrollView?: boolean;
|
|
57
59
|
} & ParentFocus;
|
|
58
60
|
|
|
59
61
|
function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
@@ -88,6 +90,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
88
90
|
data = [],
|
|
89
91
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
90
92
|
omitPropsPropagation = [],
|
|
93
|
+
useScrollView = false,
|
|
91
94
|
} = props;
|
|
92
95
|
|
|
93
96
|
useCheckItemIdsForUnique({ componentId: props.id, items: data });
|
|
@@ -273,6 +276,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
273
276
|
"initialFocusDirection",
|
|
274
277
|
"withStateMemory",
|
|
275
278
|
"useSequentialLoading",
|
|
279
|
+
"useScrollView",
|
|
276
280
|
...omitPropsPropagation,
|
|
277
281
|
],
|
|
278
282
|
R.__
|
|
@@ -295,15 +299,28 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
295
299
|
return (
|
|
296
300
|
// @ts-ignore
|
|
297
301
|
<ChildrenFocusDeactivatorView flex={1}>
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
302
|
+
{useScrollView ? (
|
|
303
|
+
<FocusableScrollView
|
|
304
|
+
ref={ref}
|
|
305
|
+
{...getFlatListProps(props)}
|
|
306
|
+
onEndReached={onEndReached}
|
|
307
|
+
initialNumToRender={initialNumToRender}
|
|
308
|
+
renderItem={renderItem}
|
|
309
|
+
focused={focused}
|
|
310
|
+
data={data}
|
|
311
|
+
/>
|
|
312
|
+
) : (
|
|
313
|
+
<FlatList
|
|
314
|
+
testID="focusable-list-flat-list"
|
|
315
|
+
focusable={false}
|
|
316
|
+
scrollEnabled={false}
|
|
317
|
+
ref={ref}
|
|
318
|
+
{...getFlatListProps(props)}
|
|
319
|
+
renderItem={renderItem}
|
|
320
|
+
onEndReached={onEndReached}
|
|
321
|
+
initialNumToRender={initialNumToRender}
|
|
322
|
+
/>
|
|
323
|
+
)}
|
|
307
324
|
</ChildrenFocusDeactivatorView>
|
|
308
325
|
);
|
|
309
326
|
}
|
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
useInitialFocus,
|
|
12
12
|
} from "@applicaster/zapp-react-native-utils/focusManager";
|
|
13
13
|
|
|
14
|
+
export type FocusableScrollViewRenderItem = (info: {
|
|
15
|
+
item: ZappUIComponent;
|
|
16
|
+
index: number;
|
|
17
|
+
focused: boolean;
|
|
18
|
+
parentFocus: ParentFocus;
|
|
19
|
+
}) => React.ReactElement;
|
|
20
|
+
|
|
14
21
|
export type Props = ScrollViewProps & {
|
|
15
22
|
id?: number | string;
|
|
16
23
|
horizontal?: boolean;
|
|
@@ -32,17 +39,27 @@ export type Props = ScrollViewProps & {
|
|
|
32
39
|
initialFocusDirection?: FocusManager.Android.FocusNavigationDirections;
|
|
33
40
|
onAllComponentsLoaded?: () => void;
|
|
34
41
|
omitPropsPropagation?: Array<keyof FlatListProps<any>>;
|
|
35
|
-
renderItem:
|
|
36
|
-
item: ZappUIComponent;
|
|
37
|
-
index: number;
|
|
38
|
-
focused: boolean;
|
|
39
|
-
parentFocus: ParentFocus;
|
|
40
|
-
}) => React.ReactElement;
|
|
42
|
+
renderItem: FocusableScrollViewRenderItem;
|
|
41
43
|
} & ParentFocus;
|
|
42
44
|
|
|
43
45
|
type State = boolean[];
|
|
44
46
|
type Action = { index?: number; isFocusable: boolean; type?: string };
|
|
45
47
|
|
|
48
|
+
const unwrapArray = (maybeArray) =>
|
|
49
|
+
Array.isArray(maybeArray) ? maybeArray[0] : maybeArray;
|
|
50
|
+
|
|
51
|
+
const getEntry = <T extends unknown>(data: T | T[], index: unknown): T => {
|
|
52
|
+
let entry;
|
|
53
|
+
|
|
54
|
+
if (R.isNil(index)) {
|
|
55
|
+
entry = unwrapArray(data);
|
|
56
|
+
} else if (typeof index === "number") {
|
|
57
|
+
entry = unwrapArray(data[index]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return entry;
|
|
61
|
+
};
|
|
62
|
+
|
|
46
63
|
const focusableStateReducer = (
|
|
47
64
|
state: State,
|
|
48
65
|
{ index = null, isFocusable, type = null }: Action
|
|
@@ -73,7 +90,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
|
|
|
73
90
|
};
|
|
74
91
|
|
|
75
92
|
_ref.scrollToIndex = (params) => {
|
|
76
|
-
const { index, viewOffset } = params;
|
|
93
|
+
const { index, viewOffset = 0 } = params;
|
|
77
94
|
|
|
78
95
|
const itemByIndex = R.find(R.propEq("index", index))(
|
|
79
96
|
R.values(childCompsMeasurementsMap)
|
|
@@ -129,8 +146,11 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
129
146
|
);
|
|
130
147
|
|
|
131
148
|
const getFocusableEntryId = React.useCallback(
|
|
132
|
-
(_entry: ZappEntry, index?: number) => {
|
|
133
|
-
const entry
|
|
149
|
+
(_entry: ZappEntry | null, index?: number) => {
|
|
150
|
+
const entry: { id?: string } = getEntry(
|
|
151
|
+
R.isNil(index) ? _entry : data,
|
|
152
|
+
index
|
|
153
|
+
);
|
|
134
154
|
|
|
135
155
|
return entry ? `${props.id}--${entry?.id}` : undefined;
|
|
136
156
|
},
|
|
@@ -273,16 +293,25 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
273
293
|
const renderItem = React.useCallback(
|
|
274
294
|
(item, index) => {
|
|
275
295
|
const renderArgs = { item, index };
|
|
276
|
-
|
|
277
|
-
const
|
|
296
|
+
|
|
297
|
+
const id = getFocusableEntryId(
|
|
298
|
+
Array.isArray(item) ? item[0] : item,
|
|
299
|
+
index
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const nextFocus = getNextFocus(index);
|
|
278
303
|
|
|
279
304
|
const onItemLayout = (event) => {
|
|
280
|
-
childCompsMeasurementsMap.current[
|
|
305
|
+
childCompsMeasurementsMap.current[
|
|
306
|
+
Array.isArray(item) ? index : item.id
|
|
307
|
+
] = {
|
|
281
308
|
index,
|
|
282
309
|
layout: event.nativeEvent.layout,
|
|
283
310
|
};
|
|
284
311
|
};
|
|
285
312
|
|
|
313
|
+
const onSetIsFocusable = setIsFocusable(renderArgs.index);
|
|
314
|
+
|
|
286
315
|
return (
|
|
287
316
|
<View key={id} onLayout={onItemLayout}>
|
|
288
317
|
<Focusable
|
|
@@ -305,6 +334,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
305
334
|
id={id}
|
|
306
335
|
disableFocus={shouldDisableFocus(renderArgs?.index)}
|
|
307
336
|
blockFocus={!isRendered(renderArgs?.index)}
|
|
337
|
+
onSetIsFocusable={onSetIsFocusable}
|
|
308
338
|
{...focusableItemProps}
|
|
309
339
|
>
|
|
310
340
|
{(focused, parentFocus, parentRef) => (
|
|
@@ -319,7 +349,7 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
319
349
|
isReadyToRender={isReadyToRender}
|
|
320
350
|
onLoadFinished={onLoadFinished(renderArgs.index)}
|
|
321
351
|
onLoadFailed={onLoadFailed(renderArgs.index)}
|
|
322
|
-
setIsFocusable={
|
|
352
|
+
setIsFocusable={onSetIsFocusable}
|
|
323
353
|
/>
|
|
324
354
|
)}
|
|
325
355
|
</Focusable>
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { ScreenLayoutContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenLayoutContext";
|
|
4
|
-
import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
5
|
-
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
6
|
-
import { useScreenConfiguration } from "../../River/useScreenConfiguration";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
7
3
|
|
|
8
4
|
type Props = {
|
|
9
5
|
children: React.ReactNode;
|
|
@@ -12,33 +8,33 @@ type Props = {
|
|
|
12
8
|
};
|
|
13
9
|
|
|
14
10
|
const styles = StyleSheet.create({
|
|
15
|
-
container: {
|
|
11
|
+
container: {
|
|
12
|
+
position: "absolute",
|
|
13
|
+
top: 0,
|
|
14
|
+
zIndex: 10,
|
|
15
|
+
flex: 1,
|
|
16
|
+
width: "100%",
|
|
17
|
+
},
|
|
18
|
+
themeStyles: {
|
|
19
|
+
// limits the height of the focusable container of the TopMenuBarTV component
|
|
20
|
+
// to prevent it from being overlapped by the screen content,
|
|
21
|
+
// as it makes TopMenuBarTV unfocusable on tvOS
|
|
22
|
+
maxHeight: 1,
|
|
23
|
+
},
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
export const NavBarContainer = ({ children, isVisible, onReady }: Props) => {
|
|
19
|
-
const screenLayout = React.useContext(ScreenLayoutContext);
|
|
20
|
-
const screenMarginTop = screenLayout?.screenMarginTop || 0;
|
|
21
|
-
const screen = useCurrentScreenData();
|
|
22
|
-
const screenConfig = useScreenConfiguration(screen?.id);
|
|
23
|
-
|
|
24
|
-
const themeStyles = React.useMemo(
|
|
25
|
-
() => ({
|
|
26
|
-
// limits the height of the focusable container of the TopMenuBarTV component
|
|
27
|
-
// to prevent it from being overlapped by the screen content,
|
|
28
|
-
// as it makes TopMenuBarTV unfocusable on tvOS
|
|
29
|
-
maxHeight: ifEmptyUseFallback(screenConfig?.marginTop, screenMarginTop),
|
|
30
|
-
}),
|
|
31
|
-
[screenLayout, screenConfig]
|
|
32
|
-
);
|
|
33
|
-
|
|
34
27
|
React.useEffect(() => {
|
|
35
28
|
setTimeout(() => {
|
|
36
29
|
onReady?.(true);
|
|
37
30
|
}, 0);
|
|
38
|
-
}, []);
|
|
31
|
+
}, [onReady]);
|
|
39
32
|
|
|
40
33
|
return isVisible ? (
|
|
41
|
-
<View
|
|
34
|
+
<View
|
|
35
|
+
testID="nav-bar-container"
|
|
36
|
+
style={[styles.container, styles.themeStyles]}
|
|
37
|
+
>
|
|
42
38
|
{children}
|
|
43
39
|
</View>
|
|
44
40
|
) : null;
|