@applicaster/zapp-react-native-ui-components 15.1.0-rc.9 → 15.1.1-rc.0

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.
Files changed (30) hide show
  1. package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
  2. package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
  3. package/Components/BackgroundImage/BackgroundImage.tv.web.tsx +42 -0
  4. package/Components/BackgroundImage/index.ts +8 -0
  5. package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
  6. package/Components/Layout/FullWidthRow.tsx +38 -0
  7. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  8. package/Components/Layout/TV/index.tsx +2 -3
  9. package/Components/Layout/TV/index.web.tsx +2 -3
  10. package/Components/MasterCell/dataAdapter.ts +15 -5
  11. package/Components/MasterCell/index.tsx +10 -1
  12. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  13. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  14. package/Components/MasterCell/utils/index.ts +89 -46
  15. package/Components/PlayerContainer/PlayerContainer.tsx +9 -3
  16. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +286 -0
  17. package/Components/River/RefreshControl.tsx +30 -13
  18. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +0 -15
  19. package/Components/Screen/index.tsx +8 -4
  20. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  21. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  22. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
  23. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +9 -4
  24. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  25. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  26. package/Helpers/index.js +7 -40
  27. package/package.json +5 -5
  28. package/Components/Layout/TV/LayoutBackground.tsx +0 -28
  29. package/Components/Screen/utils.ts +0 -16
  30. package/Helpers/Analytics/index.js +0 -95
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ ImageURISource,
6
+ ImageBackground,
7
+ } from "react-native";
8
+
9
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
10
+
11
+ const imageSource: ImageURISource = {
12
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
13
+ };
14
+
15
+ const styles = StyleSheet.create({
16
+ container: { flex: 1 },
17
+ backgroundImage: { width: "100%", height: "100%" },
18
+ });
19
+
20
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
21
+ return (
22
+ <View style={styles.container}>
23
+ <ImageBackground style={styles.backgroundImage} source={imageSource}>
24
+ {children}
25
+ </ImageBackground>
26
+ </View>
27
+ );
28
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, ImageURISource } from "react-native";
3
+
4
+ import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
5
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
6
+
7
+ const imageSource: ImageURISource = {
8
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
9
+ };
10
+
11
+ const styles = StyleSheet.create({
12
+ container: { flex: 1 },
13
+ backgroundImage: { width: "100%", height: "100%" },
14
+ });
15
+
16
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
17
+ return (
18
+ <View style={styles.container}>
19
+ <Image style={styles.backgroundImage} source={imageSource}>
20
+ {children}
21
+ </Image>
22
+ </View>
23
+ );
24
+ }
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { View, ViewStyle } from "react-native";
3
+
4
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
+ import {
6
+ selectRemoteConfigurations,
7
+ useAppSelector,
8
+ } from "@applicaster/zapp-react-native-redux";
9
+
10
+ import { getBackgroundImageUrl } from "../Layout/utils";
11
+
12
+ const baseBackgroundStyles = (imageUrl, backgroundColor) =>
13
+ ({
14
+ position: "absolute",
15
+ left: 0,
16
+ top: 0,
17
+ right: 0,
18
+ bottom: 0,
19
+ zIndex: -1,
20
+ backgroundSize: "cover",
21
+ background: imageUrl
22
+ ? `url(${imageUrl}) no-repeat top center ${backgroundColor}`
23
+ : backgroundColor,
24
+ }) as ViewStyle;
25
+
26
+ export const BackgroundImage = ({ children }: React.PropsWithChildren) => {
27
+ const theme = useTheme();
28
+
29
+ const remoteConfigurations = useAppSelector(selectRemoteConfigurations);
30
+
31
+ const backgroundColor = theme.app_background_color;
32
+ const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
33
+
34
+ return (
35
+ <View
36
+ id="background"
37
+ style={baseBackgroundStyles(backgroundImageUrl, backgroundColor)}
38
+ >
39
+ {children}
40
+ </View>
41
+ );
42
+ };
@@ -0,0 +1,8 @@
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
2
+
3
+ export const BackgroundImage = platformSelect({
4
+ tvos: require("./BackgroundImage.tv.ios").BackgroundImage,
5
+ android_tv: require("./BackgroundImage.tv.android").BackgroundImage,
6
+ amazon: require("./BackgroundImage.tv.android").BackgroundImage,
7
+ web: require("./BackgroundImage.tv.web").BackgroundImage,
8
+ });
@@ -1,12 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { FocusableGroupNative } from "@applicaster/zapp-react-native-ui-components/Components/NativeFocusables";
3
3
  import { BaseFocusable } from "@applicaster/zapp-react-native-ui-components/Components/BaseFocusable";
4
- import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
4
+ // TODO: Enable when will be feature flags
5
+ // import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
5
6
 
6
- const { log_verbose } = createLogger({
7
- subsystem: "General",
8
- category: "FocusableGroup",
9
- });
7
+ // TODO: Enable when will be feature flags
8
+ // const { log_verbose } = createLogger({
9
+ // subsystem: "General",
10
+ // category: "FocusableGroup",
11
+ // });
10
12
 
11
13
  type FocusableGroupNativeEvent = {
12
14
  nativeEvent: {
@@ -48,12 +50,14 @@ export class FocusableGroup extends BaseFocusable<Props> {
48
50
  } = this.props;
49
51
 
50
52
  const onGroupFocus = ({ nativeEvent }: FocusableGroupNativeEvent) => {
51
- log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
53
+ // TODO: Enable when will be feature flags
54
+ // log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
52
55
  this.onFocus(this.ref, nativeEvent.focusHeading);
53
56
  };
54
57
 
55
58
  const onGroupBlur = ({ nativeEvent }: FocusableGroupNativeEvent) => {
56
- log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
59
+ // TODO: Enable when will be feature flags
60
+ // log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
57
61
  this.onBlur(this.ref, nativeEvent.focusHeading);
58
62
  };
59
63
 
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+
4
+ const styles = StyleSheet.create({
5
+ row: { flexDirection: "row" },
6
+ basis: {
7
+ maxWidth: "100%",
8
+ flexBasis: "100%",
9
+ },
10
+ });
11
+
12
+ type Props = {
13
+ children: React.ReactNode;
14
+ };
15
+
16
+ /**
17
+ * Constrains its child to exactly the available parent width.
18
+ *
19
+ * UI components such as Hero and List render their items inside a parent
20
+ * `ScrollView` (e.g. when wrapped by tabs). A child placed directly in a
21
+ * scroll container can size itself to its own content rather than to the
22
+ * viewport, which causes items to be measured at a stale width and resize
23
+ * unexpectedly after layout changes such as device rotation.
24
+ *
25
+ * Wrapping the content in a `flexDirection: "row"` parent with a
26
+ * `flexBasis: "100%"` / `maxWidth: "100%"` child forces the child to
27
+ * re-derive its width from the parent on every layout pass instead of
28
+ * caching a measured pixel width, keeping it full-width and stable.
29
+ *
30
+ * @param children - The content to render at full parent width.
31
+ */
32
+ export function FullWidthRow({ children }: Props) {
33
+ return (
34
+ <View style={styles.row}>
35
+ <View style={styles.basis}>{children}</View>
36
+ </View>
37
+ );
38
+ }
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports[`Layout TV renders 1`] = `
4
4
  <View
5
- backgroundColor="#000000"
6
5
  testID="background-component"
7
6
  >
8
7
  <View
@@ -9,7 +9,6 @@ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
9
9
  import { PathnameContext } from "../../../Contexts/PathnameContext";
10
10
  import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
11
11
  import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
12
- import { LayoutBackground } from "./LayoutBackground";
13
12
 
14
13
  type Components = {
15
14
  NavBar: React.ComponentType<any>;
@@ -40,7 +39,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
40
39
  return (
41
40
  <LayoutContainer>
42
41
  <ScreenLayoutContextProvider>
43
- <LayoutBackground Background={Components.Background}>
42
+ <Components.Background>
44
43
  <ScreenDataContext.Provider value={navigator.data}>
45
44
  <PathnameContext.Provider value={navigator.currentRoute}>
46
45
  <ScreenContextProvider pathname={navigator.currentRoute}>
@@ -53,7 +52,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
53
52
  </ScreenContextProvider>
54
53
  </PathnameContext.Provider>
55
54
  </ScreenDataContext.Provider>
56
- </LayoutBackground>
55
+ </Components.Background>
57
56
  </ScreenLayoutContextProvider>
58
57
  </LayoutContainer>
59
58
  );
@@ -5,7 +5,6 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
5
 
6
6
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
7
7
  import { StackNavigator } from "../../Navigator";
8
- import { LayoutBackground } from "./LayoutBackground";
9
8
 
10
9
  type Components = {
11
10
  NavBar: React.ComponentType<any>;
@@ -26,9 +25,9 @@ const Layout = ({ Components }: Props) => {
26
25
 
27
26
  return (
28
27
  <ScreenLayoutContextProvider>
29
- <LayoutBackground Background={Components.Background}>
28
+ <Components.Background>
30
29
  <StackNavigator Components={Components} />
31
- </LayoutBackground>
30
+ </Components.Background>
32
31
  </ScreenLayoutContextProvider>
33
32
  );
34
33
  };
@@ -1,5 +1,6 @@
1
1
  import * as R from "ramda";
2
2
  import { isFunction } from "@applicaster/zapp-react-native-utils/functionUtils";
3
+ import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
3
4
 
4
5
  import { functionForName } from "./MappingFunctions";
5
6
  import { resolveColor } from "./utils";
@@ -50,7 +51,8 @@ export function configInflater(
50
51
  additionalProps?: Record<string, any>;
51
52
  data?: Array<{ propName: string; func: Function; args: any[] }>;
52
53
  elements?: any[];
53
- }
54
+ },
55
+ allowDynamicColorsOutsideExtensions: boolean
54
56
  ) {
55
57
  const props = data.reduce(
56
58
  (acc, curr) => {
@@ -65,13 +67,13 @@ export function configInflater(
65
67
 
66
68
  if (Array.isArray(elements)) {
67
69
  adjustedElements = elements.map((element) =>
68
- configInflater(entry, element as any)
70
+ configInflater(entry, element as any, allowDynamicColorsOutsideExtensions)
69
71
  );
70
72
  }
71
73
 
72
74
  return {
73
75
  type,
74
- style: resolveColor(entry, style),
76
+ style: resolveColor(entry, style, allowDynamicColorsOutsideExtensions),
75
77
  props,
76
78
  elements: adjustedElements,
77
79
  };
@@ -95,9 +97,17 @@ function resolveElementsNode(entry, state, elements) {
95
97
  }
96
98
 
97
99
  export function defaultDataAdapter(elements) {
98
- return function elementsBuilder({ entry, state = "default" }) {
100
+ return function elementsBuilder({
101
+ entry,
102
+ state = "default",
103
+ allowDynamicColorsOutsideExtensions,
104
+ }) {
99
105
  return resolveElementsNode(entry, state, elements).map((element) =>
100
- configInflater(entry, element)
106
+ configInflater(
107
+ entry,
108
+ element,
109
+ toBooleanWithDefaultFalse(allowDynamicColorsOutsideExtensions)
110
+ )
101
111
  );
102
112
  };
103
113
  }
@@ -3,6 +3,7 @@ import * as React from "react";
3
3
  import { v4 as uuid } from "uuid";
4
4
 
5
5
  import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
6
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
6
7
  import { useScreenState } from "@applicaster/zapp-react-native-utils/screenState";
7
8
  import { defaultComponents } from "./DefaultComponents";
8
9
  import { defaultDataAdapter } from "./dataAdapter";
@@ -65,6 +66,7 @@ export function masterCellBuilder({
65
66
  */
66
67
  function MasterCell({ item, state, ...otherProps }: Props) {
67
68
  const { screenData } = useRoute();
69
+ const theme = useTheme();
68
70
 
69
71
  const screenId =
70
72
  screenData && "targetScreen" in screenData
@@ -85,8 +87,15 @@ export function masterCellBuilder({
85
87
  elementsBuilder({
86
88
  entry: item,
87
89
  state: getEntryState(state, entryIsSelected),
90
+ allowDynamicColorsOutsideExtensions:
91
+ theme?.allow_dynamic_colors_outside_extensions,
88
92
  }),
89
- [state, item, entryIsSelected] // Assuming that item won't mutate
93
+ [
94
+ state,
95
+ item,
96
+ entryIsSelected,
97
+ theme?.allow_dynamic_colors_outside_extensions,
98
+ ] // Assuming that item won't mutate
90
99
  );
91
100
 
92
101
  const wrapperRef = React.useRef(null);