-
Notifications
You must be signed in to change notification settings - Fork 22
feat: chat bubble wrapper for text messages - WPB-19273 #3438
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
base: develop
Are you sure you want to change the base?
Conversation
…sage content for bubbles
…s from ConversationMessageCell to ConversationMessageCellDescription
…be done in the individual cells)
Test Results1 991 tests 1 963 ✅ 3m 8s ⏱️ Results for commit 1ab2a3e. ♻️ This comment has been updated with latest results. |
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.
Looks good, nice work 👍
Before approving, can you also please some snapshot tests @WilhelmOks ?
let cornerRadius: CGFloat = if DeveloperFlag.chatBubblesSimple.isOn { | ||
ConversationMessageContainerView.bubbleCornerRadius | ||
} else { | ||
12 | ||
} |
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.
suggestion: Since it's same in several files I'd suggest to introduce a constant and reuse if DeveloperFlag.chatBubblesSimple.isOn ...
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.
Not sure what you mean by reuse the if condition.
Do you mean extracting it into a property like this?
var: cornerRadius: CGFloat {
let cornerRadius: CGFloat = if DeveloperFlag.chatBubblesSimple.isOn {
ConversationMessageContainerView.bubbleCornerRadius
} else {
12
}
}
but then it would still be repeated in multiple files.
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 mean more like this
struct ChatBubblesConstants {
var cornerRadius: CGFloat {
if DeveloperFlag.chatBubblesSimple.isOn {
return ConversationMessageContainerView.bubbleCornerRadius
} else {
return 12
}
}
}
And then on caller side: containerView.layer.cornerRadius = ChatBubblesConstants.cornerRadius
Do you think there would be a benefit?
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 see some issues with that:
- the old value for the corner radius isn't always 12. For some views like the reply cell it's smaller.
- ChatBubblesConstants for me suggests that it's about the new chat bubbles. So putting the old value there (12) feels wrong.
- special treatment for the corner radius while the other numeric values remain number literals.
...sation/Content/Cells/ConfigurationMessageCell/Content/Text/ConversationTextMessageCell.swift
Outdated
Show resolved
Hide resolved
Assuming this is a test which compares the visual output to an image from the design: |
What do you mean by it's a test? As I understand it supposed to be released, right? Tests help make sure that while working on other parts of application already existed functionality behaves in same way. Not critical for me, we just usually add snapshot tests to views we add. cc @johnxnguyen |
Hm, probably I misunderstood what is a snapshot test. |
@WilhelmOks snapshot tests kind of what you think, but the implemented views aren't compared to the designed view, rather you implement the view according to the design, snapshot it (record a reference image from your view), then future runs of the test will assert that the view still matches the reference. Take a look at |
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.
Looks good! Left a suggestion/question.
weak var message: ZMConversationMessage? { | ||
didSet { | ||
guard let message, DeveloperFlag.chatBubblesSimple.isOn else { return } | ||
let isOwnMessage = message.isSentBySelfUser | ||
let userColor = message.senderUser?.accentColor ?? .clear | ||
container?.bubbleStyle = isOwnMessage ? .ownMessage(userColor: userColor) : .otherMessage | ||
configureTextColor(forOwnMessage: isOwnMessage) | ||
} | ||
} |
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.
suggestion: this seems to be more appropriate placed inside the func configure(with object: Configuration, animated: Bool)
method, but I then you'd need to add an extra field to the configuration for the bubble style. What do you think?
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.
My first attempt was to set both values, isBubble
and bubbleStyle
, in configure(with object: Configuration, animated: Bool)
but the problem is that for bubbleStyle
I need the info if this is the self user message. And message
is nil at this point.
So I moved the code to didSet of the message
property, because there I can be certain that the message
has been set and is not nil.
|
||
final class SimpleChatBubblesSnapshotTests: ConversationMessageSnapshotTestCase { | ||
|
||
private let record: Bool? = nil |
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.
might be removed if not used anymore
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.
The record constant?
I feel like it's useful for later when we change the bubble layout and need to generate new snapshots for all tests again in one go.
But I have no strong opinion on that.
Issue
Text Message cells are wrapped into bubbles.
The color of the bubble depends on if it's my own message or from someone else and also depends on the color selected by the user as their accent color.
The corner radius of all cell types (except small icons like reactions) like reply and file has been adjusted to be the same as the new chat bubble corner radius.
The correct alignment will be implemented in WPB-19271 and is not in scope of this PR.
Testing
If the chatBubblesSimple DeveloperFlag is disabled, everything should look and behave exactly as it was before.
If the chatBubblesSimple DeveloperFlag is enabled: