diff --git a/Mastodon/Diffiable/Profile/ProfileFieldItem.swift b/Mastodon/Diffiable/Profile/ProfileFieldItem.swift index 60651d72..47848cc0 100644 --- a/Mastodon/Diffiable/Profile/ProfileFieldItem.swift +++ b/Mastodon/Diffiable/Profile/ProfileFieldItem.swift @@ -14,6 +14,7 @@ enum ProfileFieldItem: Hashable { case field(field: FieldValue) case editField(field: FieldValue) case addEntry + case noResult } extension ProfileFieldItem { diff --git a/Mastodon/Diffiable/Profile/ProfileFieldSection.swift b/Mastodon/Diffiable/Profile/ProfileFieldSection.swift index fc2dee15..e1b0d649 100644 --- a/Mastodon/Diffiable/Profile/ProfileFieldSection.swift +++ b/Mastodon/Diffiable/Profile/ProfileFieldSection.swift @@ -107,6 +107,22 @@ extension ProfileFieldSection { cell.backgroundConfiguration = backgroundConfiguration } + let noResultCellRegistration = UICollectionView.CellRegistration { cell, indexPath, item in + guard case .noResult = item else { return } + + var contentConfiguration = cell.defaultContentConfiguration() + contentConfiguration.text = L10n.Scene.Search.Searching.EmptyState.noResults // FIXME: + contentConfiguration.textProperties.alignment = .center + cell.contentConfiguration = contentConfiguration + + + var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell() + backgroundConfiguration.backgroundColorTransformer = .init { _ in + return .secondarySystemBackground + } + cell.backgroundConfiguration = backgroundConfiguration + } + let dataSource = UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, item in switch item { case .field: @@ -127,6 +143,12 @@ extension ProfileFieldSection { for: indexPath, item: item ) + case .noResult: + return collectionView.dequeueConfiguredReusableCell( + using: noResultCellRegistration, + for: indexPath, + item: item + ) } } diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift index 66b7d25c..259cad12 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift @@ -74,6 +74,10 @@ extension ProfileAboutViewModel { items.append(.addEntry) } + if !isEditing, items.isEmpty { + items.append(.noResult) + } + snapshot.appendItems(items, toSection: .main) diffableDataSource.apply(snapshot, animatingDifferences: false, completion: nil)