Use solid color for "selected" background color of UITableViewCell.

revious color was semi-opaque black which meant the resulting color of a selected UITableViewCell's background was not something referenced in the code. Therefore it wasn't easily possible to re-use the color for non-UITableViewCell elements (e.g. creating UIButton whose colors should match UITableView's colors). With the opaque colors final color of the background of a selected cell is known and can be referenced directly.

Also removed Theme.tableCell2MultiSelectedBackgroundColor - use one color for both "single" and "multiple" selection modes.

Fix Calls tab not setting UITableViewCell properly to use custom cell background color in multi-select mode.
This commit is contained in:
Igor Solomennikov 2025-09-16 15:34:05 -07:00 committed by GitHub
parent cb9848264b
commit f4bd82dc34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 31 deletions

View File

@ -2285,6 +2285,8 @@ private extension CallsListViewController {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
multipleSelectionBackgroundView = UIView(frame: contentView.bounds)
let bodyVStack = UIStackView(arrangedSubviews: [
titleLabel,
subtitleLabel,
@ -2479,7 +2481,7 @@ private extension CallsListViewController {
private func applyTheme() {
backgroundColor = Theme.backgroundColor
selectedBackgroundView?.backgroundColor = Theme.tableCell2SelectedBackgroundColor
multipleSelectionBackgroundView?.backgroundColor = Theme.tableCell2MultiSelectedBackgroundColor
multipleSelectionBackgroundView?.backgroundColor = Theme.tableCell2SelectedBackgroundColor
titleLabel.textColor = Theme.primaryTextColor
subtitleLabel.textColor = Theme.snippetColor

View File

@ -395,19 +395,12 @@ final public class Theme: NSObject {
}
public class var tableCell2SelectedBackgroundColor: UIColor {
isDarkThemeEnabled
? darkThemeTableCell2SelectedBackgroundColor
: UIColor.Signal.primaryFill.resolvedColor(with: lightTraitCollection)
}
public class var tableCell2MultiSelectedBackgroundColor: UIColor {
isDarkThemeEnabled ? .ows_gray75 : .ows_gray05
}
public class var tableCell2PresentedSelectedBackgroundColor: UIColor {
isDarkThemeEnabled
? darkThemeTableCell2PresentedSelectedBackgroundColor
: UIColor.Signal.primaryFill.resolvedColor(with: elevatedLightTraitCollection)
UIColor(
light: UIColor(rgbHex: 0xD4D4D6),
lightHighContrast: UIColor(rgbHex: 0xD4D4D6), // TBD
dark: UIColor(rgbHex: 0x3A3A3D),
darkHighContrast: UIColor(rgbHex: 0x3A3A3D) // TBD
)
}
public class var tableView2BackgroundColor: UIColor {
@ -474,14 +467,6 @@ final public class Theme: NSObject {
UIColor.Signal.secondaryGroupedBackground.resolvedColor(with: elevatedDarkTraitCollection)
}
public class var darkThemeTableCell2SelectedBackgroundColor: UIColor {
UIColor.Signal.primaryFill.resolvedColor(with: darkTraitCollection)
}
public class var darkThemeTableCell2PresentedSelectedBackgroundColor: UIColor {
UIColor.Signal.primaryFill.resolvedColor(with: elevatedDarkTraitCollection)
}
public class var darkThemeTableView2BackgroundColor: UIColor {
UIColor.Signal.groupedBackground.resolvedColor(with: darkTraitCollection)
}

View File

@ -288,7 +288,7 @@ public class OWSTableItem {
public class func configureCell(_ cell: UITableViewCell) {
cell.backgroundColor = Theme.backgroundColor
cell.selectedBackgroundView?.backgroundColor = Theme.tableCell2SelectedBackgroundColor
cell.multipleSelectionBackgroundView?.backgroundColor = Theme.tableCell2MultiSelectedBackgroundColor
cell.multipleSelectionBackgroundView?.backgroundColor = Theme.tableCell2SelectedBackgroundColor
cell.textLabel?.font = self.primaryLabelFont
cell.textLabel?.textColor = Theme.primaryTextColor

View File

@ -957,15 +957,14 @@ extension OWSTableViewController2: UITableViewDataSource, UITableViewDelegate, O
}
public var cellSelectedBackgroundColor: UIColor {
if isUsingPresentedStyle {
return forceDarkMode
? Theme.darkThemeTableCell2PresentedSelectedBackgroundColor
: Theme.tableCell2PresentedSelectedBackgroundColor
} else {
return forceDarkMode
? Theme.darkThemeTableCell2SelectedBackgroundColor
: Theme.tableCell2SelectedBackgroundColor
Self.cellSelectedBackgroundColor(forceDarkMode: forceDarkMode)
}
public static func cellSelectedBackgroundColor(forceDarkMode: Bool = false) -> UIColor {
if forceDarkMode {
return Theme.tableCell2SelectedBackgroundColor.resolvedColor(with: UITraitCollection(userInterfaceStyle: .dark))
}
return Theme.tableCell2SelectedBackgroundColor
}
public var separatorColor: UIColor {