Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/atlou/keyboardaccessory
- Owner: atlou
- License: mit
- Created: 2024-10-31T13:43:26.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2024-10-31T15:47:47.000Z (13 days ago)
- Last Synced: 2024-10-31T16:29:11.521Z (12 days ago)
- Topics: keyboard-accessory, swiftui
- Language: Swift
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.
## Solution
Using this package, we can solve this problem and achieve the expected behavior.
## 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 packagestruct 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).