Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion examples/demo/src/components/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props {
icon?: React.ReactNode;
iconPosition?: 'left' | 'right';
leftAligned?: boolean;
compact?: boolean;
}

export default function ActionButton({
Expand All @@ -25,6 +26,7 @@ export default function ActionButton({
icon,
iconPosition = 'left',
leftAligned,
compact,
}: Props) {
const bgColor = variant === 'primary' ? AppColors.osPrimary : 'transparent';

Expand All @@ -42,6 +44,7 @@ export default function ActionButton({
styles.button,
{ backgroundColor: bgColor },
borderStyle,
compact && styles.compact,
(disabled || loading) && styles.disabled,
]}
activeOpacity={0.8}
Expand All @@ -51,7 +54,13 @@ export default function ActionButton({
) : (
<View style={[styles.inner, leftAligned && styles.leftAligned]}>
{icon && iconPosition === 'left' && <View style={styles.iconLeft}>{icon}</View>}
<Text style={[styles.text, { color: textColor }]}>{label}</Text>
<Text
style={[styles.text, { color: textColor }, compact && styles.compactText]}
numberOfLines={compact ? 1 : undefined}
adjustsFontSizeToFit={compact}
>
{label}
</Text>
{icon && iconPosition === 'right' && <View style={styles.iconRight}>{icon}</View>}
</View>
)}
Expand Down Expand Up @@ -80,6 +89,12 @@ const styles = StyleSheet.create({
fontSize: 14,
fontWeight: '600',
},
compact: {
paddingHorizontal: 8,
},
compactText: {
flexShrink: 1,
},
iconLeft: {
marginRight: 8,
},
Expand Down
42 changes: 30 additions & 12 deletions examples/demo/src/components/sections/SendIamSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';

import { InAppMessageType, iamTypeLabel } from '../../models/InAppMessageType';
import { AppSpacing } from '../../theme';
import ActionButton from '../ActionButton';
import SectionCard from '../SectionCard';

Expand All @@ -9,24 +11,40 @@ interface Props {
onInfoTap?: () => void;
}

const IAM_TYPES: InAppMessageType[] = [
InAppMessageType.TopBanner,
InAppMessageType.BottomBanner,
InAppMessageType.CenterModal,
InAppMessageType.FullScreen,
const IAM_TYPE_ROWS: InAppMessageType[][] = [
[InAppMessageType.TopBanner, InAppMessageType.BottomBanner],
[InAppMessageType.CenterModal, InAppMessageType.Html],
[InAppMessageType.FullScreen, InAppMessageType.FullBleed],
[InAppMessageType.Carousel, InAppMessageType.CarouselBleed],
];

export default function SendIamSection({ onSendIam, onInfoTap }: Props) {
return (
<SectionCard title="Send In-App Message" onInfoTap={onInfoTap} sectionKey="send_iam">
{IAM_TYPES.map((type) => (
<ActionButton
key={type}
label={iamTypeLabel[type]}
onPress={() => onSendIam(type)}
testID={`send_iam_${type}_button`}
/>
{IAM_TYPE_ROWS.map((row) => (
<View key={row.join('-')} style={styles.row}>
{row.map((type) => (
<View key={type} style={styles.cell}>
<ActionButton
label={iamTypeLabel[type]}
onPress={() => onSendIam(type)}
testID={`send_iam_${type}_button`}
compact
/>
</View>
))}
</View>
))}
</SectionCard>
);
}

const styles = StyleSheet.create({
row: {
flexDirection: 'row',
columnGap: AppSpacing.gap,
},
cell: {
flex: 1,
},
});
16 changes: 12 additions & 4 deletions examples/demo/src/models/InAppMessageType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ export enum InAppMessageType {
TopBanner = 'top_banner',
BottomBanner = 'bottom_banner',
CenterModal = 'center_modal',
Html = 'html',
FullScreen = 'full_screen',
FullBleed = 'full_bleed',
Carousel = 'carousel',
CarouselBleed = 'carousel_bleed',
}

export const iamTypeLabel: Record<InAppMessageType, string> = {
[InAppMessageType.TopBanner]: 'TOP BANNER',
[InAppMessageType.BottomBanner]: 'BOTTOM BANNER',
[InAppMessageType.CenterModal]: 'CENTER MODAL',
[InAppMessageType.FullScreen]: 'FULL SCREEN',
[InAppMessageType.TopBanner]: 'TOP',
[InAppMessageType.BottomBanner]: 'BOTTOM',
[InAppMessageType.CenterModal]: 'CENTER',
[InAppMessageType.Html]: 'HTML',
[InAppMessageType.FullScreen]: 'FULL',
[InAppMessageType.FullBleed]: 'FULL BLEED',
[InAppMessageType.Carousel]: 'CAROUSEL',
[InAppMessageType.CarouselBleed]: 'CAROUSEL BLEED',
};
Loading