-
Notifications
You must be signed in to change notification settings - Fork 99
Use scroll offset for loading more content in channel and message list #838
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
base: develop
Are you sure you want to change the base?
Conversation
SDK Size
|
ac9bc95
to
cc0353f
Compare
func onScrollPaginationChanged( | ||
in coordinateSpace: CoordinateSpace = .global, | ||
flipped: Bool = false, | ||
threshold: CGFloat = 400, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From UIKit SDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need some fine-tuning
func handleGeometryChanged(_ geometry: GeometryProxy) { | ||
let frame = geometry.frame(in: coordinateSpace) | ||
guard frame.size.height > 0 else { return } | ||
let offset = -frame.minY | ||
if offset + UIScreen.main.bounds.height + threshold > frame.height { | ||
flipped ? onTopThreshold?() : onBottomThreshold() | ||
} else if offset < threshold { | ||
flipped ? onBottomThreshold() : onTopThreshold?() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is way too difficult to get the height of the visible rect for precise calculations. Therefore, using inaccurate screen height here for simplifying it.
Geometry gives the height of the whole content view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might slow things down though, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah overall, it feels like on develop, things load faster and are bit smoother. 🤔
cc0353f
to
a2fc6a8
Compare
# Conflicts: # CHANGELOG.md
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait before merging this one until I'm back - I want to check it in more details and test it.
func handleGeometryChanged(_ geometry: GeometryProxy) { | ||
let frame = geometry.frame(in: coordinateSpace) | ||
guard frame.size.height > 0 else { return } | ||
let offset = -frame.minY | ||
if offset + UIScreen.main.bounds.height + threshold > frame.height { | ||
flipped ? onTopThreshold?() : onBottomThreshold() | ||
} else if offset < threshold { | ||
flipped ? onBottomThreshold() : onTopThreshold?() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might slow things down though, wdyt?
🔗 Issue Links
Resolves: IOS-793
🎯 Goal
If channel list is scrolled very quickly while it is loading a new page it stops loading additional pages
📝 Summary
onScrollPaginationChanged(in:flipped:threshold:onBottomThreshold:onTopThreshold:)
MessageList
andChannelList
usesContentOffsetBasedLoadMore
(since public init methods get additional arguments)🛠 Implementation
The new modifier adds
GeometryReader
to the background of the view which gives us scrolled offset and the content size. Based on the threshold, it calls one of the closures which in turn has to be hooked up the view model for loading new pages.🎨 Showcase
🧪 Manual Testing Notes
Explain how this change can be tested manually, if applicable.
☑️ Contributor Checklist
docs-content
repo