@applicaster/zapp-react-native-ui-components 15.0.0-rc.1 → 15.0.0-rc.11

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.
@@ -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] = mapping
146
- ? getInflatedDataSourceUrl({
147
- source: url,
148
- contexts: {
149
- entry: entryContext,
150
- screen: screenContext,
151
- search: getSearchContext(searchContext, mapping),
152
- },
153
- mapping,
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;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { View, StyleSheet, FlatList } from "react-native";
3
+ import { FlatList, StyleSheet, View } 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";
@@ -9,8 +9,8 @@ import { useScreenConfiguration } from "../useScreenConfiguration";
9
9
  import { RefreshControl } from "../RefreshControl";
10
10
  import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
11
11
  import {
12
- useProfilerLogging,
13
12
  usePipesCacheReset,
13
+ useProfilerLogging,
14
14
  } from "@applicaster/zapp-react-native-utils/reactHooks";
15
15
  import { useLoadingState } from "./hooks/useLoadingState";
16
16
  import { ViewportTracker } from "../../Viewport";
@@ -25,6 +25,8 @@ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHo
25
25
  import { useShallow } from "zustand/react/shallow";
26
26
 
27
27
  import { isAndroidPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
28
+ import { ComponentsMapHeightContext } from "./ContextProviders/ComponentsMapHeightContext";
29
+ import { ComponentsMapRefContext } from "./ContextProviders/ComponentsMapRefContext";
28
30
 
29
31
  const isAndroid = isAndroidPlatform();
30
32
 
@@ -70,6 +72,7 @@ function ComponentsMapComponent(props: Props) {
70
72
  } = props;
71
73
 
72
74
  const flatListRef = React.useRef<FlatList | null>(null);
75
+ const flatListWrapperRef = React.useRef<View | null>(null);
73
76
  const screenConfig = useScreenConfiguration(riverId);
74
77
  const screenData = useScreenData(riverId);
75
78
  const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
@@ -265,47 +268,51 @@ function ComponentsMapComponent(props: Props) {
265
268
  // The Screen Picker in Mobile is completly different than the TV
266
269
  // so the various offsets / margins in TV do not apply here.
267
270
  return (
268
- <View style={styles.container}>
269
- <ScreenLoadingMeasurements
270
- riverId={riverId}
271
- numberOfComponents={riverComponents.length}
272
- >
273
- <ViewportTracker>
274
- <FlatList
275
- ref={(ref) => {
276
- flatListRef.current = ref;
277
- }}
278
- // Fix for WebView rerender crashes on Android API 28+
279
- // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
280
- overScrollMode={isAndroid ? "never" : "auto"}
281
- scrollIndicatorInsets={scrollIndicatorInsets}
282
- extraData={feed}
283
- stickyHeaderIndices={stickyHeaderIndices}
284
- removeClippedSubviews={isAndroid}
285
- onLayout={handleOnLayout}
286
- initialNumToRender={3}
287
- maxToRenderPerBatch={10}
288
- windowSize={12}
289
- keyExtractor={keyExtractor}
290
- renderItem={renderRiverItem}
291
- data={riverComponents}
292
- contentContainerStyle={contentContainerStyle}
293
- ListFooterComponent={
294
- <RiverFooter
295
- flatListHeight={flatListHeight}
296
- loadingState={loadingState}
271
+ <View style={styles.container} ref={flatListWrapperRef}>
272
+ <ComponentsMapHeightContext.Provider value={flatListHeight}>
273
+ <ComponentsMapRefContext.Provider value={flatListWrapperRef}>
274
+ <ScreenLoadingMeasurements
275
+ riverId={riverId}
276
+ numberOfComponents={riverComponents.length}
277
+ >
278
+ <ViewportTracker>
279
+ <FlatList
280
+ ref={(ref) => {
281
+ flatListRef.current = ref;
282
+ }}
283
+ // Fix for WebView rerender crashes on Android API 28+
284
+ // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
285
+ overScrollMode={isAndroid ? "never" : "auto"}
286
+ scrollIndicatorInsets={scrollIndicatorInsets}
287
+ extraData={feed}
288
+ stickyHeaderIndices={stickyHeaderIndices}
289
+ removeClippedSubviews={isAndroid}
290
+ onLayout={handleOnLayout}
291
+ initialNumToRender={3}
292
+ maxToRenderPerBatch={10}
293
+ windowSize={12}
294
+ keyExtractor={keyExtractor}
295
+ renderItem={renderRiverItem}
296
+ data={riverComponents}
297
+ contentContainerStyle={contentContainerStyle}
298
+ ListFooterComponent={
299
+ <RiverFooter
300
+ flatListHeight={flatListHeight}
301
+ loadingState={loadingState}
302
+ />
303
+ }
304
+ refreshControl={refreshControl}
305
+ onScrollBeginDrag={onScrollBeginDrag}
306
+ onScroll={onScroll}
307
+ onMomentumScrollEnd={_onMomentumScrollEnd}
308
+ onScrollEndDrag={_onScrollEndDrag}
309
+ scrollEventThrottle={16}
310
+ {...scrollViewExtraProps}
297
311
  />
298
- }
299
- refreshControl={refreshControl}
300
- onScrollBeginDrag={onScrollBeginDrag}
301
- onScroll={onScroll}
302
- onMomentumScrollEnd={_onMomentumScrollEnd}
303
- onScrollEndDrag={_onScrollEndDrag}
304
- scrollEventThrottle={16}
305
- {...scrollViewExtraProps}
306
- />
307
- </ViewportTracker>
308
- </ScreenLoadingMeasurements>
312
+ </ViewportTracker>
313
+ </ScreenLoadingMeasurements>
314
+ </ComponentsMapRefContext.Provider>
315
+ </ComponentsMapHeightContext.Provider>
309
316
  </View>
310
317
  );
311
318
  }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+
3
+ export const ComponentsMapHeightContext = React.createContext<number | null>(
4
+ null
5
+ );
6
+
7
+ export const useComponentsMapHeight = () =>
8
+ React.useContext(ComponentsMapHeightContext);
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+
4
+ export const ComponentsMapRefContext =
5
+ React.createContext<React.RefObject<View | null> | null>(null);
6
+
7
+ export const useComponentsMapRef = () =>
8
+ React.useContext(ComponentsMapRefContext);
@@ -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.onContent) {
61
- setFocusOnContent(currentRoute);
62
+ if (initialFocus.onMenu) {
63
+ setFocusOnMenu(currentRoute);
62
64
 
63
65
  return;
64
66
  }
65
67
 
66
- if (initialFocus.onMenu) {
67
- setFocusOnMenu(currentRoute);
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
- // Set ready state when screen is rotated to desired orientation
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 style={style}>
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 callbackAction = useCallbackActions(
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, {
@@ -42,6 +42,8 @@ type Props = {
42
42
  children: React.ReactNode;
43
43
  };
44
44
 
45
+ const activeOffsetY = [-5, 5] as [number, number];
46
+
45
47
  export const AnimatedScrollModalComponent = ({ children }: Props) => {
46
48
  const {
47
49
  isActiveGesture,
@@ -372,9 +374,9 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
372
374
  ref={panHandlerRef}
373
375
  simultaneousHandlers={[scrollRef, tapHandlerRef]}
374
376
  shouldCancelWhenOutside={isMaximizedModal}
377
+ activeOffsetY={activeOffsetY}
375
378
  onGestureEvent={onGestureEvent}
376
379
  onHandlerStateChange={onHandlerStateChange}
377
- activeOffsetY={[-5, 5]}
378
380
  >
379
381
  <Animated.View>
380
382
  <NativeViewGestureHandler
@@ -4,8 +4,8 @@ import {
4
4
  Dimensions,
5
5
  Easing,
6
6
  StyleProp,
7
- ViewStyle,
8
7
  StyleSheet,
8
+ ViewStyle,
9
9
  } from "react-native";
10
10
  import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
11
11
  import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
@@ -69,11 +69,10 @@ export const PlayerDetails = ({
69
69
  const screenData = useTargetScreenData(entry);
70
70
  const insets = useSafeAreaInsets();
71
71
 
72
- const extraTabletStyles = !isAudioPlayer
73
- ? isTabletLandscape
72
+ const extraTabletStyles =
73
+ !isAudioPlayer && isTabletLandscape
74
74
  ? { marginTop: -insets.top, paddingTop: insets.top + 20 }
75
- : { marginTop: -8, paddingTop: -8 }
76
- : {};
75
+ : null;
77
76
 
78
77
  // Animation setup
79
78
  const translateY = useRef(new Animated.Value(50)).current;
@@ -129,6 +128,7 @@ export const PlayerDetails = ({
129
128
  riverId={screenData.id}
130
129
  feed={screenData?.data?.source}
131
130
  riverComponents={screenData.ui_components}
131
+ isScreenWrappedInContainer
132
132
  />
133
133
  ) : null}
134
134
  </Animated.View>
@@ -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
- <SafeAreaView
49
- edges={["top", "left", "right"]}
47
+ <View
50
48
  style={[style.view, isRTL ? style.rtlStyle : {}]}
51
- testID="BarView-safeAreaView"
49
+ testID="BarView-Container"
52
50
  >
53
51
  {backButton}
54
52
  <BarTitle title={barState.title} screenStyles={screenStyles} />
55
53
  {closeButton}
56
- </SafeAreaView>
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-safeAreaView").props.style).toContainEqual({
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-safeAreaView").props.style).not.toContainEqual({
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
- if (mapping) {
28
- const contexts = {
29
- entry: entryContext,
30
- screen: screenContext || screenData,
31
- search: getSearchContext(searchContext, mapping),
32
- };
27
+ const contexts = {
28
+ entry: entryContext,
29
+ screen: screenContext || screenData,
30
+ search: getSearchContext(searchContext, mapping),
31
+ };
33
32
 
34
- return getInflatedDataSourceUrl({ source, mapping, contexts });
35
- }
36
-
37
- return source;
33
+ return getInflatedDataSourceUrl({ source, mapping, contexts });
38
34
  }
39
35
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "15.0.0-rc.1",
3
+ "version": "15.0.0-rc.11",
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-rc.1",
32
- "@applicaster/zapp-react-native-bridge": "15.0.0-rc.1",
33
- "@applicaster/zapp-react-native-redux": "15.0.0-rc.1",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-rc.1",
31
+ "@applicaster/applicaster-types": "15.0.0-rc.11",
32
+ "@applicaster/zapp-react-native-bridge": "15.0.0-rc.11",
33
+ "@applicaster/zapp-react-native-redux": "15.0.0-rc.11",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-rc.11",
35
35
  "promise": "^8.3.0",
36
36
  "url": "^0.11.0",
37
37
  "uuid": "^3.3.2"