Skip to content

diegolavalledev/swiftuilib-keyboard-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyboardSupport is set of SwiftUI modifiers to make your views keyboard-aware. Whether to get the software keyboard dimensions via .keyboardFrameProvider(). Or by using .keyboardAware() to automatically pull up a view whenever the keyboard pops in.

Demo

Examples

Automatically adjust to keyboard presence

var body: some View {
  VStack {
    Spacer()
    TextField("Keyboard-Aware Text Field", text: $value)
    .keyboardAware()
  }
  .padding()
}

Obtain keyboard dimensions

struct KeyboardHeightDisplay: View {

  @Environment(\.keyboardFrame) var keyboardFrame

  var body: some View {
    Text("Current keyboard height: \(keyboardFrame.size.height)")
  }
}

struct KeyboardHeightDisplay_Container: View {

  var body: some View {
    KeyboardHeightDisplay().keyboardFrameProvider()
  }
}

More info in the docs.

Installation via SPM

In XCode add the following URL to your project's Swift Package dependencies:

https://github.com/swiftuilib/keyboard-support

Development

To modify the package contents while still being able to see SwiftUI Previews use the provided KeyboardSupportPreview.xcodeproj.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages