Skip to content

question: how to make Views concrete? (i.e not use Any View) #1249

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

russellwheatley
Copy link
Member

I cannot find a way to make it work where the Buttons are not type erased.

We have types unknown to core auth package and we're trying to render unknown button types in core auth package. How can we render without using type erasure?

If there is a clever way of doing this, I would love to know.

@morganchen12
Copy link
Contributor

I think we should just make the button views any View since they're small views that aren't nested and we can't pass type data for these particular views up from subdependencies to the root Auth module.

associatedtype ButtonType: View
@MainActor var authButton: ButtonType { get }
var id: String { get }
@MainActor func authButton() -> AnyView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try returning some View? You might need to annotate the function with @ViewBuilder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot have some View as return type on protocol apparently. Get Xcode compiler error: 'some' type cannot be the return type of a protocol requirement; did you mean to add an associated type?

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.

3 participants