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 TextField, SecureField, and a progress document #116
Conversation
Looks like Danger is failing at least because it can’t access the GitHub token since this PR comes from a fork. |
Thanks for the PR, I'll have a look a bit later today! |
progress.md
Outdated
@@ -0,0 +1,137 @@ | |||
)# Progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a file I should've created from the start, thank you for doing this! Could you also create a docs
directory and move it there? Also, seems that )
in the beginning is not needed:
)# Progress | |
# Progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How detailed should this be? I originally had it in a list format which could’ve displayed individual method names but I figured the table would give people a good overview of what is usable and where they can jump in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, what is currently there already looks great. Maybe I'd tweak table headers, they look kind of weird as empty thin rows, but don't sweat it. I think the API comparison should be automated at some point, but for the list of basic fundamental views this should be more than enough from my perspective, unless you think otherwise.
Hey @carson-katri, I'd be happy to hear your opinion on this, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can explore an automated approach. In the meantime, you could do the table with HTML to get rid of the header if you wanted to fix them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think headers are that important, so wouldn't mind if they are kept as is in this PR.
I think the text binding issues may be caused by bugs in the |
Turns out it's not a state/binding issue, but a more prosaic oversight that's fixed in #117. |
Is there a way to hook into the |
Is there a signifcant difference? I've tested your branch locally with #117 applied on top of it and it worked, or am I missing something? |
If you type in both fields they will stop updating. |
huh, good point, on it... |
I updated #117 to update properties, not attributes, so should work now when combined with this PR. |
Is it intentional that |
Updated. |
@j-f1 This is a limitation of the |
OK cool I reviewed native SwiftUI and the text field’s behavior is the same there 🤷 |
I tried to implement the other TextField initializer but it looks like |
I dislike the way the SecureField is largely a copy-paste of TextField but I can’t think of a better way since you can’t extend structs. |
Could you do a protocol that has all the fields and a |
We need to tweak |
I gave that a try and it didn’t cut down on the duplication a ton. |
commitAction = onCommit | ||
} | ||
|
||
// Currently missing feature: use a Formatter to control the value of the TextField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I think it would make sense to highlight this with a FIXME
.
// Currently missing feature: use a Formatter to control the value of the TextField | |
// FIXME: | |
// Currently missing feature: use a Formatter to control the value of the TextField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM other than a missing FIXME
. I agree that SecureField
and TextField
renderer bits generalized with a protocol probably won't save enough lines of code, but I don't have a strong opinion on whether that protocol should exist, I'll defer to @carson-katri as he suggested it 🙂
SwiftUI doesn't use a protocol, and if it's good enough for Apple then it's good enough for me 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! There's also a conflict in Sources/TokamakDemo/main.swift
to be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit 👍
Currently, it seems that changing the
text
binding doesn’t actually affect the rendered input. I’m not sure why this happens, but I’m guessing it’s because thevalue
attribute isn’t being set as<input>.value
.I’ve added two TextFields to the demo, which are supposed to have their values synced. Pressing enter in the second one will increment the commit counter.