<commit_before>//
//  DiscoverTopicViewController.swift
//  Podcast
//
//  Created by <NAME> on 2/17/18.
//  Copyright © 2018 Cornell App Development. All rights reserved.
//

import UIKit

/// Displays the discoverable content for a given topic. 
class DiscoverTopicViewController: DiscoverComponentViewController {

    var topicImageView: UIImageView!
    var topicLabel: UILabel!
    var relatedTopicsView: TrendingTopicsView!
    var episodesHeaderView: DiscoverCollectionViewHeaderView!
    var topEpisodesTableView: UITableView!
    var seriesHeaderView: DiscoverCollectionViewHeaderView!
    var topSeriesCollectionView: UICollectionView!

    let episodesReuseIdentifier = "episodes"
    let seriesReuseIdentifier = "series"
    let headerReuseIdentifier = "header"
    let episodesHeaderTag = 1
    let seriesHeaderTag = 2
    let collectionViewHeight: CGFloat = 160
    let imageViewHeight: CGFloat = 72
    let relatedTopicsHeight: CGFloat = 150

    var relatedTopics = [Topic]()
    var topEpisodes = [Episode]()
    var topSeries = [Series]()
    var parentTopic: Topic?

    var topic: Topic!
    var currentlyPlayingIndexPath: IndexPath?

    convenience init(topic: Topic, parentTopic: Topic? = nil) {
        self.init()
        self.topic = topic
        self.parentTopic = parentTopic
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        topicImageView = UIImageView(frame: .zero)
        contentView.addSubview(topicImageView)
        topicImageView.snp.makeConstraints { make in
            make.top.leading.trailing.width.equalToSuperview()
            make.height.equalTo(imageViewHeight)
        }

        topicLabel = UILabel(frame: .zero)
        topicLabel.font = ._16SemiboldFont()
        topicLabel.textColor = .offWhite
        topicLabel.textAlignment = .center
        contentView.addSubview(topicLabel)
        topicLabel.snp.makeConstraints { make in
            make.center.equalTo(topicImageView.snp.center)
        }

        relatedTopicsView = TrendingTopicsView(frame: .zero, type: .related)
        relatedTopicsView.isUserInteractionEnabled = true
        relatedTopicsView.dataSource = self
        relatedTopicsView.delegate = self
        contentView.addSubview(relatedTopicsView)
        relatedTopicsView.snp.makeConstraints { make in
            make.top.equalTo(topicImageView.snp.bottom)
            make.width.leading.trailing.equalToSuperview()
            make.height.lessThanOrEqualTo(relatedTopicsHeight)
        }

        seriesHeaderView = createCollectionHeaderView(type: .series, tag: seriesHeaderTag)
        seriesHeaderView.delegate = self
        seriesHeaderView.snp.makeConstraints { make in
            make.leading.trailing.width.equalToSuperview()
            make.top.equalTo(relatedTopicsView.snp.bottom)
            make.height.equalTo(headerHeight)
        }

        topSeriesCollectionView = createCollectionView(type: .discover)
        topSeriesCollectionView.register(SeriesGridCollectionViewCell.self, forCellWithReuseIdentifier: episodesReuseIdentifier)
        topSeriesCollectionView.delegate = self
        topSeriesCollectionView.dataSource = self
        topSeriesCollectionView.snp.makeConstraints { make in
            make.width.leading.trailing.equalToSuperview()
            make.height.equalTo(collectionViewHeight)
            make.top.equalTo(seriesHeaderView.snp.bottom)
        }

        topEpisodesTableView = createEpisodesTableView()
        topEpisodesTableView.register(EpisodeTableViewCell.self, forCellReuseIdentifier: episodesReuseIdentifier)
        topEpisodesTableView.delegate = self<commit_msg>fix discover topic constraints<commit_after>//
//  DiscoverTopicViewController.swift
//  Podcast
//
//  Created by <NAME> on 2/17/18.
//  Copyright © 2018 Cornell App Development. All rights reserved.
//

import UIKit

/// Displays the discoverable content for a given topic. 
class DiscoverTopicViewController: DiscoverComponentViewController {

    var topicImageView: UIImageView!
    var topicLabel: UILabel!
    var relatedTopicsView: TrendingTopicsView!
    var episodesHeaderView: DiscoverCollectionViewHeaderView!
    var topEpisodesTableView: UITableView!
    var seriesHeaderView: DiscoverCollectionViewHeaderView!
    var topSeriesCollectionView: UICollectionView!

    let episodesReuseIdentifier = "episodes"
    let seriesReuseIdentifier = "series"
    let headerReuseIdentifier = "header"
    let episodesHeaderTag = 1
    let seriesHeaderTag = 2
    let collectionViewHeight: CGFloat = 160
    let imageViewHeight: CGFloat = 72
    let relatedTopicsHeight: CGFloat = 150

    var relatedTopics = [Topic]()
    var topEpisodes = [Episode]()
    var topSeries = [Series]()
    var parentTopic: Topic?

    var topic: Topic!
    var currentlyPlayingIndexPath: IndexPath?

    convenience init(topic: Topic, parentTopic: Topic? = nil) {
        self.init()
        self.topic = topic
        self.parentTopic = parentTopic
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        topicImageView = UIImageView(frame: .zero)
        contentView.addSubview(topicImageView)
        topicImageView.snp.makeConstraints { make in
            make.top.leading.trailing.width.equalToSuperview()
            make.height.equalTo(imageViewHeight)
        }

        topicLabel = UILabel(frame: .zero)
        topicLabel.font = ._16SemiboldFont()
        topicLabel.textColor = .offWhite
        topicLabel.textAlignment = .center
        contentView.addSubview(topicLabel)
        topicLabel.snp.makeConstraints { make in
            make.center.equalTo(topicImageView.snp.center)
        }

        relatedTopicsView = TrendingTopicsView(frame: .zero, type: .related)
        relatedTopicsView.isUserInteractionEnabled = true
        relatedTopicsView.dataSource = self
        relatedTopicsView.delegate = self
        contentView.addSubview(relatedTopicsView)
        relatedTopicsView.snp.makeConstraints { make in
            make.top.equalTo(topicImageView.snp.bottom)
            make.width.leading.trailing.equalToSuperview()
            make.height.greaterThanOrEqualTo(relatedTopicsHeight).priority(999)
        }

        seriesHeaderView = createCollectionHeaderView(type: .series, tag: seriesHeaderTag)
        seriesHeaderView.delegate = self
        seriesHeaderView.snp.makeConstraints { make in
            make.leading.trailing.width.equalToSuperview()
            make.top.equalTo(relatedTopicsView.snp.bottom)
            make.height.equalTo(headerHeight)
        }

        topSeriesCollectionView = createCollectionView(type: .discover)
        topSeriesCollectionView.register(SeriesGridCollectionViewCell.self, forCellWithReuseIdentifier: episodesReuseIdentifier)
        topSeriesCollectionView.delegate = self
        topSeriesCollectionView.dataSource = self
        topSeriesCollectionView.snp.makeConstraints { make in
            make.width.leading.trailing.equalToSuperview()
            make.height.equalTo(collectionViewHeight)
            make.top.equalTo(seriesHeaderView.snp.bottom)
        }

        topEpisodesTableView = createEpisodesTableView()
        topEpisodesTableView.register(EpisodeTableViewCell.self, forCellReuseIdentifier: episodesReuseIdentifier)
        topEpisodesTableView.delegate = self
{'fraction_non_alphanumeric': 0.07440394628665388, 'fraction_numerical': 0.006166072896684023, 'mean_word_length': 3.1260599208592423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4428147', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1971, 'n_words': 378}