From ee324cd6248c3ea5a83df74fa784464598dfad63 Mon Sep 17 00:00:00 2001 From: Joshua James Date: Fri, 13 Dec 2024 13:13:06 +0100 Subject: [PATCH] feature: Add highlight styling to list style --- Adyen/UI/List/ListCell.swift | 10 ++++++++++ Adyen/UI/List/ListItemStyle.swift | 3 +++ 2 files changed, 13 insertions(+) diff --git a/Adyen/UI/List/ListCell.swift b/Adyen/UI/List/ListCell.swift index 32cfd727a5..5434bf2ae2 100644 --- a/Adyen/UI/List/ListCell.swift +++ b/Adyen/UI/List/ListCell.swift @@ -24,6 +24,16 @@ public final class ListCell: UITableViewCell { fatalError("init(coder:) has not been implemented") } + override public func setHighlighted(_ highlighted: Bool, animated: Bool) { + super.setHighlighted(highlighted, animated: animated) + + guard let highlightedBackgroundColor = item?.style.highlightedBackgroundColor else { + return + } + + contentView.backgroundColor = highlighted ? highlightedBackgroundColor : item?.style.backgroundColor + } + // MARK: - Item /// The item displayed in the cell cell. diff --git a/Adyen/UI/List/ListItemStyle.swift b/Adyen/UI/List/ListItemStyle.swift index 6973207040..31fd045f9d 100644 --- a/Adyen/UI/List/ListItemStyle.swift +++ b/Adyen/UI/List/ListItemStyle.swift @@ -42,6 +42,9 @@ public struct ListItemStyle: ViewStyle { public var backgroundColor = UIColor.Adyen.componentBackground + /// Background color when highlighted (tapped). + public var highlightedBackgroundColor: UIColor? + /// Initializes the list item style. /// /// - Parameter title: The title style.