Skip to content

Commit

Permalink
Move extension to NSLayoutConstraint-Axis.swift (#180)
Browse files Browse the repository at this point in the history
* Move extension to NSLayoutConstraint-Axis.swift

* Improve implementation

Co-authored-by: Christopher Fuller <[email protected]>

---------

Co-authored-by: Christopher Fuller <[email protected]>
  • Loading branch information
tinder-garricnahapetian and tinder-cfuller authored Oct 24, 2023
1 parent 4260963 commit 331e575
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
36 changes: 36 additions & 0 deletions Sources/Layout/NSLayoutConstraint-Axis.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// swiftlint:disable:this file_name
//
// All Contributions by Match Group
//
// Copyright © 2023 Tinder (Match Group, LLC)
//
// Licensed under the Match Group Modified 3-Clause BSD License.
// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information.
//

import UIKit

extension NSLayoutConstraint.Axis {

internal var orientation: String {
switch self {
case .horizontal:
return "H"
case .vertical:
return "V"
@unknown default:
return "H"
}
}

internal var attribute: NSLayoutConstraint.Attribute {
switch self {
case .horizontal:
return .centerX
case .vertical:
return .centerY
@unknown default:
return .centerX
}
}
}
27 changes: 0 additions & 27 deletions Sources/Layout/NSLayoutConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,6 @@ extension NSLayoutConstraint {
}
}

// MARK: - NSLayoutConstraint.Axis Extension

extension NSLayoutConstraint.Axis {

internal var orientation: String {
switch self {
case .horizontal:
return "H"
case .vertical:
return "V"
@unknown default:
return "H"
}
}

internal var attribute: NSLayoutConstraint.Attribute {
switch self {
case .horizontal:
return .centerX
case .vertical:
return .centerY
@unknown default:
return .notAnAttribute
}
}
}

// MARK: - NSLayoutConstraint Array Helpers

extension Array where Element == NSLayoutConstraint {
Expand Down

0 comments on commit 331e575

Please sign in to comment.