@applicaster/zapp-react-native-ui-components 15.1.14 → 15.1.15-rc.0
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/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +15 -0
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
- package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
- package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +58 -97
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +142 -142
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +628 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +448 -175
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +94 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +113 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +6 -4
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +248 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +386 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +425 -66
- 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 +157 -0
- package/Components/ModalComponent/SortableList.web.tsx +102 -0
- package/Components/ModalComponent/TextInputContent.tsx +112 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +255 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +156 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +18 -9
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +90 -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 +82 -21
- package/Components/River/ComponentsMap/ComponentsMap.tsx +87 -60
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +139 -75
- package/Components/River/__tests__/componentsMap.test.js +8 -3
- package/Components/Screen/navigationHandler.ts +8 -8
- package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
- package/Contexts/ModalNavigationContext/index.tsx +2 -2
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/package.json +6 -5
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +0 -368
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -11,6 +11,20 @@ type HookComponentProps = HookPluginProps & {
|
|
|
11
11
|
function GeneralContentScreenHookComponent(props: HookComponentProps) {
|
|
12
12
|
const { hookPlugin, focused, parentFocus } = props;
|
|
13
13
|
|
|
14
|
+
const componentsMapExtraPropsMemo = React.useMemo(
|
|
15
|
+
() => ({
|
|
16
|
+
safeArea: {
|
|
17
|
+
edges: {
|
|
18
|
+
top: "additive",
|
|
19
|
+
bottom: "additive",
|
|
20
|
+
left: "off",
|
|
21
|
+
right: "off",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
[]
|
|
26
|
+
);
|
|
27
|
+
|
|
14
28
|
if (!hookPlugin?.screen_id) {
|
|
15
29
|
log_error(
|
|
16
30
|
"GeneralContentScreenHookAdapter: This component should only be used as a hook, but no hookPlugin was provided."
|
|
@@ -26,6 +40,7 @@ function GeneralContentScreenHookComponent(props: HookComponentProps) {
|
|
|
26
40
|
isScreenWrappedInContainer={false}
|
|
27
41
|
focused={focused}
|
|
28
42
|
parentFocus={parentFocus}
|
|
43
|
+
componentsMapExtraProps={componentsMapExtraPropsMemo}
|
|
29
44
|
/>
|
|
30
45
|
</HookContentFocusGroup>
|
|
31
46
|
);
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect } from "react";
|
|
|
2
2
|
import { TouchableOpacity, ViewStyle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
5
|
+
import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
|
|
5
6
|
|
|
6
7
|
import Image from "./Image";
|
|
7
8
|
type Props = {
|
|
@@ -54,6 +55,7 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
54
55
|
) {
|
|
55
56
|
const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
|
|
56
57
|
const actionContext = useActions(action?.identifier);
|
|
58
|
+
const component = useUIComponentContext();
|
|
57
59
|
|
|
58
60
|
// TODO: add subscription API for action availability
|
|
59
61
|
const actionDisabled =
|
|
@@ -78,8 +80,9 @@ export const ActionButton = React.memo(function ActionButtonComponent(
|
|
|
78
80
|
updateState: (state) => {
|
|
79
81
|
setActionState(state);
|
|
80
82
|
},
|
|
83
|
+
...(component ? { component } : {}),
|
|
81
84
|
});
|
|
82
|
-
}, [actionState, actionContext?.state, item
|
|
85
|
+
}, [actionState, actionContext?.state, item, component]);
|
|
83
86
|
|
|
84
87
|
useEffect(() => {
|
|
85
88
|
if (typeof actionContext?.addListener === "function") {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useEntryActionState } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
3
|
+
import {
|
|
4
|
+
isActionAvailableFor,
|
|
5
|
+
RegisteredAction,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
7
|
+
|
|
8
|
+
import { Button } from "../Button";
|
|
9
|
+
|
|
10
|
+
export type ActionButtonProps = {
|
|
11
|
+
entry: ZappEntry;
|
|
12
|
+
item: RegisteredAction;
|
|
13
|
+
configuration: any;
|
|
14
|
+
width: number;
|
|
15
|
+
component?: ZappUIComponent & { parent?: ZappUIComponent };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type Props = ActionButtonProps & {
|
|
19
|
+
onPress?: (item: any) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Unified action button for the modal bottom sheet.
|
|
24
|
+
*
|
|
25
|
+
* Every item is a `RegisteredAction` resolved from the registry (entry actions,
|
|
26
|
+
* registry actions and legacy context-provider actions alike), so the button
|
|
27
|
+
* simply reads `item.action` and drives it through `useEntryActionState`
|
|
28
|
+
* (backed by the action's observable / `addListener`).
|
|
29
|
+
*/
|
|
30
|
+
export function ActionButton(props: Props) {
|
|
31
|
+
const { item, entry, onPress: onItemPress, component } = props;
|
|
32
|
+
|
|
33
|
+
const action = item?.action;
|
|
34
|
+
|
|
35
|
+
const { state, invokeAction } = useEntryActionState(action, entry);
|
|
36
|
+
|
|
37
|
+
const onPress = React.useCallback(
|
|
38
|
+
(_item) => {
|
|
39
|
+
invokeAction({
|
|
40
|
+
context: "toast",
|
|
41
|
+
dismiss: () => onItemPress?.(item),
|
|
42
|
+
...(component ? { component } : {}),
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
[invokeAction, item, onItemPress, component]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!isActionAvailableFor(action, entry as ZappEntry)) return null;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Button {...props} item={state} onPress={onPress} label={state?.label} />
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Explicitly set display name for the component
|
|
56
|
+
ActionButton.displayName = "ActionButton";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState";
|
|
2
|
+
import { boundActionButton } from "../boundActionButton";
|
|
3
|
+
import { openActionsBottomSheet } from "../openActionsBottomSheet";
|
|
4
|
+
|
|
5
|
+
jest.mock("@applicaster/zapp-react-native-utils/modalState", () => ({
|
|
6
|
+
openBottomSheetModal: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("../boundActionButton", () => ({
|
|
10
|
+
boundActionButton: jest.fn(() => jest.fn()),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe("openActionsBottomSheet", () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
jest.clearAllMocks();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("binds the List component into the sheet row button", () => {
|
|
19
|
+
const entry = { id: "entry-1" } as ZappEntry;
|
|
20
|
+
|
|
21
|
+
const component = {
|
|
22
|
+
data: { source: "https://example.com/user/collections/abc" },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const actions = [
|
|
26
|
+
{ identifier: "entry_action_0", action: { invokeAction: jest.fn() } },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
openActionsBottomSheet({
|
|
30
|
+
entry,
|
|
31
|
+
actions: actions as any,
|
|
32
|
+
component: component as any,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(boundActionButton).toHaveBeenCalledWith(entry, component);
|
|
36
|
+
expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { ActionButton, ActionButtonProps } from "./ActionButton";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Binds an entry to the sheet's row button.
|
|
7
|
+
*
|
|
8
|
+
* `BottomSheetModalContent` renders `buttonComponent` per item and does not
|
|
9
|
+
* know about entries, so the entry is closed over here instead.
|
|
10
|
+
*/
|
|
11
|
+
export const boundActionButton = (
|
|
12
|
+
entry: ZappEntry | ZappFeed,
|
|
13
|
+
component?: ZappUIComponent & { parent?: ZappUIComponent }
|
|
14
|
+
) => {
|
|
15
|
+
const ActionButtonWithEntry = (props: ActionButtonProps) => (
|
|
16
|
+
<ActionButton {...props} entry={entry as ZappEntry} component={component} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
ActionButtonWithEntry.displayName = "ActionButtonWithEntry";
|
|
20
|
+
|
|
21
|
+
return ActionButtonWithEntry;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
boundActionButton.displayName = "boundActionButton";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ActionButton } from "./ActionButton";
|
|
2
|
+
|
|
3
|
+
export type { ActionButtonProps } from "./ActionButton";
|
|
4
|
+
|
|
5
|
+
export { boundActionButton } from "./boundActionButton";
|
|
6
|
+
|
|
7
|
+
export { openActionsBottomSheet } from "./openActionsBottomSheet";
|
|
8
|
+
|
|
9
|
+
export type { OpenActionsBottomSheetArgs } from "./openActionsBottomSheet";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
2
|
+
import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState";
|
|
3
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
4
|
+
import { RegisteredAction } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
|
|
5
|
+
|
|
6
|
+
import { boundActionButton } from "./boundActionButton";
|
|
7
|
+
|
|
8
|
+
const { log_warning } = createLogger({
|
|
9
|
+
subsystem: "ActionsBottomSheet",
|
|
10
|
+
category: "Presentation",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type OpenActionsBottomSheetArgs = {
|
|
14
|
+
/** Entry the actions act on; bound into every row button. */
|
|
15
|
+
entry: ZappEntry | ZappFeed;
|
|
16
|
+
/** Already resolved and merged actions, in the order they should appear. */
|
|
17
|
+
actions: RegisteredAction[];
|
|
18
|
+
title?: string;
|
|
19
|
+
summary?: string;
|
|
20
|
+
/** List that opened the sheet; forwarded into row invokeAction context. */
|
|
21
|
+
component?: ZappUIComponent & { parent?: ZappUIComponent };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Presents a list of resolved actions in the shared bottom sheet.
|
|
26
|
+
*
|
|
27
|
+
* This is the core entry point for "show these actions in a sheet": the
|
|
28
|
+
* open-modal-bottom-sheet plugin uses it for its configured list, and the
|
|
29
|
+
* player overflow uses it for the actions that did not fit on the overlay.
|
|
30
|
+
* Neither has to know about the other, and neither needs the plugin installed.
|
|
31
|
+
*/
|
|
32
|
+
export function openActionsBottomSheet({
|
|
33
|
+
entry,
|
|
34
|
+
actions,
|
|
35
|
+
title,
|
|
36
|
+
summary,
|
|
37
|
+
component,
|
|
38
|
+
}: OpenActionsBottomSheetArgs): void {
|
|
39
|
+
if (!actions?.length) {
|
|
40
|
+
// Every action resolved away - unavailable for this entry, or not
|
|
41
|
+
// invokable. An empty sheet looks broken, so say why and stay put.
|
|
42
|
+
log_warning(
|
|
43
|
+
"openActionsBottomSheet: nothing to present - not opening the sheet",
|
|
44
|
+
{ entryId: (entry as ZappEntry)?.id }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
openBottomSheetModal({
|
|
51
|
+
modalBottomSheetContentProps: {
|
|
52
|
+
// TODO: should be optional - the button handles its own tap, but
|
|
53
|
+
// BottomSheetModalContent still requires an onPress.
|
|
54
|
+
onPress: noop,
|
|
55
|
+
items: actions,
|
|
56
|
+
buttonComponent: boundActionButton(entry, component),
|
|
57
|
+
title,
|
|
58
|
+
summary,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import React from "react";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Image,
|
|
14
|
+
Platform,
|
|
15
|
+
Pressable,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
Text,
|
|
18
|
+
View,
|
|
19
|
+
} from "react-native";
|
|
13
20
|
|
|
14
21
|
const styles = StyleSheet.create({
|
|
15
22
|
container: {
|
|
@@ -25,24 +32,6 @@ const styles = StyleSheet.create({
|
|
|
25
32
|
title: {
|
|
26
33
|
textAlign: "center",
|
|
27
34
|
},
|
|
28
|
-
demoScreen: {
|
|
29
|
-
flex: 1,
|
|
30
|
-
backgroundColor: "#1C1C1E",
|
|
31
|
-
paddingTop: 64,
|
|
32
|
-
paddingHorizontal: 24,
|
|
33
|
-
gap: 12,
|
|
34
|
-
},
|
|
35
|
-
demoHeading: {
|
|
36
|
-
color: "#FFFFFF",
|
|
37
|
-
fontSize: 20,
|
|
38
|
-
fontWeight: "600",
|
|
39
|
-
marginBottom: 8,
|
|
40
|
-
},
|
|
41
|
-
demoLabel: {
|
|
42
|
-
color: "#999999",
|
|
43
|
-
fontSize: 13,
|
|
44
|
-
marginTop: 8,
|
|
45
|
-
},
|
|
46
35
|
});
|
|
47
36
|
|
|
48
37
|
// ---------------------------------------------------------------------------
|
|
@@ -92,6 +81,8 @@ export type LeadingIconConfiguration = {
|
|
|
92
81
|
enabled: boolean;
|
|
93
82
|
/** Decides which icon will be displayed when enabled */
|
|
94
83
|
actionType?: ButtonActionType;
|
|
84
|
+
/** Optional Studio / modal-blocks asset URI (overrides actionType mapping) */
|
|
85
|
+
asset?: string;
|
|
95
86
|
};
|
|
96
87
|
|
|
97
88
|
export type IconsConfiguration = {
|
|
@@ -148,11 +139,12 @@ export type ButtonData = {
|
|
|
148
139
|
disabled?: boolean;
|
|
149
140
|
};
|
|
150
141
|
|
|
151
|
-
export type
|
|
142
|
+
export type AudioPlayerButtonProps = {
|
|
152
143
|
configuration: ButtonConfiguration;
|
|
153
144
|
data: ButtonData;
|
|
154
145
|
disabled?: boolean;
|
|
155
146
|
focused?: boolean;
|
|
147
|
+
onPress?: () => void;
|
|
156
148
|
};
|
|
157
149
|
|
|
158
150
|
// ---------------------------------------------------------------------------
|
|
@@ -170,7 +162,7 @@ const ACTION_ICON_ASSETS: Record<ButtonActionType, string> = {
|
|
|
170
162
|
confirm:
|
|
171
163
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJElEQVR42mNgGAWjYBSQCv4TwKMWDHELho/hNE/3o2AUDDcAAPv0QMAyy1CtAAAAAElFTkSuQmCC",
|
|
172
164
|
cancel:
|
|
173
|
-
"data:image/png;base64,
|
|
165
|
+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAASElEQVR42mNgGAWjGvynkVoUTf+pqA6nxv8UqiHbEooNx2cQ1QzHZiDVDcdlCcOQsoCmQUTTSKZpMqV5RqNLUUHTwm4UDBMAALBLQ73LTvoyAAAAAElFTkSuQmCC",
|
|
174
166
|
};
|
|
175
167
|
|
|
176
168
|
function getTextTransformStyle(
|
|
@@ -180,7 +172,9 @@ function getTextTransformStyle(
|
|
|
180
172
|
}
|
|
181
173
|
|
|
182
174
|
function shouldShowLeadingIcon(leadingIcon: LeadingIconConfiguration) {
|
|
183
|
-
return
|
|
175
|
+
return (
|
|
176
|
+
leadingIcon.enabled && (!!leadingIcon.actionType || !!leadingIcon.asset)
|
|
177
|
+
);
|
|
184
178
|
}
|
|
185
179
|
|
|
186
180
|
// ---------------------------------------------------------------------------
|
|
@@ -192,6 +186,7 @@ type ButtonContainerProps = {
|
|
|
192
186
|
disabled: boolean;
|
|
193
187
|
configuration: BackgroundConfiguration;
|
|
194
188
|
children: React.ReactNode;
|
|
189
|
+
onPress?: () => void;
|
|
195
190
|
};
|
|
196
191
|
|
|
197
192
|
function ButtonContainer({
|
|
@@ -199,19 +194,22 @@ function ButtonContainer({
|
|
|
199
194
|
disabled,
|
|
200
195
|
configuration,
|
|
201
196
|
children,
|
|
197
|
+
onPress,
|
|
202
198
|
}: ButtonContainerProps) {
|
|
203
|
-
const
|
|
199
|
+
const defaultBgColor = disabled
|
|
204
200
|
? configuration.inactiveColor
|
|
205
201
|
: focused
|
|
206
202
|
? configuration.focusedColor
|
|
207
203
|
: configuration.defaultColor;
|
|
208
204
|
|
|
209
205
|
return (
|
|
210
|
-
<
|
|
211
|
-
|
|
206
|
+
<Pressable
|
|
207
|
+
onPress={disabled ? undefined : onPress}
|
|
208
|
+
style={({ pressed }) => [
|
|
212
209
|
styles.container,
|
|
213
210
|
{
|
|
214
|
-
backgroundColor
|
|
211
|
+
backgroundColor:
|
|
212
|
+
pressed && !disabled ? configuration.focusedColor : defaultBgColor,
|
|
215
213
|
borderRadius: configuration.cornerRadius,
|
|
216
214
|
paddingTop: configuration.paddingTop,
|
|
217
215
|
paddingRight: configuration.paddingRight,
|
|
@@ -221,7 +219,7 @@ function ButtonContainer({
|
|
|
221
219
|
]}
|
|
222
220
|
>
|
|
223
221
|
{children}
|
|
224
|
-
</
|
|
222
|
+
</Pressable>
|
|
225
223
|
);
|
|
226
224
|
}
|
|
227
225
|
|
|
@@ -274,7 +272,7 @@ function ButtonTitle({
|
|
|
274
272
|
}
|
|
275
273
|
|
|
276
274
|
type ButtonLeadingIconProps = {
|
|
277
|
-
actionType
|
|
275
|
+
actionType?: ButtonActionType;
|
|
278
276
|
configuration: IconsConfiguration;
|
|
279
277
|
};
|
|
280
278
|
|
|
@@ -282,9 +280,17 @@ function ButtonLeadingIcon({
|
|
|
282
280
|
actionType,
|
|
283
281
|
configuration,
|
|
284
282
|
}: ButtonLeadingIconProps) {
|
|
283
|
+
const asset =
|
|
284
|
+
configuration.leadingIcon.asset ||
|
|
285
|
+
(actionType ? ACTION_ICON_ASSETS[actionType] : undefined);
|
|
286
|
+
|
|
287
|
+
if (!asset) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
|
|
285
291
|
return (
|
|
286
292
|
<Image
|
|
287
|
-
source={{ uri:
|
|
293
|
+
source={{ uri: asset }}
|
|
288
294
|
style={{
|
|
289
295
|
width: configuration.width,
|
|
290
296
|
height: configuration.height,
|
|
@@ -295,20 +301,32 @@ function ButtonLeadingIcon({
|
|
|
295
301
|
}
|
|
296
302
|
|
|
297
303
|
// ---------------------------------------------------------------------------
|
|
298
|
-
//
|
|
304
|
+
// AudioPlayerButton — single building block driven by configuration + data
|
|
299
305
|
// ---------------------------------------------------------------------------
|
|
300
306
|
|
|
301
|
-
|
|
307
|
+
import { useModalBlocksStyle } from "../../ModalBlocksStyleContext";
|
|
308
|
+
import { mergeButtonConfiguration } from "../utils/mergeStyles";
|
|
309
|
+
|
|
310
|
+
export function AudioPlayerButton({
|
|
302
311
|
configuration,
|
|
303
312
|
data,
|
|
304
313
|
disabled,
|
|
305
314
|
focused = false,
|
|
306
|
-
|
|
315
|
+
onPress,
|
|
316
|
+
}: AudioPlayerButtonProps) {
|
|
317
|
+
const modalBlocksStyle = useModalBlocksStyle();
|
|
318
|
+
const buttonBlock = modalBlocksStyle?.button;
|
|
319
|
+
const actionBlock = modalBlocksStyle?.action;
|
|
320
|
+
|
|
321
|
+
const effectiveConfig = React.useMemo(() => {
|
|
322
|
+
return mergeButtonConfiguration(configuration, buttonBlock, actionBlock);
|
|
323
|
+
}, [configuration, buttonBlock, actionBlock]);
|
|
324
|
+
|
|
307
325
|
const {
|
|
308
|
-
background:
|
|
309
|
-
title:
|
|
326
|
+
background: effectiveBgConfig,
|
|
327
|
+
title: effectiveTitleConfig,
|
|
310
328
|
icons: iconsConfiguration,
|
|
311
|
-
} =
|
|
329
|
+
} = effectiveConfig;
|
|
312
330
|
|
|
313
331
|
const { title } = data;
|
|
314
332
|
const isDisabled = disabled ?? data.disabled ?? false;
|
|
@@ -320,7 +338,8 @@ export function Item({
|
|
|
320
338
|
<ButtonContainer
|
|
321
339
|
focused={focused}
|
|
322
340
|
disabled={isDisabled}
|
|
323
|
-
configuration={
|
|
341
|
+
configuration={effectiveBgConfig}
|
|
342
|
+
onPress={onPress}
|
|
324
343
|
>
|
|
325
344
|
<View style={styles.contentRow}>
|
|
326
345
|
{showIcon ? (
|
|
@@ -329,14 +348,14 @@ export function Item({
|
|
|
329
348
|
actionType={leadingIcon.actionType}
|
|
330
349
|
configuration={iconsConfiguration}
|
|
331
350
|
/>
|
|
332
|
-
<View style={{ width:
|
|
351
|
+
<View style={{ width: effectiveBgConfig.horizontalGutter }} />
|
|
333
352
|
</>
|
|
334
353
|
) : null}
|
|
335
354
|
<ButtonTitle
|
|
336
355
|
title={title}
|
|
337
356
|
focused={focused}
|
|
338
357
|
disabled={isDisabled}
|
|
339
|
-
configuration={
|
|
358
|
+
configuration={effectiveTitleConfig}
|
|
340
359
|
/>
|
|
341
360
|
</View>
|
|
342
361
|
</ButtonContainer>
|
|
@@ -344,7 +363,7 @@ export function Item({
|
|
|
344
363
|
}
|
|
345
364
|
|
|
346
365
|
// ---------------------------------------------------------------------------
|
|
347
|
-
//
|
|
366
|
+
// Variant configurations
|
|
348
367
|
// ---------------------------------------------------------------------------
|
|
349
368
|
|
|
350
369
|
export const VARIANT_TEXT_ONLY: ButtonConfiguration = {
|
|
@@ -364,61 +383,3 @@ export const VARIANT_WITH_ICON: ButtonConfiguration = {
|
|
|
364
383
|
},
|
|
365
384
|
},
|
|
366
385
|
};
|
|
367
|
-
|
|
368
|
-
export const VARIANT_UPPERCASE_TITLE: ButtonConfiguration = {
|
|
369
|
-
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
370
|
-
title: {
|
|
371
|
-
...DEFAULT_TITLE_CONFIGURATION,
|
|
372
|
-
textTransform: "uppercase",
|
|
373
|
-
},
|
|
374
|
-
icons: DEFAULT_ICONS_CONFIGURATION,
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
export const VARIANT_LARGE_ICON: ButtonConfiguration = {
|
|
378
|
-
background: DEFAULT_BACKGROUND_CONFIGURATION,
|
|
379
|
-
title: DEFAULT_TITLE_CONFIGURATION,
|
|
380
|
-
icons: {
|
|
381
|
-
width: 32,
|
|
382
|
-
height: 32,
|
|
383
|
-
leadingIcon: {
|
|
384
|
-
enabled: true,
|
|
385
|
-
actionType: "addToQueue",
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
export default function App() {
|
|
391
|
-
return (
|
|
392
|
-
<View style={styles.demoScreen}>
|
|
393
|
-
<Text style={styles.demoHeading}>Modal Button Building Block</Text>
|
|
394
|
-
|
|
395
|
-
<Text style={styles.demoLabel}>Variant 1 — Text only (confirmation)</Text>
|
|
396
|
-
<Item configuration={VARIANT_TEXT_ONLY} data={{ title: "Confirm" }} />
|
|
397
|
-
|
|
398
|
-
<Text style={styles.demoLabel}>Variant 2 — Leading icon + text</Text>
|
|
399
|
-
<Item
|
|
400
|
-
configuration={VARIANT_WITH_ICON}
|
|
401
|
-
data={{ title: "Add To Playlist" }}
|
|
402
|
-
/>
|
|
403
|
-
|
|
404
|
-
<Text style={styles.demoLabel}>Inactive state</Text>
|
|
405
|
-
<Item
|
|
406
|
-
configuration={VARIANT_TEXT_ONLY}
|
|
407
|
-
data={{ title: "Unavailable" }}
|
|
408
|
-
disabled
|
|
409
|
-
/>
|
|
410
|
-
|
|
411
|
-
<Text style={styles.demoLabel}>Custom title config — uppercase</Text>
|
|
412
|
-
<Item
|
|
413
|
-
configuration={VARIANT_UPPERCASE_TITLE}
|
|
414
|
-
data={{ title: "Save Changes" }}
|
|
415
|
-
/>
|
|
416
|
-
|
|
417
|
-
<Text style={styles.demoLabel}>Custom icons config — 32×32</Text>
|
|
418
|
-
<Item
|
|
419
|
-
configuration={VARIANT_LARGE_ICON}
|
|
420
|
-
data={{ title: "Add To Queue" }}
|
|
421
|
-
/>
|
|
422
|
-
</View>
|
|
423
|
-
);
|
|
424
|
-
}
|