@applicaster/zapp-react-native-ui-components 15.0.0-alpha.2239032089 → 15.0.0-alpha.2882475305
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/Cell/FocusableWrapper.tsx +44 -0
- package/Components/Cell/TvOSCellComponent.tsx +80 -14
- package/Components/Focusable/Focusable.tsx +2 -4
- package/Components/Focusable/FocusableTvOS.tsx +1 -5
- package/Components/FocusableGroup/FocusableTvOS.tsx +0 -5
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +9 -11
- package/Components/River/TV/River.tsx +3 -9
- package/Components/River/TV/index.tsx +3 -3
- package/Components/River/TV/withTVEventHandler.tsx +27 -0
- package/Components/Screen/TV/hooks/useInitialFocus.ts +14 -4
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
- package/Components/Screen/index.tsx +22 -5
- package/Components/ScreenResolver/index.tsx +8 -2
- package/Components/ScreenRevealManager/utils/index.ts +23 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +12 -0
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +6 -10
- package/events/index.ts +0 -2
- package/package.json +5 -5
- package/Components/River/TV/withFocusableGroupForContent.tsx +0 -60
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
3
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
id: string;
|
|
7
|
+
groupId: string;
|
|
8
|
+
isParallaxDisabled: boolean;
|
|
9
|
+
applyWrapper: boolean;
|
|
10
|
+
children: (focused: boolean) => React.ReactNode;
|
|
11
|
+
onFocus: (arg1: any, index?: number) => void;
|
|
12
|
+
onBlur: Callback;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const FocusableWrapper = ({
|
|
16
|
+
id,
|
|
17
|
+
groupId,
|
|
18
|
+
isParallaxDisabled,
|
|
19
|
+
children,
|
|
20
|
+
applyWrapper,
|
|
21
|
+
onFocus,
|
|
22
|
+
onBlur,
|
|
23
|
+
}: Props) => {
|
|
24
|
+
if (applyWrapper) {
|
|
25
|
+
return (
|
|
26
|
+
<Focusable
|
|
27
|
+
id={id}
|
|
28
|
+
groupId={groupId}
|
|
29
|
+
isParallaxDisabled={isParallaxDisabled}
|
|
30
|
+
onFocus={onFocus}
|
|
31
|
+
onBlur={onBlur}
|
|
32
|
+
willReceiveFocus={noop}
|
|
33
|
+
hasReceivedFocus={noop}
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
offsetUpdater={noop}
|
|
36
|
+
isFocusable
|
|
37
|
+
>
|
|
38
|
+
{(focused) => children(focused)}
|
|
39
|
+
</Focusable>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <>{children(false)}</>;
|
|
44
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { View, StyleSheet } from "react-native";
|
|
4
|
+
import { first, filter } from "rxjs/operators";
|
|
5
|
+
|
|
6
|
+
import { compose } from "@applicaster/zapp-react-native-utils/utils";
|
|
4
7
|
|
|
5
8
|
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
6
9
|
import { FocusableCell } from "@applicaster/zapp-react-native-ui-components/Components/FocusableCell";
|
|
@@ -9,7 +12,11 @@ import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUti
|
|
|
9
12
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
10
13
|
import { sendSelectCellEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
11
14
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
15
|
+
import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
12
16
|
import { CellWithFocusable } from "./CellWithFocusable";
|
|
17
|
+
import { FocusableWrapper } from "./FocusableWrapper";
|
|
18
|
+
|
|
19
|
+
import { focusableButtonsRegistration$ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
|
|
13
20
|
|
|
14
21
|
type Props = {
|
|
15
22
|
item: ZappEntry;
|
|
@@ -66,6 +73,8 @@ type Props = {
|
|
|
66
73
|
shouldUpdate: boolean;
|
|
67
74
|
behavior: Behavior;
|
|
68
75
|
componentsMapOffset: number;
|
|
76
|
+
applyFocusableWrapper: boolean;
|
|
77
|
+
hasFocusableInside: boolean;
|
|
69
78
|
};
|
|
70
79
|
|
|
71
80
|
type State = {
|
|
@@ -82,7 +91,7 @@ const baseCellStyles = {
|
|
|
82
91
|
flex: 1,
|
|
83
92
|
} as const;
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
class TvOSCell extends React.Component<Props, State> {
|
|
86
95
|
cell: any;
|
|
87
96
|
target: any;
|
|
88
97
|
layout: any;
|
|
@@ -239,6 +248,8 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
239
248
|
groupId,
|
|
240
249
|
isFocusable,
|
|
241
250
|
behavior,
|
|
251
|
+
applyFocusableWrapper,
|
|
252
|
+
hasFocusableInside,
|
|
242
253
|
} = this.props;
|
|
243
254
|
|
|
244
255
|
const { id } = item;
|
|
@@ -254,24 +265,33 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
254
265
|
this.onFocus(arg1, index);
|
|
255
266
|
};
|
|
256
267
|
|
|
257
|
-
const hasFocusableInside = CellRenderer.hasFocusableInside?.(item);
|
|
258
|
-
|
|
259
268
|
if (hasFocusableInside) {
|
|
260
269
|
return (
|
|
261
270
|
<View onLayout={this.onLayout}>
|
|
262
|
-
<
|
|
263
|
-
CellRenderer={CellRenderer}
|
|
264
|
-
item={item}
|
|
271
|
+
<FocusableWrapper
|
|
265
272
|
id={focusableId}
|
|
266
|
-
groupId={(groupId || component?.id)
|
|
273
|
+
groupId={String(groupId || component?.id)}
|
|
274
|
+
isParallaxDisabled={this.layout?.width > 1740}
|
|
267
275
|
onFocus={handleFocus}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
276
|
+
onBlur={onBlur || this.onBlur}
|
|
277
|
+
applyWrapper={applyFocusableWrapper}
|
|
278
|
+
>
|
|
279
|
+
{(focused) => (
|
|
280
|
+
<CellWithFocusable
|
|
281
|
+
CellRenderer={CellRenderer}
|
|
282
|
+
item={item}
|
|
283
|
+
id={focusableId}
|
|
284
|
+
groupId={(groupId || component?.id).toString()}
|
|
285
|
+
onFocus={handleFocus}
|
|
286
|
+
index={index}
|
|
287
|
+
scrollTo={this.scrollTo}
|
|
288
|
+
preferredFocus={preferredFocus}
|
|
289
|
+
focused={focused || this.props.focused}
|
|
290
|
+
behavior={behavior}
|
|
291
|
+
isFocusable={isFocusable}
|
|
292
|
+
/>
|
|
293
|
+
)}
|
|
294
|
+
</FocusableWrapper>
|
|
275
295
|
</View>
|
|
276
296
|
);
|
|
277
297
|
}
|
|
@@ -309,3 +329,49 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
309
329
|
);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
332
|
+
|
|
333
|
+
export function withFocusableWrapperHOC(Component) {
|
|
334
|
+
return function WrappedComponent(props) {
|
|
335
|
+
const [focusableViewIsRendered, setFocusableViewIsRendered] =
|
|
336
|
+
React.useState(false);
|
|
337
|
+
|
|
338
|
+
const { CellRenderer, item, groupId, component } = props;
|
|
339
|
+
|
|
340
|
+
const isFocusable = toBooleanWithDefaultTrue(props?.isFocusable);
|
|
341
|
+
|
|
342
|
+
const focusableGroupId = String(groupId || component?.id);
|
|
343
|
+
|
|
344
|
+
const hasFocusableInside = CellRenderer.hasFocusableInside?.(item);
|
|
345
|
+
|
|
346
|
+
React.useEffect(() => {
|
|
347
|
+
// start waiting any first registration of FocusableButton inside this focusableGroup
|
|
348
|
+
// after it we could get rid of applying focusable-wrapper
|
|
349
|
+
const subscription = focusableButtonsRegistration$(focusableGroupId)
|
|
350
|
+
.pipe(
|
|
351
|
+
filter(() => isFocusable),
|
|
352
|
+
first()
|
|
353
|
+
)
|
|
354
|
+
.subscribe(() => {
|
|
355
|
+
setFocusableViewIsRendered(true);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return () => {
|
|
359
|
+
subscription.unsubscribe();
|
|
360
|
+
};
|
|
361
|
+
}, [isFocusable, focusableGroupId]);
|
|
362
|
+
|
|
363
|
+
const applyFocusableWrapper = React.useMemo(() => {
|
|
364
|
+
return isFocusable && hasFocusableInside && !focusableViewIsRendered;
|
|
365
|
+
}, [isFocusable, hasFocusableInside, focusableViewIsRendered]);
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<Component
|
|
369
|
+
{...props}
|
|
370
|
+
applyFocusableWrapper={applyFocusableWrapper}
|
|
371
|
+
hasFocusableInside={hasFocusableInside}
|
|
372
|
+
/>
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const TvOSCellComponent = compose(withFocusableWrapperHOC)(TvOSCell);
|
|
@@ -8,8 +8,6 @@ import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withF
|
|
|
8
8
|
import { StyleSheet, ViewStyle } from "react-native";
|
|
9
9
|
import { AccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager";
|
|
10
10
|
|
|
11
|
-
import { isSearchInputId } from "@applicaster/search-screen/src/tv/utils";
|
|
12
|
-
|
|
13
11
|
type Props = {
|
|
14
12
|
initialFocus?: boolean;
|
|
15
13
|
id: string;
|
|
@@ -108,7 +106,7 @@ class Focusable extends BaseFocusable<Props> {
|
|
|
108
106
|
onMouseEnter() {
|
|
109
107
|
const { id } = this.props;
|
|
110
108
|
|
|
111
|
-
if (
|
|
109
|
+
if (id !== "search_input_group_id") {
|
|
112
110
|
this.mouse = true;
|
|
113
111
|
this.props?.handleFocus?.({ mouse: true });
|
|
114
112
|
|
|
@@ -122,7 +120,7 @@ class Focusable extends BaseFocusable<Props> {
|
|
|
122
120
|
onMouseLeave() {
|
|
123
121
|
const { id } = this.props;
|
|
124
122
|
|
|
125
|
-
if (
|
|
123
|
+
if (id !== "search_input_group_id") {
|
|
126
124
|
this.mouse = false;
|
|
127
125
|
this.blur(null);
|
|
128
126
|
}
|
|
@@ -10,9 +10,8 @@ import {
|
|
|
10
10
|
forceFocusableFocus,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
12
12
|
import { findNodeHandle, ViewStyle } from "react-native";
|
|
13
|
-
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
function noop() {}
|
|
16
15
|
|
|
17
16
|
type Props = {
|
|
18
17
|
id: string;
|
|
@@ -85,9 +84,6 @@ export class Focusable extends BaseFocusable<Props> {
|
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
const id: string = nativeEvent.itemID;
|
|
89
|
-
emitFocused(id);
|
|
90
|
-
|
|
91
87
|
onFocus(nativeEvent);
|
|
92
88
|
}
|
|
93
89
|
|
|
@@ -142,17 +142,15 @@ export const useCurationAPI = (
|
|
|
142
142
|
const url = path(SOURCE_PATH, component);
|
|
143
143
|
const mapping = path(MAPPING_PATH, component);
|
|
144
144
|
|
|
145
|
-
map[component.id] =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
: url;
|
|
145
|
+
map[component.id] = getInflatedDataSourceUrl({
|
|
146
|
+
source: url,
|
|
147
|
+
contexts: {
|
|
148
|
+
entry: entryContext,
|
|
149
|
+
screen: screenContext,
|
|
150
|
+
search: getSearchContext(searchContext, mapping),
|
|
151
|
+
},
|
|
152
|
+
mapping,
|
|
153
|
+
});
|
|
156
154
|
});
|
|
157
155
|
|
|
158
156
|
return map;
|
|
@@ -4,7 +4,6 @@ import * as React from "react";
|
|
|
4
4
|
import { Text } from "react-native";
|
|
5
5
|
import * as R from "ramda";
|
|
6
6
|
|
|
7
|
-
import { isNil } from "@applicaster/zapp-react-native-utils/utils";
|
|
8
7
|
import { GeneralContentScreen } from "../../GeneralContentScreen";
|
|
9
8
|
import { ScreenResolver } from "@applicaster/zapp-react-native-ui-components/Components/ScreenResolver";
|
|
10
9
|
import { utilsLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
@@ -25,7 +24,6 @@ type Props = {
|
|
|
25
24
|
isInsideContainer?: boolean;
|
|
26
25
|
extraAnchorPointYOffset: number;
|
|
27
26
|
river?: ZappRiver | ZappEntry;
|
|
28
|
-
groupId: string;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
export const River = (props: Props) => {
|
|
@@ -37,7 +35,6 @@ export const River = (props: Props) => {
|
|
|
37
35
|
componentsMapExtraProps,
|
|
38
36
|
isInsideContainer,
|
|
39
37
|
extraAnchorPointYOffset,
|
|
40
|
-
groupId,
|
|
41
38
|
} = props;
|
|
42
39
|
|
|
43
40
|
const { title: screenTitle, summary: screenSummary } = useNavbarState();
|
|
@@ -55,7 +52,7 @@ export const River = (props: Props) => {
|
|
|
55
52
|
);
|
|
56
53
|
|
|
57
54
|
const stringOrEmpty = (value: string | number | undefined): string =>
|
|
58
|
-
isNil(value) ? "" : String(value);
|
|
55
|
+
R.isNil(value) ? "" : String(value);
|
|
59
56
|
|
|
60
57
|
React.useEffect(() => {
|
|
61
58
|
if (!isInsideContainer) {
|
|
@@ -95,10 +92,8 @@ export const River = (props: Props) => {
|
|
|
95
92
|
<ScreenResolver
|
|
96
93
|
screenType={river.type}
|
|
97
94
|
screenId={screenId}
|
|
98
|
-
screenData={
|
|
99
|
-
componentsMapExtraProps={
|
|
100
|
-
groupId,
|
|
101
|
-
})}
|
|
95
|
+
screenData={R.merge(river, { groupId: extraData?.groupId })}
|
|
96
|
+
componentsMapExtraProps={componentsMapExtraProps}
|
|
102
97
|
{...extraData}
|
|
103
98
|
/>
|
|
104
99
|
);
|
|
@@ -111,7 +106,6 @@ export const River = (props: Props) => {
|
|
|
111
106
|
isScreenWrappedInContainer={isInsideContainer}
|
|
112
107
|
extraAnchorPointYOffset={extraAnchorPointYOffset}
|
|
113
108
|
componentsMapExtraProps={componentsMapExtraProps}
|
|
114
|
-
groupId={groupId}
|
|
115
109
|
/>
|
|
116
110
|
);
|
|
117
111
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { compose } from "ramda";
|
|
2
2
|
import { River as RiverComponent } from "./River";
|
|
3
|
+
import { withTvEventHandler } from "./withTVEventHandler";
|
|
3
4
|
import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
|
|
4
5
|
import { withRiverDataLoader } from "./withRiverDataLoader";
|
|
5
|
-
import { withFocusableGroupForContent } from "./withFocusableGroupForContent";
|
|
6
6
|
|
|
7
7
|
export const River = compose(
|
|
8
|
+
withTvEventHandler,
|
|
8
9
|
withComponentsMapOffsetContext,
|
|
9
|
-
withRiverDataLoader
|
|
10
|
-
withFocusableGroupForContent
|
|
10
|
+
withRiverDataLoader
|
|
11
11
|
)(RiverComponent);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint max-len: off */
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
|
|
5
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
|
|
7
|
+
export const withTvEventHandler = (Component) => {
|
|
8
|
+
return function WithTVEventHandler(props) {
|
|
9
|
+
const navigator = useNavigation();
|
|
10
|
+
|
|
11
|
+
const remoteHandler = (event) => {
|
|
12
|
+
const { eventType } = event;
|
|
13
|
+
|
|
14
|
+
const canGoBack = navigator.canGoBack();
|
|
15
|
+
|
|
16
|
+
if (eventType === "menu" && canGoBack) {
|
|
17
|
+
navigator.goBack();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<TVEventHandlerComponent tvEventHandler={remoteHandler}>
|
|
23
|
+
<Component {...props} />
|
|
24
|
+
</TVEventHandlerComponent>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
setFocusOnMenu,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux";
|
|
12
12
|
|
|
13
|
+
import { waitUntilScreenRevealManagerIsReady } from "@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils";
|
|
14
|
+
|
|
13
15
|
type Return =
|
|
14
16
|
| {
|
|
15
17
|
onContent: true;
|
|
@@ -57,14 +59,22 @@ export const useInitialFocus = (): void => {
|
|
|
57
59
|
React.useEffect(() => {
|
|
58
60
|
const initialFocus = getInitialFocus(focusOnContent, isNavBarVisible);
|
|
59
61
|
|
|
60
|
-
if (initialFocus.
|
|
61
|
-
|
|
62
|
+
if (initialFocus.onMenu) {
|
|
63
|
+
setFocusOnMenu(currentRoute);
|
|
62
64
|
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
if (initialFocus.
|
|
67
|
-
|
|
68
|
+
if (initialFocus.onContent) {
|
|
69
|
+
const subscription = waitUntilScreenRevealManagerIsReady().subscribe(
|
|
70
|
+
() => {
|
|
71
|
+
setFocusOnContent(currentRoute);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return () => {
|
|
76
|
+
subscription.unsubscribe();
|
|
77
|
+
};
|
|
68
78
|
}
|
|
69
79
|
}, []);
|
|
70
80
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
importantForAccessibility="yes"
|
|
5
6
|
style={
|
|
6
7
|
{
|
|
7
8
|
"backgroundColor": "blue",
|
|
@@ -34,6 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
34
35
|
|
|
35
36
|
exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
|
|
36
37
|
<View
|
|
38
|
+
importantForAccessibility="yes"
|
|
37
39
|
style={
|
|
38
40
|
{
|
|
39
41
|
"backgroundColor": "blue",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { View } from "react-native";
|
|
3
|
+
import { AccessibilityInfo, findNodeHandle, View } from "react-native";
|
|
4
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
5
|
|
|
6
6
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
13
13
|
import {
|
|
14
14
|
useCurrentScreenData,
|
|
15
|
+
useIsScreenActive,
|
|
15
16
|
useNavbarState,
|
|
16
17
|
useNavigation,
|
|
17
18
|
useRoute,
|
|
@@ -57,8 +58,8 @@ export function Screen(_props: Props) {
|
|
|
57
58
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
58
59
|
|
|
59
60
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
60
|
-
getNavBarProps(currentRiver, pathname, title),
|
|
61
|
-
[currentRiver, pathname]
|
|
61
|
+
() => getNavBarProps(currentRiver, pathname, title),
|
|
62
|
+
[currentRiver, pathname, title]
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
const NavBar = React.useMemo(
|
|
@@ -89,13 +90,29 @@ export function Screen(_props: Props) {
|
|
|
89
90
|
[theme.app_background_color, backgroundColor]
|
|
90
91
|
);
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
const isActive = useIsScreenActive();
|
|
94
|
+
|
|
95
|
+
const ref = React.useRef(null);
|
|
93
96
|
const isReady = useWaitForValidOrientation();
|
|
94
97
|
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (ref.current && isActive && isReady) {
|
|
100
|
+
const nodeHandle = findNodeHandle(ref.current);
|
|
101
|
+
|
|
102
|
+
if (nodeHandle != null) {
|
|
103
|
+
AccessibilityInfo.setAccessibilityFocus(nodeHandle);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [isActive, isReady]);
|
|
107
|
+
|
|
95
108
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
96
109
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
97
110
|
return (
|
|
98
|
-
<View
|
|
111
|
+
<View
|
|
112
|
+
ref={ref}
|
|
113
|
+
style={style}
|
|
114
|
+
importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
|
|
115
|
+
>
|
|
99
116
|
{isReady ? (
|
|
100
117
|
<>
|
|
101
118
|
{navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
|
|
@@ -16,6 +16,7 @@ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
|
16
16
|
import { useScreenAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
|
|
17
17
|
|
|
18
18
|
import { useCallbackActions } from "@applicaster/zapp-react-native-utils/zappFrameworkUtils/HookCallback/useCallbackActions";
|
|
19
|
+
import { ScreenResultCallback } from "@applicaster/zapp-react-native-utils/zappFrameworkUtils/HookCallback/callbackNavigationAction";
|
|
19
20
|
|
|
20
21
|
const logger = componentsLogger.addSubsystem("ScreenResolver");
|
|
21
22
|
|
|
@@ -26,6 +27,7 @@ type Props = {
|
|
|
26
27
|
feedId?: string;
|
|
27
28
|
feedTitle?: string;
|
|
28
29
|
focused?: boolean;
|
|
30
|
+
resultCallback?: ScreenResultCallback;
|
|
29
31
|
parentFocus?: {
|
|
30
32
|
nextFocusDown?: React.Ref<any>;
|
|
31
33
|
nextFocusRight?: React.Ref<any>;
|
|
@@ -61,13 +63,17 @@ export function ScreenResolverComponent(props: Props) {
|
|
|
61
63
|
|
|
62
64
|
React.useEffect(() => {
|
|
63
65
|
setScreenContext(rivers[screenId]);
|
|
64
|
-
}, [screenId]);
|
|
66
|
+
}, [rivers, screenId, setScreenContext]);
|
|
65
67
|
|
|
66
|
-
const
|
|
68
|
+
const parentCallback = props.resultCallback;
|
|
69
|
+
|
|
70
|
+
const screenAction = useCallbackActions(
|
|
67
71
|
hookPlugin || screenData,
|
|
68
72
|
screenData.callback
|
|
69
73
|
);
|
|
70
74
|
|
|
75
|
+
const callbackAction = parentCallback || screenAction;
|
|
76
|
+
|
|
71
77
|
const ScreenPlugin =
|
|
72
78
|
findPluginByType(screenType, plugins, { skipWarning: true }) ||
|
|
73
79
|
findPluginByIdentifier(screenType, plugins) ||
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReplaySubject } from "rxjs";
|
|
2
|
+
import { pairwise, filter, first } from "rxjs/operators";
|
|
3
|
+
|
|
4
|
+
// we are interested in last 2 events, because we wait transition from <false> to <true>
|
|
5
|
+
const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
|
|
6
|
+
|
|
7
|
+
export const emitScreenRevealManagerIsReadyToShow = () => {
|
|
8
|
+
screenRevealManagerSubject$.next(true);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const emitScreenRevealManagerIsNotReadyToShow = () => {
|
|
12
|
+
screenRevealManagerSubject$.next(false);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const waitUntilScreenRevealManagerIsReady = () => {
|
|
16
|
+
return screenRevealManagerSubject$.pipe(
|
|
17
|
+
pairwise(), // emit consecutive pairs: [prev, curr]
|
|
18
|
+
filter(
|
|
19
|
+
([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady
|
|
20
|
+
), // detect transition from not_ready to ready
|
|
21
|
+
first()
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -5,6 +5,10 @@ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils"
|
|
|
5
5
|
import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
|
|
6
6
|
|
|
7
7
|
import { ScreenRevealManager } from "./ScreenRevealManager";
|
|
8
|
+
import {
|
|
9
|
+
emitScreenRevealManagerIsReadyToShow,
|
|
10
|
+
emitScreenRevealManagerIsNotReadyToShow,
|
|
11
|
+
} from "./utils";
|
|
8
12
|
|
|
9
13
|
const flex = platformSelect({
|
|
10
14
|
tvos: 1,
|
|
@@ -43,6 +47,14 @@ export const withScreenRevealManager = (Component) => {
|
|
|
43
47
|
() => new Animated.Value(HIDDEN)
|
|
44
48
|
);
|
|
45
49
|
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!isReadyToShow) {
|
|
52
|
+
emitScreenRevealManagerIsNotReadyToShow();
|
|
53
|
+
} else {
|
|
54
|
+
emitScreenRevealManagerIsReadyToShow();
|
|
55
|
+
}
|
|
56
|
+
}, [isReadyToShow]);
|
|
57
|
+
|
|
46
58
|
React.useEffect(() => {
|
|
47
59
|
if (isReadyToShow) {
|
|
48
60
|
Animated.timing(opacityRef.current, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
4
3
|
|
|
5
4
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
6
5
|
import CloseButton from "./Buttons/CloseButton";
|
|
@@ -45,15 +44,14 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
|
-
<
|
|
49
|
-
edges={["top", "left", "right"]}
|
|
47
|
+
<View
|
|
50
48
|
style={[style.view, isRTL ? style.rtlStyle : {}]}
|
|
51
|
-
testID="BarView-
|
|
49
|
+
testID="BarView-Container"
|
|
52
50
|
>
|
|
53
51
|
{backButton}
|
|
54
52
|
<BarTitle title={barState.title} screenStyles={screenStyles} />
|
|
55
53
|
{closeButton}
|
|
56
|
-
</
|
|
54
|
+
</View>
|
|
57
55
|
);
|
|
58
56
|
};
|
|
59
57
|
|
|
@@ -46,7 +46,7 @@ describe("BarView", () => {
|
|
|
46
46
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
expect(getByTestId("BarView-
|
|
49
|
+
expect(getByTestId("BarView-Container").props.style).toContainEqual({
|
|
50
50
|
transform: [{ scaleX: -1 }],
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ describe("BarView", () => {
|
|
|
58
58
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
expect(getByTestId("BarView-
|
|
61
|
+
expect(getByTestId("BarView-Container").props.style).not.toContainEqual({
|
|
62
62
|
transform: [{ scaleX: -1 }],
|
|
63
63
|
});
|
|
64
64
|
});
|
|
@@ -24,16 +24,12 @@ export const getDatasourceUrl: (
|
|
|
24
24
|
) => {
|
|
25
25
|
const { source, mapping } = R.propOr({}, ["data"], component);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
27
|
+
const contexts = {
|
|
28
|
+
entry: entryContext,
|
|
29
|
+
screen: screenContext || screenData,
|
|
30
|
+
search: getSearchContext(searchContext, mapping),
|
|
31
|
+
};
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return source;
|
|
33
|
+
return getInflatedDataSourceUrl({ source, mapping, contexts });
|
|
38
34
|
}
|
|
39
35
|
);
|
package/events/index.ts
CHANGED
|
@@ -5,6 +5,4 @@ export enum QBUIComponentEvents {
|
|
|
5
5
|
scrollVerticallyToInitialOffset = "scrollVerticallyToInitialOffset",
|
|
6
6
|
focusOnSelectedTab = "focusOnSelectedTab",
|
|
7
7
|
focusOnSelectedTopMenuItem = "focusOnSelectedTopMenuItem",
|
|
8
|
-
focusOnHomeTopMenuItem = "focusOnHomeTopMenuItem",
|
|
9
|
-
topMenuBarTV_onLayout = "topMenuBarTV_onLayout",
|
|
10
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.2882475305",
|
|
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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.2882475305",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.2882475305",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.2882475305",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.2882475305",
|
|
35
35
|
"promise": "^8.3.0",
|
|
36
36
|
"url": "^0.11.0",
|
|
37
37
|
"uuid": "^3.3.2"
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { FocusableGroup } from "@applicaster/zapp-react-native-ui-components/Components/FocusableGroup";
|
|
5
|
-
import { riverFocusManager } from "@applicaster/zapp-react-native-utils/appUtils/RiverFocusManager";
|
|
6
|
-
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
7
|
-
|
|
8
|
-
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
9
|
-
import { QBUIComponentEvents } from "@applicaster/zapp-react-native-ui-components/events";
|
|
10
|
-
|
|
11
|
-
import { QUICK_BRICK_TOP_CONTAINER } from "@applicaster/quick-brick-core/const";
|
|
12
|
-
|
|
13
|
-
const useTopMenuLayout = () => {
|
|
14
|
-
const [layout, setLayout] = React.useState(undefined);
|
|
15
|
-
|
|
16
|
-
const handleLayout = React.useCallback((layout) => {
|
|
17
|
-
setLayout(layout);
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
useSubscriberFor(QBUIComponentEvents.topMenuBarTV_onLayout, handleLayout);
|
|
21
|
-
|
|
22
|
-
return layout;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const withFocusableGroupForContent = (Component) => {
|
|
26
|
-
return function (props) {
|
|
27
|
-
const { screenId, isInsideContainer } = props;
|
|
28
|
-
|
|
29
|
-
const topMenuLayout = useTopMenuLayout();
|
|
30
|
-
|
|
31
|
-
const focusableId = React.useMemo(
|
|
32
|
-
() =>
|
|
33
|
-
riverFocusManager.screenFocusableGroupId({
|
|
34
|
-
screenId,
|
|
35
|
-
isInsideContainer,
|
|
36
|
-
}),
|
|
37
|
-
[screenId, isInsideContainer]
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (isInsideContainer) {
|
|
41
|
-
return <Component {...props} />;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const topMenuHeight = toNumberWithDefaultZero(topMenuLayout?.height);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<FocusableGroup
|
|
48
|
-
key={focusableId}
|
|
49
|
-
id={focusableId}
|
|
50
|
-
// workaround to avoid intersection between FocusableGroup for content and FocusableGroup for top-menu
|
|
51
|
-
style={{ flex: 1, marginTop: topMenuHeight }}
|
|
52
|
-
groupId={QUICK_BRICK_TOP_CONTAINER}
|
|
53
|
-
>
|
|
54
|
-
<View style={{ flex: 1, marginTop: -1 * topMenuHeight }}>
|
|
55
|
-
<Component {...props} groupId={focusableId} />
|
|
56
|
-
</View>
|
|
57
|
-
</FocusableGroup>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
};
|