Created
October 4, 2020 14:56
-
-
Save prafullakumar/6223a24769ef24b9fe00bff5655396cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct KeyboardView<Content, ToolBar> : View where Content : View, ToolBar: View { | |
@StateObject private var keyboard: KeyboardResponder = KeyboardResponder() | |
let toolbarFrame: CGSize = CGSize(width: UIScreen.main.bounds.width, height: 40.0) | |
var content: () -> Content | |
var toolBar: () -> ToolBar | |
var body: some View { | |
ZStack { | |
content() | |
.padding(.bottom, (keyboard.currentHeight == 0) ? 0 : toolbarFrame.height) | |
VStack { | |
Spacer() | |
toolBar() | |
.frame(width: toolbarFrame.width, height: toolbarFrame.height) | |
.background(Color.secondary) | |
}.opacity((keyboard.currentHeight == 0) ? 0 : 1) | |
.animation(.easeOut) | |
} | |
.padding(.bottom, keyboard.currentHeight) | |
.edgesIgnoringSafeArea(.bottom) | |
.animation(.easeOut) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment