Skip to content

Commit

Permalink
snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Oct 24, 2023
1 parent 8ff1c75 commit a6ceaa0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a6ceaa0

Please sign in to comment.