dynamic number of emojis per line

This commit is contained in:
ryanzhao 2022-05-31 11:59:24 +10:00
parent d3cc3c810d
commit 49706f620f
1 changed files with 5 additions and 4 deletions

View File

@ -18,6 +18,7 @@ final class ReactionContainerView : UIView {
private var showingAllReactions = false
private var isOutgoingMessage = false
private var maxEmojisPerLine = isIPhone6OrSmaller ? 5 : 6
var reactions: [(String, (Int, Bool))] = []
var reactionViews: [ReactionView] = []
@ -83,9 +84,9 @@ final class ReactionContainerView : UIView {
var displayedReactions: [(String, (Int, Bool))]
var expandButtonReactions: [String]
if reactions.count >= 6 {
displayedReactions = Array(reactions[0...2])
expandButtonReactions = Array(reactions[3...5]).map{ $0.0 }
if reactions.count > maxEmojisPerLine {
displayedReactions = Array(reactions[0...(maxEmojisPerLine - 3)])
expandButtonReactions = Array(reactions[(maxEmojisPerLine - 2)...maxEmojisPerLine]).map{ $0.0 }
} else {
displayedReactions = reactions
expandButtonReactions = []
@ -109,7 +110,7 @@ final class ReactionContainerView : UIView {
var reactions = self.reactions
while reactions.count > 0 {
var line: [(String, (Int, Bool))] = []
while reactions.count > 0 && line.count < 5 {
while reactions.count > 0 && line.count < maxEmojisPerLine {
line.append(reactions.removeFirst())
}
updateCollapsedReactions(line)