Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simpler way to customize header and footer views in the Message List #3567

Merged

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Jan 20, 2025

🔗 Issue Links

Resolves https://linear.app/stream/issue/IOS-450/
Resolves https://linear.app/stream/issue/IOS-560/

🎯 Goal

  • Add a simpler way to customize the header and footer views of the Message List
  • Make it easier to provide loading / error views when loading more messages in the Message List

📝 Summary

  • Adds ChatMessageListVC.headerView + ChatMessageListVC.footerView
  • Adds ChatChannelVC.loadPreviousMessages() + ChatChannelVC.didFinishLoadingPreviousMessages(error:)
  • Adds ChatChannelVC.loadNextMessages() + ChatChannelVC.didFinishLoadingNextMessages(error:)
  • Adds ChatThreadVC.loadPreviousReplies() + ChatThreadVC.didFinishLoadingPreviousReplies(error:)
  • Adds ChatThreadVC.loadNextReplies() + ChatThreadVC.didFinishLoadingNextReplies(error:)

🛠 Implementation

Header + Footer

The ChatMessageListVC.headerView and ChatMessageListVC.footerView internally account for the fact that the table view is inverted, so the views are automatically mirrored and set the header as footer and vice-versa.

Customizing loading views

Since the header and footer views are commonly used to render loading views, it made sense to merge 2 tickets into this PR.

This PR makes it easier to handle state management when loading more messages/replies in either the Channel or the Thread.

🧪 Manual Testing Notes

A simple loading view indicator was added when loading more messages in the Demo App:

  1. Open a Channel and Thread
  2. Load older pages
  3. A loading indicator should appear at the top
  4. Jump to a mid-page
  5. Load more messages
  6. A loading indicator should appear at the bottom

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@nuno-vieira nuno-vieira requested a review from a team as a code owner January 20, 2025 14:33
@nuno-vieira nuno-vieira removed the request for review from a team January 20, 2025 14:33
@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 7.0 MB 7.0 MB 0 KB 🟢
StreamChatUI 4.77 MB 4.77 MB +1 KB 🟢

@Stream-SDK-Bot
Copy link
Collaborator

SDK Performance

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 6.68 ms 33.2% 🔼 🟢
Duration 2.6 s 2.55 s 1.92% 🔼 🟢
Hitch time ratio 4 ms per s 2.63 ms per s 34.25% 🔼 🟢
Frame rate 75 fps 78.49 fps 4.65% 🔼 🟢
Number of hitches 1 0.8 20.0% 🔼 🟢

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Jan 20, 2025

SDK Size

title develop branch diff status
StreamChat 7.0 MB 7.0 MB 0 KB 🟢
StreamChatUI 4.77 MB 4.77 MB 0 KB 🟢

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think we should just keep the loading indicator in the sample app. Also, we need to add docs in the other repo.

// Example of custom header views.
// The same code should be provided to `ChatThreadVC` if you want the same behaviour in threads.

lazy var messageListHeaderView: UIView? = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the loading indicator is enough for the showcase? I think we should keep the sample app as clean as possible, and this label is not very common for messaging apps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can explain in the docs the channelController.hasLoadedAllPreviousMessages, customers here would usually show some custom UI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was planning on adding docs. So yeah maybe the "Loaded all messages" we can do it only for the docs 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ✅

Copy link
Contributor

@laevandus laevandus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see the spinner while loading more messages. ✅

@nuno-vieira nuno-vieira merged commit 02e8ba2 into develop Jan 21, 2025
4 checks passed
@nuno-vieira nuno-vieira deleted the add/simpler-way-to-add-headers-and-footers-to-message-list branch January 21, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants