From 2ed8265e61c0d3db68847dc204a059e4eb53ec2f Mon Sep 17 00:00:00 2001 From: Carter Date: Wed, 1 Oct 2025 13:17:03 -0700 Subject: [PATCH 1/2] Added layout guide option to notification presentation --- .../Components/Notification/MSFNotification.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift b/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift index a86d696c25..a35b67947f 100644 --- a/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift +++ b/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift @@ -53,6 +53,13 @@ import UIKit return notification.tokenSet } + @objc public func show(in view: UIView, + from anchorView: UIView? = nil, + animated: Bool = true, + completion: ((MSFNotification) -> Void)? = nil) { + show(in: view, from: anchorView, with:nil, animated: animated, completion: completion); + } + // MARK: - Show/Hide Methods /// `show` is used to present the view inside a container view: /// insert into layout and show with optional animation. Constraints are used for the view positioning. @@ -66,6 +73,7 @@ import UIKit /// Can be used to call `hide` with a delay. @objc public func show(in view: UIView, from anchorView: UIView? = nil, + with layoutGuide: UILayoutGuide? = nil, animated: Bool = true, completion: ((MSFNotification) -> Void)? = nil) { guard self.window == nil else { @@ -78,6 +86,7 @@ import UIKit currentToast.hide { self.show(in: view, from: anchorView, + with: layoutGuide, animated: animated, completion: completion) } @@ -93,11 +102,11 @@ import UIKit let anchor: NSLayoutYAxisAnchor if state.showFromBottom { - anchor = anchorView?.topAnchor ?? view.safeAreaLayoutGuide.bottomAnchor + anchor = anchorView?.topAnchor ?? layoutGuide?.bottomAnchor ?? view.safeAreaLayoutGuide.bottomAnchor constraintWhenHidden = self.topAnchor.constraint(equalTo: anchor) constraintWhenShown = self.bottomAnchor.constraint(equalTo: anchor, constant: -presentationOffset) } else { - anchor = anchorView?.bottomAnchor ?? view.safeAreaLayoutGuide.topAnchor + anchor = anchorView?.bottomAnchor ?? layoutGuide?.topAnchor ?? view.safeAreaLayoutGuide.topAnchor constraintWhenHidden = self.bottomAnchor.constraint(equalTo: anchor) constraintWhenShown = self.topAnchor.constraint(equalTo: anchor, constant: presentationOffset) } From 71e88384052ecb7e782240216631e229753435d1 Mon Sep 17 00:00:00 2001 From: Carter Date: Thu, 2 Oct 2025 10:54:44 -0700 Subject: [PATCH 2/2] Cleaned up comments --- .../Components/Notification/MSFNotification.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift b/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift index a35b67947f..25f0dc2712 100644 --- a/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift +++ b/Sources/FluentUI_iOS/Components/Notification/MSFNotification.swift @@ -53,6 +53,17 @@ import UIKit return notification.tokenSet } + // MARK: - Show/Hide Methods + /// `show` is used to present the view inside a container view: + /// insert into layout and show with optional animation. Constraints are used for the view positioning. + /// - Parameters: + /// - view: The container view where this view will be presented. + /// - 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. + /// - animated: Indicates whether to use animation during presentation or not. + /// - completion: The closure to be called after presentation is completed. + /// Can be used to call `hide` with a delay. @objc public func show(in view: UIView, from anchorView: UIView? = nil, animated: Bool = true, @@ -68,6 +79,7 @@ import UIKit /// - 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 /// - animated: Indicates whether to use animation during presentation or not. /// - completion: The closure to be called after presentation is completed. /// Can be used to call `hide` with a delay.