Skip to content

Commit b9fbb06

Browse files
committed
feat: add IterableEmbedded components and view type enumeration for embedded messaging
1 parent 45ef4eb commit b9fbb06

10 files changed

Lines changed: 149 additions & 0 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { View, Text } from 'react-native';
2+
3+
import type { IterableEmbeddedComponentProps } from '../types/IterableEmbeddedComponentProps';
4+
5+
export const IterableEmbeddedBanner = ({
6+
config,
7+
message,
8+
onButtonClick = () => {},
9+
}: IterableEmbeddedComponentProps) => {
10+
console.log(`🚀 > IterableEmbeddedBanner > config:`, config);
11+
console.log(`🚀 > IterableEmbeddedBanner > message:`, message);
12+
console.log(`🚀 > IterableEmbeddedBanner > onButtonClick:`, onButtonClick);
13+
14+
return (
15+
<View>
16+
<Text>IterableEmbeddedBanner</Text>
17+
</View>
18+
);
19+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { View, Text } from 'react-native';
2+
import type { IterableEmbeddedComponentProps } from '../types/IterableEmbeddedComponentProps';
3+
4+
export const IterableEmbeddedCard = ({
5+
config,
6+
message,
7+
onButtonClick = () => {},
8+
}: IterableEmbeddedComponentProps) => {
9+
console.log(`🚀 > IterableEmbeddedCard > config:`, config);
10+
console.log(`🚀 > IterableEmbeddedCard > message:`, message);
11+
console.log(`🚀 > IterableEmbeddedCard > onButtonClick:`, onButtonClick);
12+
13+
return (
14+
<View>
15+
<Text>IterableEmbeddedCard</Text>
16+
</View>
17+
);
18+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { View, Text } from 'react-native';
2+
3+
import type { IterableEmbeddedComponentProps } from '../types/IterableEmbeddedComponentProps';
4+
5+
export const IterableEmbeddedNotification = ({
6+
config,
7+
message,
8+
onButtonClick = () => {},
9+
}: IterableEmbeddedComponentProps) => {
10+
console.log(`🚀 > IterableEmbeddedNotification > config:`, config);
11+
console.log(`🚀 > IterableEmbeddedNotification > message:`, message);
12+
console.log(
13+
`🚀 > IterableEmbeddedNotification > onButtonClick:`,
14+
onButtonClick
15+
);
16+
17+
return (
18+
<View>
19+
<Text>IterableEmbeddedNotification</Text>
20+
</View>
21+
);
22+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useMemo } from 'react';
2+
3+
import { IterableEmbeddedViewType } from '../enums/IterableEmbeddedViewType';
4+
5+
import { IterableEmbeddedBanner } from './IterableEmbeddedBanner';
6+
import { IterableEmbeddedCard } from './IterableEmbeddedCard';
7+
import { IterableEmbeddedNotification } from './IterableEmbeddedNotification';
8+
import type { IterableEmbeddedComponentProps } from '../types/IterableEmbeddedComponentProps';
9+
10+
/**
11+
* The props for the IterableEmbeddedView component.
12+
*/
13+
interface IterableEmbeddedViewProps extends IterableEmbeddedComponentProps {
14+
/** The type of view to render. */
15+
viewType: IterableEmbeddedViewType;
16+
}
17+
18+
export const IterableEmbeddedView = ({
19+
viewType,
20+
...props
21+
}: IterableEmbeddedViewProps) => {
22+
const Cmp = useMemo(() => {
23+
switch (viewType) {
24+
case IterableEmbeddedViewType.Card:
25+
return IterableEmbeddedCard;
26+
case IterableEmbeddedViewType.Notification:
27+
return IterableEmbeddedNotification;
28+
case IterableEmbeddedViewType.Banner:
29+
return IterableEmbeddedBanner;
30+
default:
31+
return null;
32+
}
33+
}, [viewType]);
34+
35+
return Cmp ? <Cmp {...props} /> : null;
36+
};

src/embedded/components/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './IterableEmbeddedBanner';
2+
export * from './IterableEmbeddedCard';
3+
export * from './IterableEmbeddedNotification';
4+
export * from './IterableEmbeddedView';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* The view type for an embedded message.
3+
*/
4+
export enum IterableEmbeddedViewType {
5+
/** The embedded view is a banner */
6+
Banner = 0,
7+
/** The embedded view is a card */
8+
Card = 1,
9+
/** The embedded view is a notification */
10+
Notification = 2,
11+
}

src/embedded/enums/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './IterableEmbeddedViewType';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { IterableEmbeddedMessage } from './IterableEmbeddedMessage';
2+
import type { IterableEmbeddedMessageElementsButton } from './IterableEmbeddedMessageElementsButton';
3+
import type { IterableEmbeddedViewConfig } from './IterableEmbeddedViewConfig';
4+
5+
export interface IterableEmbeddedComponentProps {
6+
message: IterableEmbeddedMessage;
7+
config?: IterableEmbeddedViewConfig | null;
8+
onButtonClick?: (button: IterableEmbeddedMessageElementsButton) => void;
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { ColorValue } from 'react-native';
2+
3+
/**
4+
* Represents view-level styling configuration for an embedded view.
5+
*/
6+
export interface IterableEmbeddedViewConfig {
7+
/** Background color hex (e.g., 0xFF0000) */
8+
backgroundColor?: ColorValue;
9+
/** Border color hex */
10+
borderColor?: ColorValue;
11+
/** Border width in pixels */
12+
borderWidth?: number;
13+
/** Corner radius in points */
14+
borderCornerRadius?: number;
15+
/** Primary button background color hex */
16+
primaryBtnBackgroundColor?: ColorValue;
17+
/** Primary button text color hex */
18+
primaryBtnTextColor?: ColorValue;
19+
/** Secondary button background color hex */
20+
secondaryBtnBackgroundColor?: ColorValue;
21+
/** Secondary button text color hex */
22+
secondaryBtnTextColor?: ColorValue;
23+
/** Title text color hex */
24+
titleTextColor?: ColorValue;
25+
/** Body text color hex */
26+
bodyTextColor?: ColorValue;
27+
}

src/embedded/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
export * from './IterableEmbeddedComponentProps';
12
export * from './IterableEmbeddedMessage';
23
export * from './IterableEmbeddedMessageElements';
34
export * from './IterableEmbeddedMessageElementsButton';
45
export * from './IterableEmbeddedMessageElementsText';
56
export * from './IterableEmbeddedMessageMetadata';
7+
export * from './IterableEmbeddedViewConfig';

0 commit comments

Comments
 (0)