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

Update KeyboardObserver #499

Merged
merged 6 commits into from
Sep 1, 2023
Merged

Conversation

robmaceachern
Copy link
Member

@robmaceachern robmaceachern commented Aug 2, 2023

This updates the KeyboardObserver to match the more recent implementation we use elsewhere.

Changes include:

  • Support for the iOS 16.1+ changes related to the screen coordinate space. This can impact reported values when the app isn't full screen in Split View, Slide Over, and Stage Manager.
  • The delegate has been changed to report the UIView.AnimationCurve instead of UIView.AnimationOptions
  • Various formatting changes to match other implementations.
  • ListView changes:
    • We now use a UIViewPropertyAnimator instead of UIView.animate when responding to keyboard notifications.
    • The KeyboardFrameWillChangeCallback now receives the UIView.AnimationCurve instead of UIView.AnimationOptions

Note: This implementation

Checklist

Please do the following before merging:

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

@robmaceachern robmaceachern marked this pull request as ready for review August 4, 2023 20:54
- A new `custom` case is added to `KeyboardAdjustmentMode` which allows the consumer to fully customize the inset behavior. `onKeyboardFrameWillChange` and `customScrollViewInsets` have been added to `ListView` and `updateScrollViewInsets` is now public. All of these can be utilized in conjunction to respond to the keyboard and fully control the insets. For now, these are available through `ListView` only.

### Removed

### Changed

- `SwipeAction` property names have been updated to better reflect what they're for. `Completion` also now takes in a more descriptive enum, instead of a boolean, to make reading callsites clearer. Eg, `completion(.expandActions)` instead of `completion(true)`.
- `KeyboardObserverDelegate` now provides `UIView.AnimationCurve` instead of `UIView.AnimationOptions`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

God bless

// KeyboardObserver.swift
// ListableUI
//
// Created by Kyle Van Essen on 2/16/20.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow rude


var endingFrame : CGRect = .zero
@available(iOS 16.1, *)
var screen: UIScreen {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this intermediary useful? Can we not just do this in init?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAIK, you can't have stored properties that are marked with @available. So to keep the public API as accurate as possible I'm using that private optional UIScreen property for storage. There might be a cleaner way to do this but I didn't come across anything when I looked.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A ha!

Copy link
Collaborator

@kyleve kyleve left a comment

Choose a reason for hiding this comment

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

Couple small things, otherwise LGTM!

@robmaceachern
Copy link
Member Author

@kyleve The notification screen handling was updated in 27d578d to match the revised Market implementation (https://github.com/squareup/market/pull/6826).

@robmaceachern robmaceachern merged commit 138f5ad into main Sep 1, 2023
4 checks passed
@robmaceachern robmaceachern deleted the robmaceachern/keyboard-observer-updates branch September 1, 2023 19:38
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