Writing a Custom Scroll View with SwiftUI in a chat application

General News

Summary

The chat view typically starts aligned at the end of the conversation, which is the bottom of the screen. It means that you would be stuck to displaying your chat window and the top and scroll down to see the new messages, which is not acceptable. Note that you also need to edit your SceneDelegate to pass the demoConversation as a parameter when setting up your ConversationView: We now render all the message in our demo Conversation, but we see that the conversation is top aligned and there is no API at the moment to control the content offset to render the display from the bottom of the scroll view on init. By wrapping the content of the ReverseScrollView inside a GeometryReader wrapper, you can access info about the “outer” geometry (like the height). Here is an initial version of the ReverseScrollView: You can also replace the ScrollView in ConversationView to use our ReverseScrollView: In the Canvas, you can see the view is not scrolling or displayed properly with the last message at the bottom, but it is now properly fitting inside its parent view.

Classifications

industries
No industries detected
applications
Collaboration & Communication

AskAI Classifications

Labels
Software Messaging Software SaaS

Linked Companies

ProcessOne
$1M to $5M
GitHub, Inc.
$1M to $5M