Skip to content

Conversation

cacheung
Copy link
Contributor

@cacheung cacheung commented Oct 2, 2025

Add unread UI implementation
Update the dist files, so a lot of files are changed. You can ignore the dist files.

Description

Example:

Light mode with image icon set - use image and unread background color
lightMode

Dark mode with no image url for icon - default to dot and unread background color
darkMode

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Add unread UI implementation
update the unread icon mock example
Use useContainerSettigs hook and update the dist files
update unreadIcon for error handling
template.track?.('content_clicked', MessagingEdgeEventType.INTERACT, null);

// Mark as read when interacted with
setIsRead(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put a TODO: here that this shouldnt be handled internally.

: styles.container,
styleOverrides?.container
styleOverrides?.container,
getUnreadBackgroundColor() && { backgroundColor: getUnreadBackgroundColor() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions cannot be memoized by react, so Id either memoize them or just handle them inline, which reads much cleaner

}

// Helper function to convert placement from settings to component position
const convertPlacement = (placement: 'topleft' | 'topright' | 'bottomleft' | 'bottomright'): 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we really need this, also Id create a type for the placement if you want to keep it


switch (displayPosition) {
case 'top-left':
return { ...baseStyle, top: 6, left: 6 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since baseStyle is applied everywhere, you can just keep it in the styles of the component its applied to, Id also just add these styles in StyleSheet.create so they can be optimized

}
};

const getDotColor = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesnt need to be a function, you can just do
const dotColor = useMemo(() => colorScheme === 'dark'...

const unreadSettings = settings.content.unread_indicator;

// Use settings from context with fallbacks to props
const displaySize = size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just reassigns the variable and then it isnt really used differently?

}

// If image failed to load, fallback to dot
if (renderType === 'image' && imageLoadError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good logic 👍

// If image failed to load, fallback to dot
if (renderType === 'image' && imageLoadError) {
return (
<View
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here i'd make this a separate component since its the same as below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe <Dot /> ?

}

if (renderType === 'image' && (imageSource || darkImageSource)) {
const finalImageSource = colorScheme === 'dark' && darkImageSource ? darkImageSource : imageSource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id memoize this above

@dsoffiantini dsoffiantini force-pushed the content-card-containers branch 6 times, most recently from 6997afe to 81521eb Compare October 4, 2025 18:20
Update with review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants