Skip to content

Conversation

@sheep-q
Copy link
Contributor

@sheep-q sheep-q commented Oct 14, 2025

🔗 Issue Links

N/A

🎯 Goal

Be able to customize the text view for messages that contain both attachments and text.

📝 Summary

Add a method to the ViewFactory that makes the attachment text view

🛠 Implementation

Add the makeAttachmentTextView method to ViewFactory to enable customization

🎨 Showcase

Add relevant screenshots and/or videos/gifs to easily see what this PR changes, if applicable.

Before After
img img

🧪 Manual Testing Notes

Explain how this change can be tested manually, if applicable.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@sheep-q sheep-q requested a review from a team as a code owner October 14, 2025 04:52
Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

Looks good, left few small comments.

let injectedBackgroundColor: UIColor?

public init(message: ChatMessage, injectedBackgroundColor: UIColor? = nil) {
public init(factory: Factory, message: ChatMessage, injectedBackgroundColor: UIColor? = nil) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should put a default parameter DefaultViewFactory.shared to avoid breaking changes here.

Copy link
Contributor

Choose a reason for hiding this comment

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

we should put the default param here

}

public func makeAttachmentTextView(
message: ChatMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

We now follow an approach where we put an options class instead of the params directly. So this would be something like AttachmentTextViewOptions, with one property message (to enable adding new properties in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The access level of AttachmentTextViewOptions should be open, right? To allow developers to subclass and extend the class further in the feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

no, just public is enough - we would like to control the extensibility of these classes internally.

/// - Parameter message: The message containing the attachment.
/// - Returns: The view shown in the attachment text slot.
func makeAttachmentTextView(
message: ChatMessage
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually add a unit test to make sure that we don't change the returned type (see ViewFactory_Tests).

@sheep-q
Copy link
Contributor Author

sheep-q commented Oct 20, 2025

Thanks @martinmitrevski for the review. Pls take another look at new updates

@Binding public var scrolledId: String?

public init(factory: Factory, message: ChatMessage, contentWidth: CGFloat, isFirst: Bool, scrolledId: Binding<String?>) {
public init(factory: Factory = DefaultViewFactory.shared, message: ChatMessage, contentWidth: CGFloat, isFirst: Bool, scrolledId: Binding<String?>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this one is actually fine, we shouldn't change its signature, check the other one AttachmentTextView

let injectedBackgroundColor: UIColor?

public init(message: ChatMessage, injectedBackgroundColor: UIColor? = nil) {
public init(factory: Factory, message: ChatMessage, injectedBackgroundColor: UIColor? = nil) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should put the default param here

}

// Options for the attachment text view.
open class AttachmentTextViewOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be public

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Pls take another look. Thank you

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Looks good from my side ✅ @testableapple can you please run the checks before merging?

@testableapple testableapple changed the base branch from develop to test/make-attachment-text-view October 21, 2025 09:18
@testableapple testableapple merged commit faa2765 into GetStream:test/make-attachment-text-view Oct 21, 2025
5 of 9 checks passed
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Oct 22, 2025
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.

3 participants