|
| 1 | +// |
| 2 | +// Layout+Equatable.swift |
| 3 | +// CoreLayout |
| 4 | +// |
| 5 | +// Created by Jake Marsh on 7/13/17. |
| 6 | +// Copyright © 2017 Jake Marsh. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +extension Layout : Equatable { |
| 10 | + public static func ==(lhs: Layout, rhs: Layout) -> Bool { |
| 11 | + return lhs.identifier == rhs.identifier && |
| 12 | + lhs.container == rhs.container && |
| 13 | + lhs.overriddenPosition == rhs.overriddenPosition && |
| 14 | + lhs.size == rhs.size && |
| 15 | + lhs.margin == rhs.margin && |
| 16 | + lhs.padding == rhs.padding && |
| 17 | + lhs.border == rhs.border && |
| 18 | + lhs.isIncludedInLayout == rhs.isIncludedInLayout && |
| 19 | + lhs.children == rhs.children |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +extension ContainerBehavior : Equatable { |
| 24 | + public static func ==(lhs: ContainerBehavior, rhs: ContainerBehavior) -> Bool { |
| 25 | + return lhs.primaryAxis == rhs.primaryAxis && |
| 26 | + lhs.primaryAxis == rhs.primaryAxis && |
| 27 | + lhs.primaryAxisDistribution == rhs.primaryAxisDistribution && |
| 28 | + lhs.secondaryAxisDistribution == rhs.secondaryAxisDistribution && |
| 29 | + lhs.secondaryAxisDistributionWhenWrapping == rhs.secondaryAxisDistributionWhenWrapping && |
| 30 | + lhs.shouldWrap == rhs.shouldWrap && |
| 31 | + lhs.overflow == rhs.overflow |
| 32 | + } |
| 33 | + |
| 34 | +} |
| 35 | + |
| 36 | +extension WidthAndOrHeight : Equatable { |
| 37 | + public static func ==(lhs: WidthAndOrHeight, rhs: WidthAndOrHeight) -> Bool { |
| 38 | + return lhs.width == rhs.width && lhs.height == rhs.height |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +extension SizeBehavior : Equatable { |
| 43 | + public static func ==(lhs: SizeBehavior, rhs: SizeBehavior) -> Bool { |
| 44 | + func modeIsEqual() -> Bool { |
| 45 | + switch (lhs.mode, rhs.mode) { |
| 46 | + case (.flexibleShrinksButDoesntGrow, .flexible), |
| 47 | + (.flexibleShrinksButDoesntGrow, .absolute), |
| 48 | + (.flexibleShrinksButDoesntGrow, .relative), |
| 49 | + (.flexible, .flexibleShrinksButDoesntGrow), |
| 50 | + (.flexible, .absolute), |
| 51 | + (.flexible, .relative), |
| 52 | + (.absolute, .flexibleShrinksButDoesntGrow), |
| 53 | + (.absolute, .flexible), |
| 54 | + (.absolute, .relative), |
| 55 | + (.relative, .flexibleShrinksButDoesntGrow), |
| 56 | + (.relative, .flexible), |
| 57 | + (.relative, .absolute): |
| 58 | + return false |
| 59 | + |
| 60 | + case (.flexibleShrinksButDoesntGrow, .flexibleShrinksButDoesntGrow), |
| 61 | + (.relative, .relative): |
| 62 | + return true |
| 63 | + |
| 64 | + case (.absolute(let width, let height), .absolute(let width2, let height2)): |
| 65 | + return width == width2 && height == height2 |
| 66 | + |
| 67 | + case (.flexible(let units), .flexible(let units2)): |
| 68 | + return units == units2 |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + return modeIsEqual() && |
| 73 | + lhs.minimum == rhs.minimum && |
| 74 | + lhs.maximum == rhs.maximum |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +extension Edges : Equatable { |
| 79 | + public static func ==(lhs: Edges, rhs: Edges) -> Bool { |
| 80 | + return lhs.top == rhs.top && |
| 81 | + lhs.leading == rhs.leading && |
| 82 | + lhs.trailing == rhs.trailing && |
| 83 | + lhs.bottom == rhs.bottom |
| 84 | + } |
| 85 | +} |
0 commit comments