[MOB-12272] banner-component#750
[MOB-12272] banner-component#750lposen wants to merge 4 commits intoloren/embedded/MOB-12271-notification-componentfrom
Conversation
…orts for better organization
…g in IterableEmbeddedBanner
…de from Embedded component
|
Diff Coverage: The code coverage on the diff in this pull request is 33.3%. Total Coverage: This PR will increase coverage by 0.01%. File Coverage Changes
🛟 Help
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
3 new issues
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
| export const IterableEmbeddedBanner = ({ | ||
| config, | ||
| message, | ||
| onButtonClick = () => {}, | ||
| onMessageClick = () => {}, | ||
| }: IterableEmbeddedComponentProps) => { | ||
| const { parsedStyles, media, handleButtonClick, handleMessageClick } = | ||
| useEmbeddedView(IterableEmbeddedViewType.Banner, { | ||
| message, | ||
| config, | ||
| onButtonClick, | ||
| onMessageClick, | ||
| }); | ||
|
|
||
| const buttons = message.elements?.buttons ?? []; | ||
|
|
||
| return ( | ||
| <Pressable onPress={() => handleMessageClick()}> | ||
| <View | ||
| style={[ | ||
| styles.container, | ||
| { | ||
| backgroundColor: parsedStyles.backgroundColor, | ||
| borderColor: parsedStyles.borderColor, | ||
| borderRadius: parsedStyles.borderCornerRadius, | ||
| borderWidth: parsedStyles.borderWidth, | ||
| } as ViewStyle, | ||
| ]} | ||
| > | ||
| {} | ||
| <View | ||
| // eslint-disable-next-line react-native/no-inline-styles | ||
| style={[styles.bodyContainer, { gap: media.shouldShow ? 16 : 0 }]} | ||
| > | ||
| <View style={styles.textContainer}> | ||
| <Text | ||
| style={[ | ||
| styles.title, | ||
| { color: parsedStyles.titleTextColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {message.elements?.title} | ||
| </Text> | ||
| <Text | ||
| style={[ | ||
| styles.body, | ||
| { color: parsedStyles.bodyTextColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {message.elements?.body} | ||
| </Text> | ||
| </View> | ||
| {media.shouldShow && ( | ||
| <View style={styles.mediaContainer}> | ||
| <Image | ||
| source={{ | ||
| uri: media.url as string, | ||
| width: PixelRatio.getPixelSizeForLayoutSize(IMAGE_WIDTH), | ||
| height: PixelRatio.getPixelSizeForLayoutSize(IMAGE_HEIGHT), | ||
| }} | ||
| style={styles.mediaImage} | ||
| alt={media.caption as string} | ||
| /> | ||
| </View> | ||
| )} | ||
| </View> | ||
| {buttons.length > 0 && ( | ||
| <View style={styles.buttonContainer}> | ||
| {buttons.map((button, index) => { | ||
| const backgroundColor = | ||
| index === 0 | ||
| ? parsedStyles.primaryBtnBackgroundColor | ||
| : parsedStyles.secondaryBtnBackgroundColor; | ||
| const textColor = | ||
| index === 0 | ||
| ? parsedStyles.primaryBtnTextColor | ||
| : parsedStyles.secondaryBtnTextColor; | ||
| return ( | ||
| <TouchableOpacity | ||
| style={[styles.button, { backgroundColor } as ViewStyle]} | ||
| onPress={() => handleButtonClick(button)} | ||
| key={button.id} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.buttonText, | ||
| { color: textColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {button.title} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| ); | ||
| })} | ||
| </View> | ||
| )} | ||
| </View> | ||
| </Pressable> | ||
| ); |
| > | ||
| <View style={styles.textContainer}> | ||
| <Text | ||
| style={[ | ||
| styles.title, | ||
| { color: parsedStyles.titleTextColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {message.elements?.title} | ||
| </Text> | ||
| <Text | ||
| style={[ | ||
| styles.body, | ||
| { color: parsedStyles.bodyTextColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {message.elements?.body} | ||
| </Text> |
| </View> | ||
| {buttons.length > 0 && ( | ||
| <View style={styles.buttonContainer}> | ||
| {buttons.map((button, index) => { | ||
| const backgroundColor = | ||
| index === 0 | ||
| ? parsedStyles.primaryBtnBackgroundColor | ||
| : parsedStyles.secondaryBtnBackgroundColor; | ||
| const textColor = | ||
| index === 0 | ||
| ? parsedStyles.primaryBtnTextColor | ||
| : parsedStyles.secondaryBtnTextColor; | ||
| return ( | ||
| <TouchableOpacity | ||
| style={[styles.button, { backgroundColor } as ViewStyle]} | ||
| onPress={() => handleButtonClick(button)} | ||
| key={button.id} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.buttonText, | ||
| { color: textColor } as TextStyle, | ||
| ]} | ||
| > | ||
| {button.title} | ||
| </Text> | ||
| </TouchableOpacity> | ||
| ); | ||
| })} | ||
| </View> |
🔹 JIRA Ticket(s) if any
✏️ Description