@applicaster/zapp-react-native-ui-components 15.1.6-alpha.2015591222 → 15.1.6
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.
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +69 -33
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +47 -25
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +39 -122
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +131 -299
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +4 -8
- package/Components/ModalComponent/BottomSheetModalContent.tsx +55 -290
- package/Components/ModalComponent/Button/index.tsx +3 -5
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/index.tsx +0 -11
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +13 -82
- package/Components/OfflineHandler/__tests__/index.test.tsx +100 -35
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/package.json +5 -6
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +0 -671
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +0 -86
- package/Components/ModalComponent/SortableList.tsx +0 -142
- package/Components/ModalComponent/TextInputContent.tsx +0 -100
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +0 -183
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +0 -128
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +0 -95
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +0 -66
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +0 -74
- package/Components/ModalComponent/presets/index.ts +0 -27
- package/Components/ModalComponent/presets/selectableCell.tsx +0 -27
- package/Components/ModalComponent/presets/standardCell.tsx +0 -41
- package/Components/ModalComponent/presets/types.ts +0 -35
- package/Components/ModalComponent/showTextInput.ts +0 -43
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -67
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
|
@@ -12,18 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import React from "react";
|
|
15
|
-
import {
|
|
16
|
-
Image,
|
|
17
|
-
Platform,
|
|
18
|
-
Pressable,
|
|
19
|
-
StyleSheet,
|
|
20
|
-
Text,
|
|
21
|
-
View,
|
|
22
|
-
} from "react-native";
|
|
23
|
-
import {
|
|
24
|
-
MenuItem,
|
|
25
|
-
SelectionBehavior,
|
|
26
|
-
} from "@applicaster/zapp-react-native-utils/modalState/types";
|
|
15
|
+
import { Image, Platform, StyleSheet, Text, View } from "react-native";
|
|
27
16
|
|
|
28
17
|
const styles = StyleSheet.create({
|
|
29
18
|
row: {
|
|
@@ -108,6 +97,50 @@ export type ItemConfiguration = {
|
|
|
108
97
|
textLabel2: LabelConfiguration;
|
|
109
98
|
};
|
|
110
99
|
|
|
100
|
+
export interface Action {
|
|
101
|
+
type: string;
|
|
102
|
+
payload?: any;
|
|
103
|
+
options?: any;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface Header {
|
|
107
|
+
title: string;
|
|
108
|
+
subtitle?: string;
|
|
109
|
+
icon?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface Content {
|
|
113
|
+
title: string;
|
|
114
|
+
stickyTitle?: boolean;
|
|
115
|
+
items: MenuItem[];
|
|
116
|
+
itemsUrl?: string;
|
|
117
|
+
action?: Action;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface Menu {
|
|
121
|
+
header?: Header;
|
|
122
|
+
content: Content;
|
|
123
|
+
closeButton?: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface PresentSubMenuAction extends Action {
|
|
127
|
+
menu: Menu;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface SecondaryAction {
|
|
131
|
+
action: Action | PresentSubMenuAction;
|
|
132
|
+
icon?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface MenuItem {
|
|
136
|
+
title: string;
|
|
137
|
+
summary?: string;
|
|
138
|
+
icon?: string;
|
|
139
|
+
isSelected?: boolean;
|
|
140
|
+
action?: Action | PresentSubMenuAction;
|
|
141
|
+
secondaryAction?: SecondaryAction;
|
|
142
|
+
}
|
|
143
|
+
|
|
111
144
|
export const DEFAULT_TEXT_LABEL_1_CONFIGURATION: LabelConfiguration = {
|
|
112
145
|
fontColor: "#FFFFFF",
|
|
113
146
|
focusedFontColor: "#FFFFFF",
|
|
@@ -158,19 +191,14 @@ export type ItemData = {
|
|
|
158
191
|
leadingButton?: ItemButtonAction;
|
|
159
192
|
/** Button 1 (right most) — hardcoded action decides icon. */
|
|
160
193
|
trailingButton?: ItemButtonAction;
|
|
161
|
-
isSelected?: boolean;
|
|
162
194
|
};
|
|
163
195
|
|
|
164
|
-
export type
|
|
196
|
+
export type ItemProps = {
|
|
165
197
|
configuration: ItemConfiguration;
|
|
166
198
|
data: ItemData;
|
|
167
199
|
focused?: boolean;
|
|
168
200
|
focusedLeadingButton?: boolean;
|
|
169
201
|
focusedTrailingButton?: boolean;
|
|
170
|
-
onPress?: () => void;
|
|
171
|
-
onLeadingButtonPress?: () => void;
|
|
172
|
-
onTrailingButtonPress?: () => void;
|
|
173
|
-
renderHandle?: (element: React.ReactElement) => React.ReactElement;
|
|
174
202
|
};
|
|
175
203
|
|
|
176
204
|
// ---------------------------------------------------------------------------
|
|
@@ -206,9 +234,9 @@ const CONTAINER_SPEC_LARGE_IMAGE: ContainerSpec = {
|
|
|
206
234
|
|
|
207
235
|
const CONTAINER_SPEC_DEFAULT: ContainerSpec = {
|
|
208
236
|
paddingTop: 8,
|
|
209
|
-
paddingRight:
|
|
237
|
+
paddingRight: 10,
|
|
210
238
|
paddingBottom: 8,
|
|
211
|
-
paddingLeft:
|
|
239
|
+
paddingLeft: 10,
|
|
212
240
|
horizontalGutter: 12,
|
|
213
241
|
verticalGutter: 2,
|
|
214
242
|
};
|
|
@@ -269,6 +297,16 @@ const DEFAULT_THUMB_ASSET =
|
|
|
269
297
|
const DEFAULT_EQUALIZER_ASSET =
|
|
270
298
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAI0lEQVR42mNgGNTgPxTQzwB0DVQ3gKCBowbQwYAhkBIHBAAA9TvPMeOFaLMAAAAASUVORK5CYII=";
|
|
271
299
|
|
|
300
|
+
const BUTTON_ASSETS: Record<ItemButtonAction, string> = {
|
|
301
|
+
playPause:
|
|
302
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAYAAAAehFoBAAAAdklEQVR42u3ZwRUAERAEUfkn3TaF5TFTrSuCf3CgjZGg6ast7G8YaAlcB8JAj8F1MRR2G63CUNglNAqsRvmB1TAfsBoXcMABV4MFKEci4IADNrkAed2H80R66SHqvUvglh/ktoZcL5H7MHKBx/5xYH+RsP90t5t2UpF6+22a+AAAAABJRU5ErkJggg==",
|
|
303
|
+
drag: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAIklEQVR42mNgGAWjYGiC/2SCwWPBaByMxsFoHIyCUTDYAAAqhk7AVXdZJwAAAABJRU5ErkJggg==",
|
|
304
|
+
multiSelect:
|
|
305
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAWklEQVR42t2VUQ4AIAhCvf+lrQsULJJZbH7GM1cS0Uk5dd0Qqcz4GJSCSs0pSCkAHNoWBfkTgIxpgGK+ujyEKABqRGyn9FO1A+yfrf+qsGxTSx5YEs2WyU9oAKBJKg8Kfq4dAAAAAElFTkSuQmCC",
|
|
306
|
+
remove:
|
|
307
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAUklEQVR42mNgGPbgPx5AVYOJlSPJcGqrJU8DKXooCVui9FIacXj1UyNl4DWDLhYgc8nA+INpeFgwtCOZ5vmALjmZ5mURXUpTutQHdKnRRgEMAACwjWWprU1B+AAAAABJRU5ErkJggg==",
|
|
308
|
+
};
|
|
309
|
+
|
|
272
310
|
function getTextTransformStyle(
|
|
273
311
|
textTransform: TextTransform
|
|
274
312
|
): "none" | "lowercase" | "uppercase" | "capitalize" {
|
|
@@ -286,43 +324,32 @@ function resolveContainerSpec(image: ImageConfiguration): ContainerSpec {
|
|
|
286
324
|
: CONTAINER_SPEC_DEFAULT;
|
|
287
325
|
}
|
|
288
326
|
|
|
289
|
-
|
|
327
|
+
function mapMenuItemToNowPlayingData(item: MenuItem): ItemData {
|
|
290
328
|
return {
|
|
291
329
|
imageUri: item.icon,
|
|
292
330
|
textLabel1: item.title,
|
|
293
331
|
textLabel2: item.summary ?? "",
|
|
294
332
|
nowPlayingLabel: "Now Playing",
|
|
295
333
|
trailingButton: "playPause",
|
|
296
|
-
isSelected: item.isSelected,
|
|
297
334
|
};
|
|
298
335
|
}
|
|
299
336
|
|
|
300
|
-
|
|
337
|
+
function mapMenuItemToQueuedData(item: MenuItem): ItemData {
|
|
301
338
|
return {
|
|
302
339
|
imageUri: item.icon,
|
|
303
340
|
textLabel1: item.title,
|
|
304
341
|
textLabel2: item.summary ?? "",
|
|
305
342
|
leadingButton: "remove",
|
|
306
343
|
trailingButton: "drag",
|
|
307
|
-
isSelected: item.isSelected,
|
|
308
344
|
};
|
|
309
345
|
}
|
|
310
346
|
|
|
311
|
-
|
|
312
|
-
item: MenuItem,
|
|
313
|
-
behavior?: SelectionBehavior
|
|
314
|
-
): ItemData {
|
|
315
|
-
const showSelectionWidget =
|
|
316
|
-
behavior?.selectMode !== "none" && item.trailingButton !== "none";
|
|
317
|
-
|
|
347
|
+
function mapMenuItemToPlaylistData(item: MenuItem): ItemData {
|
|
318
348
|
return {
|
|
319
349
|
imageUri: item.icon,
|
|
320
350
|
textLabel1: item.title,
|
|
321
351
|
textLabel2: item.summary ?? "",
|
|
322
|
-
trailingButton:
|
|
323
|
-
? item.trailingButton || ("multiSelect" as ItemButtonAction)
|
|
324
|
-
: undefined,
|
|
325
|
-
isSelected: item.isSelected,
|
|
352
|
+
trailingButton: "multiSelect",
|
|
326
353
|
};
|
|
327
354
|
}
|
|
328
355
|
|
|
@@ -335,7 +362,6 @@ type ItemContainerProps = {
|
|
|
335
362
|
background: BackgroundConfiguration;
|
|
336
363
|
focused: boolean;
|
|
337
364
|
children: React.ReactNode;
|
|
338
|
-
onPress?: () => void;
|
|
339
365
|
};
|
|
340
366
|
|
|
341
367
|
function ItemContainer({
|
|
@@ -343,25 +369,23 @@ function ItemContainer({
|
|
|
343
369
|
background,
|
|
344
370
|
focused,
|
|
345
371
|
children,
|
|
346
|
-
onPress,
|
|
347
372
|
}: ItemContainerProps) {
|
|
348
373
|
const container = resolveContainerSpec(image);
|
|
349
374
|
const bg = focused ? background.focusedColor : background.defaultColor;
|
|
350
375
|
|
|
351
376
|
return (
|
|
352
|
-
<
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
backgroundColor: pressed ? background.focusedColor : bg,
|
|
377
|
+
<View
|
|
378
|
+
style={{
|
|
379
|
+
backgroundColor: bg,
|
|
356
380
|
borderRadius: background.cornerRadius,
|
|
357
381
|
paddingTop: container.paddingTop,
|
|
358
382
|
paddingRight: container.paddingRight,
|
|
359
383
|
paddingBottom: container.paddingBottom,
|
|
360
384
|
paddingLeft: container.paddingLeft,
|
|
361
|
-
}
|
|
385
|
+
}}
|
|
362
386
|
>
|
|
363
387
|
{children}
|
|
364
|
-
</
|
|
388
|
+
</View>
|
|
365
389
|
);
|
|
366
390
|
}
|
|
367
391
|
|
|
@@ -462,212 +486,27 @@ function NowPlayingRow({
|
|
|
462
486
|
type ItemButtonProps = {
|
|
463
487
|
action: ItemButtonAction;
|
|
464
488
|
focused?: boolean;
|
|
465
|
-
onPress?: () => void;
|
|
466
|
-
isSelected?: boolean;
|
|
467
489
|
};
|
|
468
490
|
|
|
469
|
-
function ItemButton({
|
|
470
|
-
action,
|
|
471
|
-
focused = false,
|
|
472
|
-
onPress,
|
|
473
|
-
isSelected = false,
|
|
474
|
-
}: ItemButtonProps) {
|
|
491
|
+
function ItemButton({ action, focused = false }: ItemButtonProps) {
|
|
475
492
|
const layout = BUTTON_LAYOUT_SPEC[action];
|
|
476
493
|
|
|
477
|
-
if (!layout) {
|
|
478
|
-
return null;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
const renderIcon = () => {
|
|
482
|
-
switch (action) {
|
|
483
|
-
case "playPause": {
|
|
484
|
-
const iconSize = layout.assetWidth;
|
|
485
|
-
const iconRadius = iconSize / 2;
|
|
486
|
-
|
|
487
|
-
return (
|
|
488
|
-
<View
|
|
489
|
-
style={{
|
|
490
|
-
width: iconSize,
|
|
491
|
-
height: iconSize,
|
|
492
|
-
borderRadius: iconRadius,
|
|
493
|
-
backgroundColor: "#FFFFFF",
|
|
494
|
-
justifyContent: "center",
|
|
495
|
-
alignItems: "center",
|
|
496
|
-
}}
|
|
497
|
-
>
|
|
498
|
-
{isSelected ? (
|
|
499
|
-
<View
|
|
500
|
-
style={{
|
|
501
|
-
flexDirection: "row",
|
|
502
|
-
justifyContent: "space-between",
|
|
503
|
-
width: 10,
|
|
504
|
-
height: 16,
|
|
505
|
-
}}
|
|
506
|
-
>
|
|
507
|
-
<View
|
|
508
|
-
style={{
|
|
509
|
-
width: 3.5,
|
|
510
|
-
height: 16,
|
|
511
|
-
backgroundColor: "#1e1e1e",
|
|
512
|
-
borderRadius: 1,
|
|
513
|
-
}}
|
|
514
|
-
/>
|
|
515
|
-
<View
|
|
516
|
-
style={{
|
|
517
|
-
width: 3.5,
|
|
518
|
-
height: 16,
|
|
519
|
-
backgroundColor: "#1e1e1e",
|
|
520
|
-
borderRadius: 1,
|
|
521
|
-
}}
|
|
522
|
-
/>
|
|
523
|
-
</View>
|
|
524
|
-
) : (
|
|
525
|
-
<View
|
|
526
|
-
style={{
|
|
527
|
-
width: 0,
|
|
528
|
-
height: 0,
|
|
529
|
-
backgroundColor: "transparent",
|
|
530
|
-
borderStyle: "solid",
|
|
531
|
-
borderLeftWidth: 14,
|
|
532
|
-
borderRightWidth: 0,
|
|
533
|
-
borderTopWidth: 8,
|
|
534
|
-
borderBottomWidth: 8,
|
|
535
|
-
borderLeftColor: "#1e1e1e",
|
|
536
|
-
borderRightColor: "transparent",
|
|
537
|
-
borderTopColor: "transparent",
|
|
538
|
-
borderBottomColor: "transparent",
|
|
539
|
-
marginLeft: 3,
|
|
540
|
-
}}
|
|
541
|
-
/>
|
|
542
|
-
)}
|
|
543
|
-
</View>
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
case "drag": {
|
|
548
|
-
return (
|
|
549
|
-
<View
|
|
550
|
-
style={{
|
|
551
|
-
width: 20,
|
|
552
|
-
height: 12,
|
|
553
|
-
justifyContent: "space-between",
|
|
554
|
-
}}
|
|
555
|
-
>
|
|
556
|
-
<View
|
|
557
|
-
style={{
|
|
558
|
-
height: 2,
|
|
559
|
-
backgroundColor: "rgba(255, 255, 255, 0.7)",
|
|
560
|
-
borderRadius: 1,
|
|
561
|
-
}}
|
|
562
|
-
/>
|
|
563
|
-
<View
|
|
564
|
-
style={{
|
|
565
|
-
height: 2,
|
|
566
|
-
backgroundColor: "rgba(255, 255, 255, 0.7)",
|
|
567
|
-
borderRadius: 1,
|
|
568
|
-
}}
|
|
569
|
-
/>
|
|
570
|
-
<View
|
|
571
|
-
style={{
|
|
572
|
-
height: 2,
|
|
573
|
-
backgroundColor: "rgba(255, 255, 255, 0.7)",
|
|
574
|
-
borderRadius: 1,
|
|
575
|
-
}}
|
|
576
|
-
/>
|
|
577
|
-
</View>
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
case "remove": {
|
|
582
|
-
return (
|
|
583
|
-
<View
|
|
584
|
-
style={{
|
|
585
|
-
width: 24,
|
|
586
|
-
height: 24,
|
|
587
|
-
borderRadius: 12,
|
|
588
|
-
borderWidth: 1.5,
|
|
589
|
-
borderColor: "rgba(255, 255, 255, 0.7)",
|
|
590
|
-
justifyContent: "center",
|
|
591
|
-
alignItems: "center",
|
|
592
|
-
}}
|
|
593
|
-
>
|
|
594
|
-
<View
|
|
595
|
-
style={{
|
|
596
|
-
width: 10,
|
|
597
|
-
height: 1.5,
|
|
598
|
-
backgroundColor: "rgba(255, 255, 255, 0.7)",
|
|
599
|
-
borderRadius: 1,
|
|
600
|
-
}}
|
|
601
|
-
/>
|
|
602
|
-
</View>
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
case "multiSelect": {
|
|
607
|
-
if (!isSelected) {
|
|
608
|
-
return (
|
|
609
|
-
<View
|
|
610
|
-
style={{
|
|
611
|
-
width: layout.assetWidth,
|
|
612
|
-
height: layout.assetHeight,
|
|
613
|
-
borderRadius: layout.assetWidth / 2,
|
|
614
|
-
borderWidth: 1.5,
|
|
615
|
-
borderColor: "rgba(255, 255, 255, 0.7)",
|
|
616
|
-
backgroundColor: "transparent",
|
|
617
|
-
}}
|
|
618
|
-
/>
|
|
619
|
-
);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
return (
|
|
623
|
-
<View
|
|
624
|
-
style={{
|
|
625
|
-
width: 24,
|
|
626
|
-
height: 24,
|
|
627
|
-
borderRadius: 12,
|
|
628
|
-
backgroundColor: "#FFFFFF",
|
|
629
|
-
justifyContent: "center",
|
|
630
|
-
alignItems: "center",
|
|
631
|
-
}}
|
|
632
|
-
>
|
|
633
|
-
<View
|
|
634
|
-
style={{
|
|
635
|
-
width: 6,
|
|
636
|
-
height: 10,
|
|
637
|
-
borderBottomWidth: 2,
|
|
638
|
-
borderRightWidth: 2,
|
|
639
|
-
borderColor: "#1e1e1e",
|
|
640
|
-
transform: [{ rotate: "45deg" }],
|
|
641
|
-
marginTop: -2,
|
|
642
|
-
}}
|
|
643
|
-
/>
|
|
644
|
-
</View>
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
default:
|
|
649
|
-
return null;
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
|
|
653
494
|
return (
|
|
654
|
-
<
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
495
|
+
<View
|
|
496
|
+
style={{
|
|
497
|
+
paddingTop: layout.paddingTop,
|
|
498
|
+
paddingRight: layout.paddingRight,
|
|
499
|
+
paddingBottom: layout.paddingBottom,
|
|
500
|
+
paddingLeft: layout.paddingLeft,
|
|
501
|
+
opacity: focused ? 0.7 : 1,
|
|
658
502
|
}}
|
|
659
|
-
style={({ pressed }) => [
|
|
660
|
-
{
|
|
661
|
-
paddingTop: layout.paddingTop,
|
|
662
|
-
paddingRight: layout.paddingRight,
|
|
663
|
-
paddingBottom: layout.paddingBottom,
|
|
664
|
-
paddingLeft: layout.paddingLeft,
|
|
665
|
-
opacity: pressed || focused ? 0.7 : 1,
|
|
666
|
-
},
|
|
667
|
-
]}
|
|
668
503
|
>
|
|
669
|
-
|
|
670
|
-
|
|
504
|
+
<Image
|
|
505
|
+
source={{ uri: BUTTON_ASSETS[action] }}
|
|
506
|
+
style={{ width: layout.assetWidth, height: layout.assetHeight }}
|
|
507
|
+
resizeMode="contain"
|
|
508
|
+
/>
|
|
509
|
+
</View>
|
|
671
510
|
);
|
|
672
511
|
}
|
|
673
512
|
|
|
@@ -676,10 +515,6 @@ type ItemButtonsProps = {
|
|
|
676
515
|
trailingButton?: ItemButtonAction;
|
|
677
516
|
focusedLeadingButton?: boolean;
|
|
678
517
|
focusedTrailingButton?: boolean;
|
|
679
|
-
onLeadingButtonPress?: () => void;
|
|
680
|
-
onTrailingButtonPress?: () => void;
|
|
681
|
-
isSelected?: boolean;
|
|
682
|
-
renderHandle?: (element: React.ReactElement) => React.ReactElement;
|
|
683
518
|
};
|
|
684
519
|
|
|
685
520
|
function ItemButtons({
|
|
@@ -687,10 +522,6 @@ function ItemButtons({
|
|
|
687
522
|
trailingButton,
|
|
688
523
|
focusedLeadingButton = false,
|
|
689
524
|
focusedTrailingButton = false,
|
|
690
|
-
onLeadingButtonPress,
|
|
691
|
-
onTrailingButtonPress,
|
|
692
|
-
isSelected = false,
|
|
693
|
-
renderHandle,
|
|
694
525
|
}: ItemButtonsProps) {
|
|
695
526
|
if (!leadingButton && !trailingButton) {
|
|
696
527
|
return null;
|
|
@@ -700,62 +531,28 @@ function ItemButtons({
|
|
|
700
531
|
<View style={styles.buttonsRow}>
|
|
701
532
|
{leadingButton ? (
|
|
702
533
|
<>
|
|
703
|
-
<ItemButton
|
|
704
|
-
action={leadingButton}
|
|
705
|
-
focused={focusedLeadingButton}
|
|
706
|
-
onPress={onLeadingButtonPress}
|
|
707
|
-
isSelected={isSelected}
|
|
708
|
-
/>
|
|
534
|
+
<ItemButton action={leadingButton} focused={focusedLeadingButton} />
|
|
709
535
|
<View style={{ width: BUTTONS_CONTAINER_HORIZONTAL_GUTTER }} />
|
|
710
536
|
</>
|
|
711
537
|
) : null}
|
|
712
538
|
{trailingButton ? (
|
|
713
|
-
trailingButton
|
|
714
|
-
renderHandle ? (
|
|
715
|
-
renderHandle(
|
|
716
|
-
<ItemButton
|
|
717
|
-
action={trailingButton}
|
|
718
|
-
focused={focusedTrailingButton}
|
|
719
|
-
onPress={onTrailingButtonPress}
|
|
720
|
-
isSelected={isSelected}
|
|
721
|
-
/>
|
|
722
|
-
)
|
|
723
|
-
) : (
|
|
724
|
-
<ItemButton
|
|
725
|
-
action={trailingButton}
|
|
726
|
-
focused={focusedTrailingButton}
|
|
727
|
-
onPress={onTrailingButtonPress}
|
|
728
|
-
isSelected={isSelected}
|
|
729
|
-
/>
|
|
730
|
-
)
|
|
731
|
-
) : (
|
|
732
|
-
<ItemButton
|
|
733
|
-
action={trailingButton}
|
|
734
|
-
focused={focusedTrailingButton}
|
|
735
|
-
onPress={onTrailingButtonPress}
|
|
736
|
-
isSelected={isSelected}
|
|
737
|
-
/>
|
|
738
|
-
)
|
|
539
|
+
<ItemButton action={trailingButton} focused={focusedTrailingButton} />
|
|
739
540
|
) : null}
|
|
740
541
|
</View>
|
|
741
542
|
);
|
|
742
543
|
}
|
|
743
544
|
|
|
744
545
|
// ---------------------------------------------------------------------------
|
|
745
|
-
//
|
|
546
|
+
// Item
|
|
746
547
|
// ---------------------------------------------------------------------------
|
|
747
548
|
|
|
748
|
-
export function
|
|
549
|
+
export function Item({
|
|
749
550
|
configuration,
|
|
750
551
|
data,
|
|
751
552
|
focused = false,
|
|
752
553
|
focusedLeadingButton = false,
|
|
753
554
|
focusedTrailingButton = false,
|
|
754
|
-
|
|
755
|
-
onLeadingButtonPress,
|
|
756
|
-
onTrailingButtonPress,
|
|
757
|
-
renderHandle,
|
|
758
|
-
}: AudioPlayerTrackItemProps) {
|
|
555
|
+
}: ItemProps) {
|
|
759
556
|
const {
|
|
760
557
|
background,
|
|
761
558
|
image,
|
|
@@ -769,12 +566,7 @@ export function AudioPlayerTrackItem({
|
|
|
769
566
|
const showNowPlaying = !!data.nowPlayingLabel;
|
|
770
567
|
|
|
771
568
|
return (
|
|
772
|
-
<ItemContainer
|
|
773
|
-
image={image}
|
|
774
|
-
background={background}
|
|
775
|
-
focused={focused}
|
|
776
|
-
onPress={onPress}
|
|
777
|
-
>
|
|
569
|
+
<ItemContainer image={image} background={background} focused={focused}>
|
|
778
570
|
<View style={styles.row}>
|
|
779
571
|
<ItemThumbnail configuration={image} imageUri={data.imageUri} />
|
|
780
572
|
<View style={{ width: container.horizontalGutter }} />
|
|
@@ -802,10 +594,6 @@ export function AudioPlayerTrackItem({
|
|
|
802
594
|
trailingButton={data.trailingButton}
|
|
803
595
|
focusedLeadingButton={focusedLeadingButton}
|
|
804
596
|
focusedTrailingButton={focusedTrailingButton}
|
|
805
|
-
onLeadingButtonPress={onLeadingButtonPress}
|
|
806
|
-
onTrailingButtonPress={onTrailingButtonPress}
|
|
807
|
-
isSelected={data.isSelected}
|
|
808
|
-
renderHandle={renderHandle}
|
|
809
597
|
/>
|
|
810
598
|
</View>
|
|
811
599
|
</ItemContainer>
|
|
@@ -875,3 +663,47 @@ export const VARIANT_PLAYLIST_ITEM: ItemConfiguration = {
|
|
|
875
663
|
textLabel1: DEFAULT_TEXT_LABEL_1_CONFIGURATION,
|
|
876
664
|
textLabel2: DEFAULT_TEXT_LABEL_2_CONFIGURATION,
|
|
877
665
|
};
|
|
666
|
+
|
|
667
|
+
export default function App() {
|
|
668
|
+
// Hardcoded core mock data objects matching user types framework
|
|
669
|
+
const sharedMockItem: MenuItem = {
|
|
670
|
+
title: "Content Title",
|
|
671
|
+
summary: "Artist",
|
|
672
|
+
icon: "https://picsum.photos/200",
|
|
673
|
+
action: { type: "PLAY_AUDIO" },
|
|
674
|
+
secondaryAction: { action: { type: "OPEN_CONTEXT_MENU" } },
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const playlistMockItem: MenuItem = {
|
|
678
|
+
title: "Playlist Name",
|
|
679
|
+
summary: "12 Songs",
|
|
680
|
+
icon: "https://picsum.photos/201",
|
|
681
|
+
isSelected: true,
|
|
682
|
+
action: { type: "NAVIGATE_PLAYLIST" },
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
return (
|
|
686
|
+
<View style={styles.demoScreen}>
|
|
687
|
+
<Text style={styles.demoHeading}>Modal Item Building Block</Text>
|
|
688
|
+
|
|
689
|
+
<Text style={styles.demoLabel}>Now Playing</Text>
|
|
690
|
+
<Item
|
|
691
|
+
configuration={VARIANT_NOW_PLAYING}
|
|
692
|
+
data={mapMenuItemToNowPlayingData(sharedMockItem)}
|
|
693
|
+
/>
|
|
694
|
+
|
|
695
|
+
<Text style={styles.demoLabel}>Queued Item</Text>
|
|
696
|
+
<Item
|
|
697
|
+
configuration={VARIANT_QUEUED_ITEM}
|
|
698
|
+
data={mapMenuItemToQueuedData(sharedMockItem)}
|
|
699
|
+
focused
|
|
700
|
+
/>
|
|
701
|
+
|
|
702
|
+
<Text style={styles.demoLabel}>Playlist Item</Text>
|
|
703
|
+
<Item
|
|
704
|
+
configuration={VARIANT_PLAYLIST_ITEM}
|
|
705
|
+
data={mapMenuItemToPlaylistData(playlistMockItem)}
|
|
706
|
+
/>
|
|
707
|
+
</View>
|
|
708
|
+
);
|
|
709
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Item as AudioPlayerItem } from "./Item";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Item as AudioPlayerHeader } from "./Header";
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { Item as AudioPlayerButton } from "./Button";
|
|
6
6
|
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
export { NowPlayingHeaderSection } from "./NowPlayingHeaderSection";
|
|
10
|
-
|
|
11
|
-
export { AudioPlayerInput } from "./Input";
|
|
7
|
+
export { Item as AudioPlayerAction } from "./Action";
|