@adobe/react-native-aepmessaging 7.3.0 → 7.4.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/RCTAEPMessaging.podspec +1 -1
- package/README.md +145 -16
- package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +82 -32
- package/babel.config.js +3 -0
- package/dist/module/Messaging.js +334 -0
- package/dist/module/Messaging.js.map +1 -0
- package/dist/module/index.js +30 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/models/ContentCard.js +24 -0
- package/dist/module/models/ContentCard.js.map +1 -0
- package/dist/{models → module/models}/HTMLProposition.js +8 -9
- package/dist/module/models/HTMLProposition.js.map +1 -0
- package/dist/module/models/InAppMessage.js +4 -0
- package/dist/module/models/InAppMessage.js.map +1 -0
- package/dist/module/models/JSONProposition.js +22 -0
- package/dist/module/models/JSONProposition.js.map +1 -0
- package/dist/module/models/Message.js +182 -0
- package/dist/module/models/Message.js.map +1 -0
- package/dist/module/models/MessagingDelegate.js +4 -0
- package/dist/module/models/MessagingDelegate.js.map +1 -0
- package/dist/module/models/MessagingEdgeEventType.js +24 -0
- package/dist/module/models/MessagingEdgeEventType.js.map +1 -0
- package/dist/module/models/MessagingProposition.js +57 -0
- package/dist/module/models/MessagingProposition.js.map +1 -0
- package/dist/module/models/MessagingPropositionItem.js +4 -0
- package/dist/module/models/MessagingPropositionItem.js.map +1 -0
- package/dist/module/models/PersonalizationSchema.js +26 -0
- package/dist/module/models/PersonalizationSchema.js.map +1 -0
- package/dist/module/models/PropositionItem.js +113 -0
- package/dist/module/models/PropositionItem.js.map +1 -0
- package/dist/module/models/ScopeDetails.js +2 -0
- package/dist/module/models/ScopeDetails.js.map +1 -0
- package/dist/{models/JSONProposition.js → module/models/index.js} +14 -12
- package/dist/module/models/index.js.map +1 -0
- package/dist/module/ui/components/Button/Button.js +57 -0
- package/dist/module/ui/components/Button/Button.js.map +1 -0
- package/dist/module/ui/components/Button/Button.spec.js +476 -0
- package/dist/module/ui/components/Button/Button.spec.js.map +1 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.js +257 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.js.map +1 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js +363 -0
- package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js.map +1 -0
- package/dist/module/ui/components/DismissButton/DismissButton.js +70 -0
- package/dist/module/ui/components/DismissButton/DismissButton.js.map +1 -0
- package/dist/module/ui/components/DismissButton/DismissButton.spec.js +279 -0
- package/dist/module/ui/components/DismissButton/DismissButton.spec.js.map +1 -0
- package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js +34 -0
- package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js.map +1 -0
- package/dist/module/ui/components/Inbox/EmptyState.js +64 -0
- package/dist/module/ui/components/Inbox/EmptyState.js.map +1 -0
- package/dist/module/ui/components/Inbox/Inbox.js +235 -0
- package/dist/module/ui/components/Inbox/Inbox.js.map +1 -0
- package/dist/module/ui/components/Inbox/Inbox.spec.js +847 -0
- package/dist/module/ui/components/Inbox/Inbox.spec.js.map +1 -0
- package/dist/module/ui/components/Pagination/Pagination.js +176 -0
- package/dist/module/ui/components/Pagination/Pagination.js.map +1 -0
- package/dist/module/ui/components/Pagination/Pagination.spec.js +193 -0
- package/dist/module/ui/components/Pagination/Pagination.spec.js.map +1 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.js +184 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.js.map +1 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js +815 -0
- package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js.map +1 -0
- package/dist/{models/ContentCard.js → module/ui/components/index.js} +12 -12
- package/dist/module/ui/components/index.js.map +1 -0
- package/dist/module/ui/hooks/index.js +18 -0
- package/dist/module/ui/hooks/index.js.map +1 -0
- package/dist/module/ui/hooks/useAspectRatio.js +33 -0
- package/dist/module/ui/hooks/useAspectRatio.js.map +1 -0
- package/dist/module/ui/hooks/useAspectRatio.spec.js +65 -0
- package/dist/module/ui/hooks/useAspectRatio.spec.js.map +1 -0
- package/dist/module/ui/hooks/useContentCardUI.js +51 -0
- package/dist/module/ui/hooks/useContentCardUI.js.map +1 -0
- package/dist/module/ui/hooks/useContentCardUI.spec.js +85 -0
- package/dist/module/ui/hooks/useContentCardUI.spec.js.map +1 -0
- package/dist/module/ui/hooks/useInbox.js +49 -0
- package/dist/module/ui/hooks/useInbox.js.map +1 -0
- package/dist/module/ui/hooks/useInbox.spec.js +93 -0
- package/dist/module/ui/hooks/useInbox.spec.js.map +1 -0
- package/dist/module/ui/hooks/useInboxSettings.js +26 -0
- package/dist/module/ui/hooks/useInboxSettings.js.map +1 -0
- package/dist/module/ui/hooks/useInboxSettings.spec.js +50 -0
- package/dist/module/ui/hooks/useInboxSettings.spec.js.map +1 -0
- package/dist/module/ui/index.js +10 -0
- package/dist/module/ui/index.js.map +1 -0
- package/dist/module/ui/providers/InboxProvider.js +27 -0
- package/dist/module/ui/providers/InboxProvider.js.map +1 -0
- package/dist/module/ui/theme/Theme.js +2 -0
- package/dist/module/ui/theme/Theme.js.map +1 -0
- package/dist/module/ui/theme/ThemeProvider.js +112 -0
- package/dist/module/ui/theme/ThemeProvider.js.map +1 -0
- package/dist/{models/InAppMessage.js → module/ui/theme/index.js} +6 -3
- package/dist/module/ui/theme/index.js.map +1 -0
- package/dist/module/ui/types/ContentViewEvent.js +2 -0
- package/dist/module/ui/types/ContentViewEvent.js.map +1 -0
- package/dist/module/ui/types/Templates.js +26 -0
- package/dist/module/ui/types/Templates.js.map +1 -0
- package/dist/{models/ScopeDetails.js → module/ui/types/index.js} +6 -3
- package/dist/module/ui/types/index.js.map +1 -0
- package/dist/module/ui/utils/generateCardHash.js +50 -0
- package/dist/module/ui/utils/generateCardHash.js.map +1 -0
- package/dist/module/ui/utils/generateCardHash.spec.js +103 -0
- package/dist/module/ui/utils/generateCardHash.spec.js.map +1 -0
- package/dist/module/ui/utils/inboxStorage.js +65 -0
- package/dist/module/ui/utils/inboxStorage.js.map +1 -0
- package/dist/module/ui/utils/inboxStorage.spec.js +123 -0
- package/dist/module/ui/utils/inboxStorage.spec.js.map +1 -0
- package/dist/module/ui/utils/index.js +5 -0
- package/dist/module/ui/utils/index.js.map +1 -0
- package/dist/{Messaging.d.ts → typescript/Messaging.d.ts} +23 -7
- package/dist/typescript/Messaging.d.ts.map +1 -0
- package/dist/{index.d.ts → typescript/index.d.ts} +4 -2
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/models/ContentCard.d.ts +57 -0
- package/dist/typescript/models/ContentCard.d.ts.map +1 -0
- package/dist/{models → typescript/models}/HTMLProposition.d.ts +1 -0
- package/dist/typescript/models/HTMLProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/InAppMessage.d.ts +1 -0
- package/dist/typescript/models/InAppMessage.d.ts.map +1 -0
- package/dist/{models → typescript/models}/JSONProposition.d.ts +1 -0
- package/dist/typescript/models/JSONProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/Message.d.ts +1 -0
- package/dist/typescript/models/Message.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingDelegate.d.ts +1 -0
- package/dist/typescript/models/MessagingDelegate.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingEdgeEventType.d.ts +1 -0
- package/dist/typescript/models/MessagingEdgeEventType.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingProposition.d.ts +1 -0
- package/dist/typescript/models/MessagingProposition.d.ts.map +1 -0
- package/dist/{models → typescript/models}/MessagingPropositionItem.d.ts +1 -0
- package/dist/typescript/models/MessagingPropositionItem.d.ts.map +1 -0
- package/dist/{models → typescript/models}/PersonalizationSchema.d.ts +2 -0
- package/dist/typescript/models/PersonalizationSchema.d.ts.map +1 -0
- package/dist/{models → typescript/models}/PropositionItem.d.ts +1 -0
- package/dist/typescript/models/PropositionItem.d.ts.map +1 -0
- package/dist/{models → typescript/models}/ScopeDetails.d.ts +1 -0
- package/dist/typescript/models/ScopeDetails.d.ts.map +1 -0
- package/dist/typescript/models/index.d.ts +11 -0
- package/dist/typescript/models/index.d.ts.map +1 -0
- package/dist/typescript/ui/components/Button/Button.d.ts +14 -0
- package/dist/typescript/ui/components/Button/Button.d.ts.map +1 -0
- package/dist/typescript/ui/components/Button/Button.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Button/Button.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts +39 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts.map +1 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts +2 -0
- package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts +13 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts.map +1 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts +2 -0
- package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts +5 -0
- package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/EmptyState.d.ts +19 -0
- package/dist/typescript/ui/components/Inbox/EmptyState.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/Inbox.d.ts +21 -0
- package/dist/typescript/ui/components/Inbox/Inbox.d.ts.map +1 -0
- package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/Pagination/Pagination.d.ts +14 -0
- package/dist/typescript/ui/components/Pagination/Pagination.d.ts.map +1 -0
- package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts +2 -0
- package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts +14 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts.map +1 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts +2 -0
- package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts.map +1 -0
- package/dist/typescript/ui/components/index.d.ts +10 -0
- package/dist/typescript/ui/components/index.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/index.d.ts +4 -0
- package/dist/typescript/ui/hooks/index.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useAspectRatio.d.ts +3 -0
- package/dist/typescript/ui/hooks/useAspectRatio.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useContentCardUI.d.ts +14 -0
- package/dist/typescript/ui/hooks/useContentCardUI.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInbox.d.ts +12 -0
- package/dist/typescript/ui/hooks/useInbox.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInbox.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useInbox.spec.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInboxSettings.d.ts +7 -0
- package/dist/typescript/ui/hooks/useInboxSettings.d.ts.map +1 -0
- package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts +2 -0
- package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts.map +1 -0
- package/dist/typescript/ui/index.d.ts +8 -0
- package/dist/typescript/ui/index.d.ts.map +1 -0
- package/dist/typescript/ui/providers/InboxProvider.d.ts +56 -0
- package/dist/typescript/ui/providers/InboxProvider.d.ts.map +1 -0
- package/dist/typescript/ui/theme/Theme.d.ts +44 -0
- package/dist/typescript/ui/theme/Theme.d.ts.map +1 -0
- package/dist/typescript/ui/theme/ThemeProvider.d.ts +21 -0
- package/dist/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/typescript/ui/theme/index.d.ts +3 -0
- package/dist/typescript/ui/theme/index.d.ts.map +1 -0
- package/dist/typescript/ui/types/ContentViewEvent.d.ts +9 -0
- package/dist/typescript/ui/types/ContentViewEvent.d.ts.map +1 -0
- package/dist/typescript/ui/types/Templates.d.ts +43 -0
- package/dist/typescript/ui/types/Templates.d.ts.map +1 -0
- package/dist/typescript/ui/types/index.d.ts +3 -0
- package/dist/typescript/ui/types/index.d.ts.map +1 -0
- package/dist/typescript/ui/utils/generateCardHash.d.ts +21 -0
- package/dist/typescript/ui/utils/generateCardHash.d.ts.map +1 -0
- package/dist/typescript/ui/utils/generateCardHash.spec.d.ts +2 -0
- package/dist/typescript/ui/utils/generateCardHash.spec.d.ts.map +1 -0
- package/dist/typescript/ui/utils/inboxStorage.d.ts +20 -0
- package/dist/typescript/ui/utils/inboxStorage.d.ts.map +1 -0
- package/dist/typescript/ui/utils/inboxStorage.spec.d.ts +2 -0
- package/dist/typescript/ui/utils/inboxStorage.spec.d.ts.map +1 -0
- package/dist/typescript/ui/utils/index.d.ts +3 -0
- package/dist/typescript/ui/utils/index.d.ts.map +1 -0
- package/ios/src/RCTAEPMessaging.mm +11 -0
- package/ios/src/RCTAEPMessaging.swift +30 -3
- package/jest.config.js +15 -0
- package/package.json +33 -5
- package/src/Messaging.ts +287 -32
- package/src/index.ts +3 -3
- package/src/models/ContentCard.ts +52 -27
- package/src/models/HTMLProposition.ts +1 -1
- package/src/models/JSONProposition.ts +1 -1
- package/src/models/PersonalizationSchema.ts +1 -0
- package/src/models/index.ts +22 -0
- package/src/ui/components/Button/Button.spec.tsx +496 -0
- package/src/ui/components/Button/Button.tsx +76 -0
- package/src/ui/components/ContentCardView/ContentCardView.spec.tsx +278 -0
- package/src/ui/components/ContentCardView/ContentCardView.tsx +400 -0
- package/src/ui/components/DismissButton/DismissButton.spec.tsx +314 -0
- package/src/ui/components/DismissButton/DismissButton.tsx +100 -0
- package/src/ui/components/FullScreenCenterView/FullScreenCenterView.tsx +32 -0
- package/src/ui/components/Inbox/EmptyState.tsx +89 -0
- package/src/ui/components/Inbox/Inbox.spec.tsx +478 -0
- package/src/ui/components/Inbox/Inbox.tsx +275 -0
- package/src/ui/components/Pagination/Pagination.spec.tsx +159 -0
- package/src/ui/components/Pagination/Pagination.tsx +222 -0
- package/src/ui/components/UnreadIcon/UnreadIcon.spec.tsx +878 -0
- package/src/ui/components/UnreadIcon/UnreadIcon.tsx +234 -0
- package/src/ui/components/index.ts +22 -0
- package/{dist/models/MessagingPropositionItem.js → src/ui/hooks/index.ts} +5 -4
- package/src/ui/hooks/useAspectRatio.spec.tsx +66 -0
- package/src/ui/hooks/useAspectRatio.tsx +39 -0
- package/src/ui/hooks/useContentCardUI.spec.tsx +82 -0
- package/src/ui/hooks/useContentCardUI.ts +48 -0
- package/src/ui/hooks/useInbox.spec.tsx +87 -0
- package/src/ui/hooks/useInbox.ts +46 -0
- package/src/ui/hooks/useInboxSettings.spec.tsx +41 -0
- package/src/ui/hooks/useInboxSettings.ts +24 -0
- package/src/ui/index.ts +7 -0
- package/src/ui/providers/InboxProvider.tsx +79 -0
- package/src/ui/theme/Theme.ts +57 -0
- package/src/ui/theme/ThemeProvider.tsx +120 -0
- package/src/ui/theme/index.ts +14 -0
- package/src/ui/types/ContentViewEvent.ts +20 -0
- package/src/ui/types/Templates.ts +77 -0
- package/src/ui/types/index.ts +14 -0
- package/src/ui/utils/generateCardHash.spec.tsx +86 -0
- package/src/ui/utils/generateCardHash.ts +59 -0
- package/src/ui/utils/inboxStorage.spec.tsx +136 -0
- package/src/ui/utils/inboxStorage.ts +64 -0
- package/src/ui/utils/index.ts +3 -0
- package/tutorials/ContentCardCustomizationGuide.md +661 -0
- package/tutorials/ContentCards.md +419 -0
- package/tutorials/Inbox.md +515 -0
- package/tutorials/resources/image-only-template.png +0 -0
- package/tutorials/resources/large-image-template.png +0 -0
- package/tutorials/resources/small-image-template.png +0 -0
- package/dist/Messaging.js +0 -152
- package/dist/Messaging.js.map +0 -1
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/models/ContentCard.d.ts +0 -51
- package/dist/models/ContentCard.js.map +0 -1
- package/dist/models/HTMLProposition.js.map +0 -1
- package/dist/models/InAppMessage.js.map +0 -1
- package/dist/models/JSONProposition.js.map +0 -1
- package/dist/models/Message.js +0 -156
- package/dist/models/Message.js.map +0 -1
- package/dist/models/MessagingDelegate.js +0 -14
- package/dist/models/MessagingDelegate.js.map +0 -1
- package/dist/models/MessagingEdgeEventType.js +0 -24
- package/dist/models/MessagingEdgeEventType.js.map +0 -1
- package/dist/models/MessagingProposition.js +0 -59
- package/dist/models/MessagingProposition.js.map +0 -1
- package/dist/models/MessagingPropositionItem.js.map +0 -1
- package/dist/models/PersonalizationSchema.js +0 -25
- package/dist/models/PersonalizationSchema.js.map +0 -1
- package/dist/models/PropositionItem.js +0 -78
- package/dist/models/PropositionItem.js.map +0 -1
- package/dist/models/ScopeDetails.js.map +0 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
4
|
+
"License"); you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
7
|
+
or agreed to in writing, software distributed under the License is
|
|
8
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
|
|
9
|
+
ANY KIND, either express or implied. See the License for the specific
|
|
10
|
+
language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { fireEvent, render, waitFor } from '@testing-library/react-native';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { Image, Linking } from 'react-native';
|
|
16
|
+
import MessagingEdgeEventType from '../../../models/MessagingEdgeEventType';
|
|
17
|
+
import UnreadIcon from '../UnreadIcon/UnreadIcon';
|
|
18
|
+
import { ContentCardView } from './ContentCardView';
|
|
19
|
+
|
|
20
|
+
// Mock aspect ratio hook to a stable value
|
|
21
|
+
jest.mock('../../hooks/useAspectRatio', () => ({ __esModule: true, default: () => 1.5 }));
|
|
22
|
+
|
|
23
|
+
// Mock inbox settings (unread enabled)
|
|
24
|
+
jest.mock('../../hooks/useInboxSettings', () => {
|
|
25
|
+
const fn = jest.fn(() => ({
|
|
26
|
+
content: {
|
|
27
|
+
isUnreadEnabled: true,
|
|
28
|
+
unread_indicator: { unread_bg: { clr: { light: '#EEE', dark: '#111' } } }
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
return { __esModule: true, default: fn };
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const makeTemplate = (overrides: Partial<any> = {}) => ({
|
|
35
|
+
id: 'card-1',
|
|
36
|
+
type: 'SmallImage',
|
|
37
|
+
isRead: false,
|
|
38
|
+
data: {
|
|
39
|
+
content: {
|
|
40
|
+
title: { content: 'Title' },
|
|
41
|
+
body: { content: 'Body' },
|
|
42
|
+
image: { url: 'https://example.com/img.png' },
|
|
43
|
+
dismissBtn: { style: 'close' },
|
|
44
|
+
actionUrl: 'https://adobe.com'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
track: jest.fn(),
|
|
48
|
+
...overrides,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('ContentCardView - rendering variants', () => {
|
|
52
|
+
it('renders SmallImage with title and body', () => {
|
|
53
|
+
const template = makeTemplate({ type: 'SmallImage' });
|
|
54
|
+
const { getByText } = render(
|
|
55
|
+
<ContentCardView template={template as any} />
|
|
56
|
+
);
|
|
57
|
+
expect(getByText('Title')).toBeTruthy();
|
|
58
|
+
expect(getByText('Body')).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('falls back to SmallImage when variant and template.type are missing', () => {
|
|
62
|
+
const template = makeTemplate({ type: undefined as any });
|
|
63
|
+
// remove variant prop
|
|
64
|
+
const { getByText } = render(
|
|
65
|
+
<ContentCardView template={template as any} />
|
|
66
|
+
);
|
|
67
|
+
expect(getByText('Title')).toBeTruthy();
|
|
68
|
+
expect(getByText('Body')).toBeTruthy();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('renders LargeImage with title, body, and buttons', () => {
|
|
72
|
+
const template = makeTemplate({
|
|
73
|
+
type: 'LargeImage',
|
|
74
|
+
data: {
|
|
75
|
+
content: {
|
|
76
|
+
title: { content: 'Title' },
|
|
77
|
+
body: { content: 'Body' },
|
|
78
|
+
image: { url: 'https://example.com/img.png' },
|
|
79
|
+
dismissBtn: { style: 'close' },
|
|
80
|
+
buttons: [
|
|
81
|
+
{ id: 'btn1', text: { content: 'Go' }, actionUrl: 'https://example.com/go' },
|
|
82
|
+
],
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const { getByText } = render(
|
|
88
|
+
<ContentCardView template={template as any} />
|
|
89
|
+
);
|
|
90
|
+
expect(getByText('Title')).toBeTruthy();
|
|
91
|
+
expect(getByText('Body')).toBeTruthy();
|
|
92
|
+
// Button rendered from buttons map
|
|
93
|
+
expect(getByText('Go')).toBeTruthy();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('renders ImageOnly without text sections but with image', () => {
|
|
97
|
+
const template = makeTemplate({ type: 'ImageOnly' });
|
|
98
|
+
const { queryByText, UNSAFE_getAllByType } = render(
|
|
99
|
+
<ContentCardView template={template as any} />
|
|
100
|
+
);
|
|
101
|
+
expect(queryByText('Title')).toBeNull();
|
|
102
|
+
expect(queryByText('Body')).toBeNull();
|
|
103
|
+
// Ensure an Image is rendered
|
|
104
|
+
const images = UNSAFE_getAllByType(Image);
|
|
105
|
+
expect(images.length).toBeGreaterThan(0);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('uses darkUrl for images when in dark mode', () => {
|
|
109
|
+
const rn = require('react-native');
|
|
110
|
+
const colorSpy = jest.spyOn(rn, 'useColorScheme');
|
|
111
|
+
colorSpy.mockReturnValue('dark');
|
|
112
|
+
|
|
113
|
+
const template = makeTemplate({
|
|
114
|
+
data: { content: { image: { url: 'https://light.png', darkUrl: 'https://dark.png' }, title: { content: 'Title' }, body: { content: 'Body' }, dismissBtn: { style: 'close' } } }
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const { UNSAFE_getAllByType } = render(
|
|
118
|
+
<ContentCardView template={template as any} />
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const images = UNSAFE_getAllByType(Image);
|
|
122
|
+
expect(images[0].props.source.uri).toBe('https://dark.png');
|
|
123
|
+
|
|
124
|
+
colorSpy.mockRestore();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('falls back gracefully for unknown variant (default case)', () => {
|
|
128
|
+
const template = makeTemplate({ type: 'UnknownVariant' as any });
|
|
129
|
+
const { getByText } = render(
|
|
130
|
+
<ContentCardView template={template as any} />
|
|
131
|
+
);
|
|
132
|
+
// Should still render content without throwing
|
|
133
|
+
expect(getByText('Title')).toBeTruthy();
|
|
134
|
+
expect(getByText('Body')).toBeTruthy();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('ContentCardView - interactions and tracking', () => {
|
|
140
|
+
afterEach(() => {
|
|
141
|
+
jest.restoreAllMocks();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('does not crash if Linking.openURL throws (error case)', async () => {
|
|
145
|
+
jest.spyOn(Linking, 'canOpenURL').mockResolvedValueOnce(true as any);
|
|
146
|
+
const openSpy = jest
|
|
147
|
+
.spyOn(Linking, 'openURL')
|
|
148
|
+
.mockImplementationOnce(() => Promise.reject(new Error('open failed')) as any);
|
|
149
|
+
|
|
150
|
+
const template = makeTemplate();
|
|
151
|
+
const listener = jest.fn();
|
|
152
|
+
const { getByTestId } = render(
|
|
153
|
+
<ContentCardView template={template as any} listener={listener} testID="card" />
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
expect(() => fireEvent.press(getByTestId('card'))).not.toThrow();
|
|
157
|
+
await waitFor(() => expect(openSpy).toHaveBeenCalled());
|
|
158
|
+
expect(listener).toHaveBeenCalledWith('onInteract', template);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('onPress with no track and no actionUrl does not throw or open URL', () => {
|
|
162
|
+
const openSpy = jest.spyOn(Linking, 'openURL').mockClear();
|
|
163
|
+
const base = makeTemplate();
|
|
164
|
+
const tpl = JSON.parse(JSON.stringify(base));
|
|
165
|
+
tpl.track = undefined;
|
|
166
|
+
delete tpl.data.content.actionUrl;
|
|
167
|
+
|
|
168
|
+
const { getByTestId } = render(
|
|
169
|
+
<ContentCardView template={tpl as any} testID="card" />
|
|
170
|
+
);
|
|
171
|
+
expect(() => fireEvent.press(getByTestId('card'))).not.toThrow();
|
|
172
|
+
expect(openSpy).not.toHaveBeenCalled();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('calls onDisplay once and tracks DISPLAY', () => {
|
|
176
|
+
const template = makeTemplate();
|
|
177
|
+
const listener = jest.fn();
|
|
178
|
+
render(<ContentCardView template={template as any} listener={listener} testID="card" />);
|
|
179
|
+
expect(listener).toHaveBeenCalledWith('onDisplay', template);
|
|
180
|
+
expect(template.track).toHaveBeenCalledWith(MessagingEdgeEventType.DISPLAY);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('tracks INTERACT and opens URL on press', async () => {
|
|
184
|
+
const template = makeTemplate();
|
|
185
|
+
const listener = jest.fn();
|
|
186
|
+
jest.spyOn(Linking, 'canOpenURL').mockResolvedValueOnce(true as any);
|
|
187
|
+
jest.spyOn(Linking, 'openURL').mockResolvedValueOnce(undefined as any);
|
|
188
|
+
const { getByTestId } = render(<ContentCardView template={template as any} listener={listener} testID="card" />);
|
|
189
|
+
fireEvent.press(getByTestId('card'));
|
|
190
|
+
expect(listener).toHaveBeenCalledWith('onInteract', template);
|
|
191
|
+
expect(template.track).toHaveBeenCalledWith('content_clicked', MessagingEdgeEventType.INTERACT, null);
|
|
192
|
+
await waitFor(() =>
|
|
193
|
+
expect(Linking.openURL).toHaveBeenCalledWith('https://adobe.com')
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('warns when card actionUrl cannot be opened (canOpenURL returns false)', async () => {
|
|
198
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
199
|
+
const canOpenSpy = jest.spyOn(Linking, 'canOpenURL').mockResolvedValue(false as any);
|
|
200
|
+
jest.spyOn(Linking, 'openURL').mockResolvedValue(undefined as any);
|
|
201
|
+
|
|
202
|
+
const template = makeTemplate();
|
|
203
|
+
const listener = jest.fn();
|
|
204
|
+
const { getByTestId } = render(
|
|
205
|
+
<ContentCardView template={template as any} listener={listener} testID="card" />
|
|
206
|
+
);
|
|
207
|
+
fireEvent.press(getByTestId('card'));
|
|
208
|
+
|
|
209
|
+
await waitFor(() => {
|
|
210
|
+
expect(canOpenSpy).toHaveBeenCalledWith('https://adobe.com');
|
|
211
|
+
expect(warnSpy).toHaveBeenCalledWith('Cannot open URL: https://adobe.com');
|
|
212
|
+
});
|
|
213
|
+
warnSpy.mockRestore();
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('calls listener with onInteract, template, and buttonId when a CTA button is pressed', async () => {
|
|
217
|
+
const template = makeTemplate({
|
|
218
|
+
type: 'LargeImage',
|
|
219
|
+
data: {
|
|
220
|
+
content: {
|
|
221
|
+
title: { content: 'Title' },
|
|
222
|
+
body: { content: 'Body' },
|
|
223
|
+
image: { url: 'https://example.com/img.png' },
|
|
224
|
+
dismissBtn: { style: 'close' },
|
|
225
|
+
buttons: [
|
|
226
|
+
{ id: 'btn1', text: { content: 'Go' }, actionUrl: 'https://example.com/go' },
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
const listener = jest.fn();
|
|
232
|
+
jest.spyOn(Linking, 'canOpenURL').mockResolvedValue(true as any);
|
|
233
|
+
jest.spyOn(Linking, 'openURL').mockResolvedValue(undefined as any);
|
|
234
|
+
|
|
235
|
+
const { getByText } = render(
|
|
236
|
+
<ContentCardView template={template as any} listener={listener} />
|
|
237
|
+
);
|
|
238
|
+
fireEvent.press(getByText('Go'));
|
|
239
|
+
|
|
240
|
+
expect(listener).toHaveBeenCalledWith('onInteract', template, { buttonId: 'btn1' });
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('calls onDismiss, tracks DISMISS, and hides the card', () => {
|
|
244
|
+
const template = makeTemplate();
|
|
245
|
+
const listener = jest.fn();
|
|
246
|
+
const { queryByText, getByText } = render(
|
|
247
|
+
<ContentCardView template={template as any} listener={listener} />
|
|
248
|
+
);
|
|
249
|
+
// Dismiss button renders as 'x'
|
|
250
|
+
fireEvent.press(getByText('\u00D7'));
|
|
251
|
+
expect(listener).toHaveBeenCalledWith('onDismiss', template);
|
|
252
|
+
expect(template.track).toHaveBeenCalledWith(MessagingEdgeEventType.DISMISS);
|
|
253
|
+
// Card should no longer render title after dismiss
|
|
254
|
+
expect(queryByText('Title')).toBeNull();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('ContentCardView - unread indicator and styles', () => {
|
|
260
|
+
it('renders UnreadIcon by default when settings are missing', () => {
|
|
261
|
+
const useInboxSettings = require('../../hooks/useInboxSettings').default as jest.Mock;
|
|
262
|
+
useInboxSettings.mockReturnValueOnce({});
|
|
263
|
+
const template = makeTemplate({ isRead: false });
|
|
264
|
+
const { UNSAFE_getAllByType } = render(
|
|
265
|
+
<ContentCardView template={template as any} />
|
|
266
|
+
);
|
|
267
|
+
expect(UNSAFE_getAllByType(UnreadIcon).length).toBeGreaterThan(0);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('applies dynamic Pressable style function', () => {
|
|
271
|
+
const tpl = makeTemplate();
|
|
272
|
+
const styleFn = jest.fn(() => ({}));
|
|
273
|
+
render(<ContentCardView template={tpl as any} style={styleFn as any} />);
|
|
274
|
+
expect(styleFn).toHaveBeenCalled();
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the
|
|
4
|
+
"License"); you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
|
|
7
|
+
or agreed to in writing, software distributed under the License is
|
|
8
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
|
|
9
|
+
ANY KIND, either express or implied. See the License for the specific
|
|
10
|
+
language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import React, {
|
|
14
|
+
useEffect,
|
|
15
|
+
useCallback,
|
|
16
|
+
useState,
|
|
17
|
+
useRef,
|
|
18
|
+
useMemo,
|
|
19
|
+
} from "react";
|
|
20
|
+
import {
|
|
21
|
+
ComponentOverrideProps,
|
|
22
|
+
ContentTemplate,
|
|
23
|
+
ImageOnlyContentStyle,
|
|
24
|
+
LargeImageContentStyle,
|
|
25
|
+
SmallImageContentStyle,
|
|
26
|
+
} from "../../types/Templates";
|
|
27
|
+
import { ContentViewEvent } from "../../types/ContentViewEvent";
|
|
28
|
+
import {
|
|
29
|
+
Image,
|
|
30
|
+
Linking,
|
|
31
|
+
Pressable,
|
|
32
|
+
PressableProps,
|
|
33
|
+
StyleSheet,
|
|
34
|
+
Text,
|
|
35
|
+
View
|
|
36
|
+
} from 'react-native';
|
|
37
|
+
import MessagingEdgeEventType from '../../../models/MessagingEdgeEventType';
|
|
38
|
+
import DismissButton from '../DismissButton/DismissButton';
|
|
39
|
+
import UnreadIcon from '../UnreadIcon/UnreadIcon';
|
|
40
|
+
import { useTheme } from '../../theme';
|
|
41
|
+
import useAspectRatio from '../../hooks/useAspectRatio';
|
|
42
|
+
import { ContentCardContent, ContentCardTemplate } from '../../../models';
|
|
43
|
+
import Button from '../Button/Button';
|
|
44
|
+
import useInboxSettings from '../../hooks/useInboxSettings';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Callback function that is called when a content card event occurs.
|
|
48
|
+
*/
|
|
49
|
+
export type ContentCardEventListener = (
|
|
50
|
+
/** The event that occurred, one of "onDismiss", "onDisplay", "onInteract" */
|
|
51
|
+
event?: ContentViewEvent,
|
|
52
|
+
/** The full content card data associated with the event */
|
|
53
|
+
data?: ContentTemplate,
|
|
54
|
+
/** Any additional native event data that accompanies the event */
|
|
55
|
+
nativeEvent?: any
|
|
56
|
+
) => void;
|
|
57
|
+
|
|
58
|
+
/** Props for the ContentCardView component */
|
|
59
|
+
export interface ContentViewProps
|
|
60
|
+
extends PressableProps,
|
|
61
|
+
ComponentOverrideProps {
|
|
62
|
+
/** The content card data to display */
|
|
63
|
+
template: ContentTemplate;
|
|
64
|
+
/** Style overrides per template type for the content card */
|
|
65
|
+
styleOverrides?: {
|
|
66
|
+
/** Style overrides for the small image content card */
|
|
67
|
+
smallImageStyle?: SmallImageContentStyle;
|
|
68
|
+
/** Style overrides for the large image content card */
|
|
69
|
+
largeImageStyle?: LargeImageContentStyle;
|
|
70
|
+
/** Style overrides for the image only content card */
|
|
71
|
+
imageOnlyStyle?: ImageOnlyContentStyle;
|
|
72
|
+
};
|
|
73
|
+
/** The function to call when a content card event occurs */
|
|
74
|
+
listener?: ContentCardEventListener;
|
|
75
|
+
/** The variant of the content card to display */
|
|
76
|
+
variant?: ContentCardTemplate;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @experimental
|
|
81
|
+
* Renders a content card view.
|
|
82
|
+
*/
|
|
83
|
+
export const ContentCardView: React.FC<ContentViewProps> = ({
|
|
84
|
+
template,
|
|
85
|
+
listener,
|
|
86
|
+
variant,
|
|
87
|
+
styleOverrides: _styleOverrides,
|
|
88
|
+
style,
|
|
89
|
+
ContainerProps,
|
|
90
|
+
ImageContainerProps,
|
|
91
|
+
ImageProps,
|
|
92
|
+
ContentContainerProps,
|
|
93
|
+
TextProps,
|
|
94
|
+
TitleProps,
|
|
95
|
+
BodyProps,
|
|
96
|
+
ButtonContainerProps,
|
|
97
|
+
ButtonProps,
|
|
98
|
+
DismissButtonProps,
|
|
99
|
+
...props
|
|
100
|
+
}) => {
|
|
101
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
102
|
+
const isDisplayedRef = useRef(false);
|
|
103
|
+
const { colors, isDark } = useTheme();
|
|
104
|
+
const containerSettings = useInboxSettings();
|
|
105
|
+
|
|
106
|
+
const isRead = template.isRead ?? false;
|
|
107
|
+
|
|
108
|
+
// Default to true if not specified
|
|
109
|
+
const isUnreadEnabled = containerSettings?.content?.isUnreadEnabled ?? true;
|
|
110
|
+
|
|
111
|
+
// Get unread background color based on theme
|
|
112
|
+
const unreadBackgroundColor = useMemo(() => {
|
|
113
|
+
if (!isUnreadEnabled || isRead || !containerSettings?.content?.unread_indicator?.unread_bg) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const unreadBg = containerSettings.content.unread_indicator.unread_bg;
|
|
118
|
+
return isDark ? unreadBg.clr.dark : unreadBg.clr.light;
|
|
119
|
+
}, [isUnreadEnabled, isRead, containerSettings, isDark]);
|
|
120
|
+
|
|
121
|
+
const cardVariant = useMemo<ContentCardTemplate>(
|
|
122
|
+
() => variant ?? template.type ?? "SmallImage",
|
|
123
|
+
[variant, template.type]
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const onDismiss = useCallback(() => {
|
|
127
|
+
listener?.("onDismiss", template);
|
|
128
|
+
|
|
129
|
+
// Track dismiss event using propositionItem
|
|
130
|
+
template.track?.(MessagingEdgeEventType.DISMISS);
|
|
131
|
+
|
|
132
|
+
setIsVisible(false);
|
|
133
|
+
}, [listener, template]);
|
|
134
|
+
|
|
135
|
+
const onPress = useCallback(async () => {
|
|
136
|
+
listener?.("onInteract", template);
|
|
137
|
+
|
|
138
|
+
// Track interaction event using propositionItem
|
|
139
|
+
template.track?.("content_clicked", MessagingEdgeEventType.INTERACT, null);
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
const actionUrl = template.data.content.actionUrl;
|
|
143
|
+
if (actionUrl) {
|
|
144
|
+
try {
|
|
145
|
+
const supported = await Linking.canOpenURL(actionUrl);
|
|
146
|
+
if (supported) {
|
|
147
|
+
await Linking.openURL(actionUrl);
|
|
148
|
+
} else {
|
|
149
|
+
console.warn(`Cannot open URL: ${actionUrl}`);
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.warn(
|
|
153
|
+
`Failed to open URL: ${actionUrl}`,
|
|
154
|
+
error
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, [template, listener]);
|
|
159
|
+
|
|
160
|
+
const onButtonPress = useCallback((buttonId?: string) => {
|
|
161
|
+
listener?.("onInteract", template, { buttonId });
|
|
162
|
+
}, [listener, template]);
|
|
163
|
+
|
|
164
|
+
const imageUri = useMemo(() => {
|
|
165
|
+
if (isDark && template.data?.content?.image?.darkUrl) {
|
|
166
|
+
return template.data.content.image.darkUrl;
|
|
167
|
+
}
|
|
168
|
+
return template.data.content.image?.url;
|
|
169
|
+
}, [
|
|
170
|
+
isDark,
|
|
171
|
+
template.data?.content?.image?.darkUrl,
|
|
172
|
+
template.data?.content?.image?.url,
|
|
173
|
+
]);
|
|
174
|
+
|
|
175
|
+
const imageAspectRatio = useAspectRatio(imageUri);
|
|
176
|
+
|
|
177
|
+
const styleOverrides = useMemo<
|
|
178
|
+
| (SmallImageContentStyle & LargeImageContentStyle & ImageOnlyContentStyle)
|
|
179
|
+
| null
|
|
180
|
+
>(() => {
|
|
181
|
+
switch (cardVariant) {
|
|
182
|
+
case "SmallImage":
|
|
183
|
+
return _styleOverrides?.smallImageStyle as SmallImageContentStyle;
|
|
184
|
+
case "LargeImage":
|
|
185
|
+
return _styleOverrides?.largeImageStyle as LargeImageContentStyle;
|
|
186
|
+
case "ImageOnly":
|
|
187
|
+
return _styleOverrides?.imageOnlyStyle as ImageOnlyContentStyle;
|
|
188
|
+
default:
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}, [_styleOverrides, cardVariant]);
|
|
192
|
+
|
|
193
|
+
// Call listener on mount to signal view display (only once to prevent duplicates)
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!isDisplayedRef.current) {
|
|
196
|
+
listener?.("onDisplay", template);
|
|
197
|
+
// Track display event using propositionItem
|
|
198
|
+
template.track?.(MessagingEdgeEventType.DISPLAY);
|
|
199
|
+
isDisplayedRef.current = true;
|
|
200
|
+
}
|
|
201
|
+
}, [listener, template]);
|
|
202
|
+
|
|
203
|
+
// If not visible, return null to hide the entire view
|
|
204
|
+
if (!isVisible) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!template.data) return null;
|
|
209
|
+
|
|
210
|
+
const content = template?.data?.content as ContentCardContent;
|
|
211
|
+
|
|
212
|
+
if (!content) return null;
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<Pressable
|
|
216
|
+
accessibilityLabel={content?.title?.content ?? 'Content Card'}
|
|
217
|
+
onPress={onPress}
|
|
218
|
+
style={(state) => [
|
|
219
|
+
styles.card,
|
|
220
|
+
styleOverrides?.card,
|
|
221
|
+
typeof style === "function" ? style(state) : style,
|
|
222
|
+
]}
|
|
223
|
+
{...props}
|
|
224
|
+
>
|
|
225
|
+
<View
|
|
226
|
+
style={[
|
|
227
|
+
cardVariant === "SmallImage"
|
|
228
|
+
? smallImageStyles.container
|
|
229
|
+
: styles.container,
|
|
230
|
+
styleOverrides?.container,
|
|
231
|
+
unreadBackgroundColor && { backgroundColor: unreadBackgroundColor }
|
|
232
|
+
]}
|
|
233
|
+
{...ContainerProps}
|
|
234
|
+
>
|
|
235
|
+
{imageUri && (
|
|
236
|
+
<View
|
|
237
|
+
style={[
|
|
238
|
+
cardVariant === "SmallImage"
|
|
239
|
+
? smallImageStyles.imageContainer
|
|
240
|
+
: [styles.imageContainer, { backgroundColor: colors.imageContainerColor }],
|
|
241
|
+
styleOverrides?.imageContainer,
|
|
242
|
+
]}
|
|
243
|
+
{...ImageContainerProps}
|
|
244
|
+
>
|
|
245
|
+
<Image
|
|
246
|
+
source={{ uri: imageUri }}
|
|
247
|
+
style={[
|
|
248
|
+
cardVariant === "SmallImage"
|
|
249
|
+
? smallImageStyles.image
|
|
250
|
+
: styles.image,
|
|
251
|
+
{ aspectRatio: imageAspectRatio },
|
|
252
|
+
styleOverrides?.image,
|
|
253
|
+
]}
|
|
254
|
+
resizeMode="contain"
|
|
255
|
+
{...ImageProps}
|
|
256
|
+
/>
|
|
257
|
+
</View>
|
|
258
|
+
)}
|
|
259
|
+
{cardVariant !== "ImageOnly" && (
|
|
260
|
+
<View
|
|
261
|
+
style={[cardVariant === "SmallImage"
|
|
262
|
+
? smallImageStyles.contentContainer
|
|
263
|
+
: styles.contentContainer, styleOverrides?.contentContainer]}
|
|
264
|
+
{...ContentContainerProps}
|
|
265
|
+
>
|
|
266
|
+
{content?.title?.content && (
|
|
267
|
+
<Text
|
|
268
|
+
style={[
|
|
269
|
+
styles.title,
|
|
270
|
+
{ color: colors.textPrimary },
|
|
271
|
+
styleOverrides?.text,
|
|
272
|
+
styleOverrides?.title,
|
|
273
|
+
]}
|
|
274
|
+
{...TextProps}
|
|
275
|
+
{...TitleProps}
|
|
276
|
+
>
|
|
277
|
+
{content.title.content}
|
|
278
|
+
</Text>
|
|
279
|
+
)}
|
|
280
|
+
{content?.body?.content && (
|
|
281
|
+
<Text
|
|
282
|
+
style={[
|
|
283
|
+
styles.body,
|
|
284
|
+
{ color: colors.textPrimary },
|
|
285
|
+
styleOverrides?.text,
|
|
286
|
+
styleOverrides?.body,
|
|
287
|
+
]}
|
|
288
|
+
{...TextProps}
|
|
289
|
+
{...BodyProps}
|
|
290
|
+
>
|
|
291
|
+
{content.body.content}
|
|
292
|
+
</Text>
|
|
293
|
+
)}
|
|
294
|
+
<View
|
|
295
|
+
style={[styles.buttonContainer, styleOverrides?.buttonContainer]}
|
|
296
|
+
{...ButtonContainerProps}
|
|
297
|
+
>
|
|
298
|
+
{(Array.isArray(content?.buttons) && content.buttons.length > 0) &&
|
|
299
|
+
content.buttons.map((button) => (
|
|
300
|
+
<Button
|
|
301
|
+
key={button.id}
|
|
302
|
+
interactId={button.id}
|
|
303
|
+
actionUrl={button.actionUrl}
|
|
304
|
+
title={button.text.content}
|
|
305
|
+
onPress={onButtonPress}
|
|
306
|
+
style={styleOverrides?.button}
|
|
307
|
+
textStyle={[
|
|
308
|
+
styleOverrides?.text,
|
|
309
|
+
styleOverrides?.buttonText,
|
|
310
|
+
]}
|
|
311
|
+
{...ButtonProps}
|
|
312
|
+
/>
|
|
313
|
+
))}
|
|
314
|
+
</View>
|
|
315
|
+
</View>
|
|
316
|
+
)}
|
|
317
|
+
{content?.dismissBtn && content.dismissBtn?.style !== "none" && (
|
|
318
|
+
<DismissButton
|
|
319
|
+
onPress={onDismiss}
|
|
320
|
+
type={content.dismissBtn.style}
|
|
321
|
+
{...DismissButtonProps}
|
|
322
|
+
/>
|
|
323
|
+
)}
|
|
324
|
+
{isUnreadEnabled && !isRead && (
|
|
325
|
+
<UnreadIcon accessibilityLabel="Unread Icon" />
|
|
326
|
+
)}
|
|
327
|
+
</View>
|
|
328
|
+
</Pressable>
|
|
329
|
+
);
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const styles = StyleSheet.create({
|
|
333
|
+
card: {
|
|
334
|
+
margin: 15,
|
|
335
|
+
flex: 1,
|
|
336
|
+
},
|
|
337
|
+
container: {
|
|
338
|
+
flexDirection: "column",
|
|
339
|
+
},
|
|
340
|
+
imageContainer: {
|
|
341
|
+
alignItems: "center",
|
|
342
|
+
borderRadius: 12,
|
|
343
|
+
},
|
|
344
|
+
image: {
|
|
345
|
+
width: "100%",
|
|
346
|
+
resizeMode: "contain",
|
|
347
|
+
},
|
|
348
|
+
contentContainer: {
|
|
349
|
+
paddingVertical: 16,
|
|
350
|
+
paddingHorizontal: 16,
|
|
351
|
+
justifyContent: "flex-start",
|
|
352
|
+
},
|
|
353
|
+
title: {
|
|
354
|
+
fontSize: 16,
|
|
355
|
+
fontWeight: "600",
|
|
356
|
+
marginBottom: 8,
|
|
357
|
+
marginRight: 16,
|
|
358
|
+
},
|
|
359
|
+
body: {
|
|
360
|
+
fontSize: 14,
|
|
361
|
+
lineHeight: 18,
|
|
362
|
+
},
|
|
363
|
+
buttonContainer: {
|
|
364
|
+
flexDirection: "row",
|
|
365
|
+
justifyContent: "flex-start",
|
|
366
|
+
flexWrap: "wrap",
|
|
367
|
+
paddingTop: 8,
|
|
368
|
+
gap: 8,
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
const smallImageStyles = StyleSheet.create({
|
|
373
|
+
card: {
|
|
374
|
+
borderRadius: 12,
|
|
375
|
+
flexDirection: "row",
|
|
376
|
+
gap: 8,
|
|
377
|
+
maxWidth: "100%",
|
|
378
|
+
alignItems: "center",
|
|
379
|
+
},
|
|
380
|
+
container: {
|
|
381
|
+
flexDirection: "row",
|
|
382
|
+
},
|
|
383
|
+
contentContainer: {
|
|
384
|
+
flex: 1,
|
|
385
|
+
paddingVertical: 16,
|
|
386
|
+
paddingHorizontal: 16,
|
|
387
|
+
justifyContent: "flex-start",
|
|
388
|
+
},
|
|
389
|
+
imageContainer: {
|
|
390
|
+
borderRadius: 12,
|
|
391
|
+
maxWidth: "35%",
|
|
392
|
+
alignSelf: "center",
|
|
393
|
+
},
|
|
394
|
+
image: {
|
|
395
|
+
resizeMode: "contain",
|
|
396
|
+
width: "100%",
|
|
397
|
+
maxWidth: "100%",
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
|