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

CONV-1435: Add scroll indicator insets to customScrollViewInsets #500

Merged
merged 3 commits into from
Aug 4, 2023

Conversation

gilgtm
Copy link
Collaborator

@gilgtm gilgtm commented Aug 3, 2023

  • Before: customScrollViewInsets only returns insets to adjust contentInset
  • After: customScrollViewInsets function signature matches calculateScrollViewInsets so you can specify scroll-indicator insets
  • Why? In the chat demo, the scroll bar was disappearing below the bottom inset of the list. It's likely that if you are modifying contentInset you will have to modify scroll indicator insets as well

Before

gravity-scroll-indicator-bug.mp4

After

gravity-scroll-indicator-fixed.mp4

Checklist

Please do the following before merging:

  • Ensure any public-facing changes are reflected in the changelog. Include them in the Main section.

- Before: customScrollViewInsets only returns insets to adjust contentInset
- After: customScrollViewInsets function signature matches calculateScrollViewInsets so you can specify scroll-indicator insets
- Why? In the chat demo, the scroll bar was disappearing below the bottom inset of the list. It's likely that if you are modifying contentInset you will have to modify scroll indicator insets as well
@@ -329,7 +329,11 @@ public final class ListView : UIView

/// This callback determines the scroll view's insets only when
/// `behavior.keyboardAdjustmentMode` is `.custom`
public var customScrollViewInsets: () -> UIEdgeInsets = { .zero }
public var customScrollViewInsets: () -> (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Up to you, but it may be nice to make this a real struct vs just a tuple, so we can document it, etc. But just a suggestion, not a big deal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added! new type ScrollViewInsets

@@ -338,7 +342,10 @@ public final class ListView : UIView
public func updateScrollViewInsets()
{
if case .custom = self.behavior.keyboardAdjustmentMode {
self.collectionView.contentInset = self.customScrollViewInsets()
let insets = self.customScrollViewInsets()
self.collectionView.contentInset = insets.content
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: We should wrap each of these assignments in a != check (as is done below) before assigning: It's mostly a "belt and suspenders" thing, but sometimes, even setting these values to the same exact value as before can break in-progress scroll events for whatever reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored!

Copy link
Collaborator

Choose a reason for hiding this comment

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

🙏 Thank you!

@gilgtm gilgtm force-pushed the gil/customScrollViewInsets-scroll-indicator-fix branch from 658abf7 to 80acc3b Compare August 3, 2023 20:54
@gilgtm gilgtm enabled auto-merge August 4, 2023 20:00
@gilgtm gilgtm disabled auto-merge August 4, 2023 20:00
@gilgtm gilgtm enabled auto-merge (squash) August 4, 2023 20:00
@gilgtm gilgtm merged commit df408dd into main Aug 4, 2023
@gilgtm gilgtm deleted the gil/customScrollViewInsets-scroll-indicator-fix branch August 4, 2023 20:22
@n8chur n8chur mentioned this pull request Aug 8, 2023
kyleve added a commit that referenced this pull request Sep 20, 2023
* origin/main:
  Release 13.0.0 (#504)
  Update KeyboardObserver (#499)
  CONV-1435: Gravity layout frame change fix - Before: Layout gravity doesn't take into account frame changes. For example, when the orientation changes the scroll position (relative to the bottom) changes - After: Layout gravity takes frame changes into account so the when the frame changes the scroll position relative to the bottom remains unchanged
  Release 12.0.0 (#501)
  CONV-1435: Add scroll indicator insets to customScrollViewInsets (#500)
  CONV-1435: Gravity layout - Adds a new Chat App demo and a new behavior called verticalLayoutGravity.  When verticalLayoutGravity is set to bottom, scrolling works the way you would expect for a messaging app.
  expose onKeyboardFrameWillChange on ListProperties
  onKeyboardFrameWillChange: Improve CHANGELOG, DocC
  CONV-1435: Custom keyboard adjustment mode - Adds a .custom KeyboardAdjustmentMode to fully customize inset behavior
  remove contentOffset from isContentScrollable calculation, improve comment
  Add ListView#isContentScrollable property - Add this property to ListView. It will be used in conjunction with upcoming so-called gravity scrolling changes to workaround an animation issue with paging
  Update CI script to reference the `xcodesorg/made/xcodes` package for installing simulator runtimes. (#494)
kyleve added a commit that referenced this pull request Nov 19, 2023
…rovements

* origin/main: (123 commits)
  Update CHANGELOG.md (#508)
  Revert "Supplementary Tracking Fixes (#433)"
  Revert "Force layout before appear, to avoid animated updates (#505)"
  Force layout before appear, to avoid animated updates (#505)
  Update workaround versions (#506)
  Fix supplementary view + contained first responder reuse issue (#507)
  Supplementary Tracking Fixes (#433)
  Release 13.0.0 (#504)
  Update KeyboardObserver (#499)
  CONV-1435: Gravity layout frame change fix - Before: Layout gravity doesn't take into account frame changes. For example, when the orientation changes the scroll position (relative to the bottom) changes - After: Layout gravity takes frame changes into account so the when the frame changes the scroll position relative to the bottom remains unchanged
  Release 12.0.0 (#501)
  CONV-1435: Add scroll indicator insets to customScrollViewInsets (#500)
  CONV-1435: Gravity layout - Adds a new Chat App demo and a new behavior called verticalLayoutGravity.  When verticalLayoutGravity is set to bottom, scrolling works the way you would expect for a messaging app.
  expose onKeyboardFrameWillChange on ListProperties
  onKeyboardFrameWillChange: Improve CHANGELOG, DocC
  CONV-1435: Custom keyboard adjustment mode - Adds a .custom KeyboardAdjustmentMode to fully customize inset behavior
  remove contentOffset from isContentScrollable calculation, improve comment
  Add ListView#isContentScrollable property - Add this property to ListView. It will be used in conjunction with upcoming so-called gravity scrolling changes to workaround an animation issue with paging
  Update CI script to reference the `xcodesorg/made/xcodes` package for installing simulator runtimes. (#494)
  Swipe Action Updates (#489)
  ...
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.

2 participants