@applicaster/zapp-react-native-ui-components 12.0.0-alpha.7754333813 → 12.0.0-alpha.7843515010
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 -9
- package/Components/Cell/CellWithFocusable.tsx +23 -9
- package/Components/Cell/TvOSCellComponent.tsx +3 -7
- package/Components/Focusable/Focusable.tsx +6 -1
- package/Components/FocusableGroup/index.tsx +11 -2
- package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
- package/Components/Layout/TV/ScreenContainer.tsx +79 -5
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
- 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 +14 -67
- package/Components/Layout/TV/index.web.tsx +33 -0
- package/Components/Layout/index.tsx +15 -11
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +86 -116
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/index.ts +57 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +20 -0
- package/Components/MasterCell/DefaultComponents/index.ts +2 -0
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +10 -2
- package/Components/MasterCell/dataAdapter.ts +21 -7
- package/Components/MasterCell/index.tsx +5 -3
- package/Components/MasterCell/utils/__tests__/insertBetween.test.js +9 -0
- package/Components/MasterCell/utils/index.ts +17 -30
- package/Components/Navigator/StackNavigator.tsx +57 -0
- package/Components/Navigator/index.ts +1 -0
- package/Components/PlayerContainer/PlayerContainer.tsx +5 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -0
- package/Components/River/RefreshControl.tsx +2 -2
- package/Components/River/TV/River.tsx +0 -24
- 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 +165 -0
- 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 +9 -12
- 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 +62 -44
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +47 -33
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +104 -86
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -4
- package/Components/VideoModal/ModalAnimation/utils.ts +7 -4
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- package/Components/VideoModal/PlayerWrapper.tsx +69 -62
- package/Components/VideoModal/VideoModal.tsx +4 -4
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +7 -0
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +80 -14
- 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/ScreenDataContext/index.tsx +20 -0
- package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
- 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
|
@@ -42,9 +42,14 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
42
42
|
}
|
|
43
43
|
animationType="moveUpComponent"
|
|
44
44
|
style={
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
Array [
|
|
46
|
+
Object {
|
|
47
|
+
"flexDirection": "column",
|
|
48
|
+
},
|
|
49
|
+
Object {
|
|
50
|
+
"flex": 1,
|
|
51
|
+
},
|
|
52
|
+
]
|
|
48
53
|
}
|
|
49
54
|
>
|
|
50
55
|
<View
|
|
@@ -67,12 +72,34 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
67
72
|
testID="test-player-container"
|
|
68
73
|
/>
|
|
69
74
|
<View
|
|
75
|
+
animationType="componentFade"
|
|
70
76
|
style={
|
|
71
77
|
Object {
|
|
72
78
|
"flex": 1,
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
|
-
|
|
81
|
+
>
|
|
82
|
+
<View
|
|
83
|
+
configuration={
|
|
84
|
+
Object {
|
|
85
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
86
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
entry={
|
|
90
|
+
Object {
|
|
91
|
+
"id": "test",
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
isTabletLandscape={false}
|
|
95
|
+
style={
|
|
96
|
+
Object {
|
|
97
|
+
"flex": 1,
|
|
98
|
+
"paddingTop": 20,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
</View>
|
|
76
103
|
</View>
|
|
77
104
|
</RNCSafeAreaView>
|
|
78
105
|
</RNCSafeAreaProvider>
|
|
@@ -120,9 +147,14 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
120
147
|
}
|
|
121
148
|
animationType="moveUpComponent"
|
|
122
149
|
style={
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
150
|
+
Array [
|
|
151
|
+
Object {
|
|
152
|
+
"flexDirection": "column",
|
|
153
|
+
},
|
|
154
|
+
Object {
|
|
155
|
+
"flex": 1,
|
|
156
|
+
},
|
|
157
|
+
]
|
|
126
158
|
}
|
|
127
159
|
>
|
|
128
160
|
<View
|
|
@@ -148,6 +180,7 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
148
180
|
style={
|
|
149
181
|
Object {
|
|
150
182
|
"flex": 1,
|
|
183
|
+
"paddingTop": 20,
|
|
151
184
|
}
|
|
152
185
|
}
|
|
153
186
|
/>
|
|
@@ -198,9 +231,14 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
|
198
231
|
}
|
|
199
232
|
animationType="moveUpComponent"
|
|
200
233
|
style={
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
234
|
+
Array [
|
|
235
|
+
Object {
|
|
236
|
+
"flexDirection": "row",
|
|
237
|
+
},
|
|
238
|
+
Object {
|
|
239
|
+
"flex": 1,
|
|
240
|
+
},
|
|
241
|
+
]
|
|
204
242
|
}
|
|
205
243
|
>
|
|
206
244
|
<View
|
|
@@ -239,12 +277,34 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
|
239
277
|
/>
|
|
240
278
|
</View>
|
|
241
279
|
<View
|
|
280
|
+
animationType="componentFade"
|
|
242
281
|
style={
|
|
243
282
|
Object {
|
|
244
283
|
"flex": 1,
|
|
245
284
|
}
|
|
246
285
|
}
|
|
247
|
-
|
|
286
|
+
>
|
|
287
|
+
<View
|
|
288
|
+
configuration={
|
|
289
|
+
Object {
|
|
290
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
291
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
entry={
|
|
295
|
+
Object {
|
|
296
|
+
"id": "test",
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
isTabletLandscape={true}
|
|
300
|
+
style={
|
|
301
|
+
Object {
|
|
302
|
+
"flex": 1,
|
|
303
|
+
"paddingTop": 20,
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/>
|
|
307
|
+
</View>
|
|
248
308
|
</View>
|
|
249
309
|
</RNCSafeAreaView>
|
|
250
310
|
</RNCSafeAreaProvider>
|
|
@@ -292,9 +352,14 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
292
352
|
}
|
|
293
353
|
animationType="moveUpComponent"
|
|
294
354
|
style={
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
355
|
+
Array [
|
|
356
|
+
Object {
|
|
357
|
+
"flexDirection": "column",
|
|
358
|
+
},
|
|
359
|
+
Object {
|
|
360
|
+
"flex": 1,
|
|
361
|
+
},
|
|
362
|
+
]
|
|
298
363
|
}
|
|
299
364
|
>
|
|
300
365
|
<View
|
|
@@ -320,6 +385,7 @@ exports[`PlayerWrapper renders properly 1`] = `
|
|
|
320
385
|
style={
|
|
321
386
|
Object {
|
|
322
387
|
"flex": 1,
|
|
388
|
+
"paddingTop": 20,
|
|
323
389
|
}
|
|
324
390
|
}
|
|
325
391
|
/>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Dimensions } from "react-native";
|
|
3
2
|
import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
|
|
4
3
|
import {
|
|
5
4
|
addOrientationChangeListener,
|
|
@@ -9,11 +8,10 @@ import {
|
|
|
9
8
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
10
9
|
|
|
11
10
|
import { getXray } from "@applicaster/zapp-react-native-utils/logger";
|
|
11
|
+
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
12
12
|
|
|
13
13
|
const { Logger } = getXray();
|
|
14
14
|
|
|
15
|
-
const { width: WIDTH, height: HEIGHT } = Dimensions.get("window");
|
|
16
|
-
|
|
17
15
|
const logger = new Logger(
|
|
18
16
|
"hooks",
|
|
19
17
|
"zapp-react-native-ui-components/Components/VideoModal"
|
|
@@ -24,20 +22,18 @@ type Size = {
|
|
|
24
22
|
height: number | string;
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
const MODAL_SIZE_FOR_PORTRAIT: Size = {
|
|
28
|
-
width: WIDTH,
|
|
29
|
-
height: HEIGHT,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
25
|
const MODAL_SIZE_FOR_LANDSCAPE: Size = {
|
|
33
26
|
width: "100%",
|
|
34
27
|
height: "100%",
|
|
35
28
|
};
|
|
36
29
|
|
|
37
30
|
export const useModalSize = (): Size => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
const frame = useSafeAreaFrame();
|
|
32
|
+
|
|
33
|
+
const [modalSize, setModalSize] = React.useState<Size>({
|
|
34
|
+
width: frame.width,
|
|
35
|
+
height: frame.height,
|
|
36
|
+
});
|
|
41
37
|
|
|
42
38
|
const setNewModalSize = React.useCallback((newSize, log) => {
|
|
43
39
|
setModalSize((oldSize) => {
|
|
@@ -90,7 +86,9 @@ export const useModalSize = (): Size => {
|
|
|
90
86
|
toOrientation === ORIENTATIONS.landscapeSensor;
|
|
91
87
|
|
|
92
88
|
setNewModalSize(
|
|
93
|
-
isLandscape
|
|
89
|
+
isLandscape
|
|
90
|
+
? MODAL_SIZE_FOR_LANDSCAPE
|
|
91
|
+
: { width: frame.width, height: frame.height },
|
|
94
92
|
`useModalSize: set modal size ${
|
|
95
93
|
isLandscape ? "landscape" : "portrait"
|
|
96
94
|
} for orientation: ${to}`
|
|
@@ -33,8 +33,11 @@ export const useConfiguration = () => {
|
|
|
33
33
|
...pluginConfiguration,
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
const {
|
|
37
|
-
|
|
36
|
+
const {
|
|
37
|
+
minimised_height = 0,
|
|
38
|
+
minimised_height_tablet = 0,
|
|
39
|
+
modal_background_color,
|
|
40
|
+
} = config;
|
|
38
41
|
|
|
39
42
|
const minimisedHeight = useIsTablet()
|
|
40
43
|
? minimised_height_tablet
|
|
@@ -6,23 +6,23 @@ import { callOnChildren } from "../utils";
|
|
|
6
6
|
|
|
7
7
|
export function ViewportTracker(props) {
|
|
8
8
|
const viewportEvents = useViewportEventsContext();
|
|
9
|
-
const { children } = props;
|
|
10
|
-
const [width, setWidth] = React.useState(0);
|
|
11
|
-
const [height, setHeight] = React.useState(0);
|
|
12
|
-
const [offsetX, setOffsetX] = React.useState(0);
|
|
13
|
-
const [offsetY, setOffsetY] = React.useState(0);
|
|
14
9
|
const [nodeHandle, setNodeHandle] = React.useState(null);
|
|
15
10
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const childrenRef = React.useRef(props.children);
|
|
12
|
+
|
|
13
|
+
const dimensionsRef = React.useRef({ width: 0, height: 0 });
|
|
14
|
+
const offsetRef = React.useRef({ offsetX: 0, offsetY: 0 });
|
|
15
|
+
|
|
16
|
+
const assignRef = React.useCallback((ref) => {
|
|
17
|
+
childrenRef.current?.ref?.(ref);
|
|
18
|
+
setNodeHandle(findNodeHandle(ref));
|
|
19
|
+
}, []);
|
|
23
20
|
|
|
24
21
|
const onViewportChange = React.useCallback(
|
|
25
|
-
(
|
|
22
|
+
({
|
|
23
|
+
event = { ...dimensionsRef.current, ...offsetRef.current },
|
|
24
|
+
shouldMeasureLayout = true,
|
|
25
|
+
} = {}) => {
|
|
26
26
|
if (nodeHandle && event?.width > 0 && event?.height > 0) {
|
|
27
27
|
viewportEvents?.notify?.({
|
|
28
28
|
parentHandle: nodeHandle,
|
|
@@ -36,54 +36,45 @@ export function ViewportTracker(props) {
|
|
|
36
36
|
|
|
37
37
|
const onLayout = React.useCallback(
|
|
38
38
|
(event) => {
|
|
39
|
-
callOnChildren(
|
|
40
|
-
|
|
41
|
-
setHeight(event?.nativeEvent?.layout?.height);
|
|
39
|
+
callOnChildren(childrenRef.current, "onLayout", event);
|
|
40
|
+
dimensionsRef.current = event?.nativeEvent?.layout;
|
|
42
41
|
|
|
43
|
-
onViewportChange(
|
|
44
|
-
width: event?.nativeEvent?.layout?.width,
|
|
45
|
-
height: event?.nativeEvent?.layout?.height,
|
|
46
|
-
offsetX,
|
|
47
|
-
offsetY,
|
|
48
|
-
});
|
|
42
|
+
onViewportChange();
|
|
49
43
|
},
|
|
50
|
-
[
|
|
44
|
+
[onViewportChange]
|
|
51
45
|
);
|
|
52
46
|
|
|
53
47
|
const onContentSizeChange = React.useCallback(
|
|
54
48
|
(contentWidth, contentHeight) => {
|
|
55
49
|
callOnChildren(
|
|
56
|
-
|
|
50
|
+
childrenRef.current,
|
|
57
51
|
"onContentSizeChange",
|
|
58
52
|
contentWidth,
|
|
59
53
|
contentHeight
|
|
60
54
|
);
|
|
61
55
|
|
|
62
|
-
onViewportChange(
|
|
56
|
+
onViewportChange();
|
|
63
57
|
},
|
|
64
|
-
[onViewportChange
|
|
58
|
+
[onViewportChange]
|
|
65
59
|
);
|
|
66
60
|
|
|
67
61
|
const onScroll = React.useCallback(
|
|
68
62
|
(event) => {
|
|
69
|
-
callOnChildren(
|
|
70
|
-
|
|
71
|
-
setOffsetY(event?.nativeEvent?.contentOffset?.y);
|
|
63
|
+
callOnChildren(childrenRef.current, "onScroll", event);
|
|
64
|
+
offsetRef.current = event?.nativeEvent?.contentOffset;
|
|
72
65
|
|
|
73
|
-
onViewportChange(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
height,
|
|
77
|
-
offsetX: event?.nativeEvent?.contentOffset?.x,
|
|
78
|
-
offsetY: event?.nativeEvent?.contentOffset?.y,
|
|
79
|
-
},
|
|
80
|
-
false
|
|
81
|
-
);
|
|
66
|
+
onViewportChange({
|
|
67
|
+
shouldMeasureLayout: false,
|
|
68
|
+
});
|
|
82
69
|
},
|
|
83
|
-
[onViewportChange
|
|
70
|
+
[onViewportChange]
|
|
84
71
|
);
|
|
85
72
|
|
|
86
|
-
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
childrenRef.current = props.children;
|
|
75
|
+
}, [props.children]);
|
|
76
|
+
|
|
77
|
+
return React.cloneElement(React.Children.only(props.children), {
|
|
87
78
|
ref: assignRef,
|
|
88
79
|
onLayout,
|
|
89
80
|
onContentSizeChange,
|
package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap
CHANGED
|
@@ -16,9 +16,9 @@ exports[`DefaultCellRenderer returns a react component and it renders correctly
|
|
|
16
16
|
store={null}
|
|
17
17
|
style={
|
|
18
18
|
Object {
|
|
19
|
-
"backgroundColor": "
|
|
19
|
+
"backgroundColor": "transparent",
|
|
20
20
|
"margin": 12,
|
|
21
|
-
"opacity":
|
|
21
|
+
"opacity": 1,
|
|
22
22
|
"width": 169,
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -105,7 +105,7 @@ exports[`DefaultCellRenderer returns a react component for LG TVs 1`] = `
|
|
|
105
105
|
store={null}
|
|
106
106
|
style={
|
|
107
107
|
Object {
|
|
108
|
-
"backgroundColor": "rgba(
|
|
108
|
+
"backgroundColor": "rgba(47,47,47,1.0)",
|
|
109
109
|
"borderRadius": 4,
|
|
110
110
|
"flex": 1,
|
|
111
111
|
"overflow": "hidden",
|
|
@@ -238,7 +238,7 @@ exports[`DefaultCellRenderer returns a react component for Samsung TVs 1`] = `
|
|
|
238
238
|
store={null}
|
|
239
239
|
style={
|
|
240
240
|
Object {
|
|
241
|
-
"backgroundColor": "rgba(
|
|
241
|
+
"backgroundColor": "rgba(47,47,47,1.0)",
|
|
242
242
|
"borderRadius": 4,
|
|
243
243
|
"flex": 1,
|
|
244
244
|
"overflow": "hidden",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { FocusableGroupContext } from "./FocusableGroupContext";
|
|
3
|
+
|
|
4
|
+
type ProviderArgs = {
|
|
5
|
+
id: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const FocusableGroupContextProvider = ({
|
|
10
|
+
id,
|
|
11
|
+
children,
|
|
12
|
+
}: ProviderArgs) => (
|
|
13
|
+
<FocusableGroupContext.Provider value={id}>
|
|
14
|
+
{children}
|
|
15
|
+
</FocusableGroupContext.Provider>
|
|
16
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
import { FocusableGroupContextProvider, FocusableGroupContext } from "../";
|
|
5
|
+
|
|
6
|
+
const MockComponent = () => {
|
|
7
|
+
const focusableContext = useContext(FocusableGroupContext) || "default";
|
|
8
|
+
|
|
9
|
+
return <Text testID={focusableContext} />;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe("FocusableGroupContextProvider", () => {
|
|
13
|
+
it("should provide focusable context to the wrapped component", () => {
|
|
14
|
+
const { getByTestId } = render(
|
|
15
|
+
<FocusableGroupContextProvider id="testId">
|
|
16
|
+
<MockComponent />
|
|
17
|
+
</FocusableGroupContextProvider>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect(getByTestId("testId")).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
import { withFocusableContext } from "../withFocusableContext";
|
|
5
|
+
import { FocusableGroupContext } from "../FocusableGroupContext";
|
|
6
|
+
|
|
7
|
+
const MockComponent = ({ groupId }: { groupId: string }) => (
|
|
8
|
+
<Text testID={groupId} />
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const WrappedComponent = withFocusableContext(MockComponent);
|
|
12
|
+
|
|
13
|
+
describe("withFocusableContext HOC", () => {
|
|
14
|
+
it("should provide focusable context to the wrapped component", () => {
|
|
15
|
+
const { getByTestId } = render(<WrappedComponent />, {
|
|
16
|
+
// eslint-disable-next-line react/display-name
|
|
17
|
+
wrapper: ({ children }: { children: React.ReactElement }) => (
|
|
18
|
+
<FocusableGroupContext.Provider value="test">
|
|
19
|
+
{children}
|
|
20
|
+
</FocusableGroupContext.Provider>
|
|
21
|
+
),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(getByTestId("test")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FocusableGroupContext } from "./FocusableGroupContext";
|
|
3
|
+
import { FocusableGroupContextProvider } from "./FocusableGroupContextProvider";
|
|
4
|
+
|
|
5
|
+
export { FocusableGroupContext, FocusableGroupContextProvider };
|
|
6
|
+
|
|
7
|
+
export const useGroupId = () => React.useContext(FocusableGroupContext);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FocusableGroupContext } from "./FocusableGroupContext";
|
|
3
|
+
|
|
4
|
+
export const withFocusableContext = (Component) => {
|
|
5
|
+
// eslint-disable-next-line react/display-name
|
|
6
|
+
return ({ groupId, ...props }: Record<string, any>) => (
|
|
7
|
+
<FocusableGroupContext.Consumer>
|
|
8
|
+
{(groupIdContext: string) => {
|
|
9
|
+
// eslint-disable-next-line react/display-name
|
|
10
|
+
const propsGroupId = groupId || null;
|
|
11
|
+
const providedGroupId = propsGroupId || groupIdContext;
|
|
12
|
+
|
|
13
|
+
return <Component {...props} groupId={providedGroupId} />;
|
|
14
|
+
}}
|
|
15
|
+
</FocusableGroupContext.Consumer>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -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-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.7843515010",
|
|
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-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.0-alpha.7843515010",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.7843515010",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.7843515010",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.7843515010",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet } from "react-native";
|
|
3
|
-
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
4
|
-
import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
5
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
6
|
-
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
|
-
import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
|
|
8
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
9
|
-
|
|
10
|
-
import { useScreenConfiguration } from "../../River/useScreenConfiguration";
|
|
11
|
-
|
|
12
|
-
const styles = StyleSheet.create({
|
|
13
|
-
container: {
|
|
14
|
-
position: "absolute",
|
|
15
|
-
top: 0,
|
|
16
|
-
left: 0,
|
|
17
|
-
right: 0,
|
|
18
|
-
bottom: 0,
|
|
19
|
-
|
|
20
|
-
alignItems: "center",
|
|
21
|
-
justifyContent: "center",
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const TransitionOverlay = () => {
|
|
26
|
-
const screen = useCurrentScreenData();
|
|
27
|
-
|
|
28
|
-
const { backgroundColor: screenBackgroundColor } = useScreenConfiguration(
|
|
29
|
-
screen?.id
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const theme = useTheme();
|
|
33
|
-
|
|
34
|
-
const themeBackgroundColor = React.useMemo(
|
|
35
|
-
() => theme.app_background_color,
|
|
36
|
-
[theme.app_background_color]
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const backgroundColor = ifEmptyUseFallback(
|
|
40
|
-
screenBackgroundColor,
|
|
41
|
-
themeBackgroundColor
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
appState: { isTransitioning },
|
|
46
|
-
} = usePickFromState(["appState"]);
|
|
47
|
-
|
|
48
|
-
if (!isWeb() || !isTransitioning) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<View
|
|
54
|
-
style={[
|
|
55
|
-
styles.container,
|
|
56
|
-
{
|
|
57
|
-
backgroundColor,
|
|
58
|
-
},
|
|
59
|
-
]}
|
|
60
|
-
>
|
|
61
|
-
<Spinner size={"large"} />
|
|
62
|
-
</View>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
File without changes
|
|
File without changes
|