Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add property to override badge style in navigation bar #1977

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
13 changes: 11 additions & 2 deletions ios/FluentUI/Navigation/NavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ open class NavigationBar: UINavigationBar, TokenizedControlInternal, TwoLineTitl
// @objc dynamic - so we can do KVO on this
@objc dynamic private(set) var style: Style = defaultStyle

private(set) var badgeLabelStyle: Style?

private var systemWantsCompactNavigationBar: Bool {
return traitCollection.horizontalSizeClass == .compact && traitCollection.verticalSizeClass == .compact
}
Expand Down Expand Up @@ -589,6 +591,12 @@ open class NavigationBar: UINavigationBar, TokenizedControlInternal, TwoLineTitl
titleView.avatarOverrideStyle = style
}

/// Override BadgeLabelStyle for navigation bar
kumarmohit5189 marked this conversation as resolved.
Show resolved Hide resolved
/// - Parameter badgeLabelStyle: updated style to be used
@objc public func overrideBadgeLabelStyle(_ badgeLabelStyle: Style) {
kumarmohit5189 marked this conversation as resolved.
Show resolved Hide resolved
self.badgeLabelStyle = badgeLabelStyle
}

// MARK: Element size handling

private var currentAvatarSize: ElementSize {
Expand Down Expand Up @@ -724,9 +732,10 @@ open class NavigationBar: UINavigationBar, TokenizedControlInternal, TwoLineTitl
private func createBarButtonItemButton(with item: UIBarButtonItem, isLeftItem: Bool) -> UIButton {
let button = BadgeLabelButton(type: .system)
button.item = item
if style == .system {
let finalStyle = badgeLabelStyle ?? style
if finalStyle == .system {
button.badgeLabelStyle = .system
} else if style == .gradient {
} else if finalStyle == .gradient {
button.badgeLabelStyle = .brand
} else {
button.badgeLabelStyle = .onPrimary
Expand Down
Loading