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

How to manually show/dismiss the keyboard? #19

Closed
SeRG1k17 opened this issue May 22, 2020 · 2 comments
Closed

How to manually show/dismiss the keyboard? #19

SeRG1k17 opened this issue May 22, 2020 · 2 comments

Comments

@SeRG1k17
Copy link

I found a way to hide the keyboard through the window hierarchy:

extension View {
    func endEditing(_ force: Bool) {
        UIApplication.shared.windows.forEach { $0.endEditing(force)}
    }
}

But this is clearly not the best solution.
I have not looked at all the code, but it will be sufficient to make this initializer public:

//Keyboard.swift
    public init(animationDuration: TimeInterval, height: CGFloat) {
      self.animationDuration = animationDuration
      self.height = height
    }
    var body: some View {
        KeyboardObservingView {
            NavigationView {
            }
            .onTapGesture {
                self.keyboard.state = Keyboard.State(animationDuration: 0,25, height: 0)
            }
       }
   }
@github-actions
Copy link

Thanks for creating an issue!

@nickffox
Copy link
Owner

@SeRG1k17 - this framework doesn’t actually show or hide the keyboard, it adjusts your views so that the keyboard doesn’t cover them.

If I’m understanding your question correctly it’s out of scope for this library.

I think instead of using this library to show/hide the keyboard, you’ll want to do something like what you posted where you call beginEditng/endEditing manually.

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

No branches or pull requests

2 participants