Skip to content

fix(mobile): sync img placeholder colors with current text color - #788

Open
hejsztynx wants to merge 3 commits into
mainfrom
@ksienkiewicz/fix-img-placeholder-color
Open

hejsztynx wants to merge 3 commits into
mainfrom
@ksienkiewicz/fix-img-placeholder-color

Conversation

@hejsztynx

Copy link
Copy Markdown
Collaborator

Summary

The inline image's placeholder colors were inconsistent across all platforms:

  • web: the color matched the current text color (correct)
  • iOS: the color was fixed
  • Android: the color was fixed

Test Plan

Create an inline image with an invalid url to create a img placeholder. Next adjust the EnrichedTextInput style prop, with a changed color. Notice the updated color on the placeholder.

Screenshots / Videos

Before(iOS):

Screenshot 2026-09-07 at 10 52 52

After (iOS):

Screenshot 2026-09-07 at 10 51 53

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI lite review requested due to automatic review settings September 7, 2026 08:53
@hejsztynx
hejsztynx marked this pull request as draft September 7, 2026 08:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Android AsyncDrawable’s placeholder path mutates drawable/state from a background thread (and doesn’t set placeholder bounds), which can cause incorrect rendering and thread-safety issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the iOS and Android implementations so inline image “broken/invalid” placeholders inherit the current text color, matching the intended behavior seen on web.

Changes:

  • iOS: updates attachment image view tinting to follow the current configured primary/text color during attachment layout updates.
  • Android: plumbs a “current text color” value through span factories and image span creation, and adds refresh logic to update existing placeholder tints when the text color changes.
  • Android: adds placeholder-tint support to both async (network) image drawables and static fallback placeholder drawables.
File summaries
File Description
ios/utils/AttachmentLayoutUtils.mm Updates attachment UIImageView tintColor to track the current configured color.
android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt Passes currentTextColor into image span creation for inline images.
android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputImageSpan.kt Adds placeholder tint/color plumbing and static-placeholder tracking.
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt Refreshes existing image placeholder tints when the view color changes.
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt Tracks textColor for span creation and forwards it to image span creation.
android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextImageSpan.kt Adds placeholder tint/color plumbing and static-placeholder tracking for non-input text.
android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt Refreshes existing image placeholder tints when the view color changes.
android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt Tracks textColor for span creation and forwards it to image span creation.
android/src/main/java/com/swmansion/enriched/common/spans/EnrichedImageSpan.kt Adds placeholder refresh API + passes tint color into AsyncDrawable creation.
android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt Extends the span-factory contract to carry a textColor value.
android/src/main/java/com/swmansion/enriched/common/AsyncDrawable.kt Adds placeholder tinting support for async-loaded images.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +60 to +62
mainHandler.post {
loadPlaceholderImage()
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was caught by Copilot. Previously loadPlaceholderImage which mutates AsyncDrawable internal state, could be run from a secondary thread. This may lead to some state desynchronization, so we delegate it to the main thread, just like we already do few lines above

@hejsztynx
hejsztynx marked this pull request as ready for review September 7, 2026 13:03
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