-
-
Notifications
You must be signed in to change notification settings - Fork 65
Popup Dismissal
Przez chwilę nic się nie działo. Potem - po jakiejś sekundzie - nadal nic się nie działo.
Dismissing a popup can be done in two ways - If you are working within the context of a View
, simply call one of the functions described below. Otherwise (e.g., if you want to dismiss the popup from a ViewModel
), prefix the method name with the PopupManager
class. For the sake of clarity, we will use both ways in the code examples below.
Important
All the methods below take an optional argument, popupManagerID
, which specifies the ID of the popup stack registered for a specific window (see Setup and Popup Presentation pages for the reference). If more than one popup stack is registered, please ensure that you are dismissing the popup from the correct stack.
-
func dismissLastPopup(popupManagerID: PopupManagerID = .shared)
- Dismisses the currently active popup.
-
func dismissPopup(_ id: String, popupManagerID: PopupManagerID = .shared)
- Dismisses all popups with the specified identifier from the stack.
-
func dismissPopup<P: Popup>(_ type: P.Type, popupManagerID: PopupManagerID = .shared)
- Dismisses all popups of the provided type from the stack.
-
func dismissAllPopups(popupManagerID: PopupManagerID = .shared)
- Dismisses all popups from the stack.
Note
In this section, we are using a popup structure declared here.
// Inside a View
Button(action: { dismissLastPopup() }) {
Text("Dismiss Popup")
}
// Outside a View
PopupManager.dismissLastPopup()
// Inside a View
Button(action: { dismissPopup("customPopupIdentifier") }) {
Text("Dismiss Popup")
}
// Outside a View
PopupManager.dismissPopup("customPopupIdentifier")
// Inside a View
Button(action: { dismissPopup(MyPopup.self) }) {
Text("Dismiss Popup")
}
// Outside a View
PopupManager.dismissPopup(MyPopup.self)