story:ONEAPP-6315: Changes for the ExpandDirection picker, the button icon has no border if hideBorder is turned on
This commit is contained in:
parent
206cbf04e4
commit
77c1026278
@ -139,7 +139,7 @@ open class ButtonIcon: Control {
|
|||||||
open var hideBorder: Bool = true { didSet { setNeedsUpdate() } }
|
open var hideBorder: Bool = true { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// If provided, the badge indicator will present.
|
/// 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.
|
/// If provided, the button icon will have selectable Icon.
|
||||||
open var selectable: Bool = false { didSet { setNeedsUpdate() } }
|
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.
|
/// 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() } }
|
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
|
// MARK: - Configuration
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -309,7 +312,7 @@ open class ButtonIcon: Control {
|
|||||||
|
|
||||||
//add badgeIndicator
|
//add badgeIndicator
|
||||||
addSubview(badgeIndicator)
|
addSubview(badgeIndicator)
|
||||||
badgeIndicator.isHidden = !showBadge
|
badgeIndicator.isHidden = !showBadgeIndicator
|
||||||
|
|
||||||
//determines the height/width of the icon
|
//determines the height/width of the icon
|
||||||
layoutGuideWidthConstraint = iconLayoutGuide.width(constant: size.containerSize)
|
layoutGuideWidthConstraint = iconLayoutGuide.width(constant: size.containerSize)
|
||||||
@ -344,9 +347,10 @@ open class ButtonIcon: Control {
|
|||||||
iconOffset = .init(x: 0, y: 0)
|
iconOffset = .init(x: 0, y: 0)
|
||||||
iconName = nil
|
iconName = nil
|
||||||
// selectableIconName = nil
|
// selectableIconName = nil
|
||||||
showBadge = false
|
showBadgeIndicator = false
|
||||||
selectable = false
|
selectable = false
|
||||||
badgeIndicatorModel = nil
|
badgeIndicatorModel = nil
|
||||||
|
expandDirection = .right
|
||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
@ -400,7 +404,7 @@ open class ButtonIcon: Control {
|
|||||||
layoutGuideHeightConstraint?.constant = iconLayoutSize
|
layoutGuideHeightConstraint?.constant = iconLayoutSize
|
||||||
|
|
||||||
//border
|
//border
|
||||||
if let borderable = currentConfig as? Borderable {
|
if let borderable = currentConfig as? Borderable, self.hideBorder {
|
||||||
layer.borderColor = borderable.borderColorConfiguration.getColor(self).cgColor
|
layer.borderColor = borderable.borderColorConfiguration.getColor(self).cgColor
|
||||||
layer.borderWidth = borderable.borderWidth
|
layer.borderWidth = borderable.borderWidth
|
||||||
} else {
|
} else {
|
||||||
@ -414,6 +418,9 @@ open class ButtonIcon: Control {
|
|||||||
removeDropShadow()
|
removeDropShadow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if showBadgeIndicator {
|
||||||
|
updateExpandDirectionalConstraints()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -438,6 +445,16 @@ open class ButtonIcon: Control {
|
|||||||
badgeIndicator.hideBorder = badgeIndicatorModel.hideBorder
|
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
|
// MARK: AppleGuidelinesTouchable
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user