story:ONEAPP-6315: made changes for selectedIconName, and selected state of buttonIcon

This commit is contained in:
vasavk 2024-02-09 16:45:50 +05:30
parent 0c9a689e13
commit 960cf33b41

View File

@ -75,7 +75,7 @@ open class ButtonIcon: Control {
private var badgeIndicatorLeadingConstraint: NSLayoutConstraint?
private var badgeIndicatorBottomConstraint: NSLayoutConstraint?
private var currentIconName: Icon.Name? {
if let selectedIconName {
if let selectedIconName, selectable {
return selectedIconName
} else {
return iconName
@ -120,7 +120,7 @@ open class ButtonIcon: Control {
/// Icon Name used within the Icon.
open var iconName: Icon.Name? { didSet { setNeedsUpdate() } }
/// Icon Name used within the Icon within the Selected State.
/// Selected Icon Name used within the Icon if selectable true.
open var selectedIconName: Icon.Name? { didSet { setNeedsUpdate() } }
/// Sets the size of button icon and icon.
@ -141,7 +141,7 @@ open class ButtonIcon: Control {
/// If provided, the badge indicator will present.
open var showBadgeIndicator: Bool = false { didSet { setNeedsUpdate() } }
/// If provided, the button icon will have selectable Icon.
/// If true, button will be rendered as selected, when it is selectable.
open var selectable: Bool = false { didSet { setNeedsUpdate() } }
/// Used to move the icon inside the button in both x and y axis.
@ -154,7 +154,7 @@ open class ButtonIcon: Control {
// MARK: - Configuration
//--------------------------------------------------
private var iconColorConfiguration: AnyColorable {
if selectedIconName != nil {
if selectedIconName != nil, selectable {
return selectedIconColorConfiguration
} else {
if kind == .highContrast {
@ -346,7 +346,7 @@ open class ButtonIcon: Control {
hideBorder = true
iconOffset = .init(x: 0, y: 0)
iconName = nil
// selectableIconName = nil
selectedIconName = nil
showBadgeIndicator = false
selectable = false
badgeIndicatorModel = nil