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

Tab Bar View can hide separator and disable blur effect #2119

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class TabBarViewDemoController: DemoController {
addRow(text: "Use gradient selection", items: [useGradientSelectionSwitch], textWidth: Constants.switchSettingTextWidth)
useGradientSelectionSwitch.addTarget(self, action: #selector(handleOnSwitchValueChanged), for: .valueChanged)

addRow(text: "Modify badge numbers", items: [incrementBadgeButton, decrementBadgeButton], textWidth: Constants.buttonSettingTextWidth)
addRow(text: "Modify badge numbers", items: [decrementBadgeButton, incrementBadgeButton], textWidth: Constants.buttonSettingTextWidth)

setupTabBarView()
updateBadgeButtons()
Expand Down
24 changes: 17 additions & 7 deletions Sources/FluentUI_iOS/Components/Tab Bar/TabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,25 @@ open class TabBarView: UIView, TokenizedControl {
stackView.setCustomSpacing(spacing, after: view)
}
}
/// Initializes MSTabBarView
/// - Parameter showsItemTitles: Determines whether or not to show the titles of the tab bar items.
@objc public convenience init(showsItemTitles: Bool = false) {
self.init(showsItemTitles: showsItemTitles, hideSeparator: false, disableBlur: false)
}

/// Initializes MSTabBarView
/// - Parameter showsItemTitles: Determines whether or not to show the titles of the tab bar items.
@objc public init(showsItemTitles: Bool = false) {
/// - Parameter hideSeparator: Removes the top divider displayed above the tab bar.
/// - Parameter disableBlur: Disables the blur effect applied to the tab bar.
@objc public init(showsItemTitles: Bool = false, hideSeparator: Bool = false, disableBlur: Bool = false) {
cbowdoin marked this conversation as resolved.
Show resolved Hide resolved
self.showsItemTitles = showsItemTitles

if disableBlur {
joannaquu marked this conversation as resolved.
Show resolved Hide resolved
self.backgroundView = UIVisualEffectView()
} else {
self.backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffect.Style.systemChromeMaterial))
}
cbowdoin marked this conversation as resolved.
Show resolved Hide resolved

super.init(frame: .zero)

backgroundView.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -107,6 +121,7 @@ open class TabBarView: UIView, TokenizedControl {
let stackViewInsets = Compatibility.isDeviceIdiomVision() ? UIEdgeInsets(top: 12.0, left: 0.0, bottom: 12.0, right: 0.0) : .zero
contain(view: stackView, withInsets: stackViewInsets, respectingSafeAreaInsets: true)

topBorderLine.isHidden = hideSeparator
cbowdoin marked this conversation as resolved.
Show resolved Hide resolved
topBorderLine.translatesAutoresizingMaskIntoConstraints = false
addSubview(topBorderLine)

Expand Down Expand Up @@ -159,12 +174,7 @@ open class TabBarView: UIView, TokenizedControl {
static let maxTabCount: Int = 6
}

private let backgroundView: UIVisualEffectView = {
var style = UIBlurEffect.Style.regular
style = .systemChromeMaterial

return UIVisualEffectView(effect: UIBlurEffect(style: style))
}()
private let backgroundView: UIVisualEffectView

private lazy var heightConstraint: NSLayoutConstraint = stackView.heightAnchor.constraint(equalToConstant: traitCollection.userInterfaceIdiom == .phone ? TabBarTokenSet.phonePortraitHeight : TabBarTokenSet.padHeight)

Expand Down
Loading