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

Move ParameterView integration into context.parameter functions #72

Open
mjarvis opened this issue Mar 22, 2023 · 0 comments
Open

Move ParameterView integration into context.parameter functions #72

mjarvis opened this issue Mar 22, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@mjarvis
Copy link
Owner

mjarvis commented Mar 22, 2023

Rather than providing parameter views in the environment:

  • Allow passing a view: parameter to override default parameter views.
  • Allow adding an extension to Context in order to add more default parameter views.
let foo: String = context.parameter(name: "Foo", defaultValue: "Bar") { name, value in
    Text("\(name): \(value)")
}
extension Context {
    func parameter(name: String, defaultValue: MyCustomType) -> MyCustomType {
        parameter(name: name, defaultValue: defaultValue) { name, value in
              // Default debug view for MyCustomType
        }
    }
}

Upsides:

  • Easier attachment of custom parameter views
  • Easier addition of custom types

Downsides:

  • Cannot set new defaults over existing defaults.
@mjarvis mjarvis added the enhancement New feature or request label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant