-
Notifications
You must be signed in to change notification settings - Fork 91
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
base: develop
Are you sure you want to change the base?
Fix white circle button is visible beneath the ChannelAvatarView #725
Conversation
@@ -35,16 +35,13 @@ public struct DefaultChatChannelHeader: ToolbarContent { | |||
} | |||
|
|||
public var channel: ChatChannel | |||
public var headerImage: UIImage |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
86d7021
to
1203442
Compare
@@ -71,6 +71,7 @@ public struct DefaultChatChannelHeader: ToolbarContent { | |||
.clipShape(Circle()) | |||
.offset(x: 8) | |||
} | |||
.buttonStyle(.plain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
🔗 Issue Link
Github issue
🎯 Goal
The channel avatar view should show correctly without a visible white circle below.
🛠 Implementation
🧪 Testing
🎨 Changes
☑️ Checklist