blob: 94096d341df08ab09cfcea8b9a52b3d1ca9f443a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//
// AlertPresenter.swift
// MullvadVPN
//
// Created by pronebird on 04/06/2020.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Routing
@MainActor
struct AlertPresenter {
weak var context: (any Presenting)?
func showAlert(presentation: AlertPresentation, animated: Bool) {
guard let context else { return }
context.applicationRouter?.presentAlert(
route: .alert(presentation.id),
animated: animated,
metadata: AlertMetadata(presentation: presentation, context: context)
)
}
func dismissAlert(presentation: AlertPresentation, animated: Bool) {
context?.applicationRouter?.dismiss(.alert(presentation.id), animated: animated)
}
}
extension ApplicationRouter {
func presentAlert(route: RouteType, animated: Bool, metadata: AlertMetadata) {
present(route, animated: animated, metadata: metadata)
}
}
|