align outgoing message reacts to right

This commit is contained in:
Ryan Zhao 2022-05-30 16:20:55 +10:00
parent d3675c4fe8
commit d3cc3c810d
2 changed files with 13 additions and 4 deletions

View File

@ -17,6 +17,7 @@ final class ReactionContainerView : UIView {
}()
private var showingAllReactions = false
private var isOutgoingMessage = false
var reactions: [(String, (Int, Bool))] = []
var reactionViews: [ReactionView] = []
@ -55,8 +56,9 @@ final class ReactionContainerView : UIView {
mainStackView.pin(to: self)
}
public func update(_ reactions: [(String, (Int, Bool))]) {
public func update(_ reactions: [(String, (Int, Bool))], isOutgoingMessage: Bool) {
self.reactions = reactions
self.isOutgoingMessage = isOutgoingMessage
prepareForUpdate()
if showingAllReactions {
updateAllReactions()
@ -70,6 +72,13 @@ final class ReactionContainerView : UIView {
stackView.axis = .horizontal
stackView.spacing = Values.smallSpacing
stackView.alignment = .center
if isOutgoingMessage {
stackView.semanticContentAttribute = .forceRightToLeft
reactionContainerView.semanticContentAttribute = .forceRightToLeft
} else {
stackView.semanticContentAttribute = .unspecified
reactionContainerView.semanticContentAttribute = .unspecified
}
var displayedReactions: [(String, (Int, Bool))]
var expandButtonReactions: [String]
@ -121,13 +130,13 @@ final class ReactionContainerView : UIView {
public func showAllEmojis() {
guard !showingAllReactions else { return }
showingAllReactions = true
update(reactions)
update(reactions, isOutgoingMessage: isOutgoingMessage)
}
public func showLessEmojis() {
guard showingAllReactions else { return }
showingAllReactions = false
update(reactions)
update(reactions, isOutgoingMessage: isOutgoingMessage)
}
}

View File

@ -467,7 +467,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
}
}
}
reactionContainerView.update(reactions.orderedItems)
reactionContainerView.update(reactions.orderedItems, isOutgoingMessage: direction == .outgoing)
}
override func layoutSubviews() {