Fix keyboard focus background on list cells not showing correctly

This commit is contained in:
Shadowfacts 2023-04-16 18:46:37 -04:00
parent 5ec35b6009
commit 15c83f8332
22 changed files with 60 additions and 138 deletions

View File

@ -336,6 +336,7 @@
D6F0B17524A3A1AA001E48C3 /* MainSidebarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F0B17424A3A1AA001E48C3 /* MainSidebarViewController.swift */; }; D6F0B17524A3A1AA001E48C3 /* MainSidebarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F0B17424A3A1AA001E48C3 /* MainSidebarViewController.swift */; };
D6F2E965249E8BFD005846BB /* IssueReporterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F2E963249E8BFD005846BB /* IssueReporterViewController.swift */; }; D6F2E965249E8BFD005846BB /* IssueReporterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F2E963249E8BFD005846BB /* IssueReporterViewController.swift */; };
D6F2E966249E8BFD005846BB /* IssueReporterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6F2E964249E8BFD005846BB /* IssueReporterViewController.xib */; }; D6F2E966249E8BFD005846BB /* IssueReporterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = D6F2E964249E8BFD005846BB /* IssueReporterViewController.xib */; };
D6F4D79429ECB0AF00351B87 /* UIBackgroundConfiguration+AppColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F4D79329ECB0AF00351B87 /* UIBackgroundConfiguration+AppColors.swift */; };
D6F6A550291F058600F496A8 /* CreateListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A54F291F058600F496A8 /* CreateListService.swift */; }; D6F6A550291F058600F496A8 /* CreateListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A54F291F058600F496A8 /* CreateListService.swift */; };
D6F6A552291F098700F496A8 /* RenameListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A551291F098700F496A8 /* RenameListService.swift */; }; D6F6A552291F098700F496A8 /* RenameListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A551291F098700F496A8 /* RenameListService.swift */; };
D6F6A554291F0D9600F496A8 /* DeleteListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A553291F0D9600F496A8 /* DeleteListService.swift */; }; D6F6A554291F0D9600F496A8 /* DeleteListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6F6A553291F0D9600F496A8 /* DeleteListService.swift */; };
@ -735,6 +736,7 @@
D6F0B17424A3A1AA001E48C3 /* MainSidebarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSidebarViewController.swift; sourceTree = "<group>"; }; D6F0B17424A3A1AA001E48C3 /* MainSidebarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSidebarViewController.swift; sourceTree = "<group>"; };
D6F2E963249E8BFD005846BB /* IssueReporterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporterViewController.swift; sourceTree = "<group>"; }; D6F2E963249E8BFD005846BB /* IssueReporterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporterViewController.swift; sourceTree = "<group>"; };
D6F2E964249E8BFD005846BB /* IssueReporterViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IssueReporterViewController.xib; sourceTree = "<group>"; }; D6F2E964249E8BFD005846BB /* IssueReporterViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IssueReporterViewController.xib; sourceTree = "<group>"; };
D6F4D79329ECB0AF00351B87 /* UIBackgroundConfiguration+AppColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIBackgroundConfiguration+AppColors.swift"; sourceTree = "<group>"; };
D6F6A54F291F058600F496A8 /* CreateListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateListService.swift; sourceTree = "<group>"; }; D6F6A54F291F058600F496A8 /* CreateListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateListService.swift; sourceTree = "<group>"; };
D6F6A551291F098700F496A8 /* RenameListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RenameListService.swift; sourceTree = "<group>"; }; D6F6A551291F098700F496A8 /* RenameListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RenameListService.swift; sourceTree = "<group>"; };
D6F6A553291F0D9600F496A8 /* DeleteListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteListService.swift; sourceTree = "<group>"; }; D6F6A553291F0D9600F496A8 /* DeleteListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteListService.swift; sourceTree = "<group>"; };
@ -1226,6 +1228,7 @@
D667E5F02134D5050057A976 /* UIViewController+Delegates.swift */, D667E5F02134D5050057A976 /* UIViewController+Delegates.swift */,
D667E5F72135C3040057A976 /* Mastodon+Equatable.swift */, D667E5F72135C3040057A976 /* Mastodon+Equatable.swift */,
D663626B21361C6700C9CBA2 /* Account+Preferences.swift */, D663626B21361C6700C9CBA2 /* Account+Preferences.swift */,
D6F4D79329ECB0AF00351B87 /* UIBackgroundConfiguration+AppColors.swift */,
D6333B362137838300CE884A /* AttributedString+Helpers.swift */, D6333B362137838300CE884A /* AttributedString+Helpers.swift */,
D6333B782139AEFD00CE884A /* Date+TimeAgo.swift */, D6333B782139AEFD00CE884A /* Date+TimeAgo.swift */,
D67C57AE21E28EAD00C3118B /* Array+Uniques.swift */, D67C57AE21E28EAD00C3118B /* Array+Uniques.swift */,
@ -2064,6 +2067,7 @@
D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */, D663626C21361C6700C9CBA2 /* Account+Preferences.swift in Sources */,
D67895C0246870DE00D4CD9E /* LocalAccountAvatarView.swift in Sources */, D67895C0246870DE00D4CD9E /* LocalAccountAvatarView.swift in Sources */,
D6ADB6E828E8C878009924AB /* PublicTimelineDescriptionCollectionViewCell.swift in Sources */, D6ADB6E828E8C878009924AB /* PublicTimelineDescriptionCollectionViewCell.swift in Sources */,
D6F4D79429ECB0AF00351B87 /* UIBackgroundConfiguration+AppColors.swift in Sources */,
D6333B372137838300CE884A /* AttributedString+Helpers.swift in Sources */, D6333B372137838300CE884A /* AttributedString+Helpers.swift in Sources */,
D681A29A249AD62D0085E54E /* LargeImageContentView.swift in Sources */, D681A29A249AD62D0085E54E /* LargeImageContentView.swift in Sources */,
D6DFC69E242C490400ACC392 /* TrackpadScrollGestureRecognizer.swift in Sources */, D6DFC69E242C490400ACC392 /* TrackpadScrollGestureRecognizer.swift in Sources */,

View File

@ -0,0 +1,35 @@
//
// UIBackgroundConfiguration+AppColors.swift
// Tusker
//
// Created by Shadowfacts on 4/16/23.
// Copyright © 2023 Shadowfacts. All rights reserved.
//
import UIKit
extension UIBackgroundConfiguration {
static func appListPlainCell(for state: UICellConfigurationState) -> UIBackgroundConfiguration {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
if state.isFocused {
// use default
} else if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
return config
}
static func appListGroupedCell(for state: UICellConfigurationState) -> UIBackgroundConfiguration {
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
if state.isFocused {
// use default
} else if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
return config
}
}

View File

@ -68,13 +68,7 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
cell.updateUI(accountID: item) cell.updateUI(accountID: item)
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) cell.backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
cell.backgroundConfiguration = config
} }
} }
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in

View File

@ -141,13 +141,7 @@ class ExpandThreadCollectionViewCell: UICollectionViewListCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isSelected || state.isHighlighted {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appSecondaryBackground
}
backgroundConfiguration = config
} }
} }

View File

@ -143,13 +143,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
cell.contentConfiguration = config cell.contentConfiguration = config
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell() cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
switch item { switch item {

View File

@ -81,13 +81,7 @@ class TrendingLinkTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
backgroundConfiguration = config
} }
func updateUI(card: Card) { func updateUI(card: Card) {

View File

@ -63,13 +63,7 @@ class EditListAccountsViewController: EnhancedTableViewController {
cell.delegate = self cell.delegate = self
cell.updateUI(accountID: id) cell.updateUI(accountID: id)
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
return cell return cell
}) })

View File

@ -61,13 +61,7 @@ class SwipeActionsPrefsViewController: UIViewController, UICollectionViewDelegat
cell.contentConfiguration = config cell.contentConfiguration = config
cell.accessories = [.reorder(displayed: .always)] cell.accessories = [.reorder(displayed: .always)]
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
} }
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in

View File

@ -142,13 +142,7 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
cell = collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, state)) cell = collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, state))
} }
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
return cell return cell
} }

View File

@ -89,13 +89,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
cell.updateUI(statusID: item.0, state: item.1, filterResult: .allow, precomputedContent: nil) cell.updateUI(statusID: item.0, state: item.1, filterResult: .allow, precomputedContent: nil)
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
} }
let accountCell = UICollectionView.CellRegistration<AccountCollectionViewCell, String> { [unowned self] cell, indexPath, item in let accountCell = UICollectionView.CellRegistration<AccountCollectionViewCell, String> { [unowned self] cell, indexPath, item in
@ -103,13 +97,7 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
cell.updateUI(accountID: item) cell.updateUI(accountID: item)
cell.configurationUpdateHandler = { cell, state in cell.configurationUpdateHandler = { cell, state in
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) cell.backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
cell.backgroundConfiguration = config
} }
} }
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in

View File

@ -119,7 +119,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
collectionView.delegate = self collectionView.delegate = self
collectionView.dragDelegate = self collectionView.dragDelegate = self
collectionView.allowsFocus = true collectionView.allowsFocus = true
collectionView.backgroundColor = .appBackground // collectionView.backgroundColor = .appBackground
collectionView.translatesAutoresizingMaskIntoConstraints = false collectionView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(collectionView) view.addSubview(collectionView)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@ -130,7 +130,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
]) ])
registerTimelineLikeCells() registerTimelineLikeCells()
collectionView.register(PublicTimelineDescriptionCollectionViewCell.self, forCellWithReuseIdentifier: "publicTimelineDescription")
dataSource = createDataSource() dataSource = createDataSource()
applyInitialSnapshot() applyInitialSnapshot()

View File

@ -59,13 +59,7 @@ class TrendingHashtagCollectionViewCell: UICollectionViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
backgroundConfiguration = config
} }
func updateUI(hashtag: Hashtag) { func updateUI(hashtag: Hashtag) {

View File

@ -40,13 +40,7 @@ class InstanceTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listGroupedCell() backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
backgroundConfiguration = config
} }
func updateUI(instance: InstanceSelector.Instance) { func updateUI(instance: InstanceSelector.Instance) {

View File

@ -49,13 +49,7 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
@objc func updateUIForPreferences() { @objc func updateUIForPreferences() {

View File

@ -44,13 +44,7 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
@objc func updateUIForPreferences() { @objc func updateUIForPreferences() {

View File

@ -50,13 +50,7 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
@objc func updateUIForPreferences() { @objc func updateUIForPreferences() {

View File

@ -39,13 +39,7 @@ class PollFinishedTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
func updateUI(notification: Pachyderm.Notification) { func updateUI(notification: Pachyderm.Notification) {

View File

@ -36,13 +36,7 @@ class StatusUpdatedNotificationTableViewCell: UITableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
func updateUI(notification: Pachyderm.Notification) { func updateUI(notification: Pachyderm.Notification) {

View File

@ -318,9 +318,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
config.backgroundColor = .appBackground
backgroundConfiguration = config
} }
// MARK: Configure UI // MARK: Configure UI

View File

@ -352,13 +352,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
// MARK: Accessibility // MARK: Accessibility

View File

@ -94,13 +94,7 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
} }
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state) backgroundConfiguration = .appListPlainCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appBackground
}
backgroundConfiguration = config
} }
override func createObserversIfNecessary() { override func createObserversIfNecessary() {

View File

@ -10,12 +10,6 @@ import UIKit
class TrendingStatusCollectionViewCell: TimelineStatusCollectionViewCell { class TrendingStatusCollectionViewCell: TimelineStatusCollectionViewCell {
override func updateConfiguration(using state: UICellConfigurationState) { override func updateConfiguration(using state: UICellConfigurationState) {
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) backgroundConfiguration = .appListGroupedCell(for: state)
if state.isHighlighted || state.isSelected {
config.backgroundColor = .appSelectedCellBackground
} else {
config.backgroundColor = .appGroupedCellBackground
}
backgroundConfiguration = config
} }
} }