@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4837064762 → 12.0.0-alpha.4885205607
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 +3 -3
- package/Components/Cell/Cell.tsx +30 -13
- 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/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +38 -28
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +25 -13
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +20 -75
- package/Components/Layout/TV/index.tsx +29 -181
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
- 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/LiveImage/index.tsx +20 -0
- 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/dataAdapter.ts +21 -7
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MasterCell/index.tsx +5 -3
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +32 -29
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/Navigator/StackNavigator.tsx +57 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +3 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +0 -23
- 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 +59 -45
- package/Components/Screen/__tests__/Screen.test.tsx +3 -0
- package/Components/Screen/index.tsx +55 -58
- package/Components/Screen/navigationHandler.ts +5 -0
- package/Components/ScreenResolver/index.tsx +6 -11
- package/Components/Transitioner/Scene.tsx +32 -26
- package/Components/Transitioner/Transitioner.tsx +38 -43
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -4
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
- package/Components/VideoLive/LiveImageManager.ts +28 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +52 -24
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +26 -24
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +2 -14
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +56 -43
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +42 -32
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +104 -86
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +44 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +7 -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/hooks/useModalSize.ts +10 -12
- package/Components/VideoModal/utils.ts +5 -2
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +4 -4
- 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
|
@@ -1,79 +1,49 @@
|
|
|
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
|
+
canGoBack: jest.fn(),
|
|
25
|
+
mainStack: [
|
|
26
|
+
{
|
|
27
|
+
route: "/river/A1234",
|
|
28
|
+
state: { screen: {} },
|
|
29
|
+
},
|
|
30
|
+
],
|
|
55
31
|
};
|
|
56
32
|
|
|
57
33
|
const wrapper = ({ children }) => (
|
|
58
|
-
<Provider store={
|
|
34
|
+
<Provider store={mockStore}>
|
|
59
35
|
<NavigationContext.Provider value={navigator}>
|
|
60
|
-
|
|
61
|
-
{children}
|
|
62
|
-
</ThemeContext.Provider>
|
|
36
|
+
{children}
|
|
63
37
|
</NavigationContext.Provider>
|
|
64
38
|
</Provider>
|
|
65
39
|
);
|
|
66
40
|
|
|
67
|
-
const Screen = (props) => (
|
|
68
|
-
<View testID="screen-component" {...R.omit(["children"])(props)} />
|
|
69
|
-
);
|
|
70
|
-
|
|
71
41
|
const NavBar = (props) => (
|
|
72
|
-
<View testID="nav-bar-component" {...
|
|
42
|
+
<View testID="nav-bar-component" {...withoutChildren(props)} />
|
|
73
43
|
);
|
|
74
44
|
|
|
75
45
|
const Background = (props: Record<any, any>) => (
|
|
76
|
-
<View testID="background-component" {...
|
|
46
|
+
<View testID="background-component" {...withoutChildren(props)}>
|
|
77
47
|
{props.children}
|
|
78
48
|
</View>
|
|
79
49
|
);
|
|
@@ -84,33 +54,8 @@ describe("Layout TV", () => {
|
|
|
84
54
|
};
|
|
85
55
|
|
|
86
56
|
it("renders", () => {
|
|
87
|
-
const { toJSON } = render(
|
|
88
|
-
<Layout Components={Components}>
|
|
89
|
-
<Screen />
|
|
90
|
-
</Layout>,
|
|
91
|
-
{ wrapper }
|
|
92
|
-
);
|
|
57
|
+
const { toJSON } = render(<Layout Components={Components} />, { wrapper });
|
|
93
58
|
|
|
94
59
|
expect(toJSON()).toMatchSnapshot();
|
|
95
60
|
});
|
|
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
61
|
});
|
|
@@ -1,45 +1,17 @@
|
|
|
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
|
-
|
|
10
|
-
import {
|
|
11
|
-
getNavigationProps,
|
|
12
|
-
getPathAttributes,
|
|
13
|
-
resolveNavigationPlugin,
|
|
14
|
-
routeIsPlayerScreen,
|
|
15
|
-
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
16
6
|
|
|
17
7
|
import { getBackgroundImageUrl } from "../utils";
|
|
18
8
|
import { LayoutContainer } from "./LayoutContainer";
|
|
19
|
-
import { NavBarContainer } from "./NavBarContainer";
|
|
20
9
|
import { ScreenContainer } from "./ScreenContainer";
|
|
21
|
-
import { TransitionOverlay } from "./TransitionOverlay";
|
|
22
10
|
|
|
23
11
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
24
12
|
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
|
-
});
|
|
13
|
+
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
14
|
+
import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
|
|
43
15
|
|
|
44
16
|
type Components = {
|
|
45
17
|
NavBar: React.ComponentType<any>;
|
|
@@ -47,90 +19,22 @@ type Components = {
|
|
|
47
19
|
};
|
|
48
20
|
|
|
49
21
|
type ComponentsExtraProps = {
|
|
50
|
-
NavBar?: Record<string, any>;
|
|
51
22
|
Background?: Record<string, any>;
|
|
23
|
+
NavBar?: Record<string, any>;
|
|
52
24
|
};
|
|
53
25
|
|
|
54
26
|
type Props = {
|
|
55
27
|
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);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const TransitionerTV = ({ componentsExtraProps, Components }: Props) => {
|
|
104
|
-
return (
|
|
105
|
-
<>
|
|
106
|
-
<ScreenLayoutContextProvider>
|
|
107
|
-
<StackNavigator
|
|
108
|
-
componentsExtraProps={componentsExtraProps}
|
|
109
|
-
Components={Components}
|
|
110
|
-
/>
|
|
111
|
-
</ScreenLayoutContextProvider>
|
|
112
|
-
</>
|
|
113
|
-
);
|
|
28
|
+
ComponentsExtraProps?: ComponentsExtraProps;
|
|
29
|
+
children: React.ReactNode;
|
|
114
30
|
};
|
|
115
31
|
|
|
116
|
-
// @ts-ignore
|
|
117
32
|
const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
118
33
|
const navigator = useNavigation();
|
|
119
34
|
const theme = useTheme();
|
|
120
|
-
const { title, visible } = useNavbarState();
|
|
121
|
-
const { activeRiver, currentRoute } = navigator;
|
|
122
|
-
|
|
123
|
-
const {
|
|
124
|
-
appState: { appReady = false } = {},
|
|
125
|
-
remoteConfigurations,
|
|
126
|
-
plugins = [],
|
|
127
|
-
} = usePickFromState(["appState", "remoteConfigurations", "plugins"]);
|
|
128
35
|
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
title,
|
|
132
|
-
category: "menu",
|
|
133
|
-
});
|
|
36
|
+
const { appState: { appReady = false } = {}, remoteConfigurations } =
|
|
37
|
+
usePickFromState(["appState", "remoteConfigurations", "plugins"]);
|
|
134
38
|
|
|
135
39
|
const backgroundColor = React.useMemo(() => theme.app_background_color, []);
|
|
136
40
|
|
|
@@ -139,90 +43,34 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
139
43
|
[remoteConfigurations]
|
|
140
44
|
);
|
|
141
45
|
|
|
142
|
-
const menuPlugin = React.useMemo(
|
|
143
|
-
() =>
|
|
144
|
-
resolveNavigationPlugin({
|
|
145
|
-
category: "menu",
|
|
146
|
-
navigations: activeRiver?.navigations,
|
|
147
|
-
plugins,
|
|
148
|
-
}) as QuickBrickPlugin,
|
|
149
|
-
[]
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const NavBar = React.useMemo(
|
|
153
|
-
() => Components.NavBar || (menuPlugin.module as React.ComponentType<any>),
|
|
154
|
-
[]
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const [navBarReady, setNavBarReady] = React.useState(false);
|
|
158
|
-
|
|
159
|
-
const navBarContainer = (
|
|
160
|
-
<NavBarContainer isVisible={visible} onReady={setNavBarReady}>
|
|
161
|
-
<NavBar
|
|
162
|
-
ref={ComponentsExtraProps?.NavBar?.ref}
|
|
163
|
-
isVisible={visible && !routeIsPlayerScreen(currentRoute)}
|
|
164
|
-
menuPlugin={menuPlugin}
|
|
165
|
-
navigationProps={navigationProps}
|
|
166
|
-
{...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
|
|
167
|
-
/>
|
|
168
|
-
</NavBarContainer>
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const isTVOS = isApplePlatform();
|
|
172
|
-
|
|
173
46
|
if (!appReady) {
|
|
174
47
|
return null;
|
|
175
48
|
}
|
|
176
49
|
|
|
177
50
|
return (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
) : null}
|
|
201
|
-
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
202
|
-
focus manager works correctly to focus nav bar items first **/}
|
|
203
|
-
{isTVOS ? navBarContainer : null}
|
|
204
|
-
<TransitionOverlay />
|
|
205
|
-
</Components.Background>
|
|
206
|
-
</ScreenLayoutContextProvider>
|
|
207
|
-
</LayoutContainer>
|
|
208
|
-
</TransitionerTV>
|
|
51
|
+
<LayoutContainer>
|
|
52
|
+
<ScreenLayoutContextProvider>
|
|
53
|
+
<Components.Background
|
|
54
|
+
backgroundColor={backgroundColor}
|
|
55
|
+
backgroundImageUrl={backgroundImageUrl}
|
|
56
|
+
{...R.omit(["ref"])(ComponentsExtraProps?.Background)}
|
|
57
|
+
>
|
|
58
|
+
<ScreenDataContext.Provider value={navigator.data}>
|
|
59
|
+
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
60
|
+
<ScreenContextProvider pathname={navigator.currentRoute}>
|
|
61
|
+
<ScreenContainer
|
|
62
|
+
ComponentsExtraProps={ComponentsExtraProps}
|
|
63
|
+
NavBar={Components.NavBar}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</ScreenContainer>
|
|
67
|
+
</ScreenContextProvider>
|
|
68
|
+
</PathnameContext.Provider>
|
|
69
|
+
</ScreenDataContext.Provider>
|
|
70
|
+
</Components.Background>
|
|
71
|
+
</ScreenLayoutContextProvider>
|
|
72
|
+
</LayoutContainer>
|
|
209
73
|
);
|
|
210
74
|
};
|
|
211
75
|
|
|
212
76
|
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) {
|
|
@@ -52,6 +53,7 @@ export function ActionButton(props: Props) {
|
|
|
52
53
|
const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
|
|
53
54
|
const actionContext = useActions(action?.identifier);
|
|
54
55
|
|
|
56
|
+
// TODO: add subscription API for action availability
|
|
55
57
|
const actionDisabled =
|
|
56
58
|
typeof actionContext?.isActionAvailable === "function" &&
|
|
57
59
|
!actionContext.isActionAvailable(item);
|
|
@@ -67,7 +69,7 @@ export function ActionButton(props: Props) {
|
|
|
67
69
|
if (actionDisabled || !actionContext) return;
|
|
68
70
|
|
|
69
71
|
setActionState(actionContext.initialEntryState(item));
|
|
70
|
-
}, [actionDisabled, item?.id]);
|
|
72
|
+
}, [actionDisabled, item?.id, actionContext]);
|
|
71
73
|
|
|
72
74
|
const onPress = useCallback(() => {
|
|
73
75
|
actionContext.invokeAction(item, {
|
|
@@ -108,6 +110,7 @@ export function ActionButton(props: Props) {
|
|
|
108
110
|
flavour={flavour}
|
|
109
111
|
asset={getAssetValue(asset, flavour)}
|
|
110
112
|
cellUUID={cellUUID}
|
|
113
|
+
{...(props?.extraProps ?? {})}
|
|
111
114
|
/>
|
|
112
115
|
)}
|
|
113
116
|
</TouchableOpacity>
|