aboutsummaryrefslogtreecommitdiff
path: root/Sources/NorgEditor/EnvironmentValues+EditorTheme.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2026-06-19 19:16:25 +0200
committerRuben Beltran del Rio <jj@r.bdr.sh>2026-06-19 22:32:15 +0200
commit25fc48fb17b53fe1c155c4f53f673ed91fdd8f74 (patch)
treede96add2a7ae8c5cc79a354fbffa26e80349cc15 /Sources/NorgEditor/EnvironmentValues+EditorTheme.swift
Initial extraction from Norganize
Diffstat (limited to 'Sources/NorgEditor/EnvironmentValues+EditorTheme.swift')
-rw-r--r--Sources/NorgEditor/EnvironmentValues+EditorTheme.swift21
1 files changed, 21 insertions, 0 deletions
diff --git a/Sources/NorgEditor/EnvironmentValues+EditorTheme.swift b/Sources/NorgEditor/EnvironmentValues+EditorTheme.swift
new file mode 100644
index 0000000..f0bc3c5
--- /dev/null
+++ b/Sources/NorgEditor/EnvironmentValues+EditorTheme.swift
@@ -0,0 +1,21 @@
+#if canImport(UIKit) || canImport(AppKit)
+ import SwiftUI
+
+ private struct NorgEditorThemeKey: EnvironmentKey {
+ static let defaultValue = EditorTheme.default
+ }
+
+ /// Makes NorgTheme values accessible via the environment.
+ extension EnvironmentValues {
+ public var norgEditorTheme: EditorTheme {
+ get { self[NorgEditorThemeKey.self] }
+ set { self[NorgEditorThemeKey.self] = newValue }
+ }
+ }
+
+ extension View {
+ public func norgEditorTheme(_ theme: EditorTheme) -> some View {
+ environment(\.norgEditorTheme, theme)
+ }
+ }
+#endif