Skip to content

Instantly share code, notes, and snippets.

@apatronl
Last active April 12, 2024 02:40
Show Gist options
  • Save apatronl/3b4872a85cdc46f07cf7bee4b27c0646 to your computer and use it in GitHub Desktop.
Save apatronl/3b4872a85cdc46f07cf7bee4b27c0646 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ChatMessagesList: View {
@Bindable var viewModel: ChatViewModel
var body: some View {
ScrollView {
ForEach(viewModel.messages) { message in
MessageCell(message: message)
.padding(message.role.padding)
.id(message.id)
}
}
.scrollPosition(id: $viewModel.scrollPosition)
.defaultScrollAnchor(.bottom)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment