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

Add Toggle implementation #159

Merged
merged 25 commits into from
Jul 20, 2020
Merged

Add Toggle implementation #159

merged 25 commits into from
Jul 20, 2020

Conversation

j-f1
Copy link
Member

@j-f1 j-f1 commented Jul 5, 2020

I think it’s fine to merge this without the toggle style since that’s not super common on the web.

@j-f1 j-f1 requested review from MaxDesiatov and carson-katri July 5, 2020 15:41
@MaxDesiatov MaxDesiatov added the SwiftUI compatibility Tokamak API differences with SwiftUI label Jul 5, 2020
@ie-ahm-robox

This comment has been minimized.

@ie-ahm-robox

This comment has been minimized.

@TokamakUI TokamakUI deleted a comment from ie-ahm-robox Jul 5, 2020
Co-authored-by: Max Desiatov <max@desiatov.com>
@MaxDesiatov MaxDesiatov changed the title Toggle Add Toggle implementation Jul 5, 2020
@j-f1
Copy link
Member Author

j-f1 commented Jul 5, 2020

Weird issue: when clicking the “Check me!” checkbox, I get this error: “Fatal error: ToggleStyleKey must have a renderer-provided default value.” Somehow, the default environment values are not being provided.

}

public enum ToggleStyleKey: EnvironmentKey {
public static var defaultValue: AnyToggleStyle {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the single defaultValue provided for this key. Thus fatalError is what we get, which needs to change for it to work.

Copy link
Member Author

@j-f1 j-f1 Jul 5, 2020

Choose a reason for hiding this comment

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

Yes, but the default environment includes a value for the key:

var environment = EnvironmentValues()
environment[ToggleStyleKey] = AnyToggleStyle(DefaultToggleStyle())

https://github.com/swiftwasm/Tokamak/pull/159/files#diff-6f90e40d15b14ddcb32508552c68db47R71

@MaxDesiatov
Copy link
Collaborator

Ah, this may be related to the bug I've seen where mount functions do inject the environment, but update don't. Having a look now...

@MaxDesiatov
Copy link
Collaborator

Sorry for the delay, I've stumbled upon a different (but kinda related) bug that I'm finding hard to fix without proper stacktraces, so I'm thinking that the entrypoint/polyfills code in carton needs to be updated to support stacktraces, also hoping to fix swiftwasm/carton#25 at the same time with the update. Yet another rabbit hole for me ¯\_(ツ)_/¯

@j-f1
Copy link
Member Author

j-f1 commented Jul 6, 2020

No worries! I’m fine waiting.

@carson-katri
Copy link
Member

This may be unblocked with the changes to environment in #170

@j-f1
Copy link
Member Author

j-f1 commented Jul 17, 2020

Thanks, @carson-katri! The new version seems to be working well, with the caveat that the “I’m always checked!” checkbox can still be unchecked.

@j-f1 j-f1 requested a review from MaxDesiatov July 20, 2020 20:25
Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Would you be able to resolve the conflict please?

@j-f1
Copy link
Member Author

j-f1 commented Jul 20, 2020

Done!

Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

LGTM, thank you 🙌

@j-f1 j-f1 merged commit f0e2b05 into main Jul 20, 2020
@j-f1 j-f1 deleted the toggle branch July 20, 2020 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwiftUI compatibility Tokamak API differences with SwiftUI
Development

Successfully merging this pull request may close these issues.

4 participants