@applicaster/zapp-react-native-ui-components 16.0.0-rc.4 → 16.0.0-rc.41

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 (100) hide show
  1. package/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
  2. package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
  3. package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
  4. package/Components/BackgroundImage/index.ts +1 -0
  5. package/Components/CellRendererResolver/index.ts +2 -2
  6. package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
  7. package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
  8. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  9. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  10. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  11. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  12. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  13. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
  14. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  15. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  16. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  17. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
  18. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  19. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  20. package/Components/GeneralContentScreen/index.ts +2 -0
  21. package/Components/Layout/FullWidthRow.tsx +38 -0
  22. package/Components/Layout/TV/ScreenContainer.tsx +5 -0
  23. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  24. package/Components/Layout/TV/index.tsx +3 -4
  25. package/Components/Layout/TV/index.web.tsx +2 -3
  26. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  27. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
  28. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
  29. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
  30. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
  31. package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
  32. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
  33. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
  34. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
  35. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
  36. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
  37. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
  38. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
  39. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
  40. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
  41. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
  42. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
  43. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
  44. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
  45. package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
  46. package/Components/MasterCell/dataAdapter.ts +15 -5
  47. package/Components/MasterCell/hooks/index.ts +2 -0
  48. package/Components/MasterCell/hooks/usePressedState.ts +4 -0
  49. package/Components/MasterCell/index.tsx +30 -5
  50. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  51. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  52. package/Components/MasterCell/utils/index.ts +85 -46
  53. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +332 -0
  54. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +402 -0
  55. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +811 -0
  56. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
  57. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +878 -0
  58. package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
  59. package/Components/ModalComponent/BottomSheetModalContent.tsx +34 -18
  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 +14 -10
  66. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
  67. package/Components/PreloaderWrapper/index.tsx +1 -1
  68. package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
  69. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
  70. package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
  71. package/Components/Screen/TV/hooks/index.ts +2 -0
  72. package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
  73. package/Components/Screen/TV/index.web.tsx +16 -7
  74. package/Components/Screen/index.tsx +8 -4
  75. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
  76. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
  77. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  78. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  79. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
  80. package/Components/TopCutoffOverlay/index.tsx +2 -2
  81. package/Components/Transitioner/Transitioner.tsx +28 -17
  82. package/Components/VideoLive/LiveImageManager.ts +56 -45
  83. package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
  84. package/Components/VideoModal/utils.ts +6 -1
  85. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
  86. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  87. package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
  88. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  89. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  90. package/Helpers/index.js +7 -40
  91. package/package.json +5 -5
  92. package/Components/Layout/TV/LayoutBackground.tsx +0 -31
  93. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
  94. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
  95. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
  96. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
  97. package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
  98. package/Components/Screen/utils.ts +0 -16
  99. package/Helpers/Analytics/index.js +0 -95
  100. /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
@@ -0,0 +1,878 @@
1
+ /**
2
+ * Modal Building Block — Item (Queue / Playlist)
3
+ *
4
+ * Single-file Expo Snack demo. Three item forms driven by configuration + data.
5
+ *
6
+ * Green (configurable): background, image, nowPlayingAsset, nowPlayingLabel,
7
+ * textLabel1, textLabel2
8
+ * White (hardcoded): container padding/gutters, nowPlaying container layout,
9
+ * button sizes/padding/assets
10
+ *
11
+ * Variants (VARIANT_*) are preset configuration bundles — not passed as a field.
12
+ */
13
+
14
+ import React from "react";
15
+ import {
16
+ Image,
17
+ Platform,
18
+ Pressable,
19
+ StyleSheet,
20
+ Text,
21
+ View,
22
+ } from "react-native";
23
+
24
+ const styles = StyleSheet.create({
25
+ row: {
26
+ flexDirection: "row",
27
+ alignItems: "center",
28
+ },
29
+ contentColumn: {
30
+ flex: 1,
31
+ justifyContent: "center",
32
+ },
33
+ buttonsRow: {
34
+ flexDirection: "row",
35
+ alignItems: "center",
36
+ },
37
+ demoScreen: {
38
+ flex: 1,
39
+ backgroundColor: "#1C1C1E",
40
+ paddingTop: 64,
41
+ paddingHorizontal: 0,
42
+ gap: 16,
43
+ },
44
+ demoHeading: {
45
+ color: "#FFFFFF",
46
+ fontSize: 20,
47
+ fontWeight: "600",
48
+ marginBottom: 8,
49
+ paddingHorizontal: 16,
50
+ },
51
+ demoLabel: {
52
+ color: "#999999",
53
+ fontSize: 13,
54
+ paddingHorizontal: 16,
55
+ },
56
+ });
57
+
58
+ // ---------------------------------------------------------------------------
59
+ // Configuration (green fields)
60
+ // ---------------------------------------------------------------------------
61
+
62
+ export type TextTransform =
63
+ | "default"
64
+ | "lowercase"
65
+ | "uppercase"
66
+ | "capitalize";
67
+
68
+ export type BackgroundConfiguration = {
69
+ defaultColor: string;
70
+ focusedColor: string;
71
+ cornerRadius: number;
72
+ };
73
+
74
+ export type ImageConfiguration = {
75
+ width: number;
76
+ height: number;
77
+ borderWidth: number;
78
+ borderColor: string;
79
+ cornerRadius: number;
80
+ };
81
+
82
+ export type LabelConfiguration = {
83
+ fontColor: string;
84
+ focusedFontColor?: string;
85
+ iosFontFamily: string;
86
+ androidFontFamily: string;
87
+ fontSize: number;
88
+ lineHeight: number;
89
+ iosLetterSpacing: number;
90
+ androidLetterSpacing: number;
91
+ textTransform: TextTransform;
92
+ };
93
+
94
+ export type NowPlayingAssetConfiguration = {
95
+ asset?: string;
96
+ };
97
+
98
+ export type ItemConfiguration = {
99
+ background: BackgroundConfiguration;
100
+ image: ImageConfiguration;
101
+ nowPlayingAsset: NowPlayingAssetConfiguration;
102
+ nowPlayingLabel: LabelConfiguration;
103
+ textLabel1: LabelConfiguration;
104
+ textLabel2: LabelConfiguration;
105
+ };
106
+
107
+ export interface Action {
108
+ type: string;
109
+ payload?: any;
110
+ options?: any;
111
+ }
112
+
113
+ export interface Header {
114
+ title: string;
115
+ subtitle?: string;
116
+ icon?: string;
117
+ }
118
+
119
+ export interface Content {
120
+ title: string;
121
+ stickyTitle?: boolean;
122
+ items: MenuItem[];
123
+ itemsUrl?: string;
124
+ action?: Action;
125
+ }
126
+
127
+ export interface Menu {
128
+ header?: Header;
129
+ content: Content;
130
+ closeButton?: boolean;
131
+ }
132
+
133
+ export interface PresentSubMenuAction extends Action {
134
+ menu: Menu;
135
+ }
136
+
137
+ export interface SecondaryAction {
138
+ action: Action | PresentSubMenuAction;
139
+ icon?: string;
140
+ }
141
+
142
+ export interface MenuItem {
143
+ trailingButton?: ItemButtonAction;
144
+ title: string;
145
+ summary?: string;
146
+ icon?: string;
147
+ isSelected?: boolean;
148
+ action?: Action | PresentSubMenuAction;
149
+ secondaryAction?: SecondaryAction;
150
+ }
151
+
152
+ export const DEFAULT_TEXT_LABEL_1_CONFIGURATION: LabelConfiguration = {
153
+ fontColor: "#FFFFFF",
154
+ focusedFontColor: "#FFFFFF",
155
+ iosFontFamily: "SFProText-Semibold",
156
+ androidFontFamily: "Roboto-Medium",
157
+ fontSize: 15,
158
+ lineHeight: 18,
159
+ iosLetterSpacing: -0.2,
160
+ androidLetterSpacing: 0,
161
+ textTransform: "default",
162
+ };
163
+
164
+ export const DEFAULT_TEXT_LABEL_2_CONFIGURATION: LabelConfiguration = {
165
+ fontColor: "#999999",
166
+ iosFontFamily: "SFProText-Medium",
167
+ androidFontFamily: "Roboto-Medium",
168
+ fontSize: 13,
169
+ lineHeight: 16,
170
+ iosLetterSpacing: -0.1,
171
+ androidLetterSpacing: 0,
172
+ textTransform: "default",
173
+ };
174
+
175
+ export const DEFAULT_NOW_PLAYING_LABEL_CONFIGURATION: LabelConfiguration = {
176
+ fontColor: "#FFFFFF",
177
+ iosFontFamily: "SFProText-Semibold",
178
+ androidFontFamily: "Roboto-Medium",
179
+ fontSize: 13,
180
+ lineHeight: 16,
181
+ iosLetterSpacing: 0,
182
+ androidLetterSpacing: 0,
183
+ textTransform: "default",
184
+ };
185
+
186
+ // ---------------------------------------------------------------------------
187
+ // Data
188
+ // ---------------------------------------------------------------------------
189
+
190
+ export type ItemButtonAction = "playPause" | "drag" | "multiSelect" | "remove";
191
+
192
+ export type ItemData = {
193
+ imageUri?: string;
194
+ textLabel1: string;
195
+ textLabel2: string;
196
+ /** When set, shows the Now Playing row (equalizer + label). */
197
+ nowPlayingLabel?: string;
198
+ /** Button 2 (left most) — hardcoded action decides icon. */
199
+ leadingButton?: ItemButtonAction;
200
+ /** Button 1 (right most) — hardcoded action decides icon. */
201
+ trailingButton?: ItemButtonAction;
202
+ isSelected?: boolean;
203
+ };
204
+
205
+ export type AudioPlayerTrackItemProps = {
206
+ configuration: ItemConfiguration;
207
+ data: ItemData;
208
+ focused?: boolean;
209
+ focusedLeadingButton?: boolean;
210
+ focusedTrailingButton?: boolean;
211
+ onPress?: () => void;
212
+ onLeadingButtonPress?: () => void;
213
+ onTrailingButtonPress?: () => void;
214
+ };
215
+
216
+ // ---------------------------------------------------------------------------
217
+ // Hardcoded (white fields)
218
+ // ---------------------------------------------------------------------------
219
+
220
+ type ContainerSpec = {
221
+ paddingTop: number;
222
+ paddingRight: number;
223
+ paddingBottom: number;
224
+ paddingLeft: number;
225
+ horizontalGutter: number;
226
+ verticalGutter: number;
227
+ };
228
+
229
+ type ButtonLayoutSpec = {
230
+ assetWidth: number;
231
+ assetHeight: number;
232
+ paddingTop: number;
233
+ paddingRight: number;
234
+ paddingBottom: number;
235
+ paddingLeft: number;
236
+ };
237
+
238
+ const CONTAINER_SPEC_LARGE_IMAGE: ContainerSpec = {
239
+ paddingTop: 8,
240
+ paddingRight: 20,
241
+ paddingBottom: 8,
242
+ paddingLeft: 20,
243
+ horizontalGutter: 12,
244
+ verticalGutter: 2,
245
+ };
246
+
247
+ const CONTAINER_SPEC_DEFAULT: ContainerSpec = {
248
+ paddingTop: 8,
249
+ paddingRight: 20,
250
+ paddingBottom: 8,
251
+ paddingLeft: 20,
252
+ horizontalGutter: 12,
253
+ verticalGutter: 2,
254
+ };
255
+
256
+ const BUTTONS_CONTAINER_HORIZONTAL_GUTTER = 4;
257
+
258
+ const NOW_PLAYING_CONTAINER_SPEC = {
259
+ horizontalGutter: 4,
260
+ marginTop: 0,
261
+ marginRight: 0,
262
+ marginBottom: 6,
263
+ marginLeft: 0,
264
+ };
265
+
266
+ const NOW_PLAYING_ASSET_SPEC = {
267
+ width: 16,
268
+ height: 16,
269
+ };
270
+
271
+ const BUTTON_LAYOUT_SPEC: Record<ItemButtonAction, ButtonLayoutSpec> = {
272
+ playPause: {
273
+ assetWidth: 44,
274
+ assetHeight: 44,
275
+ paddingTop: 0,
276
+ paddingRight: 0,
277
+ paddingBottom: 0,
278
+ paddingLeft: 0,
279
+ },
280
+ drag: {
281
+ assetWidth: 24,
282
+ assetHeight: 24,
283
+ paddingTop: 10,
284
+ paddingRight: 10,
285
+ paddingBottom: 10,
286
+ paddingLeft: 10,
287
+ },
288
+ multiSelect: {
289
+ assetWidth: 24,
290
+ assetHeight: 24,
291
+ paddingTop: 10,
292
+ paddingRight: 10,
293
+ paddingBottom: 10,
294
+ paddingLeft: 10,
295
+ },
296
+ remove: {
297
+ assetWidth: 24,
298
+ assetHeight: 24,
299
+ paddingTop: 10,
300
+ paddingRight: 10,
301
+ paddingBottom: 10,
302
+ paddingLeft: 10,
303
+ },
304
+ };
305
+
306
+ const DEFAULT_THUMB_ASSET =
307
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAQklEQVR42u3PMQ0AAAgDsEmcfzNggZekRwU0beezCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAhcLQVXaABdK6k6AAAAAElFTkSuQmCC";
308
+
309
+ const DEFAULT_EQUALIZER_ASSET =
310
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAI0lEQVR42mNgGNTgPxTQzwB0DVQ3gKCBowbQwYAhkBIHBAAA9TvPMeOFaLMAAAAASUVORK5CYII=";
311
+
312
+ function getTextTransformStyle(
313
+ textTransform: TextTransform
314
+ ): "none" | "lowercase" | "uppercase" | "capitalize" {
315
+ return textTransform === "default" ? "none" : textTransform;
316
+ }
317
+
318
+ function getFontFamily(ios: string, android: string) {
319
+ return Platform.select({ ios, android, default: android });
320
+ }
321
+
322
+ /** Hardcoded: large image (72) uses wider horizontal container padding. */
323
+ function resolveContainerSpec(image: ImageConfiguration): ContainerSpec {
324
+ return image.width >= 72
325
+ ? CONTAINER_SPEC_LARGE_IMAGE
326
+ : CONTAINER_SPEC_DEFAULT;
327
+ }
328
+
329
+ export function mapMenuItemToNowPlayingData(item: MenuItem): ItemData {
330
+ return {
331
+ imageUri: item.icon,
332
+ textLabel1: item.title,
333
+ textLabel2: item.summary ?? "",
334
+ nowPlayingLabel: "Now Playing",
335
+ trailingButton: "playPause",
336
+ isSelected: item.isSelected,
337
+ };
338
+ }
339
+
340
+ export function mapMenuItemToQueuedData(item: MenuItem): ItemData {
341
+ return {
342
+ imageUri: item.icon,
343
+ textLabel1: item.title,
344
+ textLabel2: item.summary ?? "",
345
+ leadingButton: "remove",
346
+ trailingButton: "drag",
347
+ isSelected: item.isSelected,
348
+ };
349
+ }
350
+
351
+ export function mapMenuItemToPlaylistData(item: MenuItem): ItemData {
352
+ return {
353
+ imageUri: item.icon,
354
+ textLabel1: item.title,
355
+ textLabel2: item.summary ?? "",
356
+ trailingButton: item.trailingButton || ("multiSelect" as ItemButtonAction),
357
+ isSelected: item.isSelected,
358
+ };
359
+ }
360
+
361
+ // ---------------------------------------------------------------------------
362
+ // Inner components
363
+ // ---------------------------------------------------------------------------
364
+
365
+ type ItemContainerProps = {
366
+ image: ImageConfiguration;
367
+ background: BackgroundConfiguration;
368
+ focused: boolean;
369
+ children: React.ReactNode;
370
+ onPress?: () => void;
371
+ };
372
+
373
+ function ItemContainer({
374
+ image,
375
+ background,
376
+ focused,
377
+ children,
378
+ onPress,
379
+ }: ItemContainerProps) {
380
+ const container = resolveContainerSpec(image);
381
+ const bg = focused ? background.focusedColor : background.defaultColor;
382
+
383
+ return (
384
+ <Pressable
385
+ onPress={onPress}
386
+ style={({ pressed }) => ({
387
+ backgroundColor: pressed ? background.focusedColor : bg,
388
+ borderRadius: background.cornerRadius,
389
+ paddingTop: container.paddingTop,
390
+ paddingRight: container.paddingRight,
391
+ paddingBottom: container.paddingBottom,
392
+ paddingLeft: container.paddingLeft,
393
+ })}
394
+ >
395
+ {children}
396
+ </Pressable>
397
+ );
398
+ }
399
+
400
+ type ItemThumbnailProps = {
401
+ configuration: ImageConfiguration;
402
+ imageUri?: string;
403
+ };
404
+
405
+ function ItemThumbnail({ configuration, imageUri }: ItemThumbnailProps) {
406
+ return (
407
+ <Image
408
+ source={{ uri: imageUri ?? DEFAULT_THUMB_ASSET }}
409
+ style={{
410
+ width: configuration.width,
411
+ height: configuration.height,
412
+ borderWidth: configuration.borderWidth,
413
+ borderColor: configuration.borderColor,
414
+ borderRadius: configuration.cornerRadius,
415
+ }}
416
+ resizeMode="cover"
417
+ />
418
+ );
419
+ }
420
+
421
+ type ItemLabelProps = {
422
+ text: string;
423
+ configuration: LabelConfiguration;
424
+ focused?: boolean;
425
+ };
426
+
427
+ function ItemLabel({ text, configuration, focused = false }: ItemLabelProps) {
428
+ const color =
429
+ focused && configuration.focusedFontColor
430
+ ? configuration.focusedFontColor
431
+ : configuration.fontColor;
432
+
433
+ return (
434
+ <Text
435
+ style={{
436
+ color,
437
+ fontSize: configuration.fontSize,
438
+ lineHeight: configuration.lineHeight,
439
+ letterSpacing:
440
+ Platform.OS === "ios"
441
+ ? configuration.iosLetterSpacing
442
+ : configuration.androidLetterSpacing,
443
+ fontFamily: getFontFamily(
444
+ configuration.iosFontFamily,
445
+ configuration.androidFontFamily
446
+ ),
447
+ textTransform: getTextTransformStyle(configuration.textTransform),
448
+ }}
449
+ numberOfLines={1}
450
+ >
451
+ {text}
452
+ </Text>
453
+ );
454
+ }
455
+
456
+ type NowPlayingRowProps = {
457
+ assetConfiguration: NowPlayingAssetConfiguration;
458
+ labelConfiguration: LabelConfiguration;
459
+ label: string;
460
+ };
461
+
462
+ function NowPlayingRow({
463
+ assetConfiguration,
464
+ labelConfiguration,
465
+ label,
466
+ }: NowPlayingRowProps) {
467
+ const asset = assetConfiguration.asset ?? DEFAULT_EQUALIZER_ASSET;
468
+
469
+ return (
470
+ <View
471
+ style={{
472
+ flexDirection: "row",
473
+ alignItems: "center",
474
+ marginTop: NOW_PLAYING_CONTAINER_SPEC.marginTop,
475
+ marginRight: NOW_PLAYING_CONTAINER_SPEC.marginRight,
476
+ marginBottom: NOW_PLAYING_CONTAINER_SPEC.marginBottom,
477
+ marginLeft: NOW_PLAYING_CONTAINER_SPEC.marginLeft,
478
+ }}
479
+ >
480
+ <Image
481
+ source={{ uri: asset }}
482
+ style={{
483
+ width: NOW_PLAYING_ASSET_SPEC.width,
484
+ height: NOW_PLAYING_ASSET_SPEC.height,
485
+ }}
486
+ resizeMode="contain"
487
+ />
488
+ <View style={{ width: NOW_PLAYING_CONTAINER_SPEC.horizontalGutter }} />
489
+ <ItemLabel text={label} configuration={labelConfiguration} />
490
+ </View>
491
+ );
492
+ }
493
+
494
+ type ItemButtonProps = {
495
+ action: ItemButtonAction;
496
+ focused?: boolean;
497
+ onPress?: () => void;
498
+ isSelected?: boolean;
499
+ };
500
+
501
+ function ItemButton({
502
+ action,
503
+ focused = false,
504
+ onPress,
505
+ isSelected = false,
506
+ }: ItemButtonProps) {
507
+ const layout = BUTTON_LAYOUT_SPEC[action];
508
+
509
+ const renderIcon = () => {
510
+ switch (action) {
511
+ case "playPause": {
512
+ const iconSize = layout.assetWidth;
513
+ const iconRadius = iconSize / 2;
514
+
515
+ return (
516
+ <View
517
+ style={{
518
+ width: iconSize,
519
+ height: iconSize,
520
+ borderRadius: iconRadius,
521
+ backgroundColor: "#FFFFFF",
522
+ justifyContent: "center",
523
+ alignItems: "center",
524
+ }}
525
+ >
526
+ {isSelected ? (
527
+ <View
528
+ style={{
529
+ flexDirection: "row",
530
+ justifyContent: "space-between",
531
+ width: 10,
532
+ height: 16,
533
+ }}
534
+ >
535
+ <View
536
+ style={{
537
+ width: 3.5,
538
+ height: 16,
539
+ backgroundColor: "#1e1e1e",
540
+ borderRadius: 1,
541
+ }}
542
+ />
543
+ <View
544
+ style={{
545
+ width: 3.5,
546
+ height: 16,
547
+ backgroundColor: "#1e1e1e",
548
+ borderRadius: 1,
549
+ }}
550
+ />
551
+ </View>
552
+ ) : (
553
+ <View
554
+ style={{
555
+ width: 0,
556
+ height: 0,
557
+ backgroundColor: "transparent",
558
+ borderStyle: "solid",
559
+ borderLeftWidth: 14,
560
+ borderRightWidth: 0,
561
+ borderTopWidth: 8,
562
+ borderBottomWidth: 8,
563
+ borderLeftColor: "#1e1e1e",
564
+ borderRightColor: "transparent",
565
+ borderTopColor: "transparent",
566
+ borderBottomColor: "transparent",
567
+ marginLeft: 3,
568
+ }}
569
+ />
570
+ )}
571
+ </View>
572
+ );
573
+ }
574
+
575
+ case "drag": {
576
+ return (
577
+ <View
578
+ style={{
579
+ width: 20,
580
+ height: 12,
581
+ justifyContent: "space-between",
582
+ }}
583
+ >
584
+ <View
585
+ style={{
586
+ height: 2,
587
+ backgroundColor: "rgba(255, 255, 255, 0.7)",
588
+ borderRadius: 1,
589
+ }}
590
+ />
591
+ <View
592
+ style={{
593
+ height: 2,
594
+ backgroundColor: "rgba(255, 255, 255, 0.7)",
595
+ borderRadius: 1,
596
+ }}
597
+ />
598
+ <View
599
+ style={{
600
+ height: 2,
601
+ backgroundColor: "rgba(255, 255, 255, 0.7)",
602
+ borderRadius: 1,
603
+ }}
604
+ />
605
+ </View>
606
+ );
607
+ }
608
+
609
+ case "remove": {
610
+ return (
611
+ <View
612
+ style={{
613
+ width: 24,
614
+ height: 24,
615
+ borderRadius: 12,
616
+ borderWidth: 1.5,
617
+ borderColor: "rgba(255, 255, 255, 0.7)",
618
+ justifyContent: "center",
619
+ alignItems: "center",
620
+ }}
621
+ >
622
+ <View
623
+ style={{
624
+ width: 10,
625
+ height: 1.5,
626
+ backgroundColor: "rgba(255, 255, 255, 0.7)",
627
+ borderRadius: 1,
628
+ }}
629
+ />
630
+ </View>
631
+ );
632
+ }
633
+
634
+ case "multiSelect": {
635
+ if (!isSelected) {
636
+ return (
637
+ <View
638
+ style={{
639
+ width: layout.assetWidth,
640
+ height: layout.assetHeight,
641
+ borderRadius: layout.assetWidth / 2,
642
+ borderWidth: 1.5,
643
+ borderColor: "rgba(255, 255, 255, 0.7)",
644
+ backgroundColor: "transparent",
645
+ }}
646
+ />
647
+ );
648
+ }
649
+
650
+ return (
651
+ <View
652
+ style={{
653
+ width: 24,
654
+ height: 24,
655
+ borderRadius: 12,
656
+ backgroundColor: "#FFFFFF",
657
+ justifyContent: "center",
658
+ alignItems: "center",
659
+ }}
660
+ >
661
+ <View
662
+ style={{
663
+ width: 6,
664
+ height: 10,
665
+ borderBottomWidth: 2,
666
+ borderRightWidth: 2,
667
+ borderColor: "#1e1e1e",
668
+ transform: [{ rotate: "45deg" }],
669
+ marginTop: -2,
670
+ }}
671
+ />
672
+ </View>
673
+ );
674
+ }
675
+
676
+ default:
677
+ return null;
678
+ }
679
+ };
680
+
681
+ return (
682
+ <Pressable
683
+ onPress={onPress}
684
+ style={({ pressed }) => [
685
+ {
686
+ paddingTop: layout.paddingTop,
687
+ paddingRight: layout.paddingRight,
688
+ paddingBottom: layout.paddingBottom,
689
+ paddingLeft: layout.paddingLeft,
690
+ opacity: pressed || focused ? 0.7 : 1,
691
+ },
692
+ ]}
693
+ >
694
+ {renderIcon()}
695
+ </Pressable>
696
+ );
697
+ }
698
+
699
+ type ItemButtonsProps = {
700
+ leadingButton?: ItemButtonAction;
701
+ trailingButton?: ItemButtonAction;
702
+ focusedLeadingButton?: boolean;
703
+ focusedTrailingButton?: boolean;
704
+ onLeadingButtonPress?: () => void;
705
+ onTrailingButtonPress?: () => void;
706
+ isSelected?: boolean;
707
+ };
708
+
709
+ function ItemButtons({
710
+ leadingButton,
711
+ trailingButton,
712
+ focusedLeadingButton = false,
713
+ focusedTrailingButton = false,
714
+ onLeadingButtonPress,
715
+ onTrailingButtonPress,
716
+ isSelected = false,
717
+ }: ItemButtonsProps) {
718
+ if (!leadingButton && !trailingButton) {
719
+ return null;
720
+ }
721
+
722
+ return (
723
+ <View style={styles.buttonsRow}>
724
+ {leadingButton ? (
725
+ <>
726
+ <ItemButton
727
+ action={leadingButton}
728
+ focused={focusedLeadingButton}
729
+ onPress={onLeadingButtonPress}
730
+ isSelected={isSelected}
731
+ />
732
+ <View style={{ width: BUTTONS_CONTAINER_HORIZONTAL_GUTTER }} />
733
+ </>
734
+ ) : null}
735
+ {trailingButton ? (
736
+ <ItemButton
737
+ action={trailingButton}
738
+ focused={focusedTrailingButton}
739
+ onPress={onTrailingButtonPress}
740
+ isSelected={isSelected}
741
+ />
742
+ ) : null}
743
+ </View>
744
+ );
745
+ }
746
+
747
+ // ---------------------------------------------------------------------------
748
+ // AudioPlayerTrackItem
749
+ // ---------------------------------------------------------------------------
750
+
751
+ export function AudioPlayerTrackItem({
752
+ configuration,
753
+ data,
754
+ focused = false,
755
+ focusedLeadingButton = false,
756
+ focusedTrailingButton = false,
757
+ onPress,
758
+ onLeadingButtonPress,
759
+ onTrailingButtonPress,
760
+ }: AudioPlayerTrackItemProps) {
761
+ const {
762
+ background,
763
+ image,
764
+ nowPlayingAsset,
765
+ nowPlayingLabel,
766
+ textLabel1,
767
+ textLabel2,
768
+ } = configuration;
769
+
770
+ const container = resolveContainerSpec(image);
771
+ const showNowPlaying = !!data.nowPlayingLabel;
772
+
773
+ return (
774
+ <ItemContainer
775
+ image={image}
776
+ background={background}
777
+ focused={focused}
778
+ onPress={onPress}
779
+ >
780
+ <View style={styles.row}>
781
+ <ItemThumbnail configuration={image} imageUri={data.imageUri} />
782
+ <View style={{ width: container.horizontalGutter }} />
783
+ <View style={styles.contentColumn}>
784
+ {showNowPlaying ? (
785
+ <>
786
+ <NowPlayingRow
787
+ assetConfiguration={nowPlayingAsset}
788
+ labelConfiguration={nowPlayingLabel}
789
+ label={data.nowPlayingLabel}
790
+ />
791
+ <View style={{ height: container.verticalGutter }} />
792
+ </>
793
+ ) : null}
794
+ <ItemLabel
795
+ text={data.textLabel1}
796
+ configuration={textLabel1}
797
+ focused={focused}
798
+ />
799
+ <View style={{ height: container.verticalGutter }} />
800
+ <ItemLabel text={data.textLabel2} configuration={textLabel2} />
801
+ </View>
802
+ <ItemButtons
803
+ leadingButton={data.leadingButton}
804
+ trailingButton={data.trailingButton}
805
+ focusedLeadingButton={focusedLeadingButton}
806
+ focusedTrailingButton={focusedTrailingButton}
807
+ onLeadingButtonPress={onLeadingButtonPress}
808
+ onTrailingButtonPress={onTrailingButtonPress}
809
+ isSelected={data.isSelected}
810
+ />
811
+ </View>
812
+ </ItemContainer>
813
+ );
814
+ }
815
+
816
+ // ---------------------------------------------------------------------------
817
+ // Variant presets — collections of configuration keys (not a variant field)
818
+ // ---------------------------------------------------------------------------
819
+
820
+ /** Variant 1 — Now Playing */
821
+ export const VARIANT_NOW_PLAYING: ItemConfiguration = {
822
+ background: {
823
+ defaultColor: "transparent",
824
+ focusedColor: "transparent",
825
+ cornerRadius: 0,
826
+ },
827
+ image: {
828
+ width: 72,
829
+ height: 72,
830
+ borderWidth: 1,
831
+ borderColor: "rgba(255, 255, 255, 0.1)",
832
+ cornerRadius: 8,
833
+ },
834
+ nowPlayingAsset: {},
835
+ nowPlayingLabel: DEFAULT_NOW_PLAYING_LABEL_CONFIGURATION,
836
+ textLabel1: DEFAULT_TEXT_LABEL_1_CONFIGURATION,
837
+ textLabel2: DEFAULT_TEXT_LABEL_2_CONFIGURATION,
838
+ };
839
+
840
+ /** Default / Variant 2 — Queued Item */
841
+ export const VARIANT_QUEUED_ITEM: ItemConfiguration = {
842
+ background: {
843
+ defaultColor: "transparent",
844
+ focusedColor: "rgba(62, 62, 62, 1)",
845
+ cornerRadius: 12,
846
+ },
847
+ image: {
848
+ width: 48,
849
+ height: 48,
850
+ borderWidth: 1,
851
+ borderColor: "rgba(255, 255, 255, 0.1)",
852
+ cornerRadius: 6,
853
+ },
854
+ nowPlayingAsset: {},
855
+ nowPlayingLabel: DEFAULT_NOW_PLAYING_LABEL_CONFIGURATION,
856
+ textLabel1: DEFAULT_TEXT_LABEL_1_CONFIGURATION,
857
+ textLabel2: DEFAULT_TEXT_LABEL_2_CONFIGURATION,
858
+ };
859
+
860
+ /** Variant 3 — Playlist Item */
861
+ export const VARIANT_PLAYLIST_ITEM: ItemConfiguration = {
862
+ background: {
863
+ defaultColor: "transparent",
864
+ focusedColor: "rgba(62, 62, 62, 1)",
865
+ cornerRadius: 12,
866
+ },
867
+ image: {
868
+ width: 48,
869
+ height: 48,
870
+ borderWidth: 1,
871
+ borderColor: "rgba(255, 255, 255, 0.1)",
872
+ cornerRadius: 6,
873
+ },
874
+ nowPlayingAsset: {},
875
+ nowPlayingLabel: DEFAULT_NOW_PLAYING_LABEL_CONFIGURATION,
876
+ textLabel1: DEFAULT_TEXT_LABEL_1_CONFIGURATION,
877
+ textLabel2: DEFAULT_TEXT_LABEL_2_CONFIGURATION,
878
+ };