@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1110044191 → 16.0.0-alpha.1110245265

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 (80) hide show
  1. package/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
  2. package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
  3. package/Components/AudioPlayer/tv/index.tsx +5 -1
  4. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -1
  5. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
  6. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
  7. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
  8. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
  9. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
  10. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
  11. package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
  12. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
  13. package/Components/MasterCell/DefaultComponents/Toggle.tsx +35 -6
  14. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +163 -0
  15. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
  16. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
  17. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
  18. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
  19. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
  20. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
  21. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
  22. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
  23. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
  24. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
  25. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
  26. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
  27. package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
  28. package/Components/MasterCell/hooks/index.ts +2 -0
  29. package/Components/MasterCell/hooks/usePressedState.ts +4 -0
  30. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +314 -0
  31. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +395 -0
  32. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +763 -0
  33. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +653 -0
  34. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +874 -0
  35. package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +89 -0
  36. package/Components/ModalComponent/AudioPlayer/Components/index.ts +11 -0
  37. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +199 -0
  38. package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
  39. package/Components/ModalComponent/BottomSheetModalContent.tsx +383 -42
  40. package/Components/ModalComponent/Button/index.tsx +5 -3
  41. package/Components/ModalComponent/Header/index.tsx +20 -7
  42. package/Components/ModalComponent/Header/utils.ts +1 -1
  43. package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
  44. package/Components/ModalComponent/SortableList.tsx +142 -0
  45. package/Components/ModalComponent/SortableList.web.tsx +102 -0
  46. package/Components/ModalComponent/TextInputContent.tsx +100 -0
  47. package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
  48. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +238 -0
  49. package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +120 -0
  50. package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
  51. package/Components/ModalComponent/index.tsx +11 -0
  52. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +66 -0
  53. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
  54. package/Components/ModalComponent/presets/index.ts +27 -0
  55. package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
  56. package/Components/ModalComponent/presets/standardCell.tsx +41 -0
  57. package/Components/ModalComponent/presets/types.ts +35 -0
  58. package/Components/ModalComponent/showTextInput.ts +43 -0
  59. package/Components/ModalComponent/utils.ts +76 -20
  60. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
  61. package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
  62. package/Components/OfflineHandler/hooks.ts +123 -0
  63. package/Components/OfflineHandler/index.tsx +51 -73
  64. package/Components/OfflineHandler/utils/index.ts +1 -13
  65. package/Components/PlayerContainer/PlayerContainer.tsx +11 -7
  66. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
  67. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
  68. package/Components/PreloaderWrapper/index.tsx +1 -1
  69. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
  70. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
  71. package/Components/TopCutoffOverlay/index.tsx +2 -2
  72. package/Components/Transitioner/Transitioner.tsx +28 -17
  73. package/Components/VideoLive/LiveImageManager.ts +1 -1
  74. package/package.json +6 -5
  75. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
  76. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
  77. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
  78. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
  79. package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
  80. /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
@@ -6,6 +6,7 @@ import {
6
6
  } from "./utils";
7
7
  import { Button } from "./Button";
8
8
  import { buildActionButtonsModel } from "../../ActionButtonsCore/model";
9
+ import { ViewStyle } from "react-native";
9
10
 
10
11
  const CONTAINER_PREFIX = "mobile_buttons_container";
11
12
  const BUTTON_PREFIX = "mobile_button";
@@ -42,9 +43,24 @@ export const MobileActionButtons = ({
42
43
  return null;
43
44
  }
44
45
 
46
+ const {
47
+ container: { stacking, verticalGutter, horizontalGutter },
48
+ } = model;
49
+
50
+ const isVertical = stacking === "vertical";
51
+ const isOverImage = position === "over_image";
52
+ const gutter = isVertical ? verticalGutter : horizontalGutter;
53
+
54
+ const containerPaddings = {
55
+ paddingTop: model.container.margins.top,
56
+ paddingRight: model.container.margins.right,
57
+ paddingBottom: model.container.margins.bottom,
58
+ paddingLeft: model.container.margins.left,
59
+ };
60
+
45
61
  const style = {
46
62
  alignItems: "center",
47
- ...(placement === "over_image"
63
+ ...(isOverImage
48
64
  ? {
49
65
  position: "absolute",
50
66
  zIndex: 10,
@@ -60,28 +76,18 @@ export const MobileActionButtons = ({
60
76
  };
61
77
 
62
78
  const contentStyle = {
63
- flexDirection: model.container.stacking === "vertical" ? "column" : "row",
64
- alignSelf:
65
- placement !== "over_image" ? model.container.horizontalAlign : undefined,
79
+ ...containerPaddings,
80
+ flexDirection: isVertical ? "column" : "row",
81
+ width: isVertical ? "100%" : undefined,
82
+ alignSelf: !isOverImage ? model.container.horizontalAlign : undefined,
66
83
  alignItems: model.container.horizontalAlign,
67
- marginTop: model.container.margins.top,
68
- marginRight: model.container.margins.right,
69
- marginBottom: model.container.margins.bottom,
70
- marginLeft: model.container.margins.left,
71
84
  };
72
85
 
73
86
  const elements = compact(
74
87
  model.buttons.map(({ renderIndex, specificPrefix, stylePrefix }) => {
75
88
  const isNotLast = renderIndex < model.buttons.length - 1;
76
89
 
77
- const {
78
- container: { stacking, verticalGutter, horizontalGutter },
79
- } = model;
80
-
81
- const isVertical = stacking === "vertical";
82
- const gutter = isVertical ? verticalGutter : horizontalGutter;
83
-
84
- const spacingStyle = {
90
+ const spacingStyle: ViewStyle = {
85
91
  [isVertical ? "marginBottom" : "marginRight"]: isNotLast ? gutter : 0,
86
92
  };
87
93
 
@@ -91,6 +97,7 @@ export const MobileActionButtons = ({
91
97
  stylePrefix,
92
98
  specificPrefix,
93
99
  spacingStyle,
100
+ isVertical,
94
101
  });
95
102
 
96
103
  if (!button) return null;
@@ -5,14 +5,19 @@ import {
5
5
  } from "..";
6
6
 
7
7
  describe("mobile action insertion helpers", () => {
8
- const labels = [{ name: "text_label_1" }, { name: "text_label_2" }];
8
+ const slots = [
9
+ { name: "text_label_1", element: { type: "View", id: "text_label_1" } },
10
+ { name: "text_label_2", element: { type: "View", id: "text_label_2" } },
11
+ ];
12
+
13
+ const labels = slots.map((slot) => slot.element);
9
14
  const buttons = { type: "View", name: "buttons" };
10
15
 
11
16
  it("inserts label buttons below target label", () => {
12
17
  const result = insertButtonsBetweenLabels(
13
18
  { mobile_buttons_container_position: "below_text_label_1" },
14
19
  buttons,
15
- labels
20
+ slots
16
21
  );
17
22
 
18
23
  expect(result).toEqual([labels[0], buttons, labels[1]]);
@@ -22,7 +27,7 @@ describe("mobile action insertion helpers", () => {
22
27
  const result = insertButtonsBetweenLabels(
23
28
  { mobile_buttons_container_position: "unknown" },
24
29
  buttons,
25
- labels
30
+ slots
26
31
  );
27
32
 
28
33
  expect(result).toEqual([labels[0], labels[1]]);
@@ -8,7 +8,7 @@ import { Platform } from "react-native";
8
8
  export const insertButtonsBetweenLabels = (
9
9
  configuration: Record<string, unknown>,
10
10
  buttons,
11
- labels = []
11
+ slots = [] // { name, element } per canonical text label slot
12
12
  ) =>
13
13
  insertBetweenLabels(
14
14
  {
@@ -19,7 +19,7 @@ export const insertButtonsBetweenLabels = (
19
19
  appendWhenMissing: false,
20
20
  },
21
21
  buttons,
22
- labels // "text_label_1", "text_label_2", "text_label_3", "text_label_4"
22
+ slots
23
23
  );
24
24
 
25
25
  export const insertButtonsBetweenLabelContainers = (
@@ -3,18 +3,20 @@ import { insertButtonsBetweenLabels } from "..";
3
3
  describe("insertButtonsBetweenLabels - depthlevel 1", () => {
4
4
  const buttons = "buttons";
5
5
 
6
- const labels = [
7
- { name: "label_1" },
8
- { name: "label_2" },
9
- { name: "label_3" },
6
+ const slots = [
7
+ { name: "label_1", element: { id: "label_1" } },
8
+ { name: "label_2", element: { id: "label_2" } },
9
+ { name: "label_3", element: { id: "label_3" } },
10
10
  ];
11
11
 
12
+ const labels = slots.map((slot) => slot.element);
13
+
12
14
  it("put buttons on top", () => {
13
15
  const configuration = {
14
16
  tv_buttons_container_position: "on_top",
15
17
  };
16
18
 
17
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
19
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
18
20
 
19
21
  expect(result).toEqual([buttons, ...labels]);
20
22
  });
@@ -24,7 +26,7 @@ describe("insertButtonsBetweenLabels - depthlevel 1", () => {
24
26
  tv_buttons_container_position: "unknown_position",
25
27
  };
26
28
 
27
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
29
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
28
30
 
29
31
  expect(result).toEqual([...labels, buttons]);
30
32
  });
@@ -34,7 +36,7 @@ describe("insertButtonsBetweenLabels - depthlevel 1", () => {
34
36
  tv_buttons_container_position: "label_1",
35
37
  };
36
38
 
37
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
39
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
38
40
 
39
41
  expect(result).toEqual([labels[0], buttons, labels[1], labels[2]]);
40
42
  });
@@ -44,7 +46,7 @@ describe("insertButtonsBetweenLabels - depthlevel 1", () => {
44
46
  tv_buttons_container_position: "label_2",
45
47
  };
46
48
 
47
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
49
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
48
50
 
49
51
  expect(result).toEqual([labels[0], labels[1], buttons, labels[2]]);
50
52
  });
@@ -54,22 +56,52 @@ describe("insertButtonsBetweenLabels - depthlevel 1", () => {
54
56
  tv_buttons_container_position: "label_3",
55
57
  };
56
58
 
57
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
59
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
58
60
 
59
61
  expect(result).toEqual([labels[0], labels[1], labels[2], buttons]);
60
62
  });
61
63
 
62
- it("put underneath all", () => {
64
+ it("put above label_2", () => {
65
+ const configuration = {
66
+ tv_buttons_container_position: "above_label_2",
67
+ };
68
+
69
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
70
+
71
+ expect(result).toEqual([labels[0], buttons, labels[1], labels[2]]);
72
+ });
73
+
74
+ it("keeps the slot when its label is empty (null element)", () => {
75
+ const slotsWithEmpty = [
76
+ { name: "label_1", element: { id: "label_1" } },
77
+ { name: "label_2", element: null },
78
+ { name: "label_3", element: { id: "label_3" } },
79
+ ];
80
+
81
+ const configuration = {
82
+ tv_buttons_container_position: "above_label_2",
83
+ };
84
+
85
+ const result = insertButtonsBetweenLabels(
86
+ configuration,
87
+ buttons,
88
+ slotsWithEmpty
89
+ );
90
+
91
+ expect(result).toEqual([{ id: "label_1" }, buttons, { id: "label_3" }]);
92
+ });
93
+
94
+ it("appends buttons when the target is unknown", () => {
63
95
  const configuration = {
64
96
  tv_buttons_container_position: "label_X",
65
97
  };
66
98
 
67
- const result = insertButtonsBetweenLabels(configuration, buttons, labels);
99
+ const result = insertButtonsBetweenLabels(configuration, buttons, slots);
68
100
 
69
101
  expect(result).toEqual([labels[0], labels[1], labels[2], buttons]);
70
102
  });
71
103
 
72
- it("put underneath all", () => {
104
+ it("appends buttons when there are no slots", () => {
73
105
  const configuration = {
74
106
  tv_buttons_container_position: "label_X",
75
107
  };
@@ -88,7 +120,7 @@ describe("insertButtonsBetweenLabels - depthlevel 1", () => {
88
120
  tv_buttons_container_position: "label_X",
89
121
  };
90
122
 
91
- const result = insertButtonsBetweenLabels(configuration, null, labels);
123
+ const result = insertButtonsBetweenLabels(configuration, null, slots);
92
124
 
93
125
  expect(result).toEqual(labels);
94
126
  });
@@ -34,7 +34,7 @@ export const memoizedGetPluginIdentifier = memoizee(getPluginIdentifier);
34
34
  export const insertButtonsBetweenLabels = (
35
35
  configuration: Record<string, unknown>,
36
36
  buttons,
37
- labels = []
37
+ slots = [] // { name, element } per canonical text label slot
38
38
  ) =>
39
39
  insertBetweenLabels(
40
40
  {
@@ -45,7 +45,7 @@ export const insertButtonsBetweenLabels = (
45
45
  appendWhenMissing: true,
46
46
  },
47
47
  buttons,
48
- labels
48
+ slots
49
49
  );
50
50
 
51
51
  export const insertButtonsBetweenLabelContainers = (
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+
3
+ export const PressedStateContext = React.createContext<boolean>(false);
@@ -1 +1,3 @@
1
1
  export { useAsyncRendering } from "./useAsyncRendering";
2
+
3
+ export { usePressedState } from "./usePressedState";
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { PressedStateContext } from "../contexts/PressedStateContext";
3
+
4
+ export const usePressedState = () => React.useContext(PressedStateContext);
@@ -0,0 +1,314 @@
1
+ /**
2
+ * Modal Building Block — Action
3
+ *
4
+ * Single-file Expo Snack demo for the Action list item building block spec.
5
+ * Three forms (text only / leading icon + text / leading + text + trailing)
6
+ * are driven by data — no separate variants.
7
+ *
8
+ * Green (configurable): background, title, trailingIcon.chevronAsset
9
+ * White (hardcoded): container padding/gutter, icon size, leading icon assets,
10
+ * leading/trailing visibility logic from data
11
+ */
12
+
13
+ import React from "react";
14
+ import {
15
+ Image,
16
+ Platform,
17
+ Pressable,
18
+ StyleSheet,
19
+ Text,
20
+ View,
21
+ } from "react-native";
22
+
23
+ const styles = StyleSheet.create({
24
+ row: {
25
+ flexDirection: "row",
26
+ alignItems: "center",
27
+ },
28
+ });
29
+
30
+ // ---------------------------------------------------------------------------
31
+ // Configuration (green / editable fields from spec)
32
+ // ---------------------------------------------------------------------------
33
+
34
+ export type TextTransform =
35
+ | "default"
36
+ | "lowercase"
37
+ | "uppercase"
38
+ | "capitalize";
39
+
40
+ export type BackgroundConfiguration = {
41
+ defaultColor: string;
42
+ focusedColor: string;
43
+ cornerRadius: number;
44
+ };
45
+
46
+ export type TitleConfiguration = {
47
+ fontColor: string;
48
+ focusedFontColor: string;
49
+ iosFontFamily: string;
50
+ androidFontFamily: string;
51
+ fontSize: number;
52
+ lineHeight: number;
53
+ iosLetterSpacing: number;
54
+ androidLetterSpacing: number;
55
+ textTransform: TextTransform;
56
+ };
57
+
58
+ export type TrailingIconConfiguration = {
59
+ chevronAsset?: string;
60
+ };
61
+
62
+ export type ActionConfiguration = {
63
+ background: BackgroundConfiguration;
64
+ title: TitleConfiguration;
65
+ trailingIcon: TrailingIconConfiguration;
66
+ };
67
+
68
+ export const DEFAULT_BACKGROUND_CONFIGURATION: BackgroundConfiguration = {
69
+ defaultColor: "transparent",
70
+ focusedColor: "rgba(62, 62, 62, 1)",
71
+ cornerRadius: 12,
72
+ };
73
+
74
+ export const DEFAULT_TITLE_CONFIGURATION: TitleConfiguration = {
75
+ fontColor: "#FFFFFF",
76
+ focusedFontColor: "#FFFFFF",
77
+ iosFontFamily: "SFProText-Semibold",
78
+ androidFontFamily: "Roboto-Medium",
79
+ fontSize: 15,
80
+ lineHeight: 24,
81
+ iosLetterSpacing: -0.2,
82
+ androidLetterSpacing: 0,
83
+ textTransform: "default",
84
+ };
85
+
86
+ export const DEFAULT_TRAILING_ICON_CONFIGURATION: TrailingIconConfiguration =
87
+ {};
88
+
89
+ export const DEFAULT_ACTION_CONFIGURATION: ActionConfiguration = {
90
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
91
+ title: DEFAULT_TITLE_CONFIGURATION,
92
+ trailingIcon: DEFAULT_TRAILING_ICON_CONFIGURATION,
93
+ };
94
+
95
+ // ---------------------------------------------------------------------------
96
+ // Data (runtime — controls which elements are shown)
97
+ // ---------------------------------------------------------------------------
98
+
99
+ export type LeadingActionType =
100
+ | "addToQueue"
101
+ | "addToPlaylist"
102
+ | "favorite"
103
+ | "share"
104
+ | "sleepTimer"
105
+ | "playbackSpeed";
106
+
107
+ export type ActionData = {
108
+ title: string;
109
+ /** When set, leading icon is shown (Enable: On). */
110
+ leadingActionType?: LeadingActionType;
111
+ /** When true, trailing chevron is shown (Enable: On). */
112
+ showTrailingChevron?: boolean;
113
+ };
114
+
115
+ export type AudioPlayerActionProps = {
116
+ configuration: ActionConfiguration;
117
+ data: ActionData;
118
+ focused?: boolean;
119
+ onPress?: () => void;
120
+ };
121
+
122
+ // ---------------------------------------------------------------------------
123
+ // Hardcoded spec values (white fields)
124
+ // ---------------------------------------------------------------------------
125
+
126
+ const CONTAINER_SPEC = {
127
+ paddingTop: 13,
128
+ paddingRight: 10,
129
+ paddingBottom: 13,
130
+ paddingLeft: 10,
131
+ horizontalGutter: 12,
132
+ };
133
+
134
+ const ICON_SPEC = {
135
+ width: 24,
136
+ height: 24,
137
+ };
138
+
139
+ const DEFAULT_CHEVRON_ASSET =
140
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAALElEQVR42mNgGAXUBlu2bPmPjIeWBeiGDy0Lhrbrh1/qGXqZaxSMglEw0gEA4c+IpUrpYX4AAAAASUVORK5CYII=";
141
+
142
+ /** Hardcoded: action type → leading icon asset (base64 PNG). */
143
+ const LEADING_ICON_ASSETS: Record<LeadingActionType, string> = {
144
+ addToQueue:
145
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAALElEQVR42mNgGAUjE/xHAzS3gFgweC0Y+nEwGslkBRFFwTj8LBjNyaNgmAMAJTf+EEEZcS0AAAAASUVORK5CYII=",
146
+ addToPlaylist:
147
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKUlEQVR42mNgGAVDBvxHA6MWjFpAvEGkglELKLdgNJmOWkA7C0YBzQAAivu+UKRR1ZIAAAAASUVORK5CYII=",
148
+ favorite:
149
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKklEQVR42mNgGAWjYBTgBP+xAGLkRi0YQhbgM4wqBo9aMHgsGAWjgCAAALyAZqh4yyZZAAAAAElFTkSuQmCC",
150
+ share:
151
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAK0lEQVR42mNgGAVDDvxHAqMWjFowUiz4TwQYgRYQYxBFlo1aMPAWjAK6AgD2g7pUUT7VeAAAAABJRU5ErkJggg==",
152
+ sleepTimer:
153
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAYUlEQVR42tWUSQ4AIAgD+f+n8eJRliIQ6MmEZTSxJZokvipdXgZpAbzOO17AglIXI7XULxmCoEMwRGuWam6AdRsN4IJYTRH4PIDkhxTA92zUPNBcFDDHaOVR0RJ2LXG9QgemFVK8tpo4PwAAAABJRU5ErkJggg==",
154
+ playbackSpeed:
155
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAK0lEQVR42mNgGAVDDvxHAqMWjFowUiz4TwQYgRYQYxBFlo1aMPAWjAK6AgD2g7pUUT7VeAAAAABJRU5ErkJggg==",
156
+ };
157
+
158
+ function getTextTransformStyle(
159
+ textTransform: TextTransform
160
+ ): "none" | "lowercase" | "uppercase" | "capitalize" {
161
+ return textTransform === "default" ? "none" : textTransform;
162
+ }
163
+
164
+ function shouldShowLeadingIcon(leadingActionType?: LeadingActionType) {
165
+ return !!leadingActionType;
166
+ }
167
+
168
+ function shouldShowTrailingIcon(showTrailingChevron?: boolean) {
169
+ return !!showTrailingChevron;
170
+ }
171
+
172
+ // ---------------------------------------------------------------------------
173
+ // Inner components
174
+ // ---------------------------------------------------------------------------
175
+
176
+ type ActionContainerProps = {
177
+ configuration: BackgroundConfiguration;
178
+ focused: boolean;
179
+ children: React.ReactNode;
180
+ onPress?: () => void;
181
+ };
182
+
183
+ function ActionContainer({
184
+ configuration,
185
+ focused,
186
+ children,
187
+ onPress,
188
+ }: ActionContainerProps) {
189
+ return (
190
+ <Pressable
191
+ onPress={onPress}
192
+ style={({ pressed }) => ({
193
+ backgroundColor:
194
+ pressed || focused
195
+ ? configuration.focusedColor
196
+ : configuration.defaultColor,
197
+ borderRadius: configuration.cornerRadius,
198
+ paddingTop: CONTAINER_SPEC.paddingTop,
199
+ paddingRight: CONTAINER_SPEC.paddingRight,
200
+ paddingBottom: CONTAINER_SPEC.paddingBottom,
201
+ paddingLeft: CONTAINER_SPEC.paddingLeft,
202
+ })}
203
+ >
204
+ {children}
205
+ </Pressable>
206
+ );
207
+ }
208
+
209
+ type ActionTitleProps = {
210
+ title: string;
211
+ configuration: TitleConfiguration;
212
+ focused: boolean;
213
+ };
214
+
215
+ function ActionTitle({ title, configuration, focused }: ActionTitleProps) {
216
+ const letterSpacing =
217
+ Platform.OS === "ios"
218
+ ? configuration.iosLetterSpacing
219
+ : configuration.androidLetterSpacing;
220
+
221
+ return (
222
+ <Text
223
+ style={{
224
+ flex: 1,
225
+ color: focused
226
+ ? configuration.focusedFontColor
227
+ : configuration.fontColor,
228
+ fontSize: configuration.fontSize,
229
+ lineHeight: configuration.lineHeight,
230
+ letterSpacing,
231
+ fontFamily: Platform.select({
232
+ ios: configuration.iosFontFamily,
233
+ android: configuration.androidFontFamily,
234
+ default: configuration.androidFontFamily,
235
+ }),
236
+ textTransform: getTextTransformStyle(configuration.textTransform),
237
+ }}
238
+ numberOfLines={1}
239
+ >
240
+ {title}
241
+ </Text>
242
+ );
243
+ }
244
+
245
+ type ActionLeadingIconProps = {
246
+ actionType: LeadingActionType;
247
+ };
248
+
249
+ function ActionLeadingIcon({ actionType }: ActionLeadingIconProps) {
250
+ return (
251
+ <Image
252
+ source={{ uri: LEADING_ICON_ASSETS[actionType] }}
253
+ style={{ width: ICON_SPEC.width, height: ICON_SPEC.height }}
254
+ resizeMode="contain"
255
+ />
256
+ );
257
+ }
258
+
259
+ type ActionTrailingIconProps = {
260
+ configuration: TrailingIconConfiguration;
261
+ };
262
+
263
+ function ActionTrailingIcon({ configuration }: ActionTrailingIconProps) {
264
+ const asset = configuration.chevronAsset ?? DEFAULT_CHEVRON_ASSET;
265
+
266
+ return (
267
+ <Image
268
+ source={{ uri: asset }}
269
+ style={{ width: ICON_SPEC.width, height: ICON_SPEC.height }}
270
+ resizeMode="contain"
271
+ />
272
+ );
273
+ }
274
+
275
+ // ---------------------------------------------------------------------------
276
+ // AudioPlayerAction
277
+ // ---------------------------------------------------------------------------
278
+
279
+ export function AudioPlayerAction({
280
+ configuration,
281
+ data,
282
+ focused = false,
283
+ onPress,
284
+ }: AudioPlayerActionProps) {
285
+ const { background, title, trailingIcon } = configuration;
286
+ const { title: label, leadingActionType, showTrailingChevron } = data;
287
+
288
+ const showLeading = shouldShowLeadingIcon(leadingActionType);
289
+ const showTrailing = shouldShowTrailingIcon(showTrailingChevron);
290
+
291
+ return (
292
+ <ActionContainer
293
+ configuration={background}
294
+ focused={focused}
295
+ onPress={onPress}
296
+ >
297
+ <View style={styles.row}>
298
+ {showLeading ? (
299
+ <>
300
+ <ActionLeadingIcon actionType={leadingActionType} />
301
+ <View style={{ width: CONTAINER_SPEC.horizontalGutter }} />
302
+ </>
303
+ ) : null}
304
+ <ActionTitle title={label} configuration={title} focused={focused} />
305
+ {showTrailing ? (
306
+ <>
307
+ <View style={{ width: CONTAINER_SPEC.horizontalGutter }} />
308
+ <ActionTrailingIcon configuration={trailingIcon} />
309
+ </>
310
+ ) : null}
311
+ </View>
312
+ </ActionContainer>
313
+ );
314
+ }