50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
import Foundation
|
|||
|
|
|
||
|
|
/// An in-app notification reporting an event of a speech model asset download.
|
||
|
|
struct AppNotification: Equatable, Identifiable {
|
||
|
|
|
||
|
|
// MARK: Properties
|
||
|
|
|
||
|
|
/// The unique identifier of the notification.
|
||
|
|
let id: UUID
|
||
|
|
|
||
|
|
/// The download event the notification reports.
|
||
|
|
let event: Event
|
||
|
|
|
||
|
|
/// The localized name of the locale whose speech model the event is about.
|
||
|
|
let localeName: String
|
||
|
|
|
||
|
|
// MARK: Initializers
|
||
|
|
|
||
|
|
/// Creates a notification for a given download event and locale name.
|
||
|
|
///
|
||
|
|
/// - Parameters:
|
||
|
|
/// - id: The unique identifier of the notification. Defaults to a newly generated identifier.
|
||
|
|
/// - event: The download event the notification reports.
|
||
|
|
/// - localeName: The localized name of the locale whose speech model the event is about.
|
||
|
|
init(
|
||
|
|
id: UUID = .init(),
|
||
|
|
event: Event,
|
||
|
|
localeName: String
|
||
|
|
) {
|
||
|
|
self.id = id
|
||
|
|
self.event = event
|
||
|
|
self.localeName = localeName
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// MARK: - Enumerations
|
||
|
|
|
||
|
|
extension AppNotification {
|
||
|
|
/// The download event the notification reports.
|
||
|
|
enum Event: Sendable {
|
||
|
|
/// The download was cancelled before it finished.
|
||
|
|
case cancelled
|
||
|
|
/// The download failed.
|
||
|
|
case failed
|
||
|
|
/// The download started.
|
||
|
|
case started
|
||
|
|
}
|
||
|
|
}
|