<commit_before>import UIKit
import AnimatedStackView

func rotationTransform(angle: Double) -> CATransform3D {
  var perspective = CATransform3DIdentity
  perspective.m34 = 1.0 / -1000
  let rotation = CATransform3DMakeRotation(CGFloat(angle), 0, 1, 0)
  return CATransform3DConcat(perspective, rotation)
}

struct CustomActiveMetric: AnimatedStackMetric {
  let alpha: CGFloat = 1
  let transform = rotationTransform(0)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return stackViewBounds
  }
}

struct CustomLeadingMetric: AnimatedStackMetric {
  let alpha: CGFloat = 0
  let transform = rotationTransform(M_PI_2)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return CGRectOffset(stackViewBounds, stackViewBounds.height, 0)
  }
}

struct CustomTrailingMetric: AnimatedStackMetric {
  let alpha: CGFloat = 0
  let transform = rotationTransform(-M_PI_2)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return CGRectOffset(stackViewBounds, -stackViewBounds.height, 0)
  }
}

struct CustomAnimationMetric: AnimationMetric {
  let duration: CFTimeInterval = 1.5
  let delay: CFTimeInterval = 0
  let damping: CGFloat = 0.5
  let initialVelocity: CGFloat = 0
  let options = UIViewAnimationOptions.BeginFromCurrentState
}

class ViewController: UIViewController {

  let titles = ["Contacts", "Videoes", "Pictures", "Activity"]
  let firstStackView: AnimatedStackView
  let secondStackView: AnimatedStackView
  var currentSliderValue: Float = 0
  @IBOutlet var containerView: UIView!

  required init?(coder: NSCoder) {

    self.firstStackView = AnimatedStackView(frame: CGRect(x: 0, y: 0, width: 100, height: 30))
    self.secondStackView = AnimatedStackView(frame: CGRect(x: 0, y: 70, width: 100, height: 30),
      activeMetric: CustomActiveMetric(),
      leadingMetric: CustomLeadingMetric(),
      trailingMetric: CustomTrailingMetric(),
      animationMetric: CustomAnimationMetric())

    super.init(coder: coder)

  }

  override func viewDidLoad() {
    super.viewDidLoad()

    self.containerView.addSubview(self.firstStackView)
    self.containerView.addSubview(self.secondStackView)

    let firstTitleLabel = self.createTitleLabel("Hi")
    let secondTitleLabel = self.createTitleLabel("Hi")

    self.firstStackView.push(firstTitleLabel, animated: false)<commit_msg>Update example app to reflect README<commit_after>import UIKit
import AnimatedStackView

func rotationTransform(angle: Double) -> CATransform3D {
  var perspective = CATransform3DIdentity
  perspective.m34 = 1.0 / -1000
  let rotation = CATransform3DMakeRotation(CGFloat(angle), 0, 1, 0)
  return CATransform3DConcat(perspective, rotation)
}

struct CustomActiveMetric: AnimatedStackMetric {
  let alpha: CGFloat = 1
  let transform = rotationTransform(0)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return stackViewBounds
  }
}

struct CustomLeadingMetric: AnimatedStackMetric {
  let alpha: CGFloat = 0
  let transform = rotationTransform(M_PI_2)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return stackViewBounds.offsetBy(dx: stackViewBounds.midX, dy: 0)
  }
}

struct CustomTrailingMetric: AnimatedStackMetric {
  let alpha: CGFloat = 0
  let transform = rotationTransform(-M_PI_2)

  func frame(view: UIView, stackViewBounds: CGRect) -> CGRect {
    return stackViewBounds.offsetBy(dx: -stackViewBounds.midX, dy: 0)
  }
}

struct CustomAnimationMetric: AnimationMetric {
  let duration: CFTimeInterval = 1
  let delay: CFTimeInterval = 0
  let damping: CGFloat = 0.8
  let initialVelocity: CGFloat = 0
  let options = UIViewAnimationOptions.BeginFromCurrentState
}

class ViewController: UIViewController {

  let titles = ["Tokyo", "New York", "Sao Paulo", "Seoul"]
  let firstStackView: AnimatedStackView
  let secondStackView: AnimatedStackView
  var currentSliderValue: Float = 0
  @IBOutlet var containerView: UIView!

  required init?(coder: NSCoder) {

    self.firstStackView = AnimatedStackView(frame: CGRect(x: 0, y: 0, width: 100, height: 30))
    self.secondStackView = AnimatedStackView(frame: CGRect(x: 0, y: 70, width: 100, height: 30),
      activeMetric: CustomActiveMetric(),
      leadingMetric: CustomLeadingMetric(),
      trailingMetric: CustomTrailingMetric(),
      animationMetric: CustomAnimationMetric())

    super.init(coder: coder)

  }

  override func viewDidLoad() {
    super.viewDidLoad()

    self.containerView.addSubview(self.firstStackView)
    self.containerView.addSubview(self.secondStackView)

    let firstTitleLabel = self.createTitleLabel(titles.first!)
    let secondTitleLabel = self.createTitleLabel(titles.first!)

    self.firstStackView.push(firstTitleLabel)
{'fraction_non_alphanumeric': 0.09193205944798301, 'fraction_numerical': 0.01889596602972399, 'mean_word_length': 4.881398252184769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4763995', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1441, 'n_words': 354}