aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Extensions/TaskStatus+UI.swift
blob: e54e511b5c87debc3387dfa8ca62c6443e91b34b (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
import Foundation
import NorgKit

/// Adds UI rendering labels for TaskStatus.
extension TaskStatus {

  /// A localized, human-readable name for the status.
  public var displayName: LocalizedStringResource {
    switch self {
    case .undone: return Self.label("Undone")
    case .done: return Self.label("Done")
    case .needsInput: return Self.label("Needs input")
    case .urgent: return Self.label("Urgent")
    case .recurring: return Self.label("Recurring")
    case .pending: return Self.label("Pending")
    case .onHold: return Self.label("On hold")
    case .cancelled: return Self.label("Cancelled")
    }
  }

  private static func label(_ value: String.LocalizationValue) -> LocalizedStringResource {
    LocalizedStringResource(value, bundle: .atURL(Bundle.module.bundleURL))
  }
}