-
Notifications
You must be signed in to change notification settings - Fork 500
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
Message bubbles: Text message layout #5383
Conversation
…vide room timeline cells.
…oom timeline cell view.
…stomize timeline appearance.
…pearance configuration.
📱 Scan the QR code below to install the build for this PR. If you can't scan the QR code you can install the build via this link: https://i.diawi.com/qx5TjS |
…s in bubble background.
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.
Looking great so far 👏 Left some comments inline.
|
||
} else if let messageTextViewHeight = cell.messageTextView?.frame.height { | ||
|
||
finalBubbleHeight = messageTextViewHeight + extraMargin |
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.
These will not build on Xcode 12 because "Cannot convert value of type 'Double' to expected argument type 'CGFloat'" (probably why the CI checks fail)
|
||
@return Last visible component or nil. | ||
*/ | ||
- (MXKRoomBubbleComponent*)getLastBubbleComponentWithDisplay; |
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.
We should probably start annotating nullability in ObjC, no matter how many warnings it generates.
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 understand your POV but we have 25k warnings to address on Xcode 13, not sure we will see them :/
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 was more thinking about the Swift point of view, expose a nice interface to it without caring about ObjC warnings.
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.
Ok I see. Yes we should do that for sure but we have to carefully inspect each ObjC properties and method to be sure we are using the right nullability flag.
for (NSInteger index = 0; index < bubbleComponents.count; index++) | ||
{ | ||
MXKRoomBubbleComponent *component = bubbleComponents[index]; | ||
if (component.attributedTextMessage) |
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.
Perhaps a foreach in reverseObjectEnumerator would be cleaner in this case. Same applies for the getFirstBubbleComponentWithDisplay
method.. not reversed of course 😄
for(MXKRoomBubbleComponent *component in bubbleComponents.reverseObjectEnumerator) {
if (component.attributedTextMessage)
{
return component;
}
}
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// Enables to register and provide room timeline cells | ||
@protocol RoomTimelineCellProviderProtocol <NSObject> |
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.
Noice! 👌
// Hide sender info and avatar for bubble outgoing messages | ||
return @{ | ||
// Clear | ||
@(RoomTimelineCellIdentifierOutgoingTextMessage) : RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.class, |
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.
Possibly typo here, should it be RoomOutgoingTextMsgBubbleCell
?
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.
In fact for outgoing text messages we are hiding sender infos every time
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.
Ah, got it 👍
let leadingAnchor = messageTextView.leadingAnchor | ||
let trailingAnchor = messageTextView.trailingAnchor | ||
|
||
bubbleBackgroundView.updateHeight(messageTextView.frame.height) |
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.
Can't we pin this to the cells content somehow so we don't have to manually manage its height?
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 problem is that the bubble background should wrap the visible text. And currently the textView is not exactly wrapping the text, especially if you add decorations such as previews and reactions.
import UIKit | ||
|
||
/// BubbleReactionsView items alignement | ||
enum BubbleReactionsViewAlignement { |
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.
Typo, should be Alignment
import UIKit | ||
|
||
/// UICollectionViewFlowLayout with right align behavior | ||
class CollectionViewRightAlignFlowLayout: UICollectionViewFlowLayout { |
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.
Feels like we should have one single parameterizable layout instead of two. Layout logic difference between left and right should be small.
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.
Yes sure but the implementation is not the same atm for the two different layout.
@@ -325,4 +325,7 @@ extern NSString *const kMXKRoomBubbleCellUrlItemInteraction; | |||
*/ | |||
- (void)setupViews; | |||
|
|||
/// Add temporary subview to `tmpSubviews` property. | |||
- (void)addTmpSubview:(UIView*)subview; |
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.
Adding subviews on cells and handling their frames externally is probably going to create more problems than it fixes. Ideally these should go in some sort of base cell container. I believe this code already existed and was just moved around but what's the long term goal?
Either way, we shouldn't use abbreviations in method names -> addTemporarySubview
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 agree that the decoration view and reuse handling can be better managed. It was already existing before as you said.
#import "RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.h" | ||
#import "RoomOutgoingAttachmentWithPaginationTitleBubbleCell.h" | ||
|
||
@implementation BubbleRoomTimelineCellProvider |
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.
Is the plan here to provide different cells classes for bubbles or to continue manually decorating/modifying them based on the layout? I imagine that ideally we would have different views with no manual customization on top but I might be missing something 🤔
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.
Ideally we should not have the RoomCellLayoutUpdaterProtocol
that updates existing cell layout. And provide appropriated cells with RoomTimelineCellProvider
for each room timeline styles.
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.
Awesome, that's what I though 👍
This might be an opportunity to close #4150 as well? |
… getLastBubbleComponentWithDisplay.
Handles #5208, #5214, #5212, #5216
Two things to make in another PR:
RoomBubbleCellData
to get only text position)