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 field(field: FieldValue)
|
||||||
case editField(field: FieldValue)
|
case editField(field: FieldValue)
|
||||||
case addEntry
|
case addEntry
|
||||||
|
case noResult
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ProfileFieldItem {
|
extension ProfileFieldItem {
|
||||||
|
|
|
@ -107,6 +107,22 @@ extension ProfileFieldSection {
|
||||||
cell.backgroundConfiguration = backgroundConfiguration
|
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
|
let dataSource = UICollectionViewDiffableDataSource<ProfileFieldSection, ProfileFieldItem>(collectionView: collectionView) { collectionView, indexPath, item in
|
||||||
switch item {
|
switch item {
|
||||||
case .field:
|
case .field:
|
||||||
|
@ -127,6 +143,12 @@ extension ProfileFieldSection {
|
||||||
for: indexPath,
|
for: indexPath,
|
||||||
item: item
|
item: item
|
||||||
)
|
)
|
||||||
|
case .noResult:
|
||||||
|
return collectionView.dequeueConfiguredReusableCell(
|
||||||
|
using: noResultCellRegistration,
|
||||||
|
for: indexPath,
|
||||||
|
item: item
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ extension ProfileAboutViewModel {
|
||||||
items.append(.addEntry)
|
items.append(.addEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isEditing, items.isEmpty {
|
||||||
|
items.append(.noResult)
|
||||||
|
}
|
||||||
|
|
||||||
snapshot.appendItems(items, toSection: .main)
|
snapshot.appendItems(items, toSection: .main)
|
||||||
|
|
||||||
diffableDataSource.apply(snapshot, animatingDifferences: false, completion: nil)
|
diffableDataSource.apply(snapshot, animatingDifferences: false, completion: nil)
|
||||||
|
|
Loading…
Reference in New Issue