1
0
mirror of https://git.zx2c4.com/wireguard-apple synced 2025-08-12 17:52:53 +00:00
Files
wireguard-apple/Sources/WireGuardApp/UI/macOS/ErrorPresenter.swift
Jason A. Donenfeld 7b279383d1 App: bump copyright
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-15 14:20:35 +01:00

24 lines
806 B
Swift

// SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
class ErrorPresenter: ErrorPresenterProtocol {
static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?, onDismissal: (() -> Void)?) {
let alert = NSAlert()
alert.messageText = title
alert.informativeText = message
onPresented?()
if let sourceVC = sourceVC as? NSViewController {
NSApp.activate(ignoringOtherApps: true)
sourceVC.view.window!.makeKeyAndOrderFront(nil)
alert.beginSheetModal(for: sourceVC.view.window!) { _ in
onDismissal?()
}
} else {
alert.runModal()
onDismissal?()
}
}
}