From 8da5bb933f2bb93a088ccc621a061d3edcec140d Mon Sep 17 00:00:00 2001 From: Joanna Qu <55368679+joannaquu@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:20:13 -0500 Subject: [PATCH 1/2] set corner radius --- ios/FluentUI/SegmentedControl/SegmentPillButton.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift index 7e516c625f..1765c4f634 100644 --- a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift +++ b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift @@ -41,6 +41,7 @@ class SegmentPillButton: UIButton { trailing: horizontalInset) configuration.background.backgroundColor = .clear configuration.baseForegroundColor = tokenSet[.restLabelColor].uiColor + configuration.background.cornerRadius = 16 let titleTransformer = UIConfigurationTextAttributesTransformer { [weak self] incoming in var outgoing = incoming outgoing.font = self?.tokenSet[.font].uiFont From e09b7e357183615b82606425a76224763d0cccae Mon Sep 17 00:00:00 2001 From: Joanna Qu <55368679+joannaquu@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:10:17 -0500 Subject: [PATCH 2/2] move const to SegmentedControlTokenSet.swift --- ios/FluentUI/SegmentedControl/SegmentPillButton.swift | 2 +- ios/FluentUI/SegmentedControl/SegmentedControl.swift | 9 +++------ .../SegmentedControl/SegmentedControlTokenSet.swift | 6 ++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift index 1765c4f634..721e7cdd39 100644 --- a/ios/FluentUI/SegmentedControl/SegmentPillButton.swift +++ b/ios/FluentUI/SegmentedControl/SegmentPillButton.swift @@ -40,8 +40,8 @@ class SegmentPillButton: UIButton { bottom: verticalInset, trailing: horizontalInset) configuration.background.backgroundColor = .clear + configuration.background.cornerRadius = SegmentedControlTokenSet.pillButtonCornerRadius configuration.baseForegroundColor = tokenSet[.restLabelColor].uiColor - configuration.background.cornerRadius = 16 let titleTransformer = UIConfigurationTextAttributesTransformer { [weak self] incoming in var outgoing = incoming outgoing.font = self?.tokenSet[.font].uiFont diff --git a/ios/FluentUI/SegmentedControl/SegmentedControl.swift b/ios/FluentUI/SegmentedControl/SegmentedControl.swift index 69dea7b31e..5a49e687fb 100644 --- a/ios/FluentUI/SegmentedControl/SegmentedControl.swift +++ b/ios/FluentUI/SegmentedControl/SegmentedControl.swift @@ -9,9 +9,6 @@ import UIKit @objc(MSFSegmentedControl) open class SegmentedControl: UIView, TokenizedControlInternal { private struct Constants { - static let selectionBarHeight: CGFloat = 1.5 - static let pillContainerHorizontalInset: CGFloat = 16 - static let pillButtonCornerRadius: CGFloat = 16 static let iPadMinimumWidth: CGFloat = 375 } @@ -56,7 +53,7 @@ open class SegmentedControl: UIView, TokenizedControlInternal { } /// only used for pill style segment control. It is used to define the inset of the pillContainerView - @objc public var contentInset: NSDirectionalEdgeInsets = NSDirectionalEdgeInsets(top: 0, leading: Constants.pillContainerHorizontalInset, bottom: 0, trailing: Constants.pillContainerHorizontalInset) { + @objc public var contentInset: NSDirectionalEdgeInsets = NSDirectionalEdgeInsets(top: 0, leading: SegmentedControlTokenSet.pillContainerHorizontalInset, bottom: 0, trailing: SegmentedControlTokenSet.pillContainerHorizontalInset) { didSet { guard oldValue != contentInset else { return @@ -197,7 +194,7 @@ open class SegmentedControl: UIView, TokenizedControlInternal { super.init(frame: .zero) scrollView.delegate = self - stackView.layer.cornerRadius = Constants.pillButtonCornerRadius + stackView.layer.cornerRadius = SegmentedControlTokenSet.pillButtonCornerRadius pillContainerView.addSubview(stackView) selectionView.backgroundColor = .black pillContainerView.addSubview(selectionView) @@ -585,7 +582,7 @@ open class SegmentedControl: UIView, TokenizedControlInternal { let button = buttons[selectedSegmentIndex] selectionView.frame = button.frame - selectionView.layer.cornerRadius = Constants.pillButtonCornerRadius + selectionView.layer.cornerRadius = SegmentedControlTokenSet.pillButtonCornerRadius } private func updateTokenizedValues() { diff --git a/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift b/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift index 8cbd4c1130..3117dc1a69 100644 --- a/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift +++ b/ios/FluentUI/SegmentedControl/SegmentedControlTokenSet.swift @@ -212,6 +212,12 @@ public class SegmentedControlTokenSet: ControlTokenSet { var style: () -> SegmentedControlStyle } +// MARK: Constants +extension SegmentedControlTokenSet { + static let pillButtonCornerRadius: CGFloat = 16 + static let pillContainerHorizontalInset: CGFloat = 16 +} + @objc(MSFSegmentedControlStyle) public enum SegmentedControlStyle: Int { /// Segments are shown as labels inside a pill for use with a neutral or white background. Selection is indicated by a thumb under the selected label.