@applicaster/zapp-react-native-ui-components 12.0.0-rc.72 → 12.0.0-rc.73
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/Layout/TV/__tests__/index.test.tsx +1 -1
- package/Components/Layout/TV/index.tsx +106 -9
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +14 -2
- package/Contexts/ScreenDataContext/index.tsx +20 -0
- package/package.json +5 -5
- package/Contexts/ScreenDataContext/index.ts +0 -3
|
@@ -1,32 +1,129 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import * as R from "ramda";
|
|
4
3
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
+
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getNavigationProps,
|
|
9
|
+
resolveNavigationPlugin,
|
|
10
|
+
routeIsPlayerScreen,
|
|
11
|
+
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
12
|
+
|
|
13
|
+
import { getBackgroundImageUrl } from "../utils";
|
|
14
|
+
import { LayoutContainer } from "./LayoutContainer";
|
|
15
|
+
import { NavBarContainer } from "./NavBarContainer";
|
|
16
|
+
import { ScreenContainer } from "./ScreenContainer";
|
|
5
17
|
|
|
6
18
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
7
|
-
import {
|
|
19
|
+
import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
20
|
+
import { PathnameContext } from "../../../Contexts/PathnameContext";
|
|
21
|
+
import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
22
|
+
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
8
23
|
|
|
9
24
|
type Components = {
|
|
10
25
|
NavBar: React.ComponentType<any>;
|
|
11
26
|
Background: React.ComponentType<any>;
|
|
12
27
|
};
|
|
13
28
|
|
|
29
|
+
type ComponentsExtraProps = {
|
|
30
|
+
Background?: Record<string, any>;
|
|
31
|
+
NavBar?: Record<string, any>;
|
|
32
|
+
};
|
|
33
|
+
|
|
14
34
|
type Props = {
|
|
15
35
|
Components: Components;
|
|
36
|
+
ComponentsExtraProps?: ComponentsExtraProps;
|
|
37
|
+
children: React.ReactNode;
|
|
16
38
|
};
|
|
17
39
|
|
|
18
|
-
const Layout = ({ Components }: Props) => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
40
|
+
const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
41
|
+
const navigator = useNavigation();
|
|
42
|
+
const theme = useTheme();
|
|
43
|
+
const { title, visible } = useNavbarState();
|
|
44
|
+
const { activeRiver, currentRoute } = navigator;
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
appState: { appReady = false } = {},
|
|
48
|
+
remoteConfigurations,
|
|
49
|
+
plugins = [],
|
|
50
|
+
} = usePickFromState(["appState", "remoteConfigurations", "plugins"]);
|
|
51
|
+
|
|
52
|
+
const navigationProps = getNavigationProps({
|
|
53
|
+
navigator,
|
|
54
|
+
title,
|
|
55
|
+
category: "menu",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const backgroundColor = React.useMemo(() => theme.app_background_color, []);
|
|
59
|
+
|
|
60
|
+
const backgroundImageUrl = React.useMemo(
|
|
61
|
+
() => getBackgroundImageUrl(remoteConfigurations),
|
|
62
|
+
[remoteConfigurations]
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const menuPlugin = React.useMemo(
|
|
66
|
+
() =>
|
|
67
|
+
resolveNavigationPlugin({
|
|
68
|
+
category: "menu",
|
|
69
|
+
navigations: activeRiver?.navigations,
|
|
70
|
+
plugins,
|
|
71
|
+
}) as QuickBrickPlugin,
|
|
72
|
+
[]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const NavBar = React.useMemo(
|
|
76
|
+
() => Components.NavBar || (menuPlugin.module as React.ComponentType<any>),
|
|
77
|
+
[]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const [navBarReady, setNavBarReady] = React.useState(false);
|
|
81
|
+
|
|
82
|
+
const navBarContainer = (
|
|
83
|
+
<NavBarContainer isVisible={visible} onReady={setNavBarReady}>
|
|
84
|
+
<NavBar
|
|
85
|
+
ref={ComponentsExtraProps?.NavBar?.ref}
|
|
86
|
+
isVisible={visible && !routeIsPlayerScreen(currentRoute)}
|
|
87
|
+
menuPlugin={menuPlugin}
|
|
88
|
+
navigationProps={navigationProps}
|
|
89
|
+
{...R.omit(["ref"])(ComponentsExtraProps?.NavBar)}
|
|
90
|
+
/>
|
|
91
|
+
</NavBarContainer>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const isTVOS = isApplePlatform();
|
|
21
95
|
|
|
22
96
|
if (!appReady) {
|
|
23
97
|
return null;
|
|
24
98
|
}
|
|
25
99
|
|
|
26
100
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
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
|
+
/**
|
|
113
|
+
Need to re-mount this component on each navigation event
|
|
114
|
+
It's a hack to work around the fact that we don't support
|
|
115
|
+
correct screen rendering in our navigator (shared currentRoute state)
|
|
116
|
+
**/
|
|
117
|
+
<ScreenContainer>{children}</ScreenContainer>
|
|
118
|
+
) : null}
|
|
119
|
+
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
120
|
+
focus manager works correctly to focus nav bar items first **/}
|
|
121
|
+
{isTVOS ? navBarContainer : null}
|
|
122
|
+
</PathnameContext.Provider>
|
|
123
|
+
</ScreenDataContext.Provider>
|
|
124
|
+
</Components.Background>
|
|
125
|
+
</ScreenLayoutContextProvider>
|
|
126
|
+
</LayoutContainer>
|
|
30
127
|
);
|
|
31
128
|
};
|
|
32
129
|
|
|
@@ -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,8 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isTV,
|
|
4
|
+
platformSelect,
|
|
5
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
6
|
|
|
4
7
|
import Mobile from "./Mobile";
|
|
5
|
-
|
|
8
|
+
|
|
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
|
+
});
|
|
6
18
|
|
|
7
19
|
export default function Layout(props) {
|
|
8
20
|
if (isTV()) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
3
|
+
|
|
4
|
+
export const ScreenDataContext = React.createContext<any>(null);
|
|
5
|
+
|
|
6
|
+
// Use this only to provide initial screenData context, before the Transitioner and Screen is rendered.
|
|
7
|
+
export const withScreenDataContextProvider = (Component: any) => {
|
|
8
|
+
return function ScreenDataContextProvider(props: any) {
|
|
9
|
+
const { activeRiver } = useNavigation();
|
|
10
|
+
|
|
11
|
+
// use only initial activeRiver as this context should only be used for "Home", initial route
|
|
12
|
+
const screenData = React.useMemo(() => ({ screen: activeRiver }), []);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<ScreenDataContext.Provider value={screenData}>
|
|
16
|
+
<Component {...props} />
|
|
17
|
+
</ScreenDataContext.Provider>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.73",
|
|
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",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.0-rc.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-rc.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-rc.73",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.73",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-rc.73",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.73",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|