<commit_before>//
//  CalendarView.swift
//  Calendar
//
//  Created by <NAME> on 3/27/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import SwiftMoment

public protocol CalendarViewDelegate {
  func calendarDidSelectDate(date: Moment)
  func calendarDidPageToDate(date: Moment)
}

public class CalendarView: UIView {

  private struct Appearance {
    static var dayBackgroundColor = UIColor.clearColor()
    static var daySelectedBackgroundColor = UIColor.orangeColor()
    static var todayBackgroundColor = UIColor.lightGrayColor()
    static var todayTextColor = UIColor.blackColor()
    static var dayTextColor = UIColor.blackColor()
    static var daySelectedTextColor = UIColor.whiteColor()
    static var otherMonthTextColor = UIColor.lightGrayColor()
    static var otherMonthBackgroundColor = UIColor.clearColor()
    static var weekLabelTextColor = UIColor.blackColor()
    static var dayFont = UIFont.systemFontOfSize(15)
  }

  public class var dayBackgroundColor: UIColor {
    get { return Appearance.dayBackgroundColor }
    set { Appearance.dayBackgroundColor = newValue }
  }
  public class var daySelectedBackgroundColor: UIColor {
    get { return Appearance.daySelectedBackgroundColor }
    set { Appearance.daySelectedBackgroundColor = newValue }
  }
  public class var todayBackgroundColor: UIColor {
    get { return Appearance.todayBackgroundColor }
    set { Appearance.todayBackgroundColor = newValue }
  }
  public class var todayTextColor: UIColor {
    get { return Appearance.todayTextColor }
    set { Appearance.todayTextColor = newValue }
  }
  public class var dayTextColor: UIColor {
    get { return Appearance.dayTextColor }
    set { Appearance.dayTextColor = newValue }
  }
  public class var daySelectedTextColor: UIColor {
    get { return Appearance.daySelectedTextColor }
    set { Appearance.daySelectedTextColor = newValue }
  }
  public class var otherMonthTextColor: UIColor {
    get { return Appearance.otherMonthTextColor }
    set { Appearance.otherMonthTextColor = newValue }
  }
  public class var otherMonthBackgroundColor: UIColor {
    get { return Appearance.otherMonthBackgroundColor }
    set { Appearance.otherMonthBackgroundColor = newValue }
  }
  public class var weekLabelTextColor: UIColor {
    get { return Appearance.weekLabelTextColor }
    set { Appearance.weekLabelTextColor = newValue }
  }
  public class var dayFont: UIFont {
    get { return Appearance.dayFont }
    set { Appearance.dayFont = newValue }
  }

  lazy var contentView: ContentView = {
    let cv = ContentView(frame: CGRectZero)
    cv.delegate = self
    self.addSubview(cv)
    return cv
  }()
  public var delegate: CalendarViewDelegate? {
    didSet {
      delegate?.calendarDidPageToDate(contentView.currentMonth().date)
    }
  }
  public var selectedDayOnPaged: Int? = 1

  required public init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    setup()
  }

  override init(frame: CGRect) {
    super.init(frame: frame)
    setup()
  }

  override public func willMoveToWindow(newWindow: UIWindow?) {
    if newWindow == nil {
      NSNotificationCenter.defaultCenter().removeObserver(self)
      contentView.removeObservers()
    } else {
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "dateSelected:", name: CalendarSelectedDayNotification, object: nil)
    }
  }

  func setup() {
    if let date = contentView.selectedDate {
      contentView.selectVisibleDate(date.day)
      delegate?.calendarDidSelectDate(moment(date))
      contentView.selectedDate = nil
    }
  }

  override public func layoutSubviews() {
    super.layoutSubviews()
    contentView.frame = bounds
    contentView.contentOffset.x = CGRectGetWidth(contentView.frame)
  }<commit_msg>Add plbuic initializers<commit_after>//
//  CalendarView.swift
//  Calendar
//
//  Created by <NAME> on 3/27/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import SwiftMoment

public protocol CalendarViewDelegate {
  func calendarDidSelectDate(date: Moment)
  func calendarDidPageToDate(date: Moment)
}

public class CalendarView: UIView {

  private struct Appearance {
    static var dayBackgroundColor = UIColor.clearColor()
    static var daySelectedBackgroundColor = UIColor.orangeColor()
    static var todayBackgroundColor = UIColor.lightGrayColor()
    static var todayTextColor = UIColor.blackColor()
    static var dayTextColor = UIColor.blackColor()
    static var daySelectedTextColor = UIColor.whiteColor()
    static var otherMonthTextColor = UIColor.lightGrayColor()
    static var otherMonthBackgroundColor = UIColor.clearColor()
    static var weekLabelTextColor = UIColor.blackColor()
    static var dayFont = UIFont.systemFontOfSize(15)
  }

  public class var dayBackgroundColor: UIColor {
    get { return Appearance.dayBackgroundColor }
    set { Appearance.dayBackgroundColor = newValue }
  }
  public class var daySelectedBackgroundColor: UIColor {
    get { return Appearance.daySelectedBackgroundColor }
    set { Appearance.daySelectedBackgroundColor = newValue }
  }
  public class var todayBackgroundColor: UIColor {
    get { return Appearance.todayBackgroundColor }
    set { Appearance.todayBackgroundColor = newValue }
  }
  public class var todayTextColor: UIColor {
    get { return Appearance.todayTextColor }
    set { Appearance.todayTextColor = newValue }
  }
  public class var dayTextColor: UIColor {
    get { return Appearance.dayTextColor }
    set { Appearance.dayTextColor = newValue }
  }
  public class var daySelectedTextColor: UIColor {
    get { return Appearance.daySelectedTextColor }
    set { Appearance.daySelectedTextColor = newValue }
  }
  public class var otherMonthTextColor: UIColor {
    get { return Appearance.otherMonthTextColor }
    set { Appearance.otherMonthTextColor = newValue }
  }
  public class var otherMonthBackgroundColor: UIColor {
    get { return Appearance.otherMonthBackgroundColor }
    set { Appearance.otherMonthBackgroundColor = newValue }
  }
  public class var weekLabelTextColor: UIColor {
    get { return Appearance.weekLabelTextColor }
    set { Appearance.weekLabelTextColor = newValue }
  }
  public class var dayFont: UIFont {
    get { return Appearance.dayFont }
    set { Appearance.dayFont = newValue }
  }

  lazy var contentView: ContentView = {
    let cv = ContentView(frame: CGRectZero)
    cv.delegate = self
    self.addSubview(cv)
    return cv
  }()
  public var delegate: CalendarViewDelegate? {
    didSet {
      delegate?.calendarDidPageToDate(contentView.currentMonth().date)
    }
  }
  public var selectedDayOnPaged: Int? = 1

  required public init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    setup()
  }

  override public init(frame: CGRect) {
    super.init(frame: frame)
    setup()
  }

  public init() {
    super.init(frame: CGRectZero)
    setup()
  }

  override public func willMoveToWindow(newWindow: UIWindow?) {
    if newWindow == nil {
      NSNotificationCenter.defaultCenter().removeObserver(self)
      contentView.removeObservers()
    } else {
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "dateSelected:", name: CalendarSelectedDayNotification, object: nil)
    }
  }

  func setup() {
    if let date = contentView.selectedDate {
      contentView.selectVisibleDate(date.day)
      delegate?.calendarDidSelectDate(moment(date))
      contentView.selectedDate = nil
    }
  }

  override public func layoutSubviews() {
    super.layoutSubviews()
    contentView.frame = bounds
    contentView.contentOffset.x = CGRectGetWidth(contentView.frame)
  }
{'fraction_non_alphanumeric': 0.08180388044048244, 'fraction_numerical': 0.003146303093864709, 'mean_word_length': 3.813249211356467, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2885927', 'n_tokens_mistral': 2224, 'n_tokens_neox': 2188, 'n_words': 528}