feat: display no results when profile field empty
This commit is contained in:
parent
66c1b71610
commit
0f3764e3af
|
@ -14,6 +14,7 @@ enum ProfileFieldItem: Hashable {
|
|||
case field(field: FieldValue)
|
||||
case editField(field: FieldValue)
|
||||
case addEntry
|
||||
case noResult
|
||||
}
|
||||
|
||||
extension ProfileFieldItem {
|
||||
|
|
|
@ -107,6 +107,22 @@ extension ProfileFieldSection {
|
|||
cell.backgroundConfiguration = backgroundConfiguration
|
||||
}
|
||||
|
||||
let noResultCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, ProfileFieldItem> { 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<ProfileFieldSection, ProfileFieldItem>(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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue