Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created August 3, 2020 07:38
Show Gist options
  • Save prafullakumar/572f1a3d5802e06dd61c603c9c0e55ec to your computer and use it in GitHub Desktop.
Save prafullakumar/572f1a3d5802e06dd61c603c9c0e55ec to your computer and use it in GitHub Desktop.
import SwiftUI
struct ChatUI : View {
@StateObject private var keyboard = KeyboardResponder()
var scrollToid = 99
func Scroll(reader :ScrollViewProxy) -> some View {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
withAnimation {
reader.scrollTo(scrollToid)
}
}
return EmptyView()
}
var body: some View {
ZStack {
ScrollView(.vertical, showsIndicators: false) {
ScrollViewReader { reader in
LazyVStack(spacing: 0.5) {
//Chat Bubbols
Rectangle()
.frame(height: 50, alignment: .center)
.foregroundColor(Color.clear).id(scrollToid)//padding from bottom
Scroll(reader: reader)
}
}
}
}
}
}
}
struct ChatUI_Previews: PreviewProvider {
static var previews: some View {
ChatUI()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment