added custom
- container size - icon size - badgeIndicator Offset Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
40129d8ce9
commit
c4b77dfc63
@ -143,10 +143,7 @@ open class ButtonIcon: Control, Changeable {
|
||||
|
||||
/// Sets the size of button icon and icon.
|
||||
open var size: Size = .large { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Sets the size of button icon and icon.
|
||||
open var customSize: Int? { didSet { setNeedsUpdate() } }
|
||||
|
||||
|
||||
/// If provided, the button icon will have a box shadow.
|
||||
open var floating: Bool = false { didSet { setNeedsUpdate() } }
|
||||
|
||||
@ -169,10 +166,20 @@ open class ButtonIcon: Control, Changeable {
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 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() } }
|
||||
|
||||
|
||||
/// Sets a custom size of button icon container.
|
||||
open var customContainerSize: Int? { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Sets a custom size of the icon.
|
||||
open var customIconSize: Int? { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Sets a custom badgeIndicator offset
|
||||
open var customBadgeIndicatorOffset: CGPoint? { didSet { setNeedsUpdate() } }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration
|
||||
//--------------------------------------------------
|
||||
@ -444,8 +451,11 @@ open class ButtonIcon: Control, Changeable {
|
||||
icon.name = currentIconName
|
||||
let color = iconColorConfiguration.getColor(self)
|
||||
icon.color = color
|
||||
icon.size = iconSize
|
||||
icon.customSize = customSize
|
||||
if let customIconSize {
|
||||
icon.customSize = customIconSize
|
||||
} else {
|
||||
icon.size = iconSize
|
||||
}
|
||||
icon.isEnabled = isEnabled
|
||||
} else {
|
||||
icon.reset()
|
||||
@ -480,8 +490,8 @@ open class ButtonIcon: Control, Changeable {
|
||||
|
||||
//updating current container size
|
||||
var iconLayoutSize = size.containerSize
|
||||
if let customSize {
|
||||
iconLayoutSize = CGFloat(customSize)
|
||||
if let customContainerSize {
|
||||
iconLayoutSize = CGFloat(customContainerSize)
|
||||
}
|
||||
// check to see if this is fitToIcon
|
||||
if fitToIcon && kind == .ghost {
|
||||
@ -503,10 +513,11 @@ open class ButtonIcon: Control, Changeable {
|
||||
layer.borderWidth = 0
|
||||
}
|
||||
|
||||
badgeIndicatorCenterXConstraint?.constant = badgeIndicatorOffset.x + badgeIndicatorDefaultSize.width/2
|
||||
badgeIndicatorCenterYConstraint?.constant = badgeIndicatorOffset.y + badgeIndicatorDefaultSize.height/2
|
||||
badgeIndicatorLeadingConstraint?.constant = badgeIndicatorOffset.x
|
||||
badgeIndicatorTrailingConstraint?.constant = badgeIndicatorOffset.x + badgeIndicatorDefaultSize.width
|
||||
let offSet = customBadgeIndicatorOffset ?? badgeIndicatorOffset
|
||||
badgeIndicatorCenterXConstraint?.constant = offSet.x + badgeIndicatorDefaultSize.width/2
|
||||
badgeIndicatorCenterYConstraint?.constant = offSet.y + badgeIndicatorDefaultSize.height/2
|
||||
badgeIndicatorLeadingConstraint?.constant = offSet.x
|
||||
badgeIndicatorTrailingConstraint?.constant = offSet.x + badgeIndicatorDefaultSize.width
|
||||
|
||||
if showBadgeIndicator {
|
||||
updateExpandDirectionalConstraints()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user