Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get selected value from SwiftUI.Picker component #242

Merged
merged 1 commit into from
May 2, 2023

Conversation

tobywoollaston
Copy link
Contributor

With TextField ViewType I am able to get the current input value with .input()

I wanted to be able get the currently selected value from a Picker ViewType without the need to inject the binding attribute or have public getters on the view.

This commit allows the selectedValue() method of InpsectableView<ViewType.Picker> to get the current value that is a binding.

let binding = Binding<String>(wrappedValue: "First Option")
let view = Picker(selection: binding, label: Text("Title")) {
        Text("First Option").tag(0)
        Text("Second Option").tag(1)
}
try view.inspect().picker().select(value: "Second Option")
        
XCTAssertEqual("Second Option", try view.inspect().picker().selectedValue())

nalexn added a commit that referenced this pull request May 2, 2023
@nalexn nalexn merged commit c58271d into nalexn:0.9.6 May 2, 2023
@nalexn
Copy link
Owner

nalexn commented May 2, 2023

Thanks for the PR @tobywoollaston ! I tweaked the API a bit to align better with the other functions

@nalexn nalexn added pending release A fixed issue that'll be released in an upcoming update and removed pending release A fixed issue that'll be released in an upcoming update labels May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants