mirror of https://github.com/xaoxuu/ProHUD
修复可能拿不到windowScene的情况
This commit is contained in:
parent
f68b0c3a9b
commit
69afc5dd6a
|
@ -52,9 +52,8 @@ extension AlertTarget {
|
|||
self.navEvents[.onViewDidDisappear]?(self)
|
||||
}
|
||||
// hide window
|
||||
guard let window = view.window as? AlertWindow, let windowScene = windowScene else { return }
|
||||
let count = window.alerts.count
|
||||
if count == 0 {
|
||||
guard let window = attachedWindow, let windowScene = windowScene ?? AppContext.windowScene else { return }
|
||||
if window.alerts.count == 0 {
|
||||
AppContext.alertWindow[windowScene] = nil
|
||||
UIView.animateLinear(duration: duration) {
|
||||
window.backgroundView.alpha = 0
|
||||
|
|
|
@ -136,7 +136,7 @@ extension CapsuleTarget {
|
|||
}
|
||||
|
||||
@objc open func pop() {
|
||||
guard let window = attachedWindow, let windowScene = windowScene else { return }
|
||||
guard let window = attachedWindow, let windowScene = windowScene ?? AppContext.windowScene else { return }
|
||||
let position = vm?.position ?? .top
|
||||
AppContext.capsuleWindows[windowScene]?[position] = nil
|
||||
navEvents[.onViewWillDisappear]?(self)
|
||||
|
|
|
@ -31,13 +31,13 @@ class SheetWindow: Window {
|
|||
|
||||
extension SheetTarget {
|
||||
func getContextWindows() -> [SheetWindow] {
|
||||
guard let windowScene = windowScene else {
|
||||
guard let windowScene = windowScene ?? AppContext.windowScene else {
|
||||
return []
|
||||
}
|
||||
return AppContext.sheetWindows[windowScene] ?? []
|
||||
}
|
||||
func setContextWindows(_ windows: [SheetWindow]) {
|
||||
guard let windowScene = windowScene else {
|
||||
guard let windowScene = windowScene ?? AppContext.windowScene else {
|
||||
return
|
||||
}
|
||||
AppContext.sheetWindows[windowScene] = windows
|
||||
|
|
|
@ -38,13 +38,13 @@ class ToastWindow: Window {
|
|||
|
||||
extension ToastTarget {
|
||||
func getContextWindows() -> [ToastWindow] {
|
||||
guard let windowScene = windowScene else {
|
||||
guard let windowScene = windowScene ?? AppContext.windowScene else {
|
||||
return []
|
||||
}
|
||||
return AppContext.toastWindows[windowScene] ?? []
|
||||
}
|
||||
func setContextWindows(_ windows: [ToastWindow]) {
|
||||
guard let windowScene = windowScene else {
|
||||
guard let windowScene = windowScene ?? AppContext.windowScene else {
|
||||
return
|
||||
}
|
||||
AppContext.toastWindows[windowScene] = windows
|
||||
|
|
Loading…
Reference in New Issue