summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift
blob: 4b4b21b4afc88f3c64736cfc1c2377d8dc0a8fef (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
//
//  InAppNotificationDescriptor.swift
//  MullvadVPN
//
//  Created by pronebird on 09/12/2022.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import UIKit.UIImage

/// Struct describing in-app notification.
struct InAppNotificationDescriptor: Equatable {
    /// Notification identifier.
    var identifier: NotificationProviderIdentifier

    /// Notification banner style.
    var style: NotificationBannerStyle

    /// Notification title.
    var title: String

    /// Notification body.
    var body: NSAttributedString

    /// Notification action.
    var button: InAppNotificationAction?

    /// Notification tap action (optional).
    var tapAction: InAppNotificationAction?
}

/// Type describing a specific in-app notification action.
struct InAppNotificationAction: Equatable {
    /// Image assigned to action button.
    var image: UIImage?

    /// Action handler for button.
    var handler: (() -> Void)?

    static func == (lhs: InAppNotificationAction, rhs: InAppNotificationAction) -> Bool {
        lhs.image == rhs.image
    }
}

enum NotificationBannerStyle {
    case success, warning, error
}