diff --git a/Sources/Defaults/SwiftUI.swift b/Sources/Defaults/SwiftUI.swift index cf3e76c..d1d8488 100644 --- a/Sources/Defaults/SwiftUI.swift +++ b/Sources/Defaults/SwiftUI.swift @@ -32,7 +32,7 @@ extension Defaults { task?.cancel() } - func observe() { + private func observe() { // We only use this on the latest OSes (as of adding this) since the backdeploy library has a lot of bugs. if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, visionOS 1.0, *) { task?.cancel() @@ -44,7 +44,7 @@ extension Defaults { return } - self.objectWillChange.send() + objectWillChange.send() } } } else { @@ -221,12 +221,26 @@ extension Defaults { } extension Defaults.Toggle { - public init(_ title: some StringProtocol, key: Defaults.Key) { + public init( + _ title: some StringProtocol, + key: Defaults.Key + ) { self.label = { Text(title) } self.observable = .init(key) } } +extension Defaults.Toggle> { + public init( + _ title: some StringProtocol, + systemImage: String, + key: Defaults.Key + ) { + self.label = { Label(title, systemImage: systemImage) } + self.observable = .init(key) + } +} + extension Defaults.Toggle { /** Do something when the value changes to a different value.