summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/View controllers/Alert/AlertPresentation.swift
blob: d7a8fb39b4362407ea4a6d520a5c0850b393931c (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
//  AlertPresentation.swift
//  MullvadVPN
//
//  Created by Jon Petersson on 2023-08-23.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import Routing

struct AlertMetadata {
    let presentation: AlertPresentation
    let context: Presenting
}

struct AlertAction {
    let title: String
    let style: AlertActionStyle
    var accessibilityId: AccessibilityIdentifier?
    var handler: (() -> Void)?
}

struct AlertPresentation: Identifiable, CustomDebugStringConvertible {
    let id: String

    var accessibilityIdentifier: AccessibilityIdentifier?
    var header: String?
    var icon: AlertIcon?
    var title: String?
    var message: String?
    var attributedMessage: NSAttributedString?
    let buttons: [AlertAction]

    var debugDescription: String {
        return id
    }
}

extension AlertPresentation: Equatable, Hashable {
    func hash(into hasher: inout Hasher) {
        hasher.combine(id)
    }

    static func == (lhs: AlertPresentation, rhs: AlertPresentation) -> Bool {
        return lhs.id == rhs.id
    }
}