@applicaster/zapp-react-native-ui-components 16.0.0-alpha.4880104344 → 16.0.0-alpha.4909430115
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/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
- package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
- package/Components/AudioPlayer/tv/index.tsx +5 -1
- package/Components/Cell/TvOSCellComponent.tsx +0 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +36 -14
- package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +54 -0
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +21 -0
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +58 -0
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +314 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +395 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +763 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +653 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +874 -0
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +89 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +11 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +199 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +383 -42
- package/Components/ModalComponent/Button/index.tsx +5 -3
- package/Components/ModalComponent/Header/index.tsx +20 -7
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
- package/Components/ModalComponent/SortableList.tsx +142 -0
- package/Components/ModalComponent/SortableList.web.tsx +102 -0
- package/Components/ModalComponent/TextInputContent.tsx +100 -0
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +238 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +120 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +11 -0
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +66 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
- package/Components/ModalComponent/presets/index.ts +27 -0
- package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
- package/Components/ModalComponent/presets/standardCell.tsx +41 -0
- package/Components/ModalComponent/presets/types.ts +35 -0
- package/Components/ModalComponent/showTextInput.ts +43 -0
- package/Components/ModalComponent/utils.ts +76 -20
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +11 -7
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +1 -1
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/package.json +6 -5
- 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 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modal Building Block — Button
|
|
3
|
+
*
|
|
4
|
+
* Single-file Expo Snack demo for the Button building block spec.
|
|
5
|
+
* Two variants (with / without leading icon) are driven only by configuration + data.
|
|
6
|
+
*
|
|
7
|
+
* Green (configurable): background, title, icons (size + leading icon enable/action type)
|
|
8
|
+
* Black (hardcoded): action type → icon asset mapping
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from "react";
|
|
12
|
+
import {
|
|
13
|
+
Image,
|
|
14
|
+
Platform,
|
|
15
|
+
Pressable,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
Text,
|
|
18
|
+
View,
|
|
19
|
+
} from "react-native";
|
|
20
|
+
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
container: {
|
|
23
|
+
alignSelf: "stretch",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
},
|
|
27
|
+
contentRow: {
|
|
28
|
+
flexDirection: "row",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
justifyContent: "center",
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
textAlign: "center",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Configuration (green / editable fields from spec)
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
export type ButtonActionType =
|
|
42
|
+
| "addToQueue"
|
|
43
|
+
| "addToPlaylist"
|
|
44
|
+
| "goToPlaylist"
|
|
45
|
+
| "confirm"
|
|
46
|
+
| "cancel";
|
|
47
|
+
|
|
48
|
+
export type TextTransform =
|
|
49
|
+
| "default"
|
|
50
|
+
| "lowercase"
|
|
51
|
+
| "uppercase"
|
|
52
|
+
| "capitalize";
|
|
53
|
+
|
|
54
|
+
export type BackgroundConfiguration = {
|
|
55
|
+
defaultColor: string;
|
|
56
|
+
focusedColor: string;
|
|
57
|
+
inactiveColor: string;
|
|
58
|
+
cornerRadius: number;
|
|
59
|
+
paddingTop: number;
|
|
60
|
+
paddingRight: number;
|
|
61
|
+
paddingBottom: number;
|
|
62
|
+
paddingLeft: number;
|
|
63
|
+
horizontalGutter: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type TitleConfiguration = {
|
|
67
|
+
fontColor: string;
|
|
68
|
+
focusedFontColor: string;
|
|
69
|
+
inactiveFontColor: string;
|
|
70
|
+
iosFontFamily: string;
|
|
71
|
+
androidFontFamily: string;
|
|
72
|
+
fontSize: number;
|
|
73
|
+
lineHeight: number;
|
|
74
|
+
iosLetterSpacing: number;
|
|
75
|
+
androidLetterSpacing: number;
|
|
76
|
+
textTransform: TextTransform;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type LeadingIconConfiguration = {
|
|
80
|
+
/** Enable: On / Off */
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
/** Decides which icon will be displayed when enabled */
|
|
83
|
+
actionType?: ButtonActionType;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type IconsConfiguration = {
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
leadingIcon: LeadingIconConfiguration;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type ButtonConfiguration = {
|
|
93
|
+
background: BackgroundConfiguration;
|
|
94
|
+
title: TitleConfiguration;
|
|
95
|
+
icons: IconsConfiguration;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const DEFAULT_BACKGROUND_CONFIGURATION: BackgroundConfiguration = {
|
|
99
|
+
defaultColor: "#FFFFFF",
|
|
100
|
+
focusedColor: "#E0E0E0",
|
|
101
|
+
inactiveColor: "#999999",
|
|
102
|
+
cornerRadius: 12,
|
|
103
|
+
paddingTop: 12,
|
|
104
|
+
paddingRight: 12,
|
|
105
|
+
paddingBottom: 12,
|
|
106
|
+
paddingLeft: 12,
|
|
107
|
+
horizontalGutter: 6,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const DEFAULT_TITLE_CONFIGURATION: TitleConfiguration = {
|
|
111
|
+
fontColor: "#000000",
|
|
112
|
+
focusedFontColor: "#000000",
|
|
113
|
+
inactiveFontColor: "#000000",
|
|
114
|
+
iosFontFamily: "SFProText-Bold",
|
|
115
|
+
androidFontFamily: "Roboto-Bold",
|
|
116
|
+
fontSize: 15,
|
|
117
|
+
lineHeight: 24,
|
|
118
|
+
iosLetterSpacing: -0.2,
|
|
119
|
+
androidLetterSpacing: 0,
|
|
120
|
+
textTransform: "default",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const DEFAULT_ICONS_CONFIGURATION: IconsConfiguration = {
|
|
124
|
+
width: 24,
|
|
125
|
+
height: 24,
|
|
126
|
+
leadingIcon: {
|
|
127
|
+
enabled: false,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// Data (runtime / localization — not styling config)
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
export type ButtonData = {
|
|
136
|
+
title: string;
|
|
137
|
+
disabled?: boolean;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type AudioPlayerButtonProps = {
|
|
141
|
+
configuration: ButtonConfiguration;
|
|
142
|
+
data: ButtonData;
|
|
143
|
+
disabled?: boolean;
|
|
144
|
+
focused?: boolean;
|
|
145
|
+
onPress?: () => void;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// Hardcoded spec values (black fields)
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
// Hardcoded: action type → icon asset mapping (base64 PNG)
|
|
153
|
+
const ACTION_ICON_ASSETS: Record<ButtonActionType, string> = {
|
|
154
|
+
addToQueue:
|
|
155
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKUlEQVR42mNgGAVDCfxHw6MWjFpAvEGk4lELKLdgNJmOWkA7C0YBbQAAwiZvkR9eFgQAAAAASUVORK5CYII=",
|
|
156
|
+
addToPlaylist:
|
|
157
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJklEQVR42mNgGAUjFvzHgmluATF4cFswGsmjkTwayaORPAqGLwAA6Jpxj9Ms9QMAAAAASUVORK5CYII=",
|
|
158
|
+
goToPlaylist:
|
|
159
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAALklEQVR42mNgGAWjYNiD/7Q2/D8tLflPiSX/ycQ0t+D/yLGAEkeMWjAKRgG9AQB4zlSshwSzWwAAAABJRU5ErkJggg==",
|
|
160
|
+
confirm:
|
|
161
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJElEQVR42mNgGAWjYBSQCv4TwKMWDHELho/hNE/3o2AUDDcAAPv0QMAyy1CtAAAAAElFTkSuQmCC",
|
|
162
|
+
cancel:
|
|
163
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAASElEQVR42mNgGAWjGvynkVoUTf+pqA6nxv8UqiHbEooNx2cQ1QzHZiDVDcdlCcOQsoCmQUTTSKZpMqV5RqNLUUHTwm4UDBMAALBLQ73LTvoyAAAAAElFTkSuQmCC",
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
function getTextTransformStyle(
|
|
167
|
+
textTransform: TextTransform
|
|
168
|
+
): "none" | "lowercase" | "uppercase" | "capitalize" {
|
|
169
|
+
return textTransform === "default" ? "none" : textTransform;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function shouldShowLeadingIcon(leadingIcon: LeadingIconConfiguration) {
|
|
173
|
+
return leadingIcon.enabled && !!leadingIcon.actionType;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
// Inner components (hardcoded styling lives here)
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
type ButtonContainerProps = {
|
|
181
|
+
focused: boolean;
|
|
182
|
+
disabled: boolean;
|
|
183
|
+
configuration: BackgroundConfiguration;
|
|
184
|
+
children: React.ReactNode;
|
|
185
|
+
onPress?: () => void;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
function ButtonContainer({
|
|
189
|
+
focused,
|
|
190
|
+
disabled,
|
|
191
|
+
configuration,
|
|
192
|
+
children,
|
|
193
|
+
onPress,
|
|
194
|
+
}: ButtonContainerProps) {
|
|
195
|
+
const defaultBgColor = disabled
|
|
196
|
+
? configuration.inactiveColor
|
|
197
|
+
: focused
|
|
198
|
+
? configuration.focusedColor
|
|
199
|
+
: configuration.defaultColor;
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<Pressable
|
|
203
|
+
onPress={disabled ? undefined : onPress}
|
|
204
|
+
style={({ pressed }) => [
|
|
205
|
+
styles.container,
|
|
206
|
+
{
|
|
207
|
+
backgroundColor:
|
|
208
|
+
pressed && !disabled ? configuration.focusedColor : defaultBgColor,
|
|
209
|
+
borderRadius: configuration.cornerRadius,
|
|
210
|
+
paddingTop: configuration.paddingTop,
|
|
211
|
+
paddingRight: configuration.paddingRight,
|
|
212
|
+
paddingBottom: configuration.paddingBottom,
|
|
213
|
+
paddingLeft: configuration.paddingLeft,
|
|
214
|
+
},
|
|
215
|
+
]}
|
|
216
|
+
>
|
|
217
|
+
{children}
|
|
218
|
+
</Pressable>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
type ButtonTitleProps = {
|
|
223
|
+
title: string;
|
|
224
|
+
focused: boolean;
|
|
225
|
+
disabled: boolean;
|
|
226
|
+
configuration: TitleConfiguration;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
function ButtonTitle({
|
|
230
|
+
title,
|
|
231
|
+
focused,
|
|
232
|
+
disabled,
|
|
233
|
+
configuration,
|
|
234
|
+
}: ButtonTitleProps) {
|
|
235
|
+
const color = disabled
|
|
236
|
+
? configuration.inactiveFontColor
|
|
237
|
+
: focused
|
|
238
|
+
? configuration.focusedFontColor
|
|
239
|
+
: configuration.fontColor;
|
|
240
|
+
|
|
241
|
+
const letterSpacing =
|
|
242
|
+
Platform.OS === "ios"
|
|
243
|
+
? configuration.iosLetterSpacing
|
|
244
|
+
: configuration.androidLetterSpacing;
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<Text
|
|
248
|
+
style={[
|
|
249
|
+
styles.title,
|
|
250
|
+
{
|
|
251
|
+
color,
|
|
252
|
+
fontSize: configuration.fontSize,
|
|
253
|
+
lineHeight: configuration.lineHeight,
|
|
254
|
+
letterSpacing,
|
|
255
|
+
fontFamily: Platform.select({
|
|
256
|
+
ios: configuration.iosFontFamily,
|
|
257
|
+
android: configuration.androidFontFamily,
|
|
258
|
+
default: configuration.androidFontFamily,
|
|
259
|
+
}),
|
|
260
|
+
textTransform: getTextTransformStyle(configuration.textTransform),
|
|
261
|
+
},
|
|
262
|
+
]}
|
|
263
|
+
numberOfLines={1}
|
|
264
|
+
>
|
|
265
|
+
{title}
|
|
266
|
+
</Text>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
type ButtonLeadingIconProps = {
|
|
271
|
+
actionType: ButtonActionType;
|
|
272
|
+
configuration: IconsConfiguration;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
function ButtonLeadingIcon({
|
|
276
|
+
actionType,
|
|
277
|
+
configuration,
|
|
278
|
+
}: ButtonLeadingIconProps) {
|
|
279
|
+
return (
|
|
280
|
+
<Image
|
|
281
|
+
source={{ uri: ACTION_ICON_ASSETS[actionType] }}
|
|
282
|
+
style={{
|
|
283
|
+
width: configuration.width,
|
|
284
|
+
height: configuration.height,
|
|
285
|
+
}}
|
|
286
|
+
resizeMode="contain"
|
|
287
|
+
/>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
// AudioPlayerButton — single building block driven by configuration + data
|
|
293
|
+
// ---------------------------------------------------------------------------
|
|
294
|
+
|
|
295
|
+
import { useModalBlocksStyle } from "../../ModalBlocksStyleContext";
|
|
296
|
+
import { mergeButtonConfiguration } from "../utils/mergeStyles";
|
|
297
|
+
|
|
298
|
+
export function AudioPlayerButton({
|
|
299
|
+
configuration,
|
|
300
|
+
data,
|
|
301
|
+
disabled,
|
|
302
|
+
focused = false,
|
|
303
|
+
onPress,
|
|
304
|
+
}: AudioPlayerButtonProps) {
|
|
305
|
+
const modalBlocksStyle = useModalBlocksStyle();
|
|
306
|
+
const buttonBlock = modalBlocksStyle?.button;
|
|
307
|
+
const actionBlock = modalBlocksStyle?.action;
|
|
308
|
+
|
|
309
|
+
const effectiveConfig = React.useMemo(() => {
|
|
310
|
+
return mergeButtonConfiguration(configuration, buttonBlock, actionBlock);
|
|
311
|
+
}, [configuration, buttonBlock, actionBlock]);
|
|
312
|
+
|
|
313
|
+
const {
|
|
314
|
+
background: effectiveBgConfig,
|
|
315
|
+
title: effectiveTitleConfig,
|
|
316
|
+
icons: iconsConfiguration,
|
|
317
|
+
} = effectiveConfig;
|
|
318
|
+
|
|
319
|
+
const { title } = data;
|
|
320
|
+
const isDisabled = disabled ?? data.disabled ?? false;
|
|
321
|
+
|
|
322
|
+
const { leadingIcon } = iconsConfiguration;
|
|
323
|
+
const showIcon = shouldShowLeadingIcon(leadingIcon);
|
|
324
|
+
|
|
325
|
+
return (
|
|
326
|
+
<ButtonContainer
|
|
327
|
+
focused={focused}
|
|
328
|
+
disabled={isDisabled}
|
|
329
|
+
configuration={effectiveBgConfig}
|
|
330
|
+
onPress={onPress}
|
|
331
|
+
>
|
|
332
|
+
<View style={styles.contentRow}>
|
|
333
|
+
{showIcon ? (
|
|
334
|
+
<>
|
|
335
|
+
<ButtonLeadingIcon
|
|
336
|
+
actionType={leadingIcon.actionType}
|
|
337
|
+
configuration={iconsConfiguration}
|
|
338
|
+
/>
|
|
339
|
+
<View style={{ width: effectiveBgConfig.horizontalGutter }} />
|
|
340
|
+
</>
|
|
341
|
+
) : null}
|
|
342
|
+
<ButtonTitle
|
|
343
|
+
title={title}
|
|
344
|
+
focused={focused}
|
|
345
|
+
disabled={isDisabled}
|
|
346
|
+
configuration={effectiveTitleConfig}
|
|
347
|
+
/>
|
|
348
|
+
</View>
|
|
349
|
+
</ButtonContainer>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// ---------------------------------------------------------------------------
|
|
354
|
+
// Snack demo — two Button variants from configuration only
|
|
355
|
+
// ---------------------------------------------------------------------------
|
|
356
|
+
|
|
357
|
+
export const VARIANT_TEXT_ONLY: ButtonConfiguration = {
|
|
358
|
+
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
359
|
+
title: DEFAULT_TITLE_CONFIGURATION,
|
|
360
|
+
icons: DEFAULT_ICONS_CONFIGURATION,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export const VARIANT_WITH_ICON: ButtonConfiguration = {
|
|
364
|
+
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
365
|
+
title: DEFAULT_TITLE_CONFIGURATION,
|
|
366
|
+
icons: {
|
|
367
|
+
...DEFAULT_ICONS_CONFIGURATION,
|
|
368
|
+
leadingIcon: {
|
|
369
|
+
enabled: true,
|
|
370
|
+
actionType: "addToPlaylist",
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export const VARIANT_UPPERCASE_TITLE: ButtonConfiguration = {
|
|
376
|
+
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
377
|
+
title: {
|
|
378
|
+
...DEFAULT_TITLE_CONFIGURATION,
|
|
379
|
+
textTransform: "uppercase",
|
|
380
|
+
},
|
|
381
|
+
icons: DEFAULT_ICONS_CONFIGURATION,
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export const VARIANT_LARGE_ICON: ButtonConfiguration = {
|
|
385
|
+
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
386
|
+
title: DEFAULT_TITLE_CONFIGURATION,
|
|
387
|
+
icons: {
|
|
388
|
+
width: 32,
|
|
389
|
+
height: 32,
|
|
390
|
+
leadingIcon: {
|
|
391
|
+
enabled: true,
|
|
392
|
+
actionType: "addToQueue",
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
};
|