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

Make UIKitAnimations' frameworks property public via SPI #272

Conversation

acosmicflamingo
Copy link
Contributor

This seems like a simple way to get access to a UIKit animation's options property, which I can then use to do something like this:

observe { transaction
  guard case let .uiKit(animation) = transaction.uiKit.animation.framework
  else { return }
  if animation.options.contains(.transitionCrossDissolve) {
    UIView.transition(with: collectionView, duration: 0.2) {
      dataSource.apply(snapshot, animatedDifferences: true)
    }
  }
}

@stephencelis
Copy link
Member

@acosmicflamingo Thanks for exploring and taking the time to PR! The current purpose of uiKit.animation is to automatically wrap observe in a UIView.animate, and so I'm not sure exposing these details for the purpose of more fine-grained animations is how we'd want to approach a solution to the problem.

As an alternative, have you considered adding a custom transaction key to UITransaction? You could, for example, add a shouldAnimateCollectionDifferences boolean and inspect that to decide whether or not you want to animate things:

observe { transaction
  if transaction.shouldAnimateCollectionDifferences {
    UIView.transition(with: collectionView, duration: 0.2) {
      dataSource.apply(snapshot, animatedDifferences: transaction)
    }
  } else {
    // ...
  }
}

@acosmicflamingo
Copy link
Contributor Author

acosmicflamingo commented Feb 19, 2025

@stephencelis I didn't know that was possible! And of course, it's already documented LOL

It's exactly what I need. Works like a charm! Thanks :)

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