Created
August 3, 2020 07:38
-
-
Save prafullakumar/572f1a3d5802e06dd61c603c9c0e55ec 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
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