<commit_before>//
//  ActivityIndicator.swift
//  TemplateKit
//
//  Created by <NAME> on 10/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public struct ActivityIndicatorProperties: Properties {
  public var core = CoreProperties()

  public var activityIndicatorViewStyle: UIActivityIndicatorViewStyle?
  public var hidesWhenStopped: Bool?
  public var color: UIColor?

  public init() {}

  public init(_ properties: [String : Any]) {
    core = CoreProperties(properties)

    activityIndicatorViewStyle = properties.cast("activityIndicatorViewStyle")
    hidesWhenStopped = properties.cast("hidesWhenStopped")
    color = properties.color("color")
  }

  public mutating func merge(_ other: ActivityIndicatorProperties) {
    core.merge(other.core)

    merge(&activityIndicatorViewStyle, other.activityIndicatorViewStyle)
    merge(&hidesWhenStopped, other.hidesWhenStopped)
    merge(&color, other.color)
  }
}

public func ==(lhs: ActivityIndicatorProperties, rhs: ActivityIndicatorProperties) -> Bool {
  return lhs.activityIndicatorViewStyle == rhs.activityIndicatorViewStyle && lhs.hidesWhenStopped == rhs.hidesWhenStopped && lhs.color == rhs.color && lhs.equals(otherProperties: rhs)
}

public class ActivityIndicator: UIActivityIndicatorView, NativeView {
  public weak var eventTarget: AnyObject?
  public lazy var eventRecognizers = EventRecognizers()

  public var properties = ActivityIndicatorProperties() {
    didSet {
      applyCoreProperties()
      applyActivityIndicatorViewProperties()
    }
  }

  public required init() {
    super.init(frame: CGRect.zero)
  }
  
  required public init(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  private func applyActivityIndicatorViewProperties() {
    activityIndicatorViewStyle = properties.activityIndicatorViewStyle ?? .white
    hidesWhenStopped = properties.hidesWhenStopped ?? true
    color = properties.color

    startAnimating()
  }

  public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)

    touchesBegan()
  }
}
<commit_msg>Only start animating when needed<commit_after>//
//  ActivityIndicator.swift
//  TemplateKit
//
//  Created by <NAME> on 10/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public struct ActivityIndicatorProperties: Properties {
  public var core = CoreProperties()

  public var activityIndicatorViewStyle: UIActivityIndicatorViewStyle?
  public var hidesWhenStopped: Bool?
  public var color: UIColor?

  public init() {}

  public init(_ properties: [String : Any]) {
    core = CoreProperties(properties)

    activityIndicatorViewStyle = properties.cast("activityIndicatorViewStyle")
    hidesWhenStopped = properties.cast("hidesWhenStopped")
    color = properties.color("color")
  }

  public mutating func merge(_ other: ActivityIndicatorProperties) {
    core.merge(other.core)

    merge(&activityIndicatorViewStyle, other.activityIndicatorViewStyle)
    merge(&hidesWhenStopped, other.hidesWhenStopped)
    merge(&color, other.color)
  }
}

public func ==(lhs: ActivityIndicatorProperties, rhs: ActivityIndicatorProperties) -> Bool {
  return lhs.activityIndicatorViewStyle == rhs.activityIndicatorViewStyle && lhs.hidesWhenStopped == rhs.hidesWhenStopped && lhs.color == rhs.color && lhs.equals(otherProperties: rhs)
}

public class ActivityIndicator: UIActivityIndicatorView, NativeView {
  public weak var eventTarget: AnyObject?
  public lazy var eventRecognizers = EventRecognizers()

  public var properties = ActivityIndicatorProperties() {
    didSet {
      applyCoreProperties()
      applyActivityIndicatorViewProperties()
    }
  }

  public required init() {
    super.init(frame: CGRect.zero)
  }
  
  required public init(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  private func applyActivityIndicatorViewProperties() {
    activityIndicatorViewStyle = properties.activityIndicatorViewStyle ?? .white
    hidesWhenStopped = properties.hidesWhenStopped ?? true
    color = properties.color

    if !isAnimating {
      startAnimating()
    }
  }

  public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)

    touchesBegan()
  }
}

{'fraction_non_alphanumeric': 0.09509555606723463, 'fraction_numerical': 0.004605111673958094, 'mean_word_length': 4.505703422053232, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1191646', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1236, 'n_words': 290}