diff --git a/Examples/Sources/ControlsExample/ControlsApp.swift b/Examples/Sources/ControlsExample/ControlsApp.swift index fe94e13ee87..8fd685df3f5 100644 --- a/Examples/Sources/ControlsExample/ControlsApp.swift +++ b/Examples/Sources/ControlsExample/ControlsApp.swift @@ -33,7 +33,7 @@ struct ControlsApp: App { #if !canImport(UIKitBackend) VStack { Text("Toggle button") - Toggle("Toggle me!", active: $exampleButtonState) + Toggle("Toggle me!", isOn: $exampleButtonState) .toggleStyle(.button) Text("Currently enabled: \(exampleButtonState)") } @@ -42,7 +42,7 @@ struct ControlsApp: App { VStack { Text("Toggle switch") - Toggle("Toggle me:", active: $exampleSwitchState) + Toggle("Toggle me:", isOn: $exampleSwitchState) .toggleStyle(.switch) Text("Currently enabled: \(exampleSwitchState)") } @@ -50,7 +50,7 @@ struct ControlsApp: App { #if !canImport(UIKitBackend) VStack { Text("Checkbox") - Toggle("Toggle me:", active: $exampleCheckboxState) + Toggle("Toggle me:", isOn: $exampleCheckboxState) .toggleStyle(.checkbox) Text("Currently enabled: \(exampleCheckboxState)") } @@ -79,7 +79,7 @@ struct ControlsApp: App { } }.padding().disabled(!enabled) - Toggle(enabled ? "Disable all" : "Enable all", active: $enabled) + Toggle(enabled ? "Disable all" : "Enable all", isOn: $enabled) .padding() } }.defaultSize(width: 400, height: 600) diff --git a/Examples/Sources/GreetingGeneratorExample/GreetingGeneratorApp.swift b/Examples/Sources/GreetingGeneratorExample/GreetingGeneratorApp.swift index 4434769400a..c6cc9e2ab58 100644 --- a/Examples/Sources/GreetingGeneratorExample/GreetingGeneratorApp.swift +++ b/Examples/Sources/GreetingGeneratorExample/GreetingGeneratorApp.swift @@ -27,7 +27,7 @@ struct GreetingGeneratorApp: App { } } - Toggle("Selectable Greeting", active: $isGreetingSelectable) + Toggle("Selectable Greeting", isOn: $isGreetingSelectable) if let latest = greetings.last { LatestGreetingDisplay() .environment(\.latestGreeting, latest) diff --git a/Sources/SwiftCrossUI/Views/Checkbox.swift b/Sources/SwiftCrossUI/Views/Checkbox.swift index 1d9d810f9b2..a7156a6e0af 100644 --- a/Sources/SwiftCrossUI/Views/Checkbox.swift +++ b/Sources/SwiftCrossUI/Views/Checkbox.swift @@ -4,7 +4,7 @@ struct Checkbox: ElementaryView, View { private var active: Binding /// Creates a checkbox. - public init(active: Binding) { + public init(isOn active: Binding) { self.active = active } diff --git a/Sources/SwiftCrossUI/Views/Toggle.swift b/Sources/SwiftCrossUI/Views/Toggle.swift index dc787811ea4..47698b94922 100644 --- a/Sources/SwiftCrossUI/Views/Toggle.swift +++ b/Sources/SwiftCrossUI/Views/Toggle.swift @@ -8,8 +8,13 @@ public struct Toggle: View { /// Whether the toggle is active or not. var active: Binding - /// Creates a toggle that displays a custom label. + @available(*, deprecated, renamed: "init(_:isOn:)") public init(_ label: String, active: Binding) { + self.init(label, isOn: active) + } + + /// Creates a toggle that displays a custom label. + public init(_ label: String, isOn active: Binding) { self.label = label self.active = active } @@ -24,15 +29,15 @@ public struct Toggle: View { Spacer() } - ToggleSwitch(active: active) + ToggleSwitch(isOn: active) } case .button: - ToggleButton(label, active: active) + ToggleButton(label, isOn: active) case .checkbox: HStack { Text(label) - Checkbox(active: active) + Checkbox(isOn: active) } } } diff --git a/Sources/SwiftCrossUI/Views/ToggleButton.swift b/Sources/SwiftCrossUI/Views/ToggleButton.swift index c6a1e129591..b39adbb305b 100644 --- a/Sources/SwiftCrossUI/Views/ToggleButton.swift +++ b/Sources/SwiftCrossUI/Views/ToggleButton.swift @@ -6,7 +6,7 @@ struct ToggleButton: ElementaryView, View { private var active: Binding /// Creates a toggle button that displays a custom label. - public init(_ label: String, active: Binding) { + public init(_ label: String, isOn active: Binding) { self.label = label self.active = active } diff --git a/Sources/SwiftCrossUI/Views/ToggleSwitch.swift b/Sources/SwiftCrossUI/Views/ToggleSwitch.swift index ccee23d89b9..41c9b3e7d80 100644 --- a/Sources/SwiftCrossUI/Views/ToggleSwitch.swift +++ b/Sources/SwiftCrossUI/Views/ToggleSwitch.swift @@ -4,7 +4,7 @@ struct ToggleSwitch: ElementaryView, View { private var active: Binding /// Creates a switch. - public init(active: Binding) { + public init(isOn active: Binding) { self.active = active }