Skip to content

Commit a97585d

Browse files
authored
Fully remove CommandBar label (#2224)
* Revert "[WIP] Add CommandBarItemGroup labels (#2143)" This reverts commit 7e5efea. * cleanup
1 parent cb03e75 commit a97585d

7 files changed

Lines changed: 15 additions & 94 deletions

File tree

Demos/FluentUIDemo_iOS/FluentUI.Demo/Demos/CommandBarDemoController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ class CommandBarDemoController: DemoController {
337337
]
338338
]
339339

340-
let itemGroups: [CommandBarItemGroup] = commandGroups.map {
341-
CommandBarItemGroup($0.map { newItem(for: $0) })
340+
let itemGroups: [CommandBarItemGroup] = commandGroups.map { commandGroup in
341+
commandGroup.map { command in
342+
newItem(for: command)
343+
}
342344
}
343345

344346
itemGroups[0][1].isEnabled = false

MicrosoftFluentUI.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ Pod::Spec.new do |s|
115115
s.subspec 'CommandBar_ios' do |commandbar_ios|
116116
commandbar_ios.platform = :ios
117117
commandbar_ios.dependency "#{s.name}/Core_ios"
118-
commandbar_ios.dependency "#{s.name}/Label_ios"
119118
commandbar_ios.source_files = ["#{ios_root}/#{components_dir}/CommandBar/**/*.{swift,h}"]
120119
end
121120

Sources/FluentUI_iOS/Components/CommandBar/CommandBarButton.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ class CommandBarButton: UIButton {
6060
}
6161
configuration = buttonConfiguration
6262

63-
setContentHuggingPriority(.required, for: .horizontal)
64-
setContentCompressionResistancePriority(.required, for: .horizontal)
65-
6663
let accessibilityDescription = item.accessibilityLabel
6764
accessibilityLabel = (accessibilityDescription != nil) ? accessibilityDescription : item.title
6865
accessibilityHint = item.accessibilityHint

Sources/FluentUI_iOS/Components/CommandBar/CommandBarButtonGroupView.swift

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ import UIKit
1010

1111
class CommandBarButtonGroupView: UIView {
1212
let buttons: [CommandBarButton]
13-
let title: String?
1413

15-
init(buttons: [CommandBarButton], title: String?, tokenSet: CommandBarTokenSet) {
14+
init(buttons: [CommandBarButton], tokenSet: CommandBarTokenSet) {
1615
self.buttons = buttons
17-
self.title = title
1816
self.tokenSet = tokenSet
1917

2018
super.init(frame: .zero)
2119
translatesAutoresizingMaskIntoConstraints = false
2220

21+
clipsToBounds = true
22+
layer.cornerRadius = tokenSet[.cornerRadius].float
23+
layer.cornerCurve = .continuous
24+
2325
configureHierarchy()
2426
applyInsets()
2527
hideGroupIfNeeded()
@@ -33,7 +35,7 @@ class CommandBarButtonGroupView: UIView {
3335
/// Hides the group view if all the views inside the `stackView` are hidden
3436
func hideGroupIfNeeded() {
3537
var allViewsHidden = true
36-
for view in buttonStackView.arrangedSubviews {
38+
for view in stackView.arrangedSubviews {
3739
if !view.isHidden {
3840
allViewsHidden = false
3941
break
@@ -45,51 +47,21 @@ class CommandBarButtonGroupView: UIView {
4547

4648
var equalWidthButtons: Bool = false {
4749
didSet {
48-
buttonStackView.distribution = equalWidthButtons ? .fillEqually : .fill
50+
stackView.distribution = equalWidthButtons ? .fillEqually : .fill
4951
}
5052
}
5153

52-
private lazy var buttonStackView: UIStackView = {
54+
private lazy var stackView: UIStackView = {
5355
let stackView = UIStackView(arrangedSubviews: buttons)
5456
stackView.translatesAutoresizingMaskIntoConstraints = false
5557
stackView.axis = .horizontal
5658
stackView.spacing = CommandBarTokenSet.itemInterspace
5759

58-
stackView.clipsToBounds = true
59-
stackView.layer.cornerRadius = tokenSet[.cornerRadius].float
60-
stackView.layer.cornerCurve = .continuous
6160
return stackView
6261
}()
6362

64-
private lazy var groupLabel: Label = {
65-
let label = Label()
66-
label.text = title
67-
label.font = tokenSet[.itemGroupLabelFont].uiFont
68-
label.translatesAutoresizingMaskIntoConstraints = false
69-
label.setContentHuggingPriority(.required, for: .vertical)
70-
label.lineBreakMode = .byClipping
71-
72-
label.accessibilityTraits.insert(.header)
73-
label.isUserInteractionEnabled = true
74-
label.addInteraction(UILargeContentViewerInteraction())
75-
label.showsLargeContentViewer = true
76-
label.largeContentTitle = title
77-
return label
78-
}()
79-
8063
private func configureHierarchy() {
81-
let stackView = UIStackView()
82-
stackView.translatesAutoresizingMaskIntoConstraints = false
83-
stackView.axis = .vertical
84-
85-
stackView.addArrangedSubview(buttonStackView)
86-
if #unavailable(iOS 26) {
87-
if title != nil {
88-
stackView.addArrangedSubview(groupLabel)
89-
}
90-
}
9164
addSubview(stackView)
92-
9365
NSLayoutConstraint.activate([
9466
stackView.topAnchor.constraint(equalTo: topAnchor),
9567
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),

Sources/FluentUI_iOS/Components/CommandBar/CommandBarCommandGroupsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CommandBarCommandGroupsView: UIView {
7070
return button
7171
}
7272

73-
let group = CommandBarButtonGroupView(buttons: buttons, title: items.label, tokenSet: tokenSet)
73+
let group = CommandBarButtonGroupView(buttons: buttons, tokenSet: tokenSet)
7474

7575
for item in items {
7676
if let button = itemsToButtonsMap[item] {

Sources/FluentUI_iOS/Components/CommandBar/CommandBarItem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import FluentUI_common
88
#endif
99
import UIKit
1010

11+
public typealias CommandBarItemGroup = [CommandBarItem]
12+
1113
@objc(MSFCommandBarItem)
1214
open class CommandBarItem: NSObject {
1315
public typealias ItemTappedHandler = ((UIView, CommandBarItem) -> Void)

Sources/FluentUI_iOS/Components/CommandBar/CommandBarItemGroup.swift

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)