summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/View controllers/Alert/AlertPresenter.swift
blob: db2c0ff97135f70583d889e13afe1e37eb92d0f5 (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
//
//  AlertPresenter.swift
//  MullvadVPN
//
//  Created by pronebird on 04/06/2020.
//  Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Routing

struct AlertPresenter {
    let context: any Presenting

    func showAlert(presentation: AlertPresentation, animated: Bool) {
        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)
    }
}