From a6ceaa0e72f5498a83b1613e91f4343009a4ebf2 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Tue, 24 Oct 2023 17:27:25 +0200 Subject: [PATCH] snapshot tests --- .../View/CompletionSuggestionView.swift | 29 ++++++------------- .../View/MentionSuggestionItemView.swift | 6 ++-- .../test_completionSuggestion.1.png | 4 +-- .../test_completionSuggestion.2.png | 4 +-- .../test_composerToolbar.With-Suggestions.png | 4 +-- .../test_mentionSuggestionItemView.1.png | 4 +-- .../test_mentionSuggestionItemView.2.png | 4 +-- 7 files changed, 22 insertions(+), 33 deletions(-) diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift b/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift index ca2394c8c3..f308e8fdfd 100644 --- a/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift +++ b/ElementX/Sources/Screens/ComposerToolbar/View/CompletionSuggestionView.swift @@ -23,19 +23,11 @@ struct CompletionSuggestionView: View { private enum Constants { static let topPadding: CGFloat = 8.0 - static let listItemPadding: CGFloat = 4.0 - static let lineSpacing: CGFloat = 10.0 - static let maxHeight: CGFloat = 300.0 + static let listItemPadding: CGFloat = 6.0 + // added by the list itself when presenting the divider + static let linePadding: CGFloat = 4.0 + static let leadingPadding: CGFloat = 16.0 static let maxVisibleRows = 4 - - /* - As of iOS 16.0, SwiftUI's List uses `UICollectionView` instead - of `UITableView` internally, this value is an adjustment to apply - to the list items in order to be as close as possible as the - `UITableView` display. - */ - @available(iOS 16.0, *) - static let collectionViewPaddingCorrection: CGFloat = -5.0 } // MARK: Public @@ -73,16 +65,17 @@ struct CompletionSuggestionView: View { } } .modifier(ListItemPaddingModifier(isFirst: items.first?.id == item.id)) + .listRowInsets(.init(top: 0, leading: Constants.leadingPadding, bottom: 0, trailing: 0)) } .listStyle(PlainListStyle()) - .frame(height: min(Constants.maxHeight, - min(contentHeightForRowCount(Constants.maxVisibleRows), - contentHeightForRowCount(items.count)))) + .frame(height: + min(contentHeightForRowCount(Constants.maxVisibleRows), + contentHeightForRowCount(items.count))) .background(Color.compound.bgCanvasDefault) } private func contentHeightForRowCount(_ count: Int) -> CGFloat { - (prototypeListItemFrame.height + (Constants.listItemPadding * 2) + Constants.lineSpacing) * CGFloat(count) + Constants.topPadding + (prototypeListItemFrame.height + Constants.listItemPadding * 2 + Constants.linePadding) * CGFloat(count) + Constants.topPadding - Constants.linePadding / 2 } private struct ListItemPaddingModifier: ViewModifier { @@ -95,10 +88,6 @@ struct CompletionSuggestionView: View { func body(content: Content) -> some View { var topPadding: CGFloat = isFirst ? Constants.listItemPadding + Constants.topPadding : Constants.listItemPadding var bottomPadding: CGFloat = Constants.listItemPadding - if #available(iOS 16.0, *) { - topPadding += Constants.collectionViewPaddingCorrection - bottomPadding += Constants.collectionViewPaddingCorrection - } return content .padding(.top, topPadding) diff --git a/ElementX/Sources/Screens/ComposerToolbar/View/MentionSuggestionItemView.swift b/ElementX/Sources/Screens/ComposerToolbar/View/MentionSuggestionItemView.swift index 88981c56cd..71bdd26625 100644 --- a/ElementX/Sources/Screens/ComposerToolbar/View/MentionSuggestionItemView.swift +++ b/ElementX/Sources/Screens/ComposerToolbar/View/MentionSuggestionItemView.swift @@ -21,13 +21,13 @@ struct MentionSuggestionItemView: View { let item: MentionSuggestionItem var body: some View { - HStack(alignment: .center) { + HStack(alignment: .center, spacing: 16) { LoadableAvatarImage(url: item.avatarURL, name: item.displayName, contentID: item.id, - avatarSize: .custom(42), + avatarSize: .custom(32), imageProvider: imageProvider) - VStack(alignment: .leading) { + VStack(alignment: .leading, spacing: 0) { Text(item.displayName ?? item.id) .font(.compound.bodyLG) .foregroundColor(.compound.textPrimary) diff --git a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.1.png b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.1.png index 56189798de..486acb2696 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.1.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1053b6b8361e483fdbfc3cab89610b5e6ba9642ee0c659a90880dc05779a0ee1 -size 87735 +oid sha256:26dc110f0558b40ad4d8113d05202e0f15e7551b179975f1c5daa5e7ce464d00 +size 85457 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png index ad35d56261..a35ef38968 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_completionSuggestion.2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7bcd00bc4f83ce36c67954aa301858ad9ea1e35eb04c735e596f6481e75070eb -size 77023 +oid sha256:afdd886a5cca78ca9c3d5a29a92bc12536d860ba7f107fbf0dabb9dd0e3cad65 +size 74899 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.With-Suggestions.png b/UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.With-Suggestions.png index 63b9541613..10a09a8fa7 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.With-Suggestions.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_composerToolbar.With-Suggestions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9b4ab3c5f407fd0cd1086e74b8b8097ce26c6a980e009b03ee2bbcf6009d088 -size 99560 +oid sha256:fa89dd783ea74eac2b86c4901c10c0f0594b80625b3f20fa6237ad27a38b412e +size 96761 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.1.png b/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.1.png index 80dae5d060..a63d78089d 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.1.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dc30346f730c3ceaf00311d6d1f50c7ebb97879d658424c8fc6624e8f78c80ee -size 63677 +oid sha256:1defe9e39eb1c83547c366965989250def123d785fd193dba29e9a57b82041a6 +size 63216 diff --git a/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.2.png b/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.2.png index 7289f9c8af..1b1b06da23 100644 --- a/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.2.png +++ b/UnitTests/__Snapshots__/PreviewTests/test_mentionSuggestionItemView.2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:792706480d9eb6b51fb407226f5ffa729ac54fc967c8f9925f2e30a6e3fe9ef2 -size 60057 +oid sha256:9a292ff4ebb5340397f839ec822ca603dcb8c443b5d7af6a31f12be361e401f4 +size 59683