@applicaster/zapp-react-native-ui-components 12.0.0-alpha.3788876021 → 12.0.0-alpha.3849101242
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/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
- package/Components/Layout/TV/index.tsx +12 -9
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -109
- package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- 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 +9 -5
- package/Components/River/ComponentsMap/ComponentsMap.tsx +92 -22
- package/Components/River/RefreshControl.tsx +55 -1
- package/Components/RouteManager/index.tsx +2 -2
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
- package/Components/Screen/index.tsx +35 -24
- 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/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +11 -4
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +9 -2
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -2
- package/Components/VideoModal/PlayerDetails.tsx +3 -3
- 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/Components/Viewport/ViewportTracker/index.tsx +1 -0
- package/Components/Viewport/utils.js +1 -1
- package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
- package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
- package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
- package/Contexts/ScreenContext/index.tsx +94 -25
- package/Contexts/ScreenDataContext/index.ts +3 -0
- package/events/index.ts +1 -0
- package/package.json +5 -5
- /package/Contexts/{index.js → index.ts} +0 -0
|
@@ -54,7 +54,10 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
|
54
54
|
import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
|
|
55
55
|
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
56
56
|
|
|
57
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
useModalAnimationContext,
|
|
59
|
+
PlayerAnimationStateEnum,
|
|
60
|
+
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
58
61
|
|
|
59
62
|
type Props = {
|
|
60
63
|
Player: React.ComponentType<any>;
|
|
@@ -231,6 +234,9 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
231
234
|
const screenData = useTargetScreenData(item);
|
|
232
235
|
const { setVisible: showNavBar } = useSetNavbarState();
|
|
233
236
|
|
|
237
|
+
const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
|
|
238
|
+
useModalAnimationContext();
|
|
239
|
+
|
|
234
240
|
const playerEvent = (event, ...args) => {
|
|
235
241
|
playerManager.invokeHandler(event, ...args);
|
|
236
242
|
};
|
|
@@ -448,7 +454,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
448
454
|
if (disableMiniPlayer) {
|
|
449
455
|
navigator.closeVideoModal();
|
|
450
456
|
} else {
|
|
451
|
-
|
|
457
|
+
setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
|
|
452
458
|
}
|
|
453
459
|
}
|
|
454
460
|
|
|
@@ -600,9 +606,6 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
600
606
|
pluginConfiguration,
|
|
601
607
|
};
|
|
602
608
|
|
|
603
|
-
const { isActiveGesture, startComponentsAnimation } =
|
|
604
|
-
useModalAnimationContext();
|
|
605
|
-
|
|
606
609
|
return (
|
|
607
610
|
<PlayerStateContext.Provider value={value}>
|
|
608
611
|
<PlayerContainerContextProvider
|
|
@@ -668,6 +671,7 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
668
671
|
setNextVideoPreloadThresholdPercentage={
|
|
669
672
|
setNextVideoPreloadThresholdPercentage
|
|
670
673
|
}
|
|
674
|
+
startComponentsAnimation={startComponentsAnimation}
|
|
671
675
|
>
|
|
672
676
|
{renderApplePlayer(applePlayerProps)}
|
|
673
677
|
</Player>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
-
import { View,
|
|
3
|
+
import { View, StyleSheet, Platform, FlatList } from "react-native";
|
|
4
4
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
5
|
import { RiverItem } from "../RiverItem";
|
|
6
6
|
import { RiverFooter } from "../RiverFooter";
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
import { useScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData";
|
|
22
22
|
import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
23
23
|
import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
|
|
24
|
-
import {
|
|
24
|
+
import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
25
|
+
import { useShallow } from "zustand/react/shallow";
|
|
25
26
|
|
|
26
27
|
type Props = {
|
|
27
28
|
feed: ZappFeed;
|
|
@@ -41,8 +42,10 @@ const styles = StyleSheet.create({
|
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const getNearestValue = (value, optionA, optionB) =>
|
|
46
|
+
Math.abs(value - optionA) < Math.abs(value - optionB) ? optionA : optionB;
|
|
45
47
|
|
|
48
|
+
const scrollIndicatorInsets = { right: 1 };
|
|
46
49
|
const keyExtractor = R.compose(String, R.prop("id"));
|
|
47
50
|
|
|
48
51
|
function ComponentsMapComponent(props: Props) {
|
|
@@ -60,6 +63,7 @@ function ComponentsMapComponent(props: Props) {
|
|
|
60
63
|
refreshingPipesV1,
|
|
61
64
|
} = props;
|
|
62
65
|
|
|
66
|
+
const flatListRef = React.useRef<FlatList | null>(null);
|
|
63
67
|
const screenConfig = useScreenConfiguration(riverId);
|
|
64
68
|
const screenData = useScreenData(riverId);
|
|
65
69
|
const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
|
|
@@ -194,26 +198,87 @@ function ComponentsMapComponent(props: Props) {
|
|
|
194
198
|
[]
|
|
195
199
|
);
|
|
196
200
|
|
|
197
|
-
const
|
|
198
|
-
({ nativeEvent }, isScrollingDone = false) => {
|
|
199
|
-
const {
|
|
200
|
-
contentOffset: { y },
|
|
201
|
-
} = nativeEvent;
|
|
201
|
+
const navBarStore = useScreenContextV2()._navBarStore;
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
scrollPosition: y,
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
[]
|
|
203
|
+
const scrollY = navBarStore(
|
|
204
|
+
useShallow(({ scrollYAnimated }) => scrollYAnimated)
|
|
209
205
|
);
|
|
210
206
|
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
const canMomentum = React.useRef(false);
|
|
208
|
+
|
|
209
|
+
const onScrollBeginDrag = React.useCallback(() => {
|
|
210
|
+
canMomentum.current = true;
|
|
211
|
+
}, []);
|
|
212
|
+
|
|
213
|
+
/* onMomentumScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
214
|
+
const _onMomentumScrollEnd = React.useCallback(({ nativeEvent }) => {
|
|
215
|
+
if (!canMomentum.current) return;
|
|
216
|
+
canMomentum.current = false;
|
|
217
|
+
|
|
218
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
219
|
+
|
|
220
|
+
const offsetY = Math.max(0, nativeEvent.contentOffset.y);
|
|
221
|
+
|
|
222
|
+
if (
|
|
223
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
224
|
+
flatListRef.current
|
|
225
|
+
) {
|
|
226
|
+
const offset =
|
|
227
|
+
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
228
|
+
-headerHeight
|
|
229
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
230
|
+
: Math.round(offsetY + scrollState);
|
|
231
|
+
|
|
232
|
+
flatListRef.current.scrollToOffset({
|
|
233
|
+
animated: true,
|
|
234
|
+
offset,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
/* onScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
|
|
240
|
+
const _onScrollEndDrag = React.useCallback(({ nativeEvent }) => {
|
|
241
|
+
const { height: headerHeight, scrollState } = navBarStore.getState();
|
|
242
|
+
|
|
243
|
+
const offsetY = Math.max(0, nativeEvent.contentOffset.y);
|
|
244
|
+
|
|
245
|
+
if (
|
|
246
|
+
!(scrollState === 0 || scrollState === -headerHeight) &&
|
|
247
|
+
flatListRef.current &&
|
|
248
|
+
nativeEvent.velocity.y === 0
|
|
249
|
+
) {
|
|
250
|
+
const offset =
|
|
251
|
+
getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
|
|
252
|
+
-headerHeight
|
|
253
|
+
? Math.round(offsetY + scrollState + headerHeight)
|
|
254
|
+
: Math.round(offsetY + scrollState);
|
|
255
|
+
|
|
256
|
+
flatListRef.current.scrollToOffset({
|
|
257
|
+
animated: true,
|
|
258
|
+
offset,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}, []);
|
|
262
|
+
|
|
263
|
+
const onScroll = React.useCallback((event) => {
|
|
264
|
+
const {
|
|
265
|
+
nativeEvent: {
|
|
266
|
+
contentOffset: { y },
|
|
267
|
+
layoutMeasurement: { height },
|
|
268
|
+
contentSize: { height: contentHeight },
|
|
269
|
+
},
|
|
270
|
+
} = event;
|
|
271
|
+
|
|
272
|
+
if (y >= 0 && y + height <= contentHeight) {
|
|
273
|
+
scrollY.setValue(y);
|
|
274
|
+
} else {
|
|
275
|
+
if (y <= 0) {
|
|
276
|
+
scrollY.setValue(0);
|
|
277
|
+
} else if (y + height > contentHeight) {
|
|
278
|
+
scrollY.setValue(contentHeight - height);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}, []);
|
|
217
282
|
|
|
218
283
|
if (shouldShowLoadingError) {
|
|
219
284
|
return <RiverError />;
|
|
@@ -230,6 +295,9 @@ function ComponentsMapComponent(props: Props) {
|
|
|
230
295
|
>
|
|
231
296
|
<ViewportTracker>
|
|
232
297
|
<FlatList
|
|
298
|
+
ref={(ref) => {
|
|
299
|
+
flatListRef.current = ref;
|
|
300
|
+
}}
|
|
233
301
|
// Fix for WebView rerender crashes on Android API 28+
|
|
234
302
|
// https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
|
|
235
303
|
overScrollMode={Platform.OS === "android" ? "never" : "auto"}
|
|
@@ -249,8 +317,10 @@ function ComponentsMapComponent(props: Props) {
|
|
|
249
317
|
}
|
|
250
318
|
ListFooterComponent={renderFooter}
|
|
251
319
|
refreshControl={refreshControl}
|
|
252
|
-
|
|
253
|
-
|
|
320
|
+
onScrollBeginDrag={onScrollBeginDrag}
|
|
321
|
+
onScroll={onScroll}
|
|
322
|
+
onMomentumScrollEnd={_onMomentumScrollEnd}
|
|
323
|
+
onScrollEndDrag={_onScrollEndDrag}
|
|
254
324
|
scrollEventThrottle={16}
|
|
255
325
|
{...scrollViewExtraProps}
|
|
256
326
|
/>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Platform,
|
|
4
|
+
RefreshControl as RNRefreshControl,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
} from "react-native";
|
|
3
7
|
import * as R from "ramda";
|
|
4
8
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
9
|
import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
@@ -8,10 +12,30 @@ import { useSendAnalyticsEventWithFunction } from "@applicaster/zapp-react-nativ
|
|
|
8
12
|
import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
9
13
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
10
14
|
import { useDispatch } from "react-redux";
|
|
15
|
+
import { useShallow } from "zustand/react/shallow";
|
|
16
|
+
import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
17
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
11
18
|
|
|
12
19
|
const BRIGHTNESS_THRESHOLD = 160;
|
|
13
20
|
const ABOVE_DEFAULT_COLOR = "gray";
|
|
14
21
|
const BELOW_DEFAULT_COLOR = "white";
|
|
22
|
+
const BASE_INDICATOR_HEIGHT = 40;
|
|
23
|
+
const BASE_INDICATOR_OFFSET = 16;
|
|
24
|
+
|
|
25
|
+
/** Return spacing required to position indicator below the navbar bottom line (Android only) */
|
|
26
|
+
const getRefreshControlOffset = () => {
|
|
27
|
+
return Platform.OS === "ios"
|
|
28
|
+
? 0
|
|
29
|
+
: BASE_INDICATOR_HEIGHT + BASE_INDICATOR_OFFSET;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const styles = StyleSheet.create({
|
|
33
|
+
// eslint-disable-next-line react-native/no-color-literals
|
|
34
|
+
control: {
|
|
35
|
+
zIndex: 1,
|
|
36
|
+
backgroundColor: "transparent",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
15
39
|
|
|
16
40
|
const getBrightness = (RGBcolor) => {
|
|
17
41
|
const RGBvalues = RGBcolor.substring(
|
|
@@ -91,6 +115,34 @@ export const usePullToRefresh = (
|
|
|
91
115
|
};
|
|
92
116
|
};
|
|
93
117
|
|
|
118
|
+
/** Returns the offset for the progress view of the RefreshControl component
|
|
119
|
+
* based on navbar content position */
|
|
120
|
+
export const useGetProgressViewOffset = () => {
|
|
121
|
+
const { _navBarStore } = useScreenContextV2();
|
|
122
|
+
const { top } = useSafeAreaInsets();
|
|
123
|
+
|
|
124
|
+
const offset = getRefreshControlOffset();
|
|
125
|
+
|
|
126
|
+
const { height, contentPosition } = _navBarStore(
|
|
127
|
+
useShallow(({ contentPosition, height }) => ({ contentPosition, height }))
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
if (height === 0) {
|
|
131
|
+
return offset;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
switch (contentPosition) {
|
|
135
|
+
case "on_bottom_status_bar":
|
|
136
|
+
// navbar height
|
|
137
|
+
return offset + height;
|
|
138
|
+
case "on_top_screen":
|
|
139
|
+
// navbar height + status bar height
|
|
140
|
+
return offset + height + top;
|
|
141
|
+
default:
|
|
142
|
+
return offset;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
94
146
|
export function RefreshControl(props: {
|
|
95
147
|
pullToRefreshPipesV1RefreshingStateUpdater?: (refreshing: boolean) => void;
|
|
96
148
|
refreshingPipesV1?: boolean;
|
|
@@ -211,6 +263,7 @@ export function RefreshControl(props: {
|
|
|
211
263
|
refreshing={refreshing}
|
|
212
264
|
onRefresh={onRefreshHandler}
|
|
213
265
|
colors={[preparedIndicatorColor]}
|
|
266
|
+
progressViewOffset={useGetProgressViewOffset()}
|
|
214
267
|
progressBackgroundColor={preparedIndicatorBackgroundColor}
|
|
215
268
|
// @ts-ignore in RN68 this `size` became string
|
|
216
269
|
size={indicatorSize}
|
|
@@ -222,6 +275,7 @@ export function RefreshControl(props: {
|
|
|
222
275
|
: null
|
|
223
276
|
}
|
|
224
277
|
titleColor={preparedTitleUnderIndicatorColor}
|
|
278
|
+
style={styles.control}
|
|
225
279
|
/>
|
|
226
280
|
);
|
|
227
281
|
}
|
|
@@ -14,7 +14,7 @@ type Props = { pathname: string; screenData: Record<string, any> };
|
|
|
14
14
|
* @param {Props}: see props above
|
|
15
15
|
*/
|
|
16
16
|
export function RouteManager(props: Props) {
|
|
17
|
-
const { pathname, screenData
|
|
17
|
+
const { pathname, screenData } = useRoute();
|
|
18
18
|
const pathAttributes = getPathAttributes({ pathname });
|
|
19
19
|
|
|
20
20
|
const { screenType, screenId } = R.last(pathAttributes);
|
|
@@ -25,7 +25,7 @@ export function RouteManager(props: Props) {
|
|
|
25
25
|
screenType={screenType}
|
|
26
26
|
screenId={screenId}
|
|
27
27
|
{...props}
|
|
28
|
-
screenData={
|
|
28
|
+
screenData={screenData}
|
|
29
29
|
/>
|
|
30
30
|
</TestId>
|
|
31
31
|
);
|
|
@@ -11,7 +11,9 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
11
11
|
}
|
|
12
12
|
>
|
|
13
13
|
<View
|
|
14
|
+
hasMenu={false}
|
|
14
15
|
id="/river/testId"
|
|
16
|
+
pathname="/river/testId"
|
|
15
17
|
selected="testId"
|
|
16
18
|
testID="navBar"
|
|
17
19
|
title=""
|
|
@@ -41,7 +43,9 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
|
|
|
41
43
|
}
|
|
42
44
|
>
|
|
43
45
|
<View
|
|
46
|
+
hasMenu={false}
|
|
44
47
|
id="/river/testId"
|
|
48
|
+
pathname="/river/testId"
|
|
45
49
|
selected="testId"
|
|
46
50
|
testID="navBar"
|
|
47
51
|
title=""
|
|
@@ -6,7 +6,10 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
6
6
|
|
|
7
7
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
8
8
|
import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getNavigationPropsV2,
|
|
11
|
+
resolveNavigationPlugin,
|
|
12
|
+
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
10
13
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
11
14
|
import {
|
|
12
15
|
useDimensions,
|
|
@@ -52,11 +55,11 @@ function isValidColor(string) {
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
type Props = {
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
pathname: unknown;
|
|
59
|
+
screenData: unknown;
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
export function Screen(
|
|
62
|
+
export function Screen(_props: Props) {
|
|
60
63
|
const theme = useTheme<BaseThemePropertiesMobile>();
|
|
61
64
|
const navigation = useNavigation();
|
|
62
65
|
const { plugins } = usePickFromState(["plugins"]);
|
|
@@ -70,26 +73,38 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
70
73
|
fullDimensions: true,
|
|
71
74
|
});
|
|
72
75
|
|
|
73
|
-
const
|
|
76
|
+
const { screenData, pathname } = useRoute();
|
|
74
77
|
|
|
75
78
|
const currentRiver = useScreenData(
|
|
76
|
-
getScreenId(
|
|
79
|
+
getScreenId(screenData, navigation.activeRiver)
|
|
77
80
|
);
|
|
78
81
|
|
|
79
82
|
const { title } = useNavbarState();
|
|
80
83
|
|
|
81
|
-
const
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
const hasMenu =
|
|
85
|
+
resolveNavigationPlugin({
|
|
86
|
+
category: "menu",
|
|
87
|
+
navigations: currentRiver.navigations,
|
|
88
|
+
plugins,
|
|
89
|
+
})?.identifier === "quick_brick_side_menu";
|
|
90
|
+
|
|
91
|
+
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(() => {
|
|
92
|
+
const props = getNavigationPropsV2({
|
|
93
|
+
currentRiver,
|
|
94
|
+
title,
|
|
95
|
+
category: "nav_bar",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (props) {
|
|
99
|
+
return {
|
|
100
|
+
...props,
|
|
101
|
+
id: pathname,
|
|
102
|
+
pathname: pathname,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return null;
|
|
107
|
+
}, [currentRiver, pathname]);
|
|
93
108
|
|
|
94
109
|
const NavBar = React.useMemo(
|
|
95
110
|
() =>
|
|
@@ -97,12 +112,10 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
97
112
|
"nav_bar",
|
|
98
113
|
currentRiver,
|
|
99
114
|
plugins
|
|
100
|
-
) as React.ComponentType<MobileNavBarPluginProps>,
|
|
115
|
+
) as React.ComponentType<MobileNavBarPluginProps & { hasMenu: boolean }>,
|
|
101
116
|
[]
|
|
102
117
|
);
|
|
103
118
|
|
|
104
|
-
const { screenData, pathname } = routeData;
|
|
105
|
-
|
|
106
119
|
const offlinePlugin = getComponentModule({
|
|
107
120
|
plugins,
|
|
108
121
|
components: {},
|
|
@@ -133,9 +146,7 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
|
|
|
133
146
|
return (
|
|
134
147
|
<ScreenContextProvider pathname={pathname}>
|
|
135
148
|
<View style={style}>
|
|
136
|
-
<NavBar
|
|
137
|
-
{...{ ...(navBarProps as MobileNavBarPluginProps), id: pathname }}
|
|
138
|
-
/>
|
|
149
|
+
{navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
|
|
139
150
|
|
|
140
151
|
<OfflineFallbackScreen screenData={targetScreenData}>
|
|
141
152
|
{/* @TODO RouteManager doesn't use props, can they be removed ? */}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "react-native";
|
|
8
8
|
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
9
9
|
import { PathnameContext } from "../../Contexts/PathnameContext";
|
|
10
|
+
import { ScreenDataContext } from "../../Contexts/ScreenDataContext";
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
12
13
|
children: any;
|
|
@@ -16,6 +17,8 @@ type Props = {
|
|
|
16
17
|
animating: boolean;
|
|
17
18
|
contentStyle: ViewStyle;
|
|
18
19
|
pathname: string;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
screenData: NavigationScreenData;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -38,34 +41,36 @@ export function Scene({
|
|
|
38
41
|
animating,
|
|
39
42
|
contentStyle,
|
|
40
43
|
pathname,
|
|
44
|
+
isActive = false,
|
|
45
|
+
screenData,
|
|
41
46
|
}: Props) {
|
|
47
|
+
const [initialScreenData, setInitialScreenData] = React.useState(screenData);
|
|
48
|
+
|
|
49
|
+
React.useLayoutEffect(() => {
|
|
50
|
+
if (isActive) {
|
|
51
|
+
setInitialScreenData(screenData);
|
|
52
|
+
}
|
|
53
|
+
}, [screenData, isActive]);
|
|
54
|
+
|
|
42
55
|
const frame = useSafeAreaFrame();
|
|
43
56
|
const { height, width } = useWindowDimensions();
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<Animated.View
|
|
50
|
-
pointerEvents={pointerEvents}
|
|
51
|
-
style={[style, contentStyle, { height, width }]}
|
|
52
|
-
>
|
|
53
|
-
<PathnameContext.Provider value={pathname}>
|
|
54
|
-
{children}
|
|
55
|
-
</PathnameContext.Provider>
|
|
56
|
-
<Animated.View style={overlayStyle} />
|
|
57
|
-
</Animated.View>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
58
|
+
// Safe frame takes too long to update,
|
|
59
|
+
// so we can not rely on it there, and use height and width instead.
|
|
60
|
+
const isAnimating = animating && overlayStyle;
|
|
61
|
+
const dimensions = isAnimating ? { height, width } : frame;
|
|
60
62
|
|
|
61
63
|
return (
|
|
62
64
|
<Animated.View
|
|
63
65
|
pointerEvents={pointerEvents}
|
|
64
|
-
style={[style, contentStyle,
|
|
66
|
+
style={[style, contentStyle, dimensions]}
|
|
65
67
|
>
|
|
66
|
-
<
|
|
67
|
-
{
|
|
68
|
-
|
|
68
|
+
<ScreenDataContext.Provider value={initialScreenData}>
|
|
69
|
+
<PathnameContext.Provider value={pathname}>
|
|
70
|
+
{children}
|
|
71
|
+
</PathnameContext.Provider>
|
|
72
|
+
</ScreenDataContext.Provider>
|
|
73
|
+
{isAnimating && <Animated.View style={overlayStyle} />}
|
|
69
74
|
</Animated.View>
|
|
70
75
|
);
|
|
71
76
|
}
|
|
@@ -278,7 +278,8 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
278
278
|
// instead of dangerous nulls or duplicates.
|
|
279
279
|
renderSingleScene({ scenes, to }) {
|
|
280
280
|
const { contentStyle, layoutData } = this.props;
|
|
281
|
-
const screenData =
|
|
281
|
+
const screenData = this.props.children.props.screenData;
|
|
282
|
+
const pathname = scenes[to.index].key;
|
|
282
283
|
|
|
283
284
|
const orientation = getScreenOrientation({
|
|
284
285
|
screenData,
|
|
@@ -296,10 +297,12 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
296
297
|
}) && (
|
|
297
298
|
<Scene
|
|
298
299
|
{...{ style: to.style }}
|
|
299
|
-
pathname={
|
|
300
|
+
pathname={pathname}
|
|
301
|
+
isActive={pathname === this.props.navigator.currentRoute}
|
|
300
302
|
contentStyle={contentStyle}
|
|
301
303
|
key={scenes[to.index].key}
|
|
302
304
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
305
|
+
screenData={screenData}
|
|
303
306
|
>
|
|
304
307
|
{scenes[to.index].children}
|
|
305
308
|
</Scene>
|
|
@@ -319,12 +322,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
319
322
|
<Scene
|
|
320
323
|
key={scenes[from.index].key}
|
|
321
324
|
pathname={scenes[from.index].key}
|
|
325
|
+
isActive={scenes[from.index].key === this.props.navigator.currentRoute}
|
|
322
326
|
style={from.style}
|
|
323
327
|
pointerEvents="none"
|
|
324
328
|
overlayStyle={from.overlayStyle}
|
|
325
329
|
animating={this.state.animating}
|
|
326
330
|
contentStyle={contentStyle}
|
|
327
331
|
screenUniqueId={scenes[from.index].screenUniqueId}
|
|
332
|
+
screenData={scenes[from.index].children.props.screenData}
|
|
328
333
|
>
|
|
329
334
|
{scenes[from.index].children}
|
|
330
335
|
</Scene>
|
|
@@ -333,12 +338,14 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
333
338
|
const toScene = scenes[to.index] && (
|
|
334
339
|
<Scene
|
|
335
340
|
pathname={scenes[to.index].key}
|
|
341
|
+
isActive={scenes[to.index].key === this.props.navigator.currentRoute}
|
|
336
342
|
key={scenes[to.index].key}
|
|
337
343
|
style={to.style}
|
|
338
344
|
overlayStyle={to.overlayStyle}
|
|
339
345
|
animating={this.state.animating}
|
|
340
346
|
contentStyle={contentStyle}
|
|
341
347
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
348
|
+
screenData={this.props.children.props.screenData}
|
|
342
349
|
>
|
|
343
350
|
{scenes[to.index].children}
|
|
344
351
|
</Scene>
|
|
@@ -21,7 +21,9 @@ exports[`<Scene /> renders correctly 1`] = `
|
|
|
21
21
|
]
|
|
22
22
|
}
|
|
23
23
|
>
|
|
24
|
-
<ContextProvider
|
|
24
|
+
<ContextProvider>
|
|
25
|
+
<ContextProvider />
|
|
26
|
+
</ContextProvider>
|
|
25
27
|
</ForwardRef(AnimatedComponentWrapper)>
|
|
26
28
|
`;
|
|
27
29
|
|
|
@@ -43,7 +45,9 @@ exports[`<Scene /> renders the overlay while animating 1`] = `
|
|
|
43
45
|
]
|
|
44
46
|
}
|
|
45
47
|
>
|
|
46
|
-
<ContextProvider
|
|
48
|
+
<ContextProvider>
|
|
49
|
+
<ContextProvider />
|
|
50
|
+
</ContextProvider>
|
|
47
51
|
<ForwardRef(AnimatedComponentWrapper)
|
|
48
52
|
style={
|
|
49
53
|
Object {
|
|
@@ -351,6 +351,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
351
351
|
item,
|
|
352
352
|
playerId: this.currentlyPlaying?.playerId,
|
|
353
353
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
354
|
+
entry: item.getPlayer().getEntry(),
|
|
354
355
|
},
|
|
355
356
|
});
|
|
356
357
|
};
|
|
@@ -385,6 +386,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
385
386
|
item,
|
|
386
387
|
playerId: this.currentlyPlaying?.playerId,
|
|
387
388
|
primaryPlayerId: this.primaryPlayer?.playerId,
|
|
389
|
+
entry: item.getPlayer().getEntry(),
|
|
388
390
|
},
|
|
389
391
|
});
|
|
390
392
|
};
|
|
@@ -419,6 +421,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
|
|
|
419
421
|
error,
|
|
420
422
|
playerId: currentItem?.playerId,
|
|
421
423
|
primaryPlayerId: currentItem?.playerId,
|
|
424
|
+
entry: item.getPlayer().getEntry(),
|
|
422
425
|
},
|
|
423
426
|
});
|
|
424
427
|
};
|