aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgUI/Theme/EnvironmentValues+NorgTheme.swift
blob: 58c2c00a36da9c741ae34dd3ba9d074838ff8d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import SwiftUI

private struct NorgThemeKey: EnvironmentKey {
  static let defaultValue = NorgTheme.default
}

/// Makes NorgTheme values accessible via the environment.
extension EnvironmentValues {
  public var norgTheme: NorgTheme {
    get { self[NorgThemeKey.self] }
    set { self[NorgThemeKey.self] = newValue }
  }
}

extension View {
  public func norgTheme(_ theme: NorgTheme) -> some View {
    environment(\.norgTheme, theme)
  }
}