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

fix bug remove constraints wrongly #406

Merged
merged 3 commits into from
Jun 11, 2021

Conversation

Juanpe
Copy link
Owner

@Juanpe Juanpe commented Jun 11, 2021

Summary

Fixes #405

This PR fixes a bug related to the constraints that SkeletonView added to labels when the skeleton is active. The previous logic was:

When the labels are prepared for the skeleton:

  1. Check the desired height for labels.
  2. If needed, backup the current constraints and remove them.
  3. Activate the calculated skeleton constraints.

When the skeleton disappears

  1. Remove all the constraints related to the height.
  2. If there are some constraints backed up, restore them.

The problem was step 1 when the skeleton disappears because we were always removing the height constraints, even if the library had added no constraints.

The solution is to add an identifier to constraints added by the library. Then, SkeletonView only removes the constraints added by the library. So, the logic now when the skeleton disappears is:

  1. Remove all the constraints related to the height added by the library.
  2. If there are some constraints backed up, restore them.

Requirements

@Juanpe Juanpe self-assigned this Jun 11, 2021
@Juanpe Juanpe merged commit c8fdd69 into main Jun 11, 2021
@Juanpe Juanpe deleted the bug/fix_bug_remove_constraints_wrongly branch June 11, 2021 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lost UILabel constraint height after call hideSkeleton
1 participant