<commit_before>// Copyright © 2020 <NAME>. All rights reserved.

import UIKit

final class PickerTableViewController: UITableViewController {
  private enum Section: CaseIterable {
    case datePicker
    case colorPicker
    case other
  }

  private let sections: [CountrySection] = RevertItems.capitalCities.data()
  private let datePickerCellIdentifier = "DatePickerCell"
  private let tableViewCellIdentifier = "UITableViewCell"

  private var pickerSections: [Section] {
    if #available(iOS 14.0, *) {
      return [.datePicker, .colorPicker, .other]
    }
    return [.datePicker, .other]
  }

  @available(iOS 14, *)
  var datePickerStyles: [UIDatePickerStyle] { [.compact, .inline, .wheels] }

  override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.register(UINib(nibName: "DatePickerTableViewCell", bundle: nil), forCellReuseIdentifier: datePickerCellIdentifier)
    self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: tableViewCellIdentifier)
  }

  override func numberOfSections(in tableView: UITableView) -> Int {
    return self.pickerSections.count
  }

  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if #available(iOS 14.0, *) {
      return pickerSections[section] == .datePicker ? datePickerStyles.count : 1
    }
    return 1
  }

  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    switch pickerSections[indexPath.section] {
    case .datePicker:
      guard let cell = tableView.dequeueReusableCell(withIdentifier: datePickerCellIdentifier) as? DatePickerTableViewCell else {
        fatalError("Expecting to dequeue a \(DatePickerTableViewCell.self) from the table view")
      }

      if #available(iOS 14.0, *) {
        cell.datePicker.preferredDatePickerStyle = datePickerStyles[indexPath.row]
      }

      return cell
    case .other:
      let identifier = "CountriesPickerCell"
      let cell = tableView.dequeueReusableCell(withIdentifier: identifier)!

      return cell
    case .colorPicker:
      let cell = UITableViewCell(style: .subtitle, reuseIdentifier: tableViewCellIdentifier)
      cell.textLabel?.text = "Color Picker"
      cell.detailTextLabel?.text = "Tap here to launch the new color picker from iOS 14"

      if #available(iOS 14.0, *) {
        cell.detailTextLabel?.textColor = .secondaryLabel
      }

      return cell
    }
  }

  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard pickerSections[indexPath.section] == .colorPicker else {
      return<commit_msg>Use explicit self<commit_after>// Copyright © 2020 Itty Bitty Apps. All rights reserved.

import UIKit

final class PickerTableViewController: UITableViewController {
  private enum Section: CaseIterable {
    case datePicker
    case colorPicker
    case other
  }

  private let sections: [CountrySection] = RevertItems.capitalCities.data()
  private let datePickerCellIdentifier = "DatePickerCell"
  private let tableViewCellIdentifier = "UITableViewCell"

  private var pickerSections: [Section] {
    if #available(iOS 14.0, *) {
      return [.datePicker, .colorPicker, .other]
    }
    return [.datePicker, .other]
  }

  @available(iOS 14, *)
  var datePickerStyles: [UIDatePickerStyle] { [.compact, .inline, .wheels] }

  override func viewDidLoad() {
    super.viewDidLoad()

    self.tableView.register(UINib(nibName: "DatePickerTableViewCell", bundle: nil), forCellReuseIdentifier: datePickerCellIdentifier)
    self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: tableViewCellIdentifier)
  }

  override func numberOfSections(in tableView: UITableView) -> Int {
    return self.pickerSections.count
  }

  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if #available(iOS 14.0, *) {
      return self.pickerSections[section] == .datePicker ? self.datePickerStyles.count : 1
    }
    return 1
  }

  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    switch pickerSections[indexPath.section] {
    case .datePicker:
      guard let cell = tableView.dequeueReusableCell(withIdentifier: self.datePickerCellIdentifier) as? DatePickerTableViewCell else {
        fatalError("Expecting to dequeue a \(DatePickerTableViewCell.self) from the table view")
      }

      if #available(iOS 14.0, *) {
        cell.datePicker.preferredDatePickerStyle = self.datePickerStyles[indexPath.row]
      }

      return cell
    case .other:
      let identifier = "CountriesPickerCell"
      let cell = tableView.dequeueReusableCell(withIdentifier: identifier)!

      return cell
    case .colorPicker:
      let cell = UITableViewCell(style: .subtitle, reuseIdentifier: self.tableViewCellIdentifier)
      cell.textLabel?.text = "Color Picker"
      cell.detailTextLabel?.text = "Tap here to launch the new color picker from iOS 14"

      if #available(iOS 14.0, *) {
        cell.detailTextLabel?.textColor = .secondaryLabel
      }

      return cell
    }
  }

  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    guard self.pickerSections[indexPath.section] == .colorPicker else {
      return
{'fraction_non_alphanumeric': 0.08993009635367466, 'fraction_numerical': 0.008312866049499339, 'mean_word_length': 3.7822944896115627, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, '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': '4546354', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1501, 'n_words': 383}