Skip to content

Commit

Permalink
- 4.0.2
Browse files Browse the repository at this point in the history
- Fixed zero height stack view relayout case
  • Loading branch information
anton-plebanovich committed Jul 24, 2019
1 parent cf25565 commit 58a63e9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion AnimatableStackView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'AnimatableStackView'
s.version = '4.0.1'
s.version = '4.0.2'
s.summary = 'UIStackView based class that allows to animate its changes.'

# This description is used to generate tags and improve search results.
Expand Down
19 changes: 12 additions & 7 deletions AnimatableStackView/Classes/AnimatableStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ open class AnimatableStackView: UIStackView {
allNewViewsWithDeletedViews.insert(view, at: previousIndex)
}

allNewViewsWithDeletedViews.forEach { self.addArrangedSubview($0) }
allNewViewsWithDeletedViews.forEach { view in
// Fixing view's width. It might be wrong in a case stack view height is zero.
UIView.performWithoutAnimation {
view.frame.size.width = bounds.size.width
view.layoutSubviewsOnly()
}

self.addArrangedSubview(view)
}

//// 4. Hide deleted views and remove them from arranged subviews after animation is done.
// Note: Async is unsafe and can be improved later with additional checks if needed.
Expand All @@ -106,12 +114,6 @@ open class AnimatableStackView: UIStackView {
viewsToUpdate.forEach { view in
guard let viewModel = viewModels.first(where: { $0.id == view.id }) else { return }
view.configure(viewModel: viewModel)

// Fixing view's width. It might be wrong in a case stack view height is zero.
UIView.performWithoutAnimation {
view.frame.size.width = bounds.size.width
view.layoutSubviewsOnly()
}
}

views = allNewViews
Expand Down Expand Up @@ -147,5 +149,8 @@ open class AnimatableStackView: UIStackView {
/// Properly removes all arranged subviews from stack view.
private func clear() {
arrangedSubviews.forEach(removeSubview)

// Update constraints so we won't have issues if we add the same views later.
layoutIfNeeded()
}
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
`AnimatableStackView` adheres to [Semantic Versioning](http://semver.org/).

## [4.0.2](https://github.com/APUtils/AnimatableStackView/releases/tag/4.0.2)
Released on 07/24/2019.

#### Fixed
- Fixed zero height stack view relayout case


## [4.0.1](https://github.com/APUtils/AnimatableStackView/releases/tag/4.0.1)
Released on 07/22/2019.

Expand Down
4 changes: 2 additions & 2 deletions Pods Project/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- AnimatableStackView (4.0.1)
- AnimatableStackView (4.0.2)

DEPENDENCIES:
- AnimatableStackView (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
AnimatableStackView: 8de62f7b0bb99b5a5838bc0093299972e6647eb4
AnimatableStackView: 9076c1f0858c2dc1ebeb587f6c65822c10b2e953

PODFILE CHECKSUM: 123792c948494fe83cc02b1d4cd49e2d2579d908

Expand Down
2 changes: 1 addition & 1 deletion checkBuild.command
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ echo -e "\nBuilding Carthage project..."
xcodebuild -project "Carthage Project/AnimatableStackView.xcodeproj" -sdk iphonesimulator -target "Example" | xcpretty

echo -e "\nPerforming tests..."
xcodebuild -project "Carthage Project/AnimatableStackView.xcodeproj" -sdk iphonesimulator -scheme "Example" -destination "platform=iOS Simulator,name=iPhone SE,OS=12.2" test | xcpretty
xcodebuild -project "Carthage Project/AnimatableStackView.xcodeproj" -sdk iphonesimulator -scheme "Example" -destination "platform=iOS Simulator,name=iPhone SE,OS=12.4" test | xcpretty

echo ""
echo "SUCCESS!"
Expand Down

0 comments on commit 58a63e9

Please sign in to comment.