From d3cc3c810da4d8f691690ed2260d6b398888dcf2 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 30 May 2022 16:20:55 +1000 Subject: [PATCH] align outgoing message reacts to right --- .../Content Views/ReactionContainerView.swift | 15 ++++++++++++--- .../Message Cells/VisibleMessageCell.swift | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift b/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift index f6dede54e..b5ee6b926 100644 --- a/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift +++ b/Session/Conversations/Message Cells/Content Views/ReactionContainerView.swift @@ -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) } } diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 0ec6d5830..dc352de16 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -467,7 +467,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { } } } - reactionContainerView.update(reactions.orderedItems) + reactionContainerView.update(reactions.orderedItems, isOutgoingMessage: direction == .outgoing) } override func layoutSubviews() {