@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4300857220 → 12.0.0-alpha.4337072244
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 +1 -1
- package/Components/Cell/Cell.tsx +5 -5
- package/Components/Cell/CellWithFocusable.tsx +17 -5
- package/Components/FocusableGroup/index.tsx +1 -0
- package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
- package/Components/Layout/TV/__tests__/index.test.tsx +18 -74
- package/Components/Layout/TV/index.tsx +43 -102
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- 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 +4 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
- package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +4 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +18 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +0 -23
- package/Components/Screen/TV/hooks/index.ts +3 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +67 -0
- package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
- package/Components/Screen/TV/index.web.tsx +174 -0
- package/Components/ScreenResolver/index.tsx +3 -1
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -2
- package/Components/VideoModal/PlayerWrapper.tsx +2 -2
- package/Components/VideoModal/VideoModal.tsx +19 -19
- package/Contexts/ScreenContext/index.tsx +2 -2
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/events/index.ts +1 -0
- package/package.json +5 -5
- package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
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,7 +207,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
207
207
|
|
|
208
208
|
const { id } = item;
|
|
209
209
|
|
|
210
|
-
const focusableId =
|
|
210
|
+
const focusableId = join("-", [component?.id, id, index]);
|
|
211
211
|
|
|
212
212
|
const handleFocus = (focusable, mouse) => {
|
|
213
213
|
const focusFn = onFocus || noop;
|
|
@@ -6,12 +6,20 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
|
6
6
|
import { isAppleTV } from "../../Helpers/Platform";
|
|
7
7
|
import { useCellState } from "../MasterCell/utils";
|
|
8
8
|
|
|
9
|
-
const useCellFocusedState = (
|
|
9
|
+
const useCellFocusedState = (
|
|
10
|
+
skipFocusManagerRegistration: boolean,
|
|
11
|
+
groupId: string,
|
|
12
|
+
id: string
|
|
13
|
+
) => {
|
|
10
14
|
const [currentCellFocused, setCurrentCellFocused] = React.useState(false);
|
|
11
15
|
|
|
12
16
|
React.useEffect(() => {
|
|
13
|
-
const isGroupItemFocused = () =>
|
|
14
|
-
|
|
17
|
+
const isGroupItemFocused = () => {
|
|
18
|
+
if (!skipFocusManagerRegistration) {
|
|
19
|
+
const isFocused = focusManager.isGroupItemFocused(groupId, id);
|
|
20
|
+
setCurrentCellFocused(isFocused);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
15
23
|
|
|
16
24
|
const handler = () => {
|
|
17
25
|
// tvOS hack for properly checking focus
|
|
@@ -29,7 +37,7 @@ const useCellFocusedState = (groupId: string, id: string) => {
|
|
|
29
37
|
return () => {
|
|
30
38
|
focusManager.removeHandler(FOCUS_EVENTS.FOCUS, handler);
|
|
31
39
|
};
|
|
32
|
-
}, [groupId]);
|
|
40
|
+
}, [groupId, skipFocusManagerRegistration]);
|
|
33
41
|
|
|
34
42
|
return currentCellFocused;
|
|
35
43
|
};
|
|
@@ -65,7 +73,11 @@ export function CellWithFocusable(props: Props) {
|
|
|
65
73
|
selected,
|
|
66
74
|
} = props;
|
|
67
75
|
|
|
68
|
-
const isFocused = useCellFocusedState(
|
|
76
|
+
const isFocused = useCellFocusedState(
|
|
77
|
+
skipFocusManagerRegistration,
|
|
78
|
+
groupId,
|
|
79
|
+
id
|
|
80
|
+
);
|
|
69
81
|
|
|
70
82
|
const state = useCellState({
|
|
71
83
|
id: item.id,
|
|
@@ -19,6 +19,7 @@ type Props = {
|
|
|
19
19
|
modalHeight?: number;
|
|
20
20
|
modalWidth?: number;
|
|
21
21
|
mode: VideoModalMode;
|
|
22
|
+
groupId?: string;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const YOUTUBE_PLUGIN_ID = "youtube-player-qb";
|
|
@@ -93,6 +94,7 @@ export function HandlePlayable({
|
|
|
93
94
|
modalHeight,
|
|
94
95
|
modalWidth,
|
|
95
96
|
mode,
|
|
97
|
+
groupId,
|
|
96
98
|
}: Props): React.ReactElement | null {
|
|
97
99
|
const state = usePickFromState();
|
|
98
100
|
|
|
@@ -167,6 +169,7 @@ export function HandlePlayable({
|
|
|
167
169
|
isModal={isModal}
|
|
168
170
|
mode={mode}
|
|
169
171
|
disableCastAction={playerModuleProperties?.disableCastAction}
|
|
172
|
+
groupId={groupId}
|
|
170
173
|
/>
|
|
171
174
|
);
|
|
172
175
|
}
|
|
@@ -60,7 +60,7 @@ export function ScreenLayoutContextProvider(props: {
|
|
|
60
60
|
initialState
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
const
|
|
63
|
+
const screenLayoutValue = React.useMemo(
|
|
64
64
|
() => ({
|
|
65
65
|
...screenLayout,
|
|
66
66
|
setScreenLayout,
|
|
@@ -69,7 +69,7 @@ export function ScreenLayoutContextProvider(props: {
|
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
|
-
<ScreenLayoutContext.Provider value={
|
|
72
|
+
<ScreenLayoutContext.Provider value={screenLayoutValue}>
|
|
73
73
|
{props.children}
|
|
74
74
|
</ScreenLayoutContext.Provider>
|
|
75
75
|
);
|
|
@@ -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
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen");
|
|
16
|
-
|
|
17
15
|
const Layout = require("..").default;
|
|
18
16
|
|
|
19
|
-
const
|
|
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,128 +1,69 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { isEmpty, pathOr } from "ramda";
|
|
3
3
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
-
import {
|
|
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";
|
|
17
|
-
import { TransitionOverlay } from "./TransitionOverlay";
|
|
5
|
+
import { getPathAttributes } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
18
6
|
|
|
19
7
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
20
|
-
import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
21
8
|
import { PathnameContext } from "../../../Contexts/PathnameContext";
|
|
22
|
-
import {
|
|
9
|
+
import { FocusableGroup } from "../../FocusableGroup";
|
|
10
|
+
import { Screen } from "../../Screen/TV/index.web";
|
|
11
|
+
|
|
12
|
+
export const ScreenDataContext = React.createContext(null);
|
|
23
13
|
|
|
24
14
|
type Components = {
|
|
25
15
|
NavBar: React.ComponentType<any>;
|
|
26
16
|
Background: React.ComponentType<any>;
|
|
27
17
|
};
|
|
28
18
|
|
|
29
|
-
type ComponentsExtraProps = {
|
|
30
|
-
Background?: Record<string, any>;
|
|
31
|
-
NavBar?: Record<string, any>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
19
|
type Props = {
|
|
35
20
|
Components: Components;
|
|
36
|
-
ComponentsExtraProps?: ComponentsExtraProps;
|
|
37
|
-
children: React.ReactNode;
|
|
38
21
|
};
|
|
39
22
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
);
|
|
23
|
+
const StackNavigator = ({ Components }: Props) => {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const { mainStack, currentRoute } = useNavigation();
|
|
26
|
+
|
|
27
|
+
const renderScreen = ({ route, state }) => {
|
|
28
|
+
const pathAttributes = getPathAttributes({ pathname: route });
|
|
29
|
+
|
|
30
|
+
if (isEmpty(pathAttributes)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const id = `${route}`;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<FocusableGroup
|
|
38
|
+
id={id}
|
|
39
|
+
preferredFocus={route === currentRoute}
|
|
40
|
+
excludeFromFocusSearching
|
|
41
|
+
key={id}
|
|
42
|
+
>
|
|
43
|
+
<ScreenDataContext.Provider value={state}>
|
|
44
|
+
<PathnameContext.Provider value={route}>
|
|
45
|
+
<Screen route={route} Components={Components} />
|
|
46
|
+
</PathnameContext.Provider>
|
|
47
|
+
</ScreenDataContext.Provider>
|
|
48
|
+
</FocusableGroup>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return mainStack.map(renderScreen);
|
|
53
|
+
};
|
|
93
54
|
|
|
94
|
-
|
|
55
|
+
const Layout = ({ Components }: Props) => {
|
|
56
|
+
const { appState } = usePickFromState(["appState"]);
|
|
57
|
+
const appReady = pathOr(false, ["appReady"], appState);
|
|
95
58
|
|
|
96
59
|
if (!appReady) {
|
|
97
60
|
return null;
|
|
98
61
|
}
|
|
99
62
|
|
|
100
63
|
return (
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
backgroundColor={backgroundColor}
|
|
105
|
-
backgroundImageUrl={backgroundImageUrl}
|
|
106
|
-
{...R.omit(["ref"])(ComponentsExtraProps?.Background)}
|
|
107
|
-
>
|
|
108
|
-
{!isTVOS ? navBarContainer : null}
|
|
109
|
-
{navBarReady ? (
|
|
110
|
-
/**
|
|
111
|
-
Need to re-mount this component on each navigation event
|
|
112
|
-
It's a hack to work around the fact that we don't support
|
|
113
|
-
correct screen rendering in our navigator (shared currentRoute state)
|
|
114
|
-
**/
|
|
115
|
-
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
116
|
-
<ScreenContainer>{children}</ScreenContainer>
|
|
117
|
-
</PathnameContext.Provider>
|
|
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
|
-
<TransitionOverlay />
|
|
123
|
-
</Components.Background>
|
|
124
|
-
</ScreenLayoutContextProvider>
|
|
125
|
-
</LayoutContainer>
|
|
64
|
+
<ScreenLayoutContextProvider>
|
|
65
|
+
<StackNavigator Components={Components} />
|
|
66
|
+
</ScreenLayoutContextProvider>
|
|
126
67
|
);
|
|
127
68
|
};
|
|
128
69
|
|
|
@@ -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>
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
|
|
3
3
|
import { LiveImage } from "../LiveImage";
|
|
4
4
|
import PureImage from "../Image";
|
|
5
|
+
import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
6
|
|
|
6
7
|
type Props = {
|
|
7
8
|
enable_video_preview: boolean;
|
|
@@ -9,7 +10,10 @@ type Props = {
|
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export const ImageContainer = (props: Props) => {
|
|
12
|
-
const
|
|
13
|
+
const isActive = useIsScreenActive();
|
|
14
|
+
|
|
15
|
+
const Component =
|
|
16
|
+
isVideoPreviewEnabled(props) && isActive ? LiveImage : PureImage;
|
|
13
17
|
|
|
14
18
|
return <Component {...props} />;
|
|
15
19
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Text } from "react-native";
|
|
3
3
|
import { omit } from "ramda";
|
|
4
|
-
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
5
4
|
import {
|
|
6
5
|
textTransform,
|
|
7
6
|
dateFormat,
|
|
@@ -9,6 +8,9 @@ import {
|
|
|
9
8
|
|
|
10
9
|
import { useTextLabel, withFocusedStyles } from "./hooks";
|
|
11
10
|
import { withScaledLineHeight } from "./utils";
|
|
11
|
+
import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
12
|
+
import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
|
|
13
|
+
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
12
14
|
|
|
13
15
|
type Props = {
|
|
14
16
|
style: any;
|
|
@@ -32,14 +34,24 @@ const _Text = ({
|
|
|
32
34
|
...otherProps
|
|
33
35
|
}: Props) => {
|
|
34
36
|
const _label = useTextLabel({ label, entry });
|
|
37
|
+
const isMeasurement = React.useContext(MeasurementPortalContext);
|
|
35
38
|
|
|
36
39
|
if (isNilOrEmpty(_label)) {
|
|
37
40
|
return null;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
// set maximum possible height for the text in case of measurement
|
|
44
|
+
const height =
|
|
45
|
+
isMeasurement && otherProps.numberOfLines && style.lineHeight
|
|
46
|
+
? toNumber(otherProps.numberOfLines) * toNumber(style.lineHeight)
|
|
47
|
+
: undefined;
|
|
48
|
+
|
|
40
49
|
return (
|
|
41
50
|
<Text
|
|
42
|
-
style={
|
|
51
|
+
style={[
|
|
52
|
+
withScaledLineHeight(withFocusedStyles({ style, otherProps })),
|
|
53
|
+
{ height },
|
|
54
|
+
]}
|
|
43
55
|
{...withoutLabel(otherProps)}
|
|
44
56
|
>
|
|
45
57
|
{dateTransformEnabled
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
2
|
+
import RN from "react-native";
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import TestRenderer from "react-test-renderer";
|
|
5
|
-
import
|
|
6
|
-
import CustomText from "../Text";
|
|
5
|
+
import configureStoreFn from "redux-mock-store";
|
|
7
6
|
|
|
8
|
-
const
|
|
7
|
+
const mockUseIsRTL = jest.fn(() => true);
|
|
8
|
+
const mockGetIsRTL = jest.fn(() => true);
|
|
9
|
+
const mockUseLocalizedStrings = jest.fn(() => ({}));
|
|
10
|
+
const mockGetUILanguage = jest.fn(() => "he-HE");
|
|
11
|
+
|
|
12
|
+
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
13
|
+
useIsRTL: mockUseIsRTL,
|
|
14
|
+
getIsRTL: mockGetIsRTL,
|
|
15
|
+
useLocalizedStrings: mockUseLocalizedStrings,
|
|
16
|
+
getUILanguage: mockGetUILanguage,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const CustomText = require("../Text").default;
|
|
20
|
+
const mockStore = configureStoreFn();
|
|
9
21
|
|
|
10
22
|
const defaultProps = {
|
|
11
23
|
entry: {},
|
|
@@ -22,7 +34,7 @@ const getRenderedText = (label: string, store: any) => {
|
|
|
22
34
|
</Provider>
|
|
23
35
|
);
|
|
24
36
|
|
|
25
|
-
return testRenderer.root.findByType(Text).props.children;
|
|
37
|
+
return testRenderer.root.findByType(RN.Text).props.children;
|
|
26
38
|
};
|
|
27
39
|
|
|
28
40
|
describe("RTL app: Hebrew text contains english word", () => {
|
|
@@ -34,7 +46,7 @@ describe("RTL app: Hebrew text contains english word", () => {
|
|
|
34
46
|
remoteConfigurations: { localizations: { he: {} } },
|
|
35
47
|
appData: {
|
|
36
48
|
languageCode: "he",
|
|
37
|
-
countryCode: "
|
|
49
|
+
countryCode: "IL",
|
|
38
50
|
},
|
|
39
51
|
});
|
|
40
52
|
|
|
@@ -47,18 +59,22 @@ describe("RTL app: Hebrew text contains english word", () => {
|
|
|
47
59
|
|
|
48
60
|
it("Hebrew text contains not first english word", () => {
|
|
49
61
|
const renderedText = getRenderedText(textWithNotFirstEnglishWord, store);
|
|
50
|
-
|
|
51
62
|
expect(renderedText).toEqual(textWithNotFirstEnglishWord);
|
|
52
63
|
});
|
|
53
64
|
|
|
54
65
|
it("Hebrew text doesn't contain english word", () => {
|
|
55
66
|
const renderedText = getRenderedText(textWithoutEnglishWord, store);
|
|
56
|
-
|
|
57
67
|
expect(renderedText).toEqual(textWithoutEnglishWord);
|
|
58
68
|
});
|
|
59
69
|
});
|
|
60
70
|
|
|
61
71
|
describe("LTR app: English text", () => {
|
|
72
|
+
beforeAll(() => {
|
|
73
|
+
mockUseIsRTL.mockReturnValue(false);
|
|
74
|
+
mockGetIsRTL.mockReturnValue(false);
|
|
75
|
+
mockGetUILanguage.mockReturnValue("en-US");
|
|
76
|
+
});
|
|
77
|
+
|
|
62
78
|
const englishText = "Test sentence";
|
|
63
79
|
|
|
64
80
|
const store = mockStore({
|
|
@@ -71,7 +87,6 @@ describe("LTR app: English text", () => {
|
|
|
71
87
|
|
|
72
88
|
it("English text", () => {
|
|
73
89
|
const renderedText = getRenderedText(englishText, store);
|
|
74
|
-
|
|
75
90
|
expect(renderedText).toEqual(englishText);
|
|
76
91
|
});
|
|
77
92
|
});
|