@applicaster/zapp-react-native-ui-components 13.0.0-rc.14 → 13.0.0-rc.141

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 (226) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
  3. package/Components/AudioPlayer/index.tsx +15 -0
  4. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  5. package/Components/AudioPlayer/mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap +66 -0
  6. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  7. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  8. package/Components/AudioPlayer/tv/Artwork.tsx +40 -0
  9. package/Components/AudioPlayer/{AudioPlayerLayout.tsx → tv/Layout.tsx} +37 -79
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +2 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +12 -9
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +12 -9
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +5 -8
  14. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +6 -6
  15. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +11 -6
  16. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +170 -0
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/channel.test.js.snap +3 -3
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +3 -3
  19. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +3 -3
  20. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +3 -5
  21. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +9 -7
  22. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +3 -5
  23. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +3 -5
  24. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +3 -5
  25. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +3 -5
  26. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +14 -63
  27. package/Components/AudioPlayer/types.ts +40 -0
  28. package/Components/BaseFocusable/index.ios.ts +1 -1
  29. package/Components/BaseFocusable/index.tsx +67 -31
  30. package/Components/Cell/Cell.tsx +14 -14
  31. package/Components/Cell/CellWithFocusable.tsx +50 -59
  32. package/Components/Cell/CellWrapper.tsx +18 -0
  33. package/Components/Cell/TvOSCellComponent.tsx +20 -26
  34. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  35. package/Components/Cell/index.js +3 -1
  36. package/Components/Cell/styles.ts +17 -0
  37. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +50 -50
  38. package/Components/CellRendererResolver/index.ts +2 -1
  39. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  40. package/Components/ComponentResolver/__tests__/componentResolver.test.js +26 -30
  41. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  42. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  43. package/Components/ErrorScreen/index.tsx +14 -6
  44. package/Components/Focusable/Focusable.tsx +1 -54
  45. package/Components/Focusable/FocusableTvOS.tsx +6 -2
  46. package/Components/Focusable/Touchable.tsx +19 -20
  47. package/Components/Focusable/index.android.tsx +10 -3
  48. package/Components/FocusableCell/index.tsx +1 -1
  49. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
  50. package/Components/FocusableGroup/index.tsx +0 -3
  51. package/Components/FocusableList/index.tsx +26 -10
  52. package/Components/FocusableScrollView/index.tsx +43 -13
  53. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
  54. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
  55. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +5 -3
  56. package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
  57. package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
  58. package/Components/Layout/TV/LayoutBackground.tsx +28 -0
  59. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  60. package/Components/Layout/TV/ScreenContainer.tsx +8 -2
  61. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  62. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +3 -1
  63. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  64. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +6 -5
  65. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +12 -11
  66. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
  67. package/Components/Layout/TV/__tests__/index.test.tsx +14 -4
  68. package/Components/Layout/TV/index.tsx +6 -20
  69. package/Components/Layout/TV/index.web.tsx +4 -1
  70. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  71. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  72. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  73. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +10 -15
  74. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  75. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  76. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  77. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  78. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  79. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  80. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
  81. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
  82. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  83. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  84. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  85. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +11 -19
  86. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +6 -235
  87. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  88. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  89. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  90. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  91. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  92. package/Components/MasterCell/utils/index.ts +9 -135
  93. package/Components/ModalComponent/BottomSheetModalContent.tsx +66 -54
  94. package/Components/ModalComponent/Button/Item.tsx +6 -5
  95. package/Components/ModalComponent/Button/assets.ts +1 -1
  96. package/Components/ModalComponent/Button/index.tsx +45 -62
  97. package/Components/ModalComponent/Header/index.tsx +12 -11
  98. package/Components/ModalComponent/utils.ts +55 -7
  99. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  100. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  101. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  102. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  103. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  104. package/Components/OfflineHandler/utils/index.ts +1 -1
  105. package/Components/PlayerContainer/PlayerContainer.tsx +76 -66
  106. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  107. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  108. package/Components/PlayerImageBackground/index.tsx +2 -2
  109. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -68
  110. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  111. package/Components/River/RefreshControl.tsx +1 -1
  112. package/Components/River/RiverFooter.tsx +39 -9
  113. package/Components/River/RiverItem.tsx +44 -4
  114. package/Components/River/TV/index.tsx +6 -1
  115. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +115 -46
  116. package/Components/River/__tests__/__snapshots__/river.test.js.snap +21 -83
  117. package/Components/River/__tests__/componentsMap.test.js +64 -17
  118. package/Components/River/__tests__/river.test.js +75 -40
  119. package/Components/RouteManager/TestId.tsx +1 -5
  120. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -5
  121. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  122. package/Components/RouteManager/__tests__/testId.test.js +4 -6
  123. package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
  124. package/Components/Screen/TV/index.web.tsx +5 -6
  125. package/Components/Screen/__tests__/Screen.test.tsx +53 -31
  126. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +6 -6
  127. package/Components/Screen/hooks.ts +53 -0
  128. package/Components/Screen/index.tsx +16 -42
  129. package/Components/ScreenResolver/__tests__/screenResolver.test.js +95 -70
  130. package/Components/Tabs/Tab.tsx +12 -9
  131. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  132. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  133. package/Components/TextInputTv/index.tsx +6 -5
  134. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
  135. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  136. package/Components/TrackedView/index.tsx +1 -0
  137. package/Components/Transitioner/AnimationManager.js +15 -15
  138. package/Components/Transitioner/Scene.tsx +53 -24
  139. package/Components/Transitioner/Transitioner.tsx +3 -3
  140. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  141. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  142. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +10 -50
  143. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  144. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
  145. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  146. package/Components/Transitioner/index.js +8 -4
  147. package/Components/VideoLive/LiveImageManager.ts +27 -1
  148. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  149. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  150. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +6 -10
  151. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  152. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +51 -31
  153. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +8 -4
  154. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +48 -23
  155. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +16 -15
  156. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  157. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  158. package/Components/VideoModal/ModalAnimation/index.ts +4 -1
  159. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  160. package/Components/VideoModal/ModalAnimation/utils.ts +32 -2
  161. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  162. package/Components/VideoModal/PlayerDetails.tsx +18 -10
  163. package/Components/VideoModal/PlayerWrapper.tsx +51 -57
  164. package/Components/VideoModal/VideoModal.tsx +17 -11
  165. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  166. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  167. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
  168. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +74 -104
  169. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +51 -0
  170. package/Components/VideoModal/hooks/index.ts +7 -0
  171. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +38 -0
  172. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  173. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  174. package/Components/VideoModal/utils.ts +6 -9
  175. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  176. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  177. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  178. package/Components/Viewport/__tests__/utils.test.js +5 -4
  179. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  180. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  181. package/Components/ZappUIComponent/index.tsx +4 -17
  182. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  183. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  184. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  185. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  186. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  187. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  188. package/Contexts/ScreenContext/index.tsx +6 -12
  189. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  190. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  191. package/Decorators/Navigator/index.tsx +1 -1
  192. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  193. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  194. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  195. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  196. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  197. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  198. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  199. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +27 -27
  200. package/Decorators/RiverResolver/index.tsx +6 -8
  201. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  202. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  203. package/Decorators/ZappPipesDataConnector/index.tsx +7 -3
  204. package/package.json +13 -11
  205. package/tsconfig.json +2 -3
  206. package/.babelrc +0 -8
  207. package/Components/AudioPlayer/Artwork.tsx +0 -35
  208. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +0 -123
  209. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -50
  210. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -27
  211. package/Components/AudioPlayer/index.ts +0 -1
  212. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  213. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  214. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  215. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  216. package/Components/Cell/CellStyles/colors.js +0 -40
  217. package/Components/Cell/CellStyles/index.js +0 -15
  218. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  219. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  220. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  221. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  222. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  223. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  224. package/Decorators/RiverFeedLoader/utils.ts +0 -100
  225. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
  226. /package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +0 -0
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { View, Text } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+ import { AppContainer } from "../index";
5
5
 
6
6
  const styles = {
7
7
  iphone: {
@@ -15,11 +15,9 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
15
15
  })),
16
16
  }));
17
17
 
18
- const { AppContainer } = require("../index");
19
-
20
18
  describe("<AppContainer />", () => {
21
19
  it("renders correctly", () => {
22
- const wrapper = shallow(
20
+ const { toJSON } = render(
23
21
  <AppContainer styles={styles}>
24
22
  <View>
25
23
  <Text>I'm an app</Text>
@@ -27,6 +25,6 @@ describe("<AppContainer />", () => {
27
25
  </AppContainer>
28
26
  );
29
27
 
30
- expect(shallowToJson(wrapper)).toMatchSnapshot();
28
+ expect(toJSON()).toMatchSnapshot();
31
29
  });
32
30
  });
@@ -3,7 +3,7 @@
3
3
  exports[`<AppContainer /> renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "backgroundColor": "rgba(255, 255, 255, 1)",
8
8
  "flex": 1,
9
9
  }
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
3
+
4
+ import { AudioPlayerTV } from "./tv";
5
+ import { AudioPlayerMobile } from "./mobile";
6
+
7
+ import { Props } from "./types";
8
+
9
+ export function AudioPlayer(props: Props) {
10
+ if (isTV()) {
11
+ return <AudioPlayerTV {...props} />;
12
+ }
13
+
14
+ return <AudioPlayerMobile {...props} />;
15
+ }
@@ -0,0 +1,66 @@
1
+ import React, { useRef } from "react";
2
+ import {
3
+ View,
4
+ ImageBackground,
5
+ Animated,
6
+ ViewStyle,
7
+ StyleSheet,
8
+ } from "react-native";
9
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
10
+
11
+ const THREE_SECONDS = 3000;
12
+
13
+ const styles = StyleSheet.create({
14
+ flex: {
15
+ flex: 1,
16
+ },
17
+ });
18
+
19
+ type Props = {
20
+ backgroundImageSource: { uri: string };
21
+ style: ViewStyle;
22
+ };
23
+
24
+ export function AudioPlayerMobileLayout({
25
+ backgroundImageSource,
26
+ style,
27
+ }: Props) {
28
+ const fadeAnimation = useRef(new Animated.Value(0)).current;
29
+
30
+ const mainContainerStyles = platformSelect({
31
+ native: {
32
+ backgroundColor: "transparent",
33
+ overflow: "hidden",
34
+ ...style,
35
+ },
36
+ });
37
+
38
+ React.useEffect(() => {
39
+ Animated.timing(fadeAnimation, {
40
+ toValue: 1,
41
+ duration: THREE_SECONDS,
42
+ useNativeDriver: true,
43
+ }).start();
44
+ }, []);
45
+
46
+ return (
47
+ <View style={mainContainerStyles} pointerEvents="none">
48
+ <Animated.View
49
+ style={[
50
+ mainContainerStyles,
51
+ {
52
+ opacity: fadeAnimation,
53
+ },
54
+ ]}
55
+ >
56
+ <ImageBackground
57
+ source={backgroundImageSource}
58
+ style={styles.flex}
59
+ resizeMode="cover"
60
+ >
61
+ <View style={mainContainerStyles} />
62
+ </ImageBackground>
63
+ </Animated.View>
64
+ </View>
65
+ );
66
+ }
@@ -0,0 +1,66 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<AudioPlayerMobileLayout /> renders correctly 1`] = `
4
+ <View
5
+ pointerEvents="none"
6
+ style={
7
+ {
8
+ "backgroundColor": "transparent",
9
+ "overflow": "hidden",
10
+ }
11
+ }
12
+ >
13
+ <View
14
+ collapsable={false}
15
+ style={
16
+ {
17
+ "backgroundColor": "transparent",
18
+ "opacity": 0,
19
+ "overflow": "hidden",
20
+ }
21
+ }
22
+ >
23
+ <View
24
+ accessibilityIgnoresInvertColors={true}
25
+ style={
26
+ {
27
+ "flex": 1,
28
+ }
29
+ }
30
+ >
31
+ <Image
32
+ resizeMode="cover"
33
+ source={
34
+ {
35
+ "uri": "background_image_url",
36
+ }
37
+ }
38
+ style={
39
+ [
40
+ {
41
+ "bottom": 0,
42
+ "left": 0,
43
+ "position": "absolute",
44
+ "right": 0,
45
+ "top": 0,
46
+ },
47
+ {
48
+ "height": undefined,
49
+ "width": undefined,
50
+ },
51
+ undefined,
52
+ ]
53
+ }
54
+ />
55
+ <View
56
+ style={
57
+ {
58
+ "backgroundColor": "transparent",
59
+ "overflow": "hidden",
60
+ }
61
+ }
62
+ />
63
+ </View>
64
+ </View>
65
+ </View>
66
+ `;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+
4
+ import { AudioPlayerMobileLayout } from "../Layout";
5
+
6
+ const audioPlayerLayoutProps = {
7
+ backgroundImageSource: { uri: "background_image_url" },
8
+ };
9
+
10
+ describe("<AudioPlayerMobileLayout />", () => {
11
+ it("renders correctly", () => {
12
+ const { toJSON } = render(
13
+ <AudioPlayerMobileLayout {...audioPlayerLayoutProps} />
14
+ );
15
+
16
+ expect(toJSON()).toMatchSnapshot();
17
+ });
18
+ });
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { useBackgroundImage } from "@applicaster/zapp-react-native-utils/audioPlayerUtils";
3
+
4
+ import { AudioPlayerMobileLayout } from "./Layout";
5
+ import { Props } from "../types";
6
+
7
+ export function AudioPlayerMobile(props: Props) {
8
+ const { audio_item, style = {} } = props;
9
+
10
+ const backgroundImageSource = useBackgroundImage(audio_item);
11
+
12
+ return (
13
+ <AudioPlayerMobileLayout
14
+ backgroundImageSource={backgroundImageSource}
15
+ style={style}
16
+ />
17
+ );
18
+ }
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import { View, Image, StyleSheet } from "react-native";
3
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
4
+
5
+ const styles = StyleSheet.create({
6
+ container: {
7
+ marginHorizontal: 24,
8
+ },
9
+ image: {
10
+ width: 400,
11
+ height: 400,
12
+ },
13
+ });
14
+
15
+ type Props = {
16
+ srcImage: string;
17
+ config?: {
18
+ titleColor: string;
19
+ summaryColor: string;
20
+ backgroundColor: string;
21
+ backgroundImage: string;
22
+ isRTL: boolean;
23
+ artworkBorderRadius: Option<number>;
24
+ };
25
+ };
26
+
27
+ export function Artwork({ srcImage, config }: Props) {
28
+ const borderRadius = toNumberWithDefaultZero(config.artworkBorderRadius);
29
+
30
+ return (
31
+ <View style={styles.container}>
32
+ <Image
33
+ fadeDuration={0}
34
+ source={{ uri: srcImage }}
35
+ style={[styles.image, { borderRadius }]}
36
+ resizeMode="cover"
37
+ />
38
+ </View>
39
+ );
40
+ }
@@ -1,5 +1,5 @@
1
- import React, { useRef } from "react";
2
- import { View, ImageBackground, Animated, ViewStyle } from "react-native";
1
+ import * as React from "react";
2
+ import { View, ImageBackground, ViewStyle } from "react-native";
3
3
 
4
4
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
5
 
@@ -7,32 +7,28 @@ import { Artwork } from "./Artwork";
7
7
  import { directionStyles } from "./helpers";
8
8
 
9
9
  type Props = {
10
- artwork?: string;
10
+ artwork: string;
11
11
  config: {
12
12
  titleColor: string;
13
13
  summaryColor: string;
14
14
  backgroundColor: string;
15
- backgroundImage: string;
15
+ backgroundImage: Option<string>;
16
16
  isRTL: boolean;
17
+ artworkBorderRadius: Option<number>;
17
18
  };
18
19
  children: React.ReactNode;
19
20
  style: ViewStyle;
20
21
  };
21
22
 
22
- export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
23
- const fadeAnimation = useRef(new Animated.Value(0)).current;
24
-
25
- const fadeAudioPlayerIn = () => {
26
- Animated.timing(fadeAnimation, {
27
- toValue: 1,
28
- duration: 3000,
29
- useNativeDriver: true,
30
- }).start();
31
- };
32
-
23
+ export function AudioPlayerTVLayout({
24
+ artwork,
25
+ config,
26
+ children,
27
+ style,
28
+ }: Props) {
33
29
  const { isRTL, backgroundColor, backgroundImage } = config;
34
30
 
35
- const backgroundImg = { uri: backgroundImage };
31
+ const backgroundImageSource = { uri: backgroundImage };
36
32
 
37
33
  const backgroundColorStyle = backgroundImage
38
34
  ? "transparent"
@@ -40,17 +36,16 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
40
36
 
41
37
  const mainContainerStyles = platformSelect({
42
38
  tvos: {
43
- width: 1920,
44
- height: 1080,
39
+ width: "100%",
40
+ height: "100%",
45
41
  alignItems: "center",
46
42
  justifyContent: "center",
47
43
  flexDirection: directionStyles(isRTL).flexDirection,
48
44
  backgroundColor: backgroundColorStyle,
49
45
  },
50
46
  android_tv: {
51
- position: "absolute",
52
- width: 1920,
53
- height: 1080,
47
+ width: "100%",
48
+ height: "100%",
54
49
  alignItems: "center",
55
50
  justifyContent: "center",
56
51
  flexDirection: directionStyles(isRTL).flexDirection,
@@ -97,15 +92,14 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
97
92
 
98
93
  const backgroundImgStyles = platformSelect({
99
94
  tvos: {
100
- width: 1920,
101
- height: 1080,
95
+ width: "100%",
96
+ height: "100%",
102
97
  alignItems: "center",
103
98
  justifyContent: "center",
104
99
  },
105
100
  android_tv: {
106
- position: "absolute",
107
- width: 1920,
108
- height: 1080,
101
+ width: "100%",
102
+ height: "100%",
109
103
  alignItems: "center",
110
104
  justifyContent: "center",
111
105
  },
@@ -120,9 +114,6 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
120
114
  alignItems: "center",
121
115
  justifyContent: "center",
122
116
  },
123
- native: {
124
- flex: 1,
125
- },
126
117
  });
127
118
 
128
119
  const textContainerStyles = platformSelect({
@@ -146,58 +137,25 @@ export function AudioPlayerLayout({ artwork, config, children, style }: Props) {
146
137
  },
147
138
  });
148
139
 
149
- const audioPlayerLayoutTV = backgroundImg?.uri ? (
150
- <ImageBackground
151
- source={backgroundImg}
152
- style={backgroundImgStyles}
153
- resizeMode="cover"
154
- >
155
- <View style={mainContainerStyles}>
156
- {!!artwork && <Artwork srcImage={artwork} config={config} />}
157
- <View style={textContainerStyles}>{children}</View>
158
- </View>
159
- </ImageBackground>
160
- ) : (
140
+ if (backgroundImage) {
141
+ return (
142
+ <ImageBackground
143
+ source={backgroundImageSource}
144
+ style={backgroundImgStyles}
145
+ resizeMode="cover"
146
+ >
147
+ <View style={mainContainerStyles}>
148
+ <Artwork srcImage={artwork} config={config} />
149
+ <View style={textContainerStyles}>{children}</View>
150
+ </View>
151
+ </ImageBackground>
152
+ );
153
+ }
154
+
155
+ return (
161
156
  <View style={mainContainerStyles}>
162
- {!!artwork && <Artwork srcImage={artwork} config={config} />}
157
+ <Artwork srcImage={artwork} config={config} />
163
158
  <View style={textContainerStyles}>{children}</View>
164
159
  </View>
165
160
  );
166
-
167
- const audioPlayerLayoutMobile = () => {
168
- fadeAudioPlayerIn();
169
-
170
- return (
171
- <View style={mainContainerStyles} pointerEvents="none">
172
- <Animated.View
173
- style={[
174
- mainContainerStyles,
175
- {
176
- opacity: fadeAnimation,
177
- },
178
- ]}
179
- >
180
- <ImageBackground
181
- source={backgroundImg}
182
- style={backgroundImgStyles}
183
- resizeMode="cover"
184
- >
185
- <View style={mainContainerStyles} />
186
- </ImageBackground>
187
- </Animated.View>
188
- </View>
189
- );
190
- };
191
-
192
- const audioPlayerLayout = platformSelect({
193
- tvos: audioPlayerLayoutTV,
194
- android_tv: audioPlayerLayoutTV,
195
- web: audioPlayerLayoutTV,
196
- samsung_tv: audioPlayerLayoutTV,
197
- lg_tv: audioPlayerLayoutTV,
198
- ios: audioPlayerLayoutMobile(),
199
- android: audioPlayerLayoutMobile(),
200
- });
201
-
202
- return audioPlayerLayout;
203
161
  }
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { View, Text, ViewStyle, TextStyle } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
  import { directionStyles } from "./helpers";
4
5
 
5
6
  type Props = {
@@ -31,7 +32,7 @@ const textStyles = ({
31
32
  }) => ({
32
33
  color: summaryColor,
33
34
  opacity: 0.8,
34
- fontSize: runTimeFontSize ? Number(runTimeFontSize) : 20,
35
+ fontSize: toNumberWithDefault(20, runTimeFontSize),
35
36
  fontFamily: runTimeFontFamily || null,
36
37
  ...directionStyles(isRTL),
37
38
  });
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, Text, TextStyle } from "react-native";
2
+ import { View, Text, TextStyle, StyleSheet } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
 
4
5
  type Props = {
5
6
  config: {
@@ -14,11 +15,13 @@ type Props = {
14
15
  summary: string | number;
15
16
  };
16
17
 
17
- const containerStyles = {
18
- width: 600,
19
- height: 80,
20
- marginBottom: 30,
21
- };
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ width: 600,
21
+ height: 80,
22
+ marginBottom: 30,
23
+ },
24
+ });
22
25
 
23
26
  const textStyles = ({
24
27
  summaryColor,
@@ -26,8 +29,8 @@ const textStyles = ({
26
29
  summaryFontFamily,
27
30
  summaryFontSize,
28
31
  }) => ({
29
- textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
30
- fontSize: summaryFontSize ? Number(summaryFontSize) : 20,
32
+ textAlign: (isRTL ? "right" : "left") as TextStyle["textAlign"],
33
+ fontSize: toNumberWithDefault(20, summaryFontSize),
31
34
  color: summaryColor,
32
35
  fontWeight: "600" as TextStyle["fontWeight"],
33
36
  opacity: 0.8,
@@ -36,7 +39,7 @@ const textStyles = ({
36
39
 
37
40
  export function Summary({ summary, config }: Props) {
38
41
  return (
39
- <View style={containerStyles}>
42
+ <View style={styles.container}>
40
43
  <Text style={textStyles(config)} numberOfLines={2}>
41
44
  {summary}
42
45
  </Text>
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { View, Text, TextStyle } from "react-native";
2
+ import { View, Text, TextStyle, StyleSheet } from "react-native";
3
+ import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
3
4
 
4
5
  type Props = {
5
6
  config: {
@@ -14,15 +15,17 @@ type Props = {
14
15
  title: string | number;
15
16
  };
16
17
 
17
- const containerStyles = {
18
- width: 600,
19
- height: 100,
20
- marginBottom: 12,
21
- };
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ width: 600,
21
+ height: 100,
22
+ marginBottom: 12,
23
+ },
24
+ });
22
25
 
23
26
  const textStyles = ({ titleColor, isRTL, titleFontFamily, titleFontSize }) => ({
24
- textAlign: (isRTL ? "left" : "right") as TextStyle["textAlign"],
25
- fontSize: titleFontSize ? Number(titleFontSize) : 38,
27
+ textAlign: (isRTL ? "right" : "left") as TextStyle["textAlign"],
28
+ fontSize: toNumberWithDefault(38, titleFontSize),
26
29
  fontWeight: "600" as TextStyle["fontWeight"],
27
30
  color: titleColor,
28
31
  fontFamily: titleFontFamily || null,
@@ -30,7 +33,7 @@ const textStyles = ({ titleColor, isRTL, titleFontFamily, titleFontSize }) => ({
30
33
 
31
34
  export function Title({ title, config }: Props) {
32
35
  return (
33
- <View style={containerStyles}>
36
+ <View style={styles.container}>
34
37
  <Text style={textStyles(config)} numberOfLines={2}>
35
38
  {title}
36
39
  </Text>
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Runtime } from "../Runtime";
6
5
 
@@ -18,14 +17,12 @@ const RuntimeProps = (isRTL) => ({
18
17
 
19
18
  describe("<Runtime />", () => {
20
19
  it("RTL renders correctly", () => {
21
- const wrapper = shallow(<Runtime {...RuntimeProps(true)} />);
22
-
23
- expect(shallowToJson(wrapper)).toMatchSnapshot();
20
+ const { toJSON } = render(<Runtime {...RuntimeProps(true)} />);
21
+ expect(toJSON()).toMatchSnapshot();
24
22
  });
25
23
 
26
24
  it("LTR renders correctly", () => {
27
- const wrapper = shallow(<Runtime {...RuntimeProps(false)} />);
28
-
29
- expect(shallowToJson(wrapper)).toMatchSnapshot();
25
+ const { toJSON } = render(<Runtime {...RuntimeProps(false)} />);
26
+ expect(toJSON()).toMatchSnapshot();
30
27
  });
31
28
  });
@@ -3,7 +3,7 @@
3
3
  exports[`<Runtime /> LTR renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "height": 40,
8
8
  "justifyContent": "flex-start",
9
9
  "width": 600,
@@ -12,7 +12,7 @@ exports[`<Runtime /> LTR renders correctly 1`] = `
12
12
  >
13
13
  <Text
14
14
  style={
15
- Object {
15
+ {
16
16
  "alignItems": "flex-end",
17
17
  "color": "white",
18
18
  "flexDirection": "row",
@@ -20,7 +20,7 @@ exports[`<Runtime /> LTR renders correctly 1`] = `
20
20
  "fontSize": 20,
21
21
  "justifyContent": "flex-start",
22
22
  "opacity": 0.8,
23
- "textAlign": "right",
23
+ "textAlign": "left",
24
24
  }
25
25
  }
26
26
  >
@@ -32,7 +32,7 @@ exports[`<Runtime /> LTR renders correctly 1`] = `
32
32
  exports[`<Runtime /> RTL renders correctly 1`] = `
33
33
  <View
34
34
  style={
35
- Object {
35
+ {
36
36
  "height": 40,
37
37
  "justifyContent": "flex-end",
38
38
  "width": 600,
@@ -41,7 +41,7 @@ exports[`<Runtime /> RTL renders correctly 1`] = `
41
41
  >
42
42
  <Text
43
43
  style={
44
- Object {
44
+ {
45
45
  "alignItems": "flex-start",
46
46
  "color": "white",
47
47
  "flexDirection": "row-reverse",
@@ -49,7 +49,7 @@ exports[`<Runtime /> RTL renders correctly 1`] = `
49
49
  "fontSize": 20,
50
50
  "justifyContent": "flex-end",
51
51
  "opacity": 0.8,
52
- "textAlign": "left",
52
+ "textAlign": "right",
53
53
  }
54
54
  }
55
55
  >
@@ -3,7 +3,7 @@
3
3
  exports[`<Artwork /> renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "marginHorizontal": 24,
8
8
  }
9
9
  }
@@ -12,15 +12,20 @@ exports[`<Artwork /> renders correctly 1`] = `
12
12
  fadeDuration={0}
13
13
  resizeMode="cover"
14
14
  source={
15
- Object {
15
+ {
16
16
  "uri": "https://example.com",
17
17
  }
18
18
  }
19
19
  style={
20
- Object {
21
- "height": 400,
22
- "width": 400,
23
- }
20
+ [
21
+ {
22
+ "height": 400,
23
+ "width": 400,
24
+ },
25
+ {
26
+ "borderRadius": 0,
27
+ },
28
+ ]
24
29
  }
25
30
  />
26
31
  </View>