Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initials Placeholder for ChatAvatarView #2087

Open
martindaum opened this issue Jun 14, 2022 · 9 comments
Open

Initials Placeholder for ChatAvatarView #2087

martindaum opened this issue Jun 14, 2022 · 9 comments
Labels
🙏 Feature Request A new feature request 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK

Comments

@martindaum
Copy link

What are you trying to achieve?

If there is no image set for an Avatar, I would like to show a placeholder with the initials of the user instead of an avatar placeholder.

If possible, how can you achieve this currently?

I guess I could create a custom view for it and use a custom MessageContentView to inject it

What would be the better way?

The Android SDK falls back to the initials view, so it would be great if the iOS SDK also has the same behaviour.

GetStream Environment

GetStream Chat version: 4.16.0
GetStream Chat frameworks: StreamChat, StreamChatUI
iOS version:
Swift version:
Xcode version:
Device:

Additional context

@b-onc
Copy link
Contributor

b-onc commented Jun 14, 2022

Hello @martindaum ,

The "initials as channel avatar" behavior is outdated, our current Design Kit has "merged avatars" as default. You can see it in Swift SDK and React SDK (https://getstream.io/chat/demos/messaging/)

If you want to implement this behavior yourself, you can do so as:

class InitialsChannelAvatarView: ChatChannelAvatarView {
    override func loadMergedAvatars(channel: ChatChannel) {
        // .. get initials from the member
        // assign the avatar
        loadIntoAvatarImageView(from: nil, placeholder: yourNewInitialsImage)
    }
}

and inject your new class via Components

Do you need more help regarding this?

@b-onc b-onc added the ❓ Question Question regarding a specific subject label Jun 14, 2022
@b-onc b-onc self-assigned this Jun 14, 2022
@b-onc b-onc added the 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK label Jun 14, 2022
@martindaum
Copy link
Author

I would want it in the MessageView, not for the Channel Avatar!

@b-onc
Copy link
Contributor

b-onc commented Jun 14, 2022

Ah, thanks for clarifying, I misunderstood.

Indeed it's a missing feature from Swift SDK. We're internally tracking this as CIS-1978.

Meanwhile, you can apply the same logic from my message above, customize MessageContentView.updateContent func to create your initials avatar if the user's avatar is nil and assign it to authorAvatarView

@b-onc b-onc added 📆 Planned 🙏 Feature Request A new feature request and removed ❓ Question Question regarding a specific subject labels Jun 14, 2022
@martindaum
Copy link
Author

Okay thanks! I will implement it that way!

@martindaum
Copy link
Author

public private(set) var authorAvatarView: ChatAvatarView?

I am not able to set the authorAvatarView because the setter is private. In the samples I have seen you can assign a custom ChatAvatarView to components, but then I am not able to retrieve the name. I am missing something?

@b-onc
Copy link
Contributor

b-onc commented Jun 15, 2022

You wouldn't assign authorAvatarView, you'd assign an image to authorAvatarView.imageView.image

@bielikb
Copy link
Contributor

bielikb commented Jun 23, 2022

Hi @martindaum,

Im just following up in here. Did your issue got resolved? Or are you still encountering some issues?

Best,
Boris

@martindaum
Copy link
Author

Not an ideal solution, because I have to render an image instead of designing a custom view. But as a workaround it would work. It would help if we could inject a custom view for the avatar view (which also has access to content) instead of having to use an image.

@bielikb
Copy link
Contributor

bielikb commented Jun 27, 2022

Hey @martindaum,

thanks for the feedback! Ill create an issue internally for us to review this part of our SDK.

Best,
Boris

@b-onc b-onc removed their assignment Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 Feature Request A new feature request 🎨 SDK: StreamChatUI Tasks related to the StreamChatUI SDK
Projects
None yet
Development

No branches or pull requests

4 participants