@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5350212300 → 12.0.0-alpha.5400461972
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 +1 -5
- package/Components/Cell/CellWithFocusable.tsx +5 -17
- package/Components/FocusableGroup/index.tsx +0 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +0 -3
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- package/Components/Layout/TV/index.tsx +27 -123
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- 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/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 +2 -3
- package/Components/River/ComponentsMap/ComponentsMap.tsx +24 -17
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/River/TV/River.tsx +1 -0
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/ScreenResolver/index.tsx +1 -3
- package/Components/Transitioner/Scene.tsx +24 -19
- package/Components/Transitioner/Transitioner.tsx +9 -2
- 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 +3 -0
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -2
- package/Components/VideoModal/PlayerWrapper.tsx +67 -60
- package/Components/VideoModal/VideoModal.tsx +19 -19
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
- package/Contexts/ScreenContext/index.tsx +2 -2
- package/Contexts/ScreenDataContext/index.ts +3 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- package/events/index.ts +1 -0
- package/package.json +5 -5
- package/Components/Screen/TV/index.web.tsx +0 -159
|
@@ -73,7 +73,7 @@ export class BaseFocusable<
|
|
|
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
|
@@ -207,11 +207,7 @@ export class CellComponent extends React.Component<Props> {
|
|
|
207
207
|
|
|
208
208
|
const { id } = item;
|
|
209
209
|
|
|
210
|
-
const focusableId = R.join("-", [
|
|
211
|
-
`componentId:${component?.id}`,
|
|
212
|
-
`id:${id}`,
|
|
213
|
-
`index:${index}`,
|
|
214
|
-
]);
|
|
210
|
+
const focusableId = R.join("-", [component?.id, id, index]);
|
|
215
211
|
|
|
216
212
|
const handleFocus = (focusable, mouse) => {
|
|
217
213
|
const focusFn = onFocus || noop;
|
|
@@ -6,20 +6,12 @@ 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 = (
|
|
10
|
-
skipFocusManagerRegistration: boolean,
|
|
11
|
-
groupId: string,
|
|
12
|
-
id: string
|
|
13
|
-
) => {
|
|
9
|
+
const useCellFocusedState = (groupId: string, id: string) => {
|
|
14
10
|
const [currentCellFocused, setCurrentCellFocused] = React.useState(false);
|
|
15
11
|
|
|
16
12
|
React.useEffect(() => {
|
|
17
|
-
const isGroupItemFocused = () =>
|
|
18
|
-
|
|
19
|
-
const isFocused = focusManager.isGroupItemFocused(groupId, id);
|
|
20
|
-
setCurrentCellFocused(isFocused);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
13
|
+
const isGroupItemFocused = () =>
|
|
14
|
+
setCurrentCellFocused(focusManager.isGroupItemFocused(groupId, id));
|
|
23
15
|
|
|
24
16
|
const handler = () => {
|
|
25
17
|
// tvOS hack for properly checking focus
|
|
@@ -37,7 +29,7 @@ const useCellFocusedState = (
|
|
|
37
29
|
return () => {
|
|
38
30
|
focusManager.removeHandler(FOCUS_EVENTS.FOCUS, handler);
|
|
39
31
|
};
|
|
40
|
-
}, [groupId
|
|
32
|
+
}, [groupId]);
|
|
41
33
|
|
|
42
34
|
return currentCellFocused;
|
|
43
35
|
};
|
|
@@ -73,11 +65,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
73
65
|
selected,
|
|
74
66
|
} = props;
|
|
75
67
|
|
|
76
|
-
const isFocused = useCellFocusedState(
|
|
77
|
-
skipFocusManagerRegistration,
|
|
78
|
-
groupId,
|
|
79
|
-
id
|
|
80
|
-
);
|
|
68
|
+
const isFocused = useCellFocusedState(groupId, id);
|
|
81
69
|
|
|
82
70
|
const state = useCellState({
|
|
83
71
|
id: item.id,
|
|
@@ -19,7 +19,6 @@ type Props = {
|
|
|
19
19
|
modalHeight?: number;
|
|
20
20
|
modalWidth?: number;
|
|
21
21
|
mode: VideoModalMode;
|
|
22
|
-
groupId?: string;
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
const YOUTUBE_PLUGIN_ID = "youtube-player-qb";
|
|
@@ -94,7 +93,6 @@ export function HandlePlayable({
|
|
|
94
93
|
modalHeight,
|
|
95
94
|
modalWidth,
|
|
96
95
|
mode,
|
|
97
|
-
groupId,
|
|
98
96
|
}: Props): React.ReactElement | null {
|
|
99
97
|
const state = usePickFromState();
|
|
100
98
|
|
|
@@ -169,7 +167,6 @@ export function HandlePlayable({
|
|
|
169
167
|
isModal={isModal}
|
|
170
168
|
mode={mode}
|
|
171
169
|
disableCastAction={playerModuleProperties?.disableCastAction}
|
|
172
|
-
groupId={groupId}
|
|
173
170
|
/>
|
|
174
171
|
);
|
|
175
172
|
}
|
|
@@ -60,7 +60,7 @@ export function ScreenLayoutContextProvider(props: {
|
|
|
60
60
|
initialState
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
const
|
|
63
|
+
const screeenLayoutValue = 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={screeenLayoutValue}>
|
|
73
73
|
{props.children}
|
|
74
74
|
</ScreenLayoutContext.Provider>
|
|
75
75
|
);
|
|
@@ -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";
|
|
@@ -21,25 +17,10 @@ import { ScreenContainer } from "./ScreenContainer";
|
|
|
21
17
|
import { TransitionOverlay } from "./TransitionOverlay";
|
|
22
18
|
|
|
23
19
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
20
|
+
import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
24
21
|
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
|
-
});
|
|
22
|
+
import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
23
|
+
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
43
24
|
|
|
44
25
|
type Components = {
|
|
45
26
|
NavBar: React.ComponentType<any>;
|
|
@@ -47,73 +28,16 @@ type Components = {
|
|
|
47
28
|
};
|
|
48
29
|
|
|
49
30
|
type ComponentsExtraProps = {
|
|
50
|
-
NavBar?: Record<string, any>;
|
|
51
31
|
Background?: Record<string, any>;
|
|
32
|
+
NavBar?: Record<string, any>;
|
|
52
33
|
};
|
|
53
34
|
|
|
54
35
|
type Props = {
|
|
55
36
|
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);
|
|
37
|
+
ComponentsExtraProps?: ComponentsExtraProps;
|
|
38
|
+
children: React.ReactNode;
|
|
101
39
|
};
|
|
102
40
|
|
|
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
41
|
const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
118
42
|
const navigator = useNavigation();
|
|
119
43
|
const theme = useTheme();
|
|
@@ -175,54 +99,34 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
175
99
|
}
|
|
176
100
|
|
|
177
101
|
return (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{!isTVOS ? navBarContainer : null}
|
|
191
|
-
{navBarReady ? (
|
|
192
|
-
/**
|
|
102
|
+
<LayoutContainer>
|
|
103
|
+
<ScreenLayoutContextProvider>
|
|
104
|
+
<Components.Background
|
|
105
|
+
backgroundColor={backgroundColor}
|
|
106
|
+
backgroundImageUrl={backgroundImageUrl}
|
|
107
|
+
{...R.omit(["ref"])(ComponentsExtraProps?.Background)}
|
|
108
|
+
>
|
|
109
|
+
<ScreenDataContext.Provider value={navigator.data}>
|
|
110
|
+
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
111
|
+
{!isTVOS ? navBarContainer : null}
|
|
112
|
+
{navBarReady ? (
|
|
113
|
+
/**
|
|
193
114
|
Need to re-mount this component on each navigation event
|
|
194
115
|
It's a hack to work around the fact that we don't support
|
|
195
116
|
correct screen rendering in our navigator (shared currentRoute state)
|
|
196
117
|
**/
|
|
197
|
-
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
198
118
|
<ScreenContainer>{children}</ScreenContainer>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
119
|
+
) : null}
|
|
120
|
+
{/** Render NavBarContainer over ScreenContainer to let tvOS native
|
|
202
121
|
focus manager works correctly to focus nav bar items first **/}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
</
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
122
|
+
{isTVOS ? navBarContainer : null}
|
|
123
|
+
</PathnameContext.Provider>
|
|
124
|
+
</ScreenDataContext.Provider>
|
|
125
|
+
<TransitionOverlay />
|
|
126
|
+
</Components.Background>
|
|
127
|
+
</ScreenLayoutContextProvider>
|
|
128
|
+
</LayoutContainer>
|
|
209
129
|
);
|
|
210
130
|
};
|
|
211
131
|
|
|
212
132
|
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
|
-
*/
|
|
@@ -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>
|
|
@@ -4,6 +4,7 @@ import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerM
|
|
|
4
4
|
|
|
5
5
|
type DynamicBadgeProps = {
|
|
6
6
|
cellUUID?: string;
|
|
7
|
+
uri?: string;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
@@ -12,11 +13,12 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
|
12
13
|
// TODO: Initial value should depends on player state (playing or not)
|
|
13
14
|
const [showImage, setShowImage] = React.useState(true);
|
|
14
15
|
const player = usePlayer(playerId);
|
|
16
|
+
const uri = props?.uri;
|
|
15
17
|
|
|
16
18
|
React.useEffect(() => {
|
|
17
19
|
if (playerId && player) {
|
|
18
20
|
return player.addListener({
|
|
19
|
-
id:
|
|
21
|
+
id: `dynamic-badges-${uri}`,
|
|
20
22
|
listener: {
|
|
21
23
|
onPlayerClose: () => {
|
|
22
24
|
setShowImage(true);
|
|
@@ -35,7 +37,7 @@ const DynamicBadgeComponent = (props: DynamicBadgeProps) => {
|
|
|
35
37
|
} else {
|
|
36
38
|
setShowImage(true);
|
|
37
39
|
}
|
|
38
|
-
}, [player]);
|
|
40
|
+
}, [player, uri]);
|
|
39
41
|
|
|
40
42
|
if (!showImage) {
|
|
41
43
|
return null;
|
|
@@ -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
|
});
|
|
@@ -51,9 +51,7 @@ export const CollapsibleTextContainer = ({
|
|
|
51
51
|
func: (data) => {
|
|
52
52
|
return getColorFromData({
|
|
53
53
|
data,
|
|
54
|
-
|
|
55
|
-
key: "background_color",
|
|
56
|
-
defaultColor: additionalStyles.backgroundColor,
|
|
54
|
+
valueFromLayout: additionalStyles.backgroundColor,
|
|
57
55
|
});
|
|
58
56
|
},
|
|
59
57
|
propName: "backgroundColor",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { MeasurementPortalContext } from "./MeasurementsPortal";
|
|
3
4
|
|
|
4
5
|
type Props = {
|
|
5
6
|
Component: React.ElementType;
|
|
@@ -19,13 +20,16 @@ const _MeasurementsPortal = (
|
|
|
19
20
|
{ Component, onLayout, componentProps, containerStyle }: Props,
|
|
20
21
|
ref
|
|
21
22
|
) => (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
// hack for cell to determine if cell is in measurement mode
|
|
24
|
+
<MeasurementPortalContext.Provider value={{}}>
|
|
25
|
+
<View
|
|
26
|
+
onLayout={onLayout}
|
|
27
|
+
style={[styles.container, containerStyle]}
|
|
28
|
+
ref={ref}
|
|
29
|
+
>
|
|
30
|
+
<Component {...componentProps} />
|
|
31
|
+
</View>
|
|
32
|
+
</MeasurementPortalContext.Provider>
|
|
29
33
|
);
|
|
30
34
|
|
|
31
35
|
export const MeasurementsPortal = React.forwardRef(_MeasurementsPortal);
|
|
@@ -35,7 +35,16 @@ const MeasurementsPortal = ({ Component, onLayout, componentProps }: Props) => {
|
|
|
35
35
|
);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
type MeasurementPortalContextType = {
|
|
39
|
+
measureComponent?: (
|
|
40
|
+
comp: React.ElementType,
|
|
41
|
+
props: Record<any, any>
|
|
42
|
+
) => Promise<any>;
|
|
43
|
+
measuringInProgress?: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const MeasurementPortalContext =
|
|
47
|
+
React.createContext<null | MeasurementPortalContextType>(null);
|
|
39
48
|
|
|
40
49
|
const MeasurementsPortalContextProvider = ({ children }) => {
|
|
41
50
|
const Component = React.useRef(View);
|
|
@@ -68,7 +68,6 @@ type Props = {
|
|
|
68
68
|
mode?: VideoModalMode;
|
|
69
69
|
loadPipesData: (url: string, options: {}) => void;
|
|
70
70
|
disableCastAction?: boolean;
|
|
71
|
-
groupId?: string;
|
|
72
71
|
};
|
|
73
72
|
|
|
74
73
|
type ScreenStyles = ZappRiver["styles"] & {
|
|
@@ -201,7 +200,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
201
200
|
style: videoStyle,
|
|
202
201
|
mode = VideoModalMode.MAXIMIZED,
|
|
203
202
|
disableCastAction = false,
|
|
204
|
-
groupId,
|
|
205
203
|
} = props;
|
|
206
204
|
|
|
207
205
|
// Hooks
|
|
@@ -251,6 +249,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
251
249
|
return;
|
|
252
250
|
}
|
|
253
251
|
|
|
252
|
+
navigator.goBack();
|
|
254
253
|
showNavBar(true);
|
|
255
254
|
}, [isModal, navigator.goBack, showNavBar]);
|
|
256
255
|
|
|
@@ -630,7 +629,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
630
629
|
style={styles.focusableGroup}
|
|
631
630
|
preferredFocus
|
|
632
631
|
shouldUsePreferredFocus
|
|
633
|
-
groupId={groupId}
|
|
634
632
|
>
|
|
635
633
|
{/* Video player and components */}
|
|
636
634
|
<View
|
|
@@ -673,6 +671,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
673
671
|
setNextVideoPreloadThresholdPercentage={
|
|
674
672
|
setNextVideoPreloadThresholdPercentage
|
|
675
673
|
}
|
|
674
|
+
startComponentsAnimation={startComponentsAnimation}
|
|
676
675
|
>
|
|
677
676
|
{renderApplePlayer(applePlayerProps)}
|
|
678
677
|
</Player>
|