story:ONEAPP-6315: Changes for the ExpandDirection picker, the button icon has no border if hideBorder is turned on

This commit is contained in:
vasavk 2024-02-08 22:58:15 +05:30
parent 206cbf04e4
commit 77c1026278

View File

@ -139,7 +139,7 @@ open class ButtonIcon: Control {
open var hideBorder: Bool = true { didSet { setNeedsUpdate() } }
/// If provided, the badge indicator will present.
open var showBadge: Bool = false { didSet { setNeedsUpdate() } }
open var showBadgeIndicator: Bool = false { didSet { setNeedsUpdate() } }
/// If provided, the button icon will have selectable Icon.
open var selectable: Bool = false { didSet { setNeedsUpdate() } }
@ -147,6 +147,9 @@ open class ButtonIcon: Control {
/// Used to move the icon inside the button in both x and y axis.
open var iconOffset: CGPoint = .init(x: 0, y: 0) { didSet { setNeedsUpdate() } }
/// Applies expand direction to Badge Indicator if shows badge indicator.
open var expandDirection: ExpandDirection = .right { didSet { setNeedsUpdate() } }
//--------------------------------------------------
// MARK: - Configuration
//--------------------------------------------------
@ -309,7 +312,7 @@ open class ButtonIcon: Control {
//add badgeIndicator
addSubview(badgeIndicator)
badgeIndicator.isHidden = !showBadge
badgeIndicator.isHidden = !showBadgeIndicator
//determines the height/width of the icon
layoutGuideWidthConstraint = iconLayoutGuide.width(constant: size.containerSize)
@ -344,9 +347,10 @@ open class ButtonIcon: Control {
iconOffset = .init(x: 0, y: 0)
iconName = nil
// selectableIconName = nil
showBadge = false
showBadgeIndicator = false
selectable = false
badgeIndicatorModel = nil
expandDirection = .right
shouldUpdateView = true
setNeedsUpdate()
}
@ -400,7 +404,7 @@ open class ButtonIcon: Control {
layoutGuideHeightConstraint?.constant = iconLayoutSize
//border
if let borderable = currentConfig as? Borderable {
if let borderable = currentConfig as? Borderable, self.hideBorder {
layer.borderColor = borderable.borderColorConfiguration.getColor(self).cgColor
layer.borderWidth = borderable.borderWidth
} else {
@ -413,7 +417,10 @@ open class ButtonIcon: Control {
} else {
removeDropShadow()
}
if showBadgeIndicator {
updateExpandDirectionalConstraints()
}
}
//--------------------------------------------------
@ -438,6 +445,16 @@ open class ButtonIcon: Control {
badgeIndicator.hideBorder = badgeIndicatorModel.hideBorder
}
}
private func updateExpandDirectionalConstraints() {
if expandDirection == .right {
print("expandDirection -> Right")
} else if expandDirection == .center {
print("expandDirection -> center")
} else if expandDirection == .left {
print("expandDirection -> left")
}
}
}
// MARK: AppleGuidelinesTouchable