diff --git a/Tusker/Screens/Conversation/ExpandThreadCollectionViewCell.swift b/Tusker/Screens/Conversation/ExpandThreadCollectionViewCell.swift index 5a40676b..e7e1400d 100644 --- a/Tusker/Screens/Conversation/ExpandThreadCollectionViewCell.swift +++ b/Tusker/Screens/Conversation/ExpandThreadCollectionViewCell.swift @@ -8,7 +8,7 @@ import UIKit -class ExpandThreadCollectionViewCell: UICollectionViewCell { +class ExpandThreadCollectionViewCell: UICollectionViewListCell { private var avatarContainerView: UIView! private var avatarContainerWidthConstraint: NSLayoutConstraint! @@ -46,8 +46,6 @@ class ExpandThreadCollectionViewCell: UICollectionViewCell { contentView.addSubview(hStack) stackViewLeadingConstraint = hStack.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16) - // TODO: separator - threadLinkView = UIView() threadLinkView.backgroundColor = .tintColor.withAlphaComponent(0.5) threadLinkView.layer.cornerRadius = 2.5 @@ -142,4 +140,19 @@ class ExpandThreadCollectionViewCell: UICollectionViewCell { } } + override func updateConfiguration(using state: UICellConfigurationState) { + var config = UIBackgroundConfiguration.listPlainCell() + if state.isSelected || state.isHighlighted { + var hue: CGFloat = 0 + var saturation: CGFloat = 0 + var brightness: CGFloat = 0 + UIColor.secondarySystemBackground.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil) + let sign: CGFloat = traitCollection.userInterfaceStyle == .dark ? 1 : -1 + config.backgroundColor = UIColor(hue: hue, saturation: saturation, brightness: max(0, brightness + sign * 0.1), alpha: 1) + } else { + config.backgroundColor = .secondarySystemBackground + } + backgroundConfiguration = config.updated(for: state) + } + }