<commit_before>//
//  LayoutContraint.swift
//  FastTap
//
//  Created by mhelmbre on 4/1/15.
//  Copyright (c) 2015 At-World. All rights reserved.
//

#if os(iOS) || os(tvOS)
  import UIKit
  public typealias View = UIView
#else
  import AppKit
  public typealias View = NSView
#endif
import Cartography


public struct CartographyKit{
  
}


//TODO: All the rest

//Baselines
private protocol BasicBaselines{
  static func baseline(_ view: View) -> NSLayoutConstraint?
  static func lastBaseline(_ view: View) -> NSLayoutConstraint?
  static func firstBaseline(_ view: View) -> NSLayoutConstraint?
}

////////////////////////////////////////////////////////////////////////////////////////////////
//To other view(s)
////////////////////////////////////////////////////////////////////////////////////////////////
private protocol ToOtherViews{
  static func topToOtherViewsBottom(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?
  static func bottomToOtherViewsTop(_ view1: View, otherView: View, minus: CGFloat) -> NSLayoutConstraint?
  static func topToOtherViewsCenterX(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?
}


////////////////////

extension CartographyKit: ToOtherViews{
  @discardableResult
  public static func topToOtherViewsBottom(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.top == otherView.bottom + plus
      return
    }
    return c
  }
  
  @discardableResult
  public static func bottomToOtherViewsTop(_ view1: View, otherView: View, minus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.bottom == otherView.top - minus
      return
    }
    return c
  }
  
  @discardableResult
  public static func topToOtherViewsCenterX(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.top == otherView.centerY + plus
      return
    }
    return c
  }
}

private protocol LayoutGuides{
  static func topToLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?
  static func topBottomLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?
}

extension CartographyKit: LayoutGuides{
  @discardableResult
  public static func topToLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view, layoutguide){ view, layoutguide in
      c = view.top == layoutguide.bottom
      return
    }
    return c
  }
  
  @discardableResult
  public static func topBottomLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view, layoutguide){ view, layoutguide in
      c = view.bottom == layoutguide.top
      return
    }
    return c
  }
}



<commit_msg>Added CenterX and Y to other View<commit_after>//
//  LayoutContraint.swift
//  FastTap
//
//  Created by mhelmbre on 4/1/15.
//  Copyright (c) 2015 At-World. All rights reserved.
//

#if os(iOS) || os(tvOS)
  import UIKit
  public typealias View = UIView
#else
  import AppKit
  public typealias View = NSView
#endif
import Cartography


public struct CartographyKit{
  
}


//TODO: All the rest

//Baselines
private protocol BasicBaselines{
  static func baseline(_ view: View) -> NSLayoutConstraint?
  static func lastBaseline(_ view: View) -> NSLayoutConstraint?
  static func firstBaseline(_ view: View) -> NSLayoutConstraint?
}

////////////////////////////////////////////////////////////////////////////////////////////////
//To other view(s)
////////////////////////////////////////////////////////////////////////////////////////////////
private protocol ToOtherViews{
  static func topToOtherViewsBottom(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?
  static func bottomToOtherViewsTop(_ view1: View, otherView: View, minus: CGFloat) -> NSLayoutConstraint?
  static func topToOtherViewsCenterX(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?
}


////////////////////

extension CartographyKit{
  @discardableResult
  public static func centerYToView(_ view1: View, view2: View) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, view2){ view1, view2 in
      c = view1.centerY == view2.centerY
      return
    }
    return c
  }
  
  @discardableResult
  public static func centerXToView(_ view1: View, view2: View) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, view2){ view1, view2 in
      c = view1.centerX == view2.centerX
      return
    }
    return c
  }
  
}

extension CartographyKit: ToOtherViews{
  @discardableResult
  public static func topToOtherViewsBottom(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.top == otherView.bottom + plus
      return
    }
    return c
  }
  
  @discardableResult
  public static func bottomToOtherViewsTop(_ view1: View, otherView: View, minus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.bottom == otherView.top - minus
      return
    }
    return c
  }
  
  @discardableResult
  public static func topToOtherViewsCenterX(_ view1: View, otherView: View, plus: CGFloat) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view1, otherView){ view1, otherView in
      c = view1.top == otherView.centerY + plus
      return
    }
    return c
  }
}

private protocol LayoutGuides{
  static func topToLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?
  static func topBottomLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?
}

extension CartographyKit: LayoutGuides{
  @discardableResult
  public static func topToLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view, layoutguide){ view, layoutguide in
      c = view.top == layoutguide.bottom
      return
    }
    return c
  }
  
  @discardableResult
  public static func topBottomLayoutGuide(_ view: View, layoutguide: LayoutSupport) -> NSLayoutConstraint?{
    var c: NSLayoutConstraint?
    constrain(view, layoutguide){ view, layoutguide in
      c = view.bottom == layoutguide.top
      return
    }
    return c
  }
}




{'fraction_non_alphanumeric': 0.14801389518199667, 'fraction_numerical': 0.009364144389065096, 'mean_word_length': 2.8079355951696376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5982725', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1897, 'n_words': 562}