Skip to content

Make insets of active state updatable - #5

Open
jonasbeckers wants to merge 2 commits into
masterfrom
feature/update-insets-after-transition
Open

Make insets of active state updatable#5
jonasbeckers wants to merge 2 commits into
masterfrom
feature/update-insets-after-transition

Conversation

@jonasbeckers

Copy link
Copy Markdown
Contributor

Allow the user to manually update the insets after the state view is already added.

Comment thread Sources/ViewStateMachine.swift Outdated
Comment thread Sources/ViewStateMachine.swift Outdated
Comment thread Sources/ViewStateMachine.swift Outdated
Comment thread Sources/ViewStateMachine.swift Outdated
@jonasbeckers
jonasbeckers force-pushed the feature/update-insets-after-transition branch from db327b6 to 9df0419 Compare May 3, 2024 10:59
@ernest-app ernest-app Bot added 📃 S PR and removed 📃 XS PR labels May 3, 2024
let animationCompletion: (Bool) -> Void = { [weak self] _ in
for (_, view) in store {
view.removeFromSuperview()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this isn't needed, as the callback closure you've configured above has a weak reference to instance. So once the placeholder view is deallocated, the closure will be deleted as well.

But… better safe than sorry 😉


func updateConstraints(for view: UIView, insets: UIEdgeInsets) {
let constraints = Dictionary(grouping: view.constraints) { $0.identifier.flatMap { ConstraintIdentifier(rawValue: $0) } }
constraints[.top]?.forEach { $0.constant = insets.top }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These can probably use first instead of forEach 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants