paescebu / CustomKeyboardKit

Creating custom In App Keyboards with SwiftUI has never been easier!
GNU General Public License v3.0
203 stars 20 forks source link

SwiftUI: Conditionally switch between custom / system keyboard #11

Closed laosb closed 1 year ago

laosb commented 1 year ago

In our case the design calls for a text field with optional custom options (in custom keyboard), with a switch keyboard button in accessory view.

paescebu commented 1 year ago

@laosb Thanks for trying out my swift package! Do you have some example code that I could take a look at to try to find a solution for?

paescebu commented 1 year ago

Hey @laosb,

I have here two examples that might help you. I hope I understood your request correctly.

I might search for something that allows a simpler approach out of the box from CustomKeyboardKit. Let me know if for now this helped at least! :-)

Approaches.zip

laosb commented 1 year ago

Hi, sorry for the delay, but we ended up manually introspecting our way to attach a custom keyboard, and when switching just change the inputView property and reload input views.

That works well, so this approach may work in this package. It should be easy to accept a Binding<Bool> in the modifier, and/or more flexible Binding<some Hashable?> for switching between multiple custom keyboards & system.

paescebu commented 1 year ago

Hi @laosb Thank you so much for your reply and suggestion. If you feel that approach could benefit others, feel free to issue a PR that I can dice into.

It definitely sounds interesting. I will observe if that request to dynamically switch between Keyboards is something the Community would need.

Kind regards and all the best! Pascal