summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift
blob: 7ed81c1e772aa8742059ea6b63b4ddeaaddfaeb0 (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
//
//  InAppNotificationDescriptor.swift
//  MullvadVPN
//
//  Created by pronebird on 09/12/2022.
//  Copyright © 2022 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 action: 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
}