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 support for View optionals, fixing @ViewBuilder conditionals. #58

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Samuel-IH
Copy link

Previously conditionals had to have a trailing "else {...}" at the end because of lack of optional support from the View protocol.
This fix will introduce View optionals and make the behavior more like SwiftUI's View.

Note:
I had to add an optional check inside ComponentReflection.swift, I'm not 100% sure of the inner workings of this file but this doesn't seem to be causing any conflicts.

Previously conditionals had to have a trailing "else {...}" at the end because of lack of optional support from the View protocol.
This fix will introduce View optionals and make the behavior more like SwiftUI's View.

(cherry picked from commit 223bc36)
@helje5
Copy link
Member

helje5 commented Sep 18, 2020

Thanks for your PRs! It'll take me a while to find the time to review the things.

//support for optional Views, mainly for @ViewBuilder convenience
extension Optional : View where Wrapped : View {
public var body: EmptyView {
EmptyView()
Copy link
Member

Choose a reason for hiding this comment

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

Better late than never, but that seems wrong. The Optional View should be the wrapped if set, and EmptyView only in the .none case.

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