Skip to content

Commit

Permalink
4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Mar 13, 2024
1 parent 7b17395 commit 50c086f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ import PackageDescription
let package = Package(
name: "SomeProject",
dependencies: [
.package(url: "https://github.com/dankinsoid/VDFlow.git", from: "4.4.0")
.package(url: "https://github.com/dankinsoid/VDFlow.git", from: "4.5.0")
],
targets: [
.target(name: "SomeProject", dependencies: ["VDFlow"])
Expand Down
25 changes: 25 additions & 0 deletions Sources/VDFlow/StepBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@ public struct StepBinding<Root: StepsCollection, Value> {
public var isSelected: Binding<Bool> {
$root.isSelected(step)
}

public func isSelected(_ value: Value) -> Binding<Bool> {
Binding {
$root.isSelected(step).wrappedValue
} set: {
if $0 {
$root.wrappedValue[keyPath: keyPath].wrappedValue = value
} else {
$root.wrappedValue.selected = nil
}
}
}

public func callAsFunction(_ value: Value) -> StepBinding {
StepBinding(
root: Binding {
root
} set: {
var new = $0
new[keyPath: keyPath].wrappedValue = value
root = new
},
keyPath: keyPath
)
}
}

extension Binding where Value: StepsCollection {
Expand Down
4 changes: 2 additions & 2 deletions Tests/VDFlowTests/VDFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public struct NavigationSteps {

@Steps
public struct PickerSteps {
public var text1
public var text2
public var text1
public var text2
}

0 comments on commit 50c086f

Please sign in to comment.