Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atlou/keyboardaccessory

SwiftUI implementation of KeyboardAccessory. This resolves the keyboard interactive dismissal animation issue.
https://github.com/atlou/keyboardaccessory

keyboard-accessory swiftui

Last synced: 12 days ago
JSON representation

SwiftUI implementation of KeyboardAccessory. This resolves the keyboard interactive dismissal animation issue.

Awesome Lists containing this project

README

        

# KeyboardAccessory

## Problem

In SwiftUI, there is this bug where a bottom view will not follow the interactive dismissal of the keyboard.

Screenshot of the problem

## Solution

Using this package, we can solve this problem and achieve the expected behavior.

Screenshot of the problem

## Using the package

First, you need to add this package to your project dependencies. Then, you can import the package and use the `.keyboardAccessory` modifier on any type of scrolling view.

```swift
import SwiftUI
import KeyboardAccessory // Import the package

struct ContentView: View {
var body: some View {
VStack {
ChatView()
.keyboardAccessory {
InputView() // The view you want to use as an accessory
}
.scrollDismissesKeyboard(.interactively) // Dismiss the keyboard interactively
}
}
}
```

There is also a `background` closure that lets you add a background view.

```swift
ScrollView {}
.keyboardAccessory {
// Accessory
} background {
Rectangle()
.fill(.regularMaterial)
}
```

## Credits

This package was built using [BottomInputBarSwiftUI](https://github.com/frogcjn/BottomInputBarSwiftUI), which is used under the MIT license as per the user's permission. I only made some changes to the modifier and created a package. All credit for the actual implementation goes to [frogcjn](https://github.com/frogcjn).