align outgoing message reacts to right

pull/638/head
Ryan Zhao 3 years ago
parent d3675c4fe8
commit d3cc3c810d

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

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

Loading…
Cancel
Save