story:ONEAPP-6315: expand direction configuration changes
This commit is contained in:
parent
960cf33b41
commit
ff5f7e5f55
@ -73,7 +73,9 @@ open class ButtonIcon: Control {
|
|||||||
private var layoutGuideWidthConstraint: NSLayoutConstraint?
|
private var layoutGuideWidthConstraint: NSLayoutConstraint?
|
||||||
private var layoutGuideHeightConstraint: NSLayoutConstraint?
|
private var layoutGuideHeightConstraint: NSLayoutConstraint?
|
||||||
private var badgeIndicatorLeadingConstraint: NSLayoutConstraint?
|
private var badgeIndicatorLeadingConstraint: NSLayoutConstraint?
|
||||||
private var badgeIndicatorBottomConstraint: NSLayoutConstraint?
|
private var badgeIndicatorTrailingConstraint: NSLayoutConstraint?
|
||||||
|
private var badgeIndicatorCenterXConstraint: NSLayoutConstraint?
|
||||||
|
private var badgeIndicatorCenterYConstraint: NSLayoutConstraint?
|
||||||
private var currentIconName: Icon.Name? {
|
private var currentIconName: Icon.Name? {
|
||||||
if let selectedIconName, selectable {
|
if let selectedIconName, selectable {
|
||||||
return selectedIconName
|
return selectedIconName
|
||||||
@ -295,7 +297,9 @@ open class ButtonIcon: Control {
|
|||||||
var shadowOffset: CGSize = .init(width: 0, height: 2)
|
var shadowOffset: CGSize = .init(width: 0, height: 2)
|
||||||
var shadowRadius: CGFloat = 6
|
var shadowRadius: CGFloat = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var badgeIndicatorDefaultSize: CGSize = .zero
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -313,13 +317,17 @@ open class ButtonIcon: Control {
|
|||||||
//add badgeIndicator
|
//add badgeIndicator
|
||||||
addSubview(badgeIndicator)
|
addSubview(badgeIndicator)
|
||||||
badgeIndicator.isHidden = !showBadgeIndicator
|
badgeIndicator.isHidden = !showBadgeIndicator
|
||||||
|
badgeIndicatorDefaultSize = badgeIndicator.frame.size
|
||||||
|
|
||||||
//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)
|
||||||
layoutGuideHeightConstraint = iconLayoutGuide.height(constant: size.containerSize)
|
layoutGuideHeightConstraint = iconLayoutGuide.height(constant: size.containerSize)
|
||||||
badgeIndicatorBottomConstraint = icon.centerYAnchor.constraint(equalTo: badgeIndicator.bottomAnchor)
|
|
||||||
badgeIndicatorLeadingConstraint = badgeIndicator.leadingAnchor.constraint(equalTo: icon.centerXAnchor)
|
badgeIndicatorLeadingConstraint = badgeIndicator.leadingAnchor.constraint(equalTo: icon.centerXAnchor)
|
||||||
badgeIndicatorBottomConstraint?.isActive = true
|
badgeIndicatorTrailingConstraint = badgeIndicator.trailingAnchor.constraint(equalTo: icon.centerXAnchor)
|
||||||
|
badgeIndicatorCenterXConstraint = badgeIndicator.centerXAnchor.constraint(equalTo: icon.centerXAnchor)
|
||||||
|
badgeIndicatorCenterYConstraint = icon.centerYAnchor.constraint(equalTo: badgeIndicator.centerYAnchor)
|
||||||
|
badgeIndicatorCenterYConstraint?.isActive = true
|
||||||
|
|
||||||
badgeIndicatorLeadingConstraint?.isActive = true
|
badgeIndicatorLeadingConstraint?.isActive = true
|
||||||
//pin layout guide
|
//pin layout guide
|
||||||
iconLayoutGuide
|
iconLayoutGuide
|
||||||
@ -370,8 +378,6 @@ open class ButtonIcon: Control {
|
|||||||
icon.reset()
|
icon.reset()
|
||||||
}
|
}
|
||||||
updateBadgeIndicator()
|
updateBadgeIndicator()
|
||||||
badgeIndicatorLeadingConstraint?.constant = badgeIndicatorOffset.x
|
|
||||||
badgeIndicatorBottomConstraint?.constant = badgeIndicatorOffset.y
|
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +423,12 @@ open class ButtonIcon: Control {
|
|||||||
} else {
|
} else {
|
||||||
removeDropShadow()
|
removeDropShadow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badgeIndicatorCenterXConstraint?.constant = badgeIndicatorOffset.x + badgeIndicatorDefaultSize.width/2
|
||||||
|
badgeIndicatorCenterYConstraint?.constant = badgeIndicatorOffset.y + badgeIndicatorDefaultSize.height/2
|
||||||
|
badgeIndicatorLeadingConstraint?.constant = badgeIndicatorOffset.x
|
||||||
|
badgeIndicatorTrailingConstraint?.constant = badgeIndicatorOffset.x + badgeIndicatorDefaultSize.width
|
||||||
|
|
||||||
if showBadgeIndicator {
|
if showBadgeIndicator {
|
||||||
updateExpandDirectionalConstraints()
|
updateExpandDirectionalConstraints()
|
||||||
}
|
}
|
||||||
@ -447,12 +458,19 @@ open class ButtonIcon: Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updateExpandDirectionalConstraints() {
|
private func updateExpandDirectionalConstraints() {
|
||||||
if expandDirection == .right {
|
switch expandDirection {
|
||||||
print("expandDirection -> Right")
|
case .right:
|
||||||
} else if expandDirection == .center {
|
badgeIndicatorLeadingConstraint?.isActive = true
|
||||||
print("expandDirection -> center")
|
badgeIndicatorTrailingConstraint?.isActive = false
|
||||||
} else if expandDirection == .left {
|
badgeIndicatorCenterXConstraint?.isActive = false
|
||||||
print("expandDirection -> left")
|
case .center:
|
||||||
|
badgeIndicatorLeadingConstraint?.isActive = false
|
||||||
|
badgeIndicatorTrailingConstraint?.isActive = false
|
||||||
|
badgeIndicatorCenterXConstraint?.isActive = true
|
||||||
|
case .left:
|
||||||
|
badgeIndicatorLeadingConstraint?.isActive = false
|
||||||
|
badgeIndicatorCenterXConstraint?.isActive = false
|
||||||
|
badgeIndicatorTrailingConstraint?.isActive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user