Skip to content

Commit 0990bec

Browse files
ivanvorobeiclaude
andcommitted
Remove saveOriginal parameter from updateImageDimming
The parameter leaked internal caching logic into the public call sites. Now the method auto-detects a new original image via identity check (content.image !== originalImage), so callers no longer need to know about the caching mechanism. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 20dcf95 commit 0990bec

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Sources/DiffableKit/Table/Cells/DiffableButtonTableViewCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ open class DiffableButtonTableViewCell: DiffableTableViewCell {
1616
super.init(coder: coder)
1717
}
1818

19-
override func updateImageDimming(saveOriginal: Bool = false) {
19+
override func updateImageDimming() {
2020
guard var content = contentConfiguration as? UIListContentConfiguration else { return }
2121
let dimmed = tintAdjustmentMode == .dimmed
2222
let color: UIColor = dimmed ? .secondaryLabel : tintColor
2323
if content.textProperties.color != color {
2424
content.textProperties.color = color
2525
contentConfiguration = content
2626
}
27-
super.updateImageDimming(saveOriginal: saveOriginal)
27+
super.updateImageDimming()
2828
}
2929

3030
open override func setHighlighted(_ highlighted: Bool, animated: Bool) {

Sources/DiffableKit/Table/Cells/DiffableTableViewCell.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ open class DiffableTableViewCell: UITableViewCell {
3030
updateImageDimming()
3131
}
3232

33-
func updateImageDimming(saveOriginal: Bool = false) {
33+
func updateImageDimming() {
3434
guard var content = contentConfiguration as? UIListContentConfiguration else { return }
35-
if saveOriginal { originalImage = content.image }
35+
if content.image !== originalImage {
36+
originalImage = content.image
37+
}
3638
let dimmed = tintAdjustmentMode == .dimmed
3739
if dimmed {
3840
guard let desaturated = originalImage?.desaturated() else { return }

Sources/DiffableKit/Table/DataSource/DiffableTableDataSource+CellProvider.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extension DiffableTableDataSource {
5151
content.image = item.icon
5252
applyImageLayout(&content)
5353
cell.contentConfiguration = content
54-
cell.updateImageDimming(saveOriginal: true)
54+
cell.updateImageDimming()
5555
cell.accessoryType = item.accessoryType
5656
cell.selectionStyle = item.selectionStyle
5757
return cell
@@ -68,7 +68,7 @@ extension DiffableTableDataSource {
6868
content.image = item.icon
6969
applyImageLayout(&content)
7070
cell.contentConfiguration = content
71-
cell.updateImageDimming(saveOriginal: true)
71+
cell.updateImageDimming()
7272
cell.accessoryType = item.accessoryType
7373
cell.selectionStyle = item.selectionStyle
7474
return cell
@@ -87,7 +87,7 @@ extension DiffableTableDataSource {
8787
let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
8888
content.textProperties.font = UIFont.systemFont(ofSize: descriptor.pointSize, weight: .medium)
8989
cell.contentConfiguration = content
90-
cell.updateImageDimming(saveOriginal: true)
90+
cell.updateImageDimming()
9191
cell.accessoryType = item.accessoryType
9292
return cell
9393
}
@@ -102,7 +102,7 @@ extension DiffableTableDataSource {
102102
content.image = item.icon
103103
applyImageLayout(&content)
104104
cell.contentConfiguration = content
105-
cell.updateImageDimming(saveOriginal: true)
105+
cell.updateImageDimming()
106106

107107
if let control = cell.accessoryView as? DiffableSwitch {
108108
control.action = item.action
@@ -127,7 +127,7 @@ extension DiffableTableDataSource {
127127
content.image = item.icon
128128
applyImageLayout(&content)
129129
cell.contentConfiguration = content
130-
cell.updateImageDimming(saveOriginal: true)
130+
cell.updateImageDimming()
131131

132132
if let control = cell.accessoryView as? DiffableStepper {
133133
control.action = item.action

0 commit comments

Comments
 (0)