From 77c1026278cb8c456ec75824c003bda128dd1360 Mon Sep 17 00:00:00 2001 From: vasavk Date: Thu, 8 Feb 2024 22:58:15 +0530 Subject: [PATCH] story:ONEAPP-6315: Changes for the ExpandDirection picker, the button icon has no border if hideBorder is turned on --- .../Icon/ButtonIcon/ButtonIcon.swift | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index a15cef68..5b09a13d 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -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