TagKit
TagKit copied to clipboard
Why not storing the text of TagTextField locally?
I wonder why it has to be provided from outside and not internally?
@State private var theText: String = ""
If needed, then we can add
private var theTextBinding: Binding<String>{
return Binding<String>(
get: { return self.theText.slugified()},
set: { self.theText = $0.slugified()}
)
}
Woudn't that be easier?
Hi @Vithanco
I'm not sure, I will check :)
Closing this due to inactivity.
nice... I didn't know that one can close issues that were not looked into... :-) Did you want any input from me?
Oh damn, I've been working with most of my open-source projects in parallel for the last few days, to update them for Swift 6, and must have confused two tickets in the many open tabs I had going on.
Sorry about that, and thank you for letting me know!
Which text is it that you have to provide from the outside, that you'd like the library to resolve internally?
it is the just that the TagTextField needs an externally created text instead of using an internal one?
public init(
text: Binding<String>,
placeholder: String = "",
configuration: SlugConfiguration = .standard
) {
self.text = Binding<String>(
get: { text.wrappedValue.slugified() },
set: { text.wrappedValue = $0.slugified() }
)
self.placeholder = placeholder
self.configuration = configuration
}
It is fine to provide the possibility for externally created, but wouldn't it make sense to have it locally initiated if this functionality isn't needed?
sorry, different profiles, same user
Hi @KneupnerTrackunit
I see what you mean. However, the idea with TagTextField is to be a replacement for a regular TextField, where the text you type is automatically slugified. Just like TextField, it takes a binding and leaves the utility of the text up to you.
How would you use the text field if it could also set up an internal binding. How would you then access the slugified text?
Hi Daniel! Thanks for coming back to me. I fear I stole your time. I think when I wrote this, I didn't understand SwiftUI properly. I now went through my code and indeed, it looks completely fine as you designed it. My apologies and thank you for entertaining me. Klaus
No worries, I'm happy to have these discussions! :)
Wishing you all the best in your future SwiftUI endeavors.