Comments (5)
Hi @srgray,
Yes, that is normal, unfortunately. Since our Message List is an inverted UITableView and not a UICollectionView, embedding self-resizing collection views won't work very well. Although it might be possible to build that UI with some workarounds. You can try the following:
- If possible, use a UIStackView. If you are not expecting many tags per message, this could be enough, and the performance penalty of using a stack view won't be noticeable.
- The other option is to find a way to explicitly reload the cell whenever the tags grow to a specific size. One idea is to override the
ChatMessageListView.reuseIdentifier()
function which is the one responsible for calculating the cell identifier based on theChatMessageLayoutOption
and the message content. You could use thetags.count
and post-fix the cell identifier to make sure that whenever the tags change, it reloads the cell 🤔
The pseudo code for 2:
class CustomMessageListView: ChatMessageListView {
override func reuseIdentifier(
contentViewClass: ChatMessageContentView.Type,
attachmentViewInjectorType: AttachmentViewInjector.Type?,
layoutOptions: ChatMessageLayoutOptions,
message: ChatMessage?
) -> String {
var identifier = super.reuseIdentifier(
contentViewClass: contentViewClass,
attachmentViewInjectorType: attachmentViewInjectorType,
layoutOptions: layoutOptions,
message: message
)
if message.tags.count > 0 {
identifier += "_\(message.tags.count)"
}
return identifier
}
}
Let us know if you were able to find a workaround for this.
Best,
Nuno
from stream-chat-swift.
@srgray We have a similar UI in our Slack Example App. We use a collection view there, but we have a height constraint that we change depending on the number of reactions.
The code:
- https://github.com/GetStream/stream-chat-swift/blob/develop/Examples/SlackClone/SlackChatMessageContentView.swift
- https://github.com/GetStream/stream-chat-swift/blob/develop/Examples/SlackClone/SlackReactionsView.swift
This works best whenever the collection view has a predictable number of items per row since we can do this to calculate the height constraint:
let numberOfItemsPerRow = 3
let numberOfRows = Double(reactions.count).truncatingRemainder(dividingBy: numberOfItemsPerRow)
heightConstraint?.constant = ceil(numberOfRows) * reactionRowHeight
But yeah, these use cases are a bit tricky when working with a UITableView, unfortunatly it is a short-coming of our Message List at the moment, and solving it completely would require refactoring it to a UICollectionView, which we are not planning to do at the moment.
Best,
Nuno
from stream-chat-swift.
Hi @srgray,
Did one of the solutions provided work for you? If yes, which option did you choose?
Best,
Nuno
from stream-chat-swift.
Hey @srgray,
I'm closing this for now. Feel free to reply and re open it in case you are still having problems or want to share your solution.
Best,
Nuno
from stream-chat-swift.
Related Issues (20)
- Still seeing #2840 HOT 5
- Whole interface blocked when swipe photo in fullscreen mode HOT 3
- Showing Translated Message After Delete The Message HOT 1
- Does ChatChannelController.loadPreviousMessages has a maximum pageSize? HOT 4
- Slack-style reactions HOT 8
- For iOS is not a valid binary HOT 2
- Not able to connect user to the Chat HOT 2
- Token provider keeps retrying after calling disconnect HOT 5
- Passing an Invalid Token during connection triggers an infinity loop. HOT 3
- Unable to receive push Notifications: error "DeviceTokenNotForTopic" HOT 2
- Missing super.init in AsyncOperation HOT 2
- Error "'shared' is unavailable in application extensions for iOS..." when using UNNotificationServiceExtension HOT 1
- App crash on creating a new 1:1 chat, found nil when unwrapping optional in ListDataBaseObserver HOT 26
- Composer text input not resizing correctly HOT 6
- Message author miscomputed after user id change during the same session HOT 3
- Multiple didUpdateChannel with unreadCount 0 HOT 23
- Upload Image to GetStream CDN HOT 1
- See Original and Translated Message HOT 6
- Message Search Not Working HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stream-chat-swift.