Skip to content

Commit

Permalink
issue-907: Fixed layout ordering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dahan committed Oct 19, 2017
1 parent 8e91d13 commit 6f9098e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.12.3

* [issue-907](https://github.com/CosmicMind/Material/issues/907): Fixed Layout ordering issues.

## 2.12.2

* [issue-860](https://github.com/CosmicMind/Material/issues/860): Updated TabBar color states and added an independent line color state.
Expand Down
2 changes: 1 addition & 1 deletion Material.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '2.12.2'
s.version = '2.12.3'
s.license = 'BSD-3-Clause'
s.summary = 'A UI/UX framework for creating beautiful applications.'
s.homepage = 'http://materialswift.com'
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.12.2</string>
<string>2.12.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
30 changes: 19 additions & 11 deletions Sources/iOS/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -631,14 +631,26 @@ public class Layout {

fileprivate extension Layout {
/**
Updates and lays out the constraints for a given view.
Updates the consraints for a given view.
- Parameter for view: A UIView.
*/
class func updateConstraints(for view: UIView) {
view.updateConstraintsIfNeeded()
view.updateConstraints()
view.setNeedsLayout()
view.layoutIfNeeded()
DispatchQueue.main.async {
view.setNeedsLayout()
view.layoutIfNeeded()
view.updateConstraintsIfNeeded()
view.updateConstraints()
}
}

/**
Updates the constraints for a given Array of views.
- Parameter for [view]: An Array of UIViews.
*/
class func updateConstraints(for views: [UIView]) {
for v in views {
updateConstraints(for: v)
}
}
}

Expand Down Expand Up @@ -700,9 +712,7 @@ extension Layout {
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .right, relatedBy: .equal, toItem: parent, attribute: .right, multiplier: 1, constant: -right))
}

for child in children {
updateConstraints(for: child)
}
updateConstraints(for: children)
}

/**
Expand All @@ -726,9 +736,7 @@ extension Layout {
parent.addConstraint(NSLayoutConstraint(item: children[children.count - 1], attribute: .bottom, relatedBy: .equal, toItem: parent, attribute: .bottom, multiplier: 1, constant: -bottom))
}

for child in children {
updateConstraints(for: child)
}
updateConstraints(for: children)
}

/**
Expand Down

0 comments on commit 6f9098e

Please sign in to comment.