@applicaster/zapp-react-native-ui-components 12.0.0-alpha.9233494544 → 12.0.0-alpha.9262177070
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/BaseFocusable/index.tsx +2 -2
- package/Components/Cell/Cell.tsx +5 -9
- package/Components/Cell/CellWithFocusable.tsx +6 -4
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +10 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +19 -75
- package/Components/Layout/TV/index.tsx +26 -124
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -112
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/Navigator/StackNavigator.tsx +48 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +6 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +0 -22
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/TV/hooks/index.ts +3 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
- package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
- package/Components/Screen/TV/index.web.tsx +44 -35
- package/Components/Screen/__tests__/Screen.test.tsx +3 -0
- package/Components/Screen/index.tsx +29 -1
- package/Components/Transitioner/Scene.tsx +24 -19
- package/Components/Transitioner/Transitioner.tsx +21 -28
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/VideoLive/LiveImageManager.ts +28 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +48 -38
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +40 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +98 -81
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +23 -4
- package/Components/VideoModal/ModalAnimation/utils.ts +6 -4
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- package/Components/VideoModal/PlayerWrapper.tsx +67 -60
- package/Components/VideoModal/VideoModal.tsx +17 -17
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +32 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Contexts/FocusableGroupContext/FocusableGroupContext.ts +3 -0
- package/Contexts/FocusableGroupContext/FocusableGroupContextProvider.tsx +16 -0
- package/Contexts/FocusableGroupContext/__tests__/FocusableGroupContextProvider.test.tsx +22 -0
- package/Contexts/FocusableGroupContext/__tests__/withFocusableContext.test.tsx +26 -0
- package/Contexts/FocusableGroupContext/index.ts +7 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +17 -0
- package/Contexts/ScreenContext/index.tsx +2 -2
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/events/index.ts +1 -0
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
- /package/Components/FocusableGroup/{index.android.js → index.android.ts} +0 -0
- /package/Components/FocusableGroup/{index.ios.js → index.ios.ts} +0 -0
|
@@ -66,14 +66,14 @@ export class BaseFocusable<
|
|
|
66
66
|
const { initialFocus } = this.props;
|
|
67
67
|
|
|
68
68
|
if (initialFocus) {
|
|
69
|
-
focusManager.
|
|
69
|
+
focusManager.setFocus(this.getId());
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
getId(props?: { id: string; groupId: string }) {
|
|
74
74
|
const { id, groupId = null } = props || this.props;
|
|
75
75
|
|
|
76
|
-
return groupId ?
|
|
76
|
+
return groupId ? `${groupId}-${id}` : id;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
getRect() {
|
package/Components/Cell/Cell.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { join, path, merge } from "ramda";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
|
|
5
5
|
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
|
|
@@ -105,8 +105,8 @@ export class CellComponent extends React.Component<Props> {
|
|
|
105
105
|
onPress(item, index);
|
|
106
106
|
} else {
|
|
107
107
|
const { item, navigator, component, appData } = this.props;
|
|
108
|
-
const itemTargetScreen =
|
|
109
|
-
const componentTargetScreen =
|
|
108
|
+
const itemTargetScreen = path(["screen_type"], item);
|
|
109
|
+
const componentTargetScreen = path(["data", "target"], component);
|
|
110
110
|
const itemType = getItemType(item, appData?.layoutVersion);
|
|
111
111
|
|
|
112
112
|
sendSelectCellEvent(item, component, item.title, index);
|
|
@@ -116,7 +116,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
116
116
|
componentTargetScreen &&
|
|
117
117
|
!itemTargetScreen
|
|
118
118
|
) {
|
|
119
|
-
navigator.push(
|
|
119
|
+
navigator.push(merge(item, { screen_type: componentTargetScreen }));
|
|
120
120
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -207,11 +207,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
207
207
|
|
|
208
208
|
const { id } = item;
|
|
209
209
|
|
|
210
|
-
const focusableId =
|
|
211
|
-
`componentId:${component?.id}`,
|
|
212
|
-
`id:${id}`,
|
|
213
|
-
`index:${index}`,
|
|
214
|
-
]);
|
|
210
|
+
const focusableId = join("-", [component?.id, id, index]);
|
|
215
211
|
|
|
216
212
|
const handleFocus = (focusable, mouse) => {
|
|
217
213
|
const focusFn = onFocus || noop;
|
|
@@ -3,6 +3,8 @@ 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
|
+
|
|
6
8
|
import { isAppleTV } from "../../Helpers/Platform";
|
|
7
9
|
import { useCellState } from "../MasterCell/utils";
|
|
8
10
|
|
|
@@ -54,7 +56,7 @@ type Props = {
|
|
|
54
56
|
skipFocusManagerRegistration?: boolean;
|
|
55
57
|
isFocusable?: boolean;
|
|
56
58
|
behavior: Behavior;
|
|
57
|
-
|
|
59
|
+
focused?: boolean;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
export function CellWithFocusable(props: Props) {
|
|
@@ -70,7 +72,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
70
72
|
skipFocusManagerRegistration,
|
|
71
73
|
isFocusable,
|
|
72
74
|
behavior,
|
|
73
|
-
|
|
75
|
+
focused,
|
|
74
76
|
} = props;
|
|
75
77
|
|
|
76
78
|
const isFocused = useCellFocusedState(
|
|
@@ -82,8 +84,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
82
84
|
const state = useCellState({
|
|
83
85
|
id: item.id,
|
|
84
86
|
behavior,
|
|
85
|
-
focused: isFocused,
|
|
86
|
-
selected,
|
|
87
|
+
focused: isFocused || toBooleanWithDefaultFalse(focused),
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
const [focusedButtonId, setFocusedButtonId] = React.useState(undefined);
|
|
@@ -114,6 +115,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
114
115
|
preferredFocus={preferredFocus}
|
|
115
116
|
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
116
117
|
isFocusable={isFocusable}
|
|
118
|
+
focused={focused}
|
|
117
119
|
/>
|
|
118
120
|
);
|
|
119
121
|
}
|
|
@@ -226,13 +226,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
226
226
|
|
|
227
227
|
hasReceivedFocus() {}
|
|
228
228
|
|
|
229
|
-
scrollTo(
|
|
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
|
-
}
|
|
229
|
+
scrollTo() {}
|
|
236
230
|
|
|
237
231
|
render() {
|
|
238
232
|
const {
|
|
@@ -279,7 +273,9 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
279
273
|
index={index}
|
|
280
274
|
scrollTo={this.scrollTo}
|
|
281
275
|
preferredFocus={preferredFocus}
|
|
276
|
+
focused={this.props.focused}
|
|
282
277
|
behavior={behavior}
|
|
278
|
+
isFocusable={isFocusable}
|
|
283
279
|
/>
|
|
284
280
|
</View>
|
|
285
281
|
);
|
|
@@ -4,6 +4,7 @@ import * as R from "ramda";
|
|
|
4
4
|
import { BaseFocusable } from "../BaseFocusable";
|
|
5
5
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
6
6
|
import { LONG_KEY_PRESS_TIMEOUT } from "@applicaster/quick-brick-core/const";
|
|
7
|
+
import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withFocusableContext";
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
initialFocus?: boolean;
|
|
@@ -23,7 +24,7 @@ type Props = {
|
|
|
23
24
|
style?: React.CSSProperties;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
class Focusable extends BaseFocusable<Props> {
|
|
27
28
|
isGroup: boolean;
|
|
28
29
|
mouse: boolean;
|
|
29
30
|
longPressTimeout = null;
|
|
@@ -198,3 +199,7 @@ export class Focusable extends BaseFocusable<Props> {
|
|
|
198
199
|
);
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
|
|
203
|
+
const FocusableWithFocusableContext = withFocusableContext(Focusable);
|
|
204
|
+
|
|
205
|
+
export { FocusableWithFocusableContext as Focusable };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { BaseFocusable } from "../BaseFocusable";
|
|
4
|
+
import { FocusableGroupContextProvider } from "../../Contexts/FocusableGroupContext";
|
|
5
|
+
import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withFocusableContext";
|
|
4
6
|
|
|
5
7
|
type Props = {
|
|
6
8
|
testID?: string;
|
|
@@ -29,7 +31,7 @@ type Props = {
|
|
|
29
31
|
excludeFromFocusSearching?: boolean;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
class FocusableGroup extends BaseFocusable<Props> {
|
|
33
35
|
constructor(props) {
|
|
34
36
|
super(props);
|
|
35
37
|
this.isGroup = true;
|
|
@@ -82,8 +84,14 @@ export class FocusableGroup extends BaseFocusable<Props> {
|
|
|
82
84
|
style={style}
|
|
83
85
|
ref={this.ref}
|
|
84
86
|
>
|
|
85
|
-
{
|
|
87
|
+
<FocusableGroupContextProvider id={id}>
|
|
88
|
+
{children}
|
|
89
|
+
</FocusableGroupContextProvider>
|
|
86
90
|
</div>
|
|
87
91
|
);
|
|
88
92
|
}
|
|
89
93
|
}
|
|
94
|
+
|
|
95
|
+
const FocusableGroupWithFocusableContext = withFocusableContext(FocusableGroup);
|
|
96
|
+
|
|
97
|
+
export { FocusableGroupWithFocusableContext as FocusableGroup };
|
|
@@ -2,58 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Layout TV renders 1`] = `
|
|
4
4
|
<View
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"height": 1080,
|
|
9
|
-
"width": 1920,
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
testID="layout-container"
|
|
5
|
+
excludeFromFocusSearching={true}
|
|
6
|
+
id="/river/A1234"
|
|
7
|
+
preferredFocus={true}
|
|
13
8
|
>
|
|
14
9
|
<View
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
style={
|
|
20
|
-
Array [
|
|
21
|
-
Object {
|
|
22
|
-
"position": "absolute",
|
|
23
|
-
"top": 0,
|
|
24
|
-
"width": 1920,
|
|
25
|
-
"zIndex": 10,
|
|
26
|
-
},
|
|
27
|
-
Object {
|
|
28
|
-
"maxHeight": 10,
|
|
29
|
-
},
|
|
30
|
-
]
|
|
10
|
+
Components={
|
|
11
|
+
Object {
|
|
12
|
+
"Background": [Function],
|
|
13
|
+
"NavBar": [Function],
|
|
31
14
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
isVisible={true}
|
|
36
|
-
menuPlugin={
|
|
37
|
-
Object {
|
|
38
|
-
"module": [Function],
|
|
39
|
-
"name": "resolved-menu-plug",
|
|
40
|
-
"type": "menu",
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
navigationProps={
|
|
44
|
-
Object {
|
|
45
|
-
"assets": undefined,
|
|
46
|
-
"home": undefined,
|
|
47
|
-
"nav_items": undefined,
|
|
48
|
-
"rules": undefined,
|
|
49
|
-
"selected": undefined,
|
|
50
|
-
"styles": undefined,
|
|
51
|
-
"title": "",
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
testID="nav-bar-component"
|
|
55
|
-
/>
|
|
56
|
-
</View>
|
|
57
|
-
</View>
|
|
15
|
+
}
|
|
16
|
+
route="/river/A1234"
|
|
17
|
+
/>
|
|
58
18
|
</View>
|
|
59
19
|
`;
|
|
@@ -1,79 +1,48 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { omit } from "ramda";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { render } from "@testing-library/react-native";
|
|
5
5
|
import { Provider } from "react-redux";
|
|
6
|
-
import { createStore } from "redux";
|
|
7
6
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
7
|
+
import configureStore from "redux-mock-store";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const withoutChildren = omit(["children"]);
|
|
10
10
|
|
|
11
|
-
jest.mock("
|
|
12
|
-
|
|
11
|
+
jest.mock("../../../Screen/TV/index.web", () => ({
|
|
12
|
+
Screen: View,
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const Layout = require("../index.web").default;
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const ResolvedMenuPlug = () => <View testID="resolved-menu-plug" />;
|
|
20
|
-
|
|
21
|
-
const plugins = [
|
|
22
|
-
{
|
|
23
|
-
module: ResolvedMenuPlug,
|
|
24
|
-
type: "menu",
|
|
25
|
-
name: "resolved-menu-plug",
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const bgImage = "http://applicaster.com";
|
|
30
|
-
const isNavBarVisible = true;
|
|
31
|
-
|
|
32
|
-
const store = createStore(() => ({
|
|
17
|
+
const mockStore = configureStore()({
|
|
33
18
|
appState: { appReady: true },
|
|
34
|
-
|
|
35
|
-
plugins,
|
|
36
|
-
}));
|
|
19
|
+
});
|
|
37
20
|
|
|
38
21
|
describe("Layout TV", () => {
|
|
39
|
-
const themes = {
|
|
40
|
-
myTheme: { screen_margin_top: 10, screen_margin_bottom: 10 },
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const selectedThemeId = "myTheme";
|
|
44
|
-
|
|
45
22
|
const navigator = {
|
|
46
|
-
activeRiver: {
|
|
47
|
-
navigations: [{ category: "menu", navigation_type: "menu" }],
|
|
48
|
-
},
|
|
49
|
-
canGoBack: () => false,
|
|
50
23
|
currentRoute: "/river/A1234",
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
mainStack: [
|
|
25
|
+
{
|
|
26
|
+
route: "/river/A1234",
|
|
27
|
+
state: "state",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
55
30
|
};
|
|
56
31
|
|
|
57
32
|
const wrapper = ({ children }) => (
|
|
58
|
-
<Provider store={
|
|
33
|
+
<Provider store={mockStore}>
|
|
59
34
|
<NavigationContext.Provider value={navigator}>
|
|
60
|
-
|
|
61
|
-
{children}
|
|
62
|
-
</ThemeContext.Provider>
|
|
35
|
+
{children}
|
|
63
36
|
</NavigationContext.Provider>
|
|
64
37
|
</Provider>
|
|
65
38
|
);
|
|
66
39
|
|
|
67
|
-
const Screen = (props) => (
|
|
68
|
-
<View testID="screen-component" {...R.omit(["children"])(props)} />
|
|
69
|
-
);
|
|
70
|
-
|
|
71
40
|
const NavBar = (props) => (
|
|
72
|
-
<View testID="nav-bar-component" {...
|
|
41
|
+
<View testID="nav-bar-component" {...withoutChildren(props)} />
|
|
73
42
|
);
|
|
74
43
|
|
|
75
44
|
const Background = (props: Record<any, any>) => (
|
|
76
|
-
<View testID="background-component" {...
|
|
45
|
+
<View testID="background-component" {...withoutChildren(props)}>
|
|
77
46
|
{props.children}
|
|
78
47
|
</View>
|
|
79
48
|
);
|
|
@@ -84,33 +53,8 @@ describe("Layout TV", () => {
|
|
|
84
53
|
};
|
|
85
54
|
|
|
86
55
|
it("renders", () => {
|
|
87
|
-
const { toJSON } = render(
|
|
88
|
-
<Layout Components={Components}>
|
|
89
|
-
<Screen />
|
|
90
|
-
</Layout>,
|
|
91
|
-
{ wrapper }
|
|
92
|
-
);
|
|
56
|
+
const { toJSON } = render(<Layout Components={Components} />, { wrapper });
|
|
93
57
|
|
|
94
58
|
expect(toJSON()).toMatchSnapshot();
|
|
95
59
|
});
|
|
96
|
-
|
|
97
|
-
describe("props passed to background component", () => {
|
|
98
|
-
it("passes correct props", () => {
|
|
99
|
-
const { getByTestId } = render(
|
|
100
|
-
<Layout
|
|
101
|
-
Components={Components}
|
|
102
|
-
ComponentsExtraProps={{
|
|
103
|
-
Background: { testProp: true },
|
|
104
|
-
}}
|
|
105
|
-
>
|
|
106
|
-
<Screen />
|
|
107
|
-
</Layout>,
|
|
108
|
-
{ wrapper }
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
const bgComponent = getByTestId("background-component");
|
|
112
|
-
expect(bgComponent.props.backgroundImageUrl).toBe(bgImage);
|
|
113
|
-
expect(bgComponent.props.testProp).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
60
|
});
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { View, StyleSheet } from "react-native";
|
|
4
3
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
6
5
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
7
|
-
import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
8
|
-
import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
9
6
|
|
|
10
7
|
import {
|
|
11
8
|
getNavigationProps,
|
|
12
|
-
getPathAttributes,
|
|
13
9
|
resolveNavigationPlugin,
|
|
14
10
|
routeIsPlayerScreen,
|
|
15
11
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
@@ -18,28 +14,12 @@ import { getBackgroundImageUrl } from "../utils";
|
|
|
18
14
|
import { LayoutContainer } from "./LayoutContainer";
|
|
19
15
|
import { NavBarContainer } from "./NavBarContainer";
|
|
20
16
|
import { ScreenContainer } from "./ScreenContainer";
|
|
21
|
-
import { TransitionOverlay } from "./TransitionOverlay";
|
|
22
17
|
|
|
23
18
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
19
|
+
import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
24
20
|
import { PathnameContext } from "../../../Contexts/PathnameContext";
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
import { Screen } from "../../Screen/TV/index.web";
|
|
28
|
-
|
|
29
|
-
export const ScreenDataContext = React.createContext(null);
|
|
30
|
-
|
|
31
|
-
const styles = StyleSheet.create({
|
|
32
|
-
container: {
|
|
33
|
-
position: "absolute",
|
|
34
|
-
width: 1920,
|
|
35
|
-
height: 1080,
|
|
36
|
-
backgroundColor: "black",
|
|
37
|
-
// opacity: 0.5,
|
|
38
|
-
|
|
39
|
-
borderWidth: 4,
|
|
40
|
-
borderColor: "magenta",
|
|
41
|
-
},
|
|
42
|
-
});
|
|
21
|
+
import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
22
|
+
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
43
23
|
|
|
44
24
|
type Components = {
|
|
45
25
|
NavBar: React.ComponentType<any>;
|
|
@@ -47,73 +27,16 @@ type Components = {
|
|
|
47
27
|
};
|
|
48
28
|
|
|
49
29
|
type ComponentsExtraProps = {
|
|
50
|
-
NavBar?: Record<string, any>;
|
|
51
30
|
Background?: Record<string, any>;
|
|
31
|
+
NavBar?: Record<string, any>;
|
|
52
32
|
};
|
|
53
33
|
|
|
54
34
|
type Props = {
|
|
55
35
|
Components: Components;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const StackNavigator = ({ Components }: Props) => {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
const { mainStack, currentRoute } = useNavigation();
|
|
62
|
-
|
|
63
|
-
// console.log("debug_2", "DEBUG", { mainStack });
|
|
64
|
-
|
|
65
|
-
const renderScreen = ({ route, action, key, state }, index) => {
|
|
66
|
-
const pathAttributes = getPathAttributes({ pathname: route });
|
|
67
|
-
|
|
68
|
-
if (R.isEmpty(pathAttributes)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// console.log("debug_2", "StackNavigator - renderScreen", {
|
|
73
|
-
// index,
|
|
74
|
-
// route,
|
|
75
|
-
// state,
|
|
76
|
-
// key,
|
|
77
|
-
// action,
|
|
78
|
-
// });
|
|
79
|
-
|
|
80
|
-
const id = `${route}`;
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<FocusableGroup
|
|
84
|
-
id={id}
|
|
85
|
-
preferredFocus={route === currentRoute}
|
|
86
|
-
excludeFromFocusSearching
|
|
87
|
-
key={id}
|
|
88
|
-
>
|
|
89
|
-
<View style={styles.container}>
|
|
90
|
-
<ScreenDataContext.Provider value={state}>
|
|
91
|
-
<PathnameContext.Provider value={route}>
|
|
92
|
-
<Screen route={route} Components={Components} />
|
|
93
|
-
</PathnameContext.Provider>
|
|
94
|
-
</ScreenDataContext.Provider>
|
|
95
|
-
</View>
|
|
96
|
-
</FocusableGroup>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
return mainStack.map(renderScreen);
|
|
36
|
+
ComponentsExtraProps?: ComponentsExtraProps;
|
|
37
|
+
children: React.ReactNode;
|
|
101
38
|
};
|
|
102
39
|
|
|
103
|
-
const TransitionerTV = ({ componentsExtraProps, Components }: Props) => {
|
|
104
|
-
return (
|
|
105
|
-
<>
|
|
106
|
-
<ScreenLayoutContextProvider>
|
|
107
|
-
<StackNavigator
|
|
108
|
-
componentsExtraProps={componentsExtraProps}
|
|
109
|
-
Components={Components}
|
|
110
|
-
/>
|
|
111
|
-
</ScreenLayoutContextProvider>
|
|
112
|
-
</>
|
|
113
|
-
);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// @ts-ignore
|
|
117
40
|
const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
118
41
|
const navigator = useNavigation();
|
|
119
42
|
const theme = useTheme();
|
|
@@ -175,54 +98,33 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
175
98
|
}
|
|
176
99
|
|
|
177
100
|
return (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{!isTVOS ? navBarContainer : null}
|
|
191
|
-
{navBarReady ? (
|
|
192
|
-
/**
|
|
101
|
+
<LayoutContainer>
|
|
102
|
+
<ScreenLayoutContextProvider>
|
|
103
|
+
<Components.Background
|
|
104
|
+
backgroundColor={backgroundColor}
|
|
105
|
+
backgroundImageUrl={backgroundImageUrl}
|
|
106
|
+
{...R.omit(["ref"])(ComponentsExtraProps?.Background)}
|
|
107
|
+
>
|
|
108
|
+
<ScreenDataContext.Provider value={navigator.data}>
|
|
109
|
+
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
110
|
+
{!isTVOS ? navBarContainer : null}
|
|
111
|
+
{navBarReady ? (
|
|
112
|
+
/**
|
|
193
113
|
Need to re-mount this component on each navigation event
|
|
194
114
|
It's a hack to work around the fact that we don't support
|
|
195
115
|
correct screen rendering in our navigator (shared currentRoute state)
|
|
196
116
|
**/
|
|
197
|
-
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
198
117
|
<ScreenContainer>{children}</ScreenContainer>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
118
|
+
) : null}
|
|
119
|
+
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
202
120
|
focus manager works correctly to focus nav bar items first **/}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
</
|
|
206
|
-
</
|
|
207
|
-
</
|
|
208
|
-
</
|
|
121
|
+
{isTVOS ? navBarContainer : null}
|
|
122
|
+
</PathnameContext.Provider>
|
|
123
|
+
</ScreenDataContext.Provider>
|
|
124
|
+
</Components.Background>
|
|
125
|
+
</ScreenLayoutContextProvider>
|
|
126
|
+
</LayoutContainer>
|
|
209
127
|
);
|
|
210
128
|
};
|
|
211
129
|
|
|
212
130
|
export default Layout;
|
|
213
|
-
|
|
214
|
-
/// Transitioner:
|
|
215
|
-
/*
|
|
216
|
-
Component: Transitioner
|
|
217
|
-
Responsibilities:
|
|
218
|
-
- Transitione between screens.
|
|
219
|
-
Tehere is no transition on Tv so no need for transitioner.
|
|
220
|
-
|
|
221
|
-
Component: StackNavigator
|
|
222
|
-
Responsibilities:
|
|
223
|
-
- Render the screens in the stack.
|
|
224
|
-
- Render the NavBar? I guess navbar should be part of the screen
|
|
225
|
-
- Render the screen.
|
|
226
|
-
|
|
227
|
-
Q
|
|
228
|
-
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { pathOr } from "ramda";
|
|
3
|
+
|
|
4
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
|
+
|
|
6
|
+
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
7
|
+
import { StackNavigator } from "../../Navigator";
|
|
8
|
+
|
|
9
|
+
type Components = {
|
|
10
|
+
NavBar: React.ComponentType<any>;
|
|
11
|
+
Background: React.ComponentType<any>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
Components: Components;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Layout = ({ Components }: Props) => {
|
|
19
|
+
const { appState } = usePickFromState(["appState"]);
|
|
20
|
+
const appReady = pathOr(false, ["appReady"], appState);
|
|
21
|
+
|
|
22
|
+
if (!appReady) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ScreenLayoutContextProvider>
|
|
28
|
+
<StackNavigator Components={Components} />
|
|
29
|
+
</ScreenLayoutContextProvider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default Layout;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
isTV,
|
|
4
|
+
platformSelect,
|
|
5
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
6
|
|
|
6
7
|
import Mobile from "./Mobile";
|
|
7
|
-
import TV from "./TV";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import TVWeb from "./TV/index.web";
|
|
10
|
+
import TVDefault from "./TV/index";
|
|
11
|
+
|
|
12
|
+
const TV = platformSelect({
|
|
13
|
+
samsung_tv: TVWeb,
|
|
14
|
+
lg_tv: TVWeb,
|
|
15
|
+
web: TVWeb,
|
|
16
|
+
default: TVDefault,
|
|
17
|
+
});
|
|
11
18
|
|
|
19
|
+
export default function Layout(props) {
|
|
12
20
|
if (isTV()) {
|
|
13
|
-
return
|
|
14
|
-
<ScreenContextProvider pathname={pathname}>
|
|
15
|
-
<TV {...props} />
|
|
16
|
-
</ScreenContextProvider>
|
|
17
|
-
);
|
|
21
|
+
return <TV {...props} />;
|
|
18
22
|
} else {
|
|
19
23
|
return <Mobile {...props} />;
|
|
20
24
|
}
|
|
@@ -25,6 +25,7 @@ type Props = {
|
|
|
25
25
|
testID?: string;
|
|
26
26
|
accessibilityLabel?: string;
|
|
27
27
|
cellUUID?: string;
|
|
28
|
+
extraProps?: Record<string, any>;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
function isStringAsset(asset) {
|
|
@@ -108,6 +109,7 @@ export function ActionButton(props: Props) {
|
|
|
108
109
|
flavour={flavour}
|
|
109
110
|
asset={getAssetValue(asset, flavour)}
|
|
110
111
|
cellUUID={cellUUID}
|
|
112
|
+
{...(props?.extraProps ?? {})}
|
|
111
113
|
/>
|
|
112
114
|
)}
|
|
113
115
|
</TouchableOpacity>
|