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

Fix white circle button is visible beneath the ChannelAvatarView #725

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

sheep-q
Copy link

@sheep-q sheep-q commented Jan 21, 2025

🔗 Issue Link

Github issue

🎯 Goal

The channel avatar view should show correctly without a visible white circle below.

🛠 Implementation

  • Change the style of button inside ToolbarItem
  • Update the initialization of ChannelAvatarView to remove deprecated init warninig.

🧪 Testing

🎨 Changes

image

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created)

@@ -35,16 +35,13 @@ public struct DefaultChatChannelHeader: ToolbarContent {
}

public var channel: ChatChannel
public var headerImage: UIImage
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, we can't do any changes to the public API at the moment (only in major versions, but the next one is a minor upgrade). Could you please take these out and just keep the buttonStyle change.
Is there an additional issue with the headerImage?

Copy link
Author

Choose a reason for hiding this comment

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

Got it, I deleted headerImage because when using it in the initialization of ChannelAvatarView, it shows warning init(avatar:showOnlineIndicator:size:)' is deprecated: Use automatically refreshing avatar initializer.
But no problem, it's not the main reason so I just keep the buttonStyle change

@sheep-q sheep-q force-pushed the fix/trailing-toolbarItem-button-style branch from 86d7021 to 1203442 Compare January 21, 2025 09:23
@@ -71,6 +71,7 @@ public struct DefaultChatChannelHeader: ToolbarContent {
.clipShape(Circle())
.offset(x: 8)
}
.buttonStyle(.plain)
Copy link
Contributor

Choose a reason for hiding this comment

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

I did some testing and seems like it also changes spacings:
Before:
Before
After:
After
I'll investigate this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

What does not break the padding is changing the Button's offset from 8 -> 4.

Copy link
Author

Choose a reason for hiding this comment

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

I think changing the Button's offset causes confusing. Clearly, this offset should be equal offset of ChannelAvatarView, either both set to 0 or 8.
I believe that, the issue was from SwiftUI framework that automatically add padding to ToolbarItem(placement: .navigationBarTrailing). I tested the same ZStack's content to several wrapped views without encountering any issues

Copy link
Author

Choose a reason for hiding this comment

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

Or you can just configure Button like this without multiple layers in ZStack, it doesn't care about additional padding.
I'm not sure about the purpose of your using separate layers, so I wouldn't use this approach.

               Button {
                    resignFirstResponder()
                    isActive = true
                } label: {
                    ChannelAvatarView(
                        avatar: headerImage,
                        showOnlineIndicator: onlineIndicatorShown,
                        size: CGSize(width: 36, height: 36)
                    )
                    .offset(x: 8)
                }

Copy link
Contributor

Choose a reason for hiding this comment

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

Our default design has custom spacing defined for the avatar shown in the toolbar in relative to the messages in the message list. This is why the offset is used there.

Copy link
Contributor

Choose a reason for hiding this comment

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

This change also has to work for iOS 14 which has brought most of the complexities.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @sheep-q I did some testing on older iOS versions and this is OK. Also looked into the question of the offset, and the correct is actually 4, not 8. Please change your snippet above to use 4 and let's get this change in.

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