Skip to content

Commit 64b2773

Browse files
authored
Update CommandBar styling on iOS 18 to match iOS 26 (#2235)
1 parent e9453bc commit 64b2773

File tree

3 files changed

+8
-40
lines changed

3 files changed

+8
-40
lines changed

Sources/FluentUI_iOS/Components/CommandBar/CommandBar.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ public class CommandBar: UIView, Shadowable, TokenizedControl {
151151
public override func layoutSubviews() {
152152
super.layoutSubviews()
153153

154-
if #available(iOS 26, *) {
155-
layer.cornerRadius = bounds.height / 2
156-
}
154+
layer.cornerRadius = bounds.height / 2
157155
updateShadow()
158156
updateScrollViewShadow()
159157
}
@@ -372,12 +370,7 @@ public class CommandBar: UIView, Shadowable, TokenizedControl {
372370
}
373371

374372
private func stackViewLayoutMargins() -> NSDirectionalEdgeInsets {
375-
var padding: CGFloat
376-
if #available(iOS 26, *) {
377-
padding = CommandBarTokenSet.barInsets
378-
} else {
379-
padding = 0
380-
}
373+
let padding: CGFloat = CommandBarTokenSet.barInsets
381374
return NSDirectionalEdgeInsets(top: 0,
382375
leading: leadingCommandGroupsView.isHidden ? 0 : padding,
383376
bottom: 0,

Sources/FluentUI_iOS/Components/CommandBar/CommandBarButton.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ class CommandBarButton: UIButton {
5353
var buttonConfiguration = UIButton.Configuration.plain()
5454
buttonConfiguration.imagePadding = CommandBarTokenSet.buttonImagePadding
5555
buttonConfiguration.contentInsets = CommandBarTokenSet.buttonContentInsets
56-
if #available(iOS 26, *) {
57-
buttonConfiguration.background.cornerRadius = tokenSet[.cornerRadius].float
58-
} else {
59-
buttonConfiguration.background.cornerRadius = 0
60-
}
56+
buttonConfiguration.background.cornerRadius = tokenSet[.cornerRadius].float
6157
configuration = buttonConfiguration
6258

6359
let accessibilityDescription = item.accessibilityLabel

Sources/FluentUI_iOS/Components/CommandBar/CommandBarTokenSet.swift

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public enum CommandBarToken: Int, TokenSetKey {
1212
/// The background color of the Command Bar.
1313
case backgroundColor
1414

15-
/// The corner radius for each group of item(s) inside the Command Bar.
16-
/// On iOS 26+, this is also the corner radius for each Command Bar Button.
15+
/// The corner radius for each Command Bar Button.
1716
case cornerRadius
1817

1918
/// The background color of a single Command Bar Item when in rest.
@@ -65,11 +64,7 @@ public class CommandBarTokenSet: ControlTokenSet<CommandBarToken> {
6564
return .float { GlobalTokens.corner(.radius120) }
6665

6766
case .itemBackgroundColorRest:
68-
if #available(iOS 26, *) {
69-
return .uiColor { .clear }
70-
} else {
71-
return .uiColor { theme.color(.background5) }
72-
}
67+
return .uiColor { .clear }
7368

7469
case .itemBackgroundColorHover:
7570
return .uiColor { theme.color(.background5) }
@@ -102,11 +97,7 @@ public class CommandBarTokenSet: ControlTokenSet<CommandBarToken> {
10297
return .uiFont { theme.typography(.caption2, adjustsForContentSizeCategory: false) }
10398

10499
case .shadow:
105-
if #available(iOS 26, *) {
106-
return .shadowInfo { theme.shadow(.shadow08) }
107-
} else {
108-
return .shadowInfo { theme.shadow(.clear) }
109-
}
100+
return .shadowInfo { theme.shadow(.shadow08) }
110101
}
111102
}
112103
}
@@ -116,13 +107,7 @@ public class CommandBarTokenSet: ControlTokenSet<CommandBarToken> {
116107

117108
extension CommandBarTokenSet {
118109
/// The spacing between each Command Bar Group.
119-
static var groupInterspace: CGFloat {
120-
if #available(iOS 26, *) {
121-
GlobalTokens.spacing(.size20)
122-
} else {
123-
GlobalTokens.spacing(.size80)
124-
}
125-
}
110+
static let groupInterspace: CGFloat = GlobalTokens.spacing(.size20)
126111

127112
/// The spacing between each Command Bar Group for iPad.
128113
static let groupInterspaceWide: CGFloat = GlobalTokens.spacing(.size160)
@@ -137,13 +122,7 @@ extension CommandBarTokenSet {
137122
static let dismissGradientWidth: CGFloat = GlobalTokens.spacing(.size160)
138123

139124
/// The edge inset values for the Command Bar.
140-
static var barInsets: CGFloat {
141-
if #available(iOS 26, *) {
142-
GlobalTokens.spacing(.size40)
143-
} else {
144-
GlobalTokens.spacing(.size80)
145-
}
146-
}
125+
static let barInsets: CGFloat = GlobalTokens.spacing(.size40)
147126

148127
/// The edge inset values for the Command Bar Button.
149128
static let buttonContentInsets = NSDirectionalEdgeInsets(top: 8.0,

0 commit comments

Comments
 (0)