Skip to content

Add support for a UIBlurEffect Background to the BottomSheetController#2146

Merged
amoggo merged 8 commits intomicrosoft:mainfrom
amoggo:user/amaralim/BottomSheetBlurView
May 6, 2025
Merged

Add support for a UIBlurEffect Background to the BottomSheetController#2146
amoggo merged 8 commits intomicrosoft:mainfrom
amoggo:user/amaralim/BottomSheetBlurView

Conversation

@amoggo
Copy link
Copy Markdown
Contributor

@amoggo amoggo commented May 3, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

DESCRIPTION

  • Adds an opt-in Blur Effect background for the BottomSheet Contro
  • Add UIBlurEffect support to the BottomSheet by using a UIVisualEffectsView.
  • Add an optional usesBlurEffectBackground to BottomSheetController and BottomCommandingController initializers, to opt into this new effect.
  • Also account for a ShadowEffect which needs a special case handling for UIVisualEffectsView shadows, which would need a different logic from that currently implemented in Fluent Shadow API ShadowInfo:applyShadow:to:. This applyShadow API adds additional CALayers (configured with shadow properties) as shadow layers to the View essentially relying on the view having an opaque backgroundColor for the shadow to show (the opacity of the backgroundColor is directly proportional to the shadow opacity). But when using a UIVisualEffectsView, we can't set an opaque backgroundColor, as it would obstruct the content blurring/sampling feature of this special effects view and would defeat the purpose of using it entirely. So directly add the Shadow tokens to the UIVisualEffectsView layer.

Verification

  • Tested locally by opting into the usesBlurEffectBackground by doing a let bottomCommandingVC = BottomCommandingController(with: optionTableViewController, usesBlurEffectBackgroundForBottomSheet: true) in the corresponding demo controller.
  • The default behavior is unaffected. ie. uses opaque background.
Visual Verification (NOTE: very subtle difference - there's a blue color bleed through under the Mode button
Before After
Screenshot 2025-05-02 at 19 12 46 Screenshot 2025-05-02 at 19 12 25

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)

@amoggo amoggo changed the title Stand up changes to optionally use a BlurEffect view for BottomSheet Add support for a UIBlurEffect Background to the BottomSheetController May 3, 2025
@amoggo amoggo marked this pull request as ready for review May 5, 2025 16:08
@amoggo amoggo requested a review from a team as a code owner May 5, 2025 16:08
@amoggo amoggo merged commit ca7b412 into microsoft:main May 6, 2025
7 checks passed
@anandrajeswaran
Copy link
Copy Markdown
Contributor

One thing we should do after - should add a case or toggle using this new behavior to the demo app

/// - Parameters:
/// - contentViewController: View controller that will be displayed below the bottom commanding UI.
/// - bottomSheetControllerStyle: The style override for the BottomSheet's background material.
@objc public init(with contentViewController: UIViewController?, bottomSheetControllerStyle: BottomSheetControllerStyle) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems minor but since it's a part of our public api, can we rename this to style to match our other controls

@mischreiber mischreiber mentioned this pull request Jun 13, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants