Skip to content

Conversation

cbowdoin
Copy link
Contributor

@cbowdoin cbowdoin commented Oct 1, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

Added the ability to present notifications relative to a layout guide when there is no anchor view provided.

Verification

Verified by creating a layout guide in the test app to present the notification higher than it normally would present.

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)
Microsoft Reviewers: Open in CodeFlow

@cbowdoin cbowdoin requested a review from a team as a code owner October 1, 2025 20:38
@nodes11
Copy link
Contributor

nodes11 commented Oct 2, 2025

Can an example of a notification using the layoutGuide parameter be added to the demo controller.

/// - anchorView: The view used as the bottom anchor for presentation
/// (notification view is always presented up from the anchor). When no anchor view is provided the
/// bottom anchor of the container's safe area is used.
/// - layoutGuide: The layout guide used to present the toast inside of when no `anchorView` is provided
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will adding this parameter cause any problems for our Objective-C clients?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think objC just ignores default parameters and forces us to add a value. I'm personally mixed as to whether that mismatch has enough practical badness to cause us to avoid it iff we feel there is substantial benefit to swift consumers of the API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya this should be fine for our existing clients since they can still use the old method with fewer params since objC will require all parameters to be filled

/// Can be used to call `hide` with a delay.
@objc public func show(in view: UIView,
from anchorView: UIView? = nil,
with layoutGuide: UILayoutGuide? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: preference - I've tended away from using argument labels (i.e. with). For some small cases it helps make things more natural, but especially in functions like this with a lot of parameters, it tends to remove some clarity in the caller in how the parameter is being used

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed; I'd like to redo the MSFNotification API entirely one of these days (for lots of reasons, but this is one of them).

/// - anchorView: The view used as the bottom anchor for presentation
/// (notification view is always presented up from the anchor). When no anchor view is provided the
/// bottom anchor of the container's safe area is used.
/// - layoutGuide: The layout guide used to present the toast inside of when no `anchorView` is provided
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we describe "how" the layout guide is used? Which part of the notification is aligned with the layout guide? And probably worth explaining what happens if both an anchorView and a layoutGuide are provided

/// - anchorView: The view used as the bottom anchor for presentation
/// (notification view is always presented up from the anchor). When no anchor view is provided the
/// bottom anchor of the container's safe area is used.
/// - layoutGuide: The layout guide used to present the toast inside of when no `anchorView` is provided
Copy link
Contributor

Choose a reason for hiding this comment

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

I think objC just ignores default parameters and forces us to add a value. I'm personally mixed as to whether that mismatch has enough practical badness to cause us to avoid it iff we feel there is substantial benefit to swift consumers of the API

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.

4 participants