Skip to content

Commit

Permalink
LayoutViewJSONParser now checks for arrays as valid constraint argume…
Browse files Browse the repository at this point in the history
…nts, allowing for multiple constraints to be placed on each attribute
  • Loading branch information
dalewebster48 committed Feb 24, 2017
1 parent 2d16445 commit 372cd5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions EverLayout/Parsers/LayoutViewJSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,22 @@ class LayoutViewJSONParser: NSObject , LayoutViewParser
{
guard let source = self.parseSource(source: source) else { return nil }
guard let jsonData = source.viewData[LayoutViewJSONParser.KEY_CONSTRAINTS]?.dictionary else { return nil }

var constraints : [ELConstraint?] = []

return jsonData.map({ (key , value) -> ELConstraint? in
guard let value = value.string else { return nil }

return ELConstraint(rawData: (key , value) , parser: LayoutConstraintJSONParser())
})
for (lhs , rhs) in jsonData {
// rhs can either be a constraint argument as a String, or an array of constraint arguments
if let rhs = rhs.string {
constraints.append(ELConstraint(rawData: (lhs , rhs), parser: LayoutConstraintJSONParser()))
} else if let rhs = rhs.array {
for argument in rhs {
guard let argument = argument.string else { return nil }
constraints.append(ELConstraint(rawData: (lhs , argument) , parser: LayoutConstraintJSONParser()))
}
}
}

return constraints
}

/// Get the z-index of this view
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ DEPENDENCIES:
SPEC CHECKSUMS:
Socket.IO-Client-Swift: 900cf511777045c80d1ce1f11f71261e87765dd1

PODFILE CHECKSUM: 83ea6e5016c26b9a778d1ae57c7d123c347e10ee
PODFILE CHECKSUM: c81d7c93c2b79f2277a7ebb3b559d9b9e3f858ea

COCOAPODS: 1.2.0.beta.1

0 comments on commit 372cd5b

Please sign in to comment.