let cellConfigiuration = UICollectionView.CellRegistration<UICollectionViewListCell, String> { cell, indexPath, itemIdentifier in
var contentConfiguration = UIListContentConfiguration.sidebarSubtitleCell()
contentConfiguration.text = "Primary Text: \(itemIdentifier)"
contentConfiguration.secondaryText = "Secondary Text"
cell.contentConfiguration = contentConfiguration
var backgroundConfiguration = UIBackgroundConfiguration.listSidebarCell()
backgroundConfiguration.backgroundColor = .systemGray5
cell.backgroundConfiguration = backgroundConfiguration
cell.configurationUpdateHandler = { cell, state in
guard var cConfig = cell.contentConfiguration?.updated(for: state) as? UIListContentConfiguration else { return }
cConfig.textProperties.colorTransformer = UIConfigurationColorTransformer { color in
state.isSelected || state.isHighlighted ? .white : .black
}
cConfig.secondaryTextProperties.colorTransformer = UIConfigurationColorTransformer { color in
state.isSelected || state.isHighlighted ? .white : .black
}
cell.contentConfiguration = cConfig
guard var bConfig = cell.backgroundConfiguration?.updated(for: state) else { return }
bConfig.backgroundColorTransformer = UIConfigurationColorTransformer { color in
state.isSelected || state.isHighlighted ? .systemMint : .systemGray5
}
cell.backgroundConfiguration = bConfig
}
}