<commit_before>//
//  FeedElementTableViewCell.swift
//  Podcast
//
//  Created by <NAME> on 10/7/17.
//  Copyright © 2017 Cornell App Development. All rights reserved.
//

import UIKit
import SnapKit

protocol FeedElementTableViewCellDelegate: class {
    func feedElementTableViewCellDidPressEpisodeSubjectViewMoreButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewPlayPauseButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewBookmarkButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewTagButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView, index: Int)
    func feedElementTableViewCellDidPressEpisodeSubjectViewRecommendedButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressSupplierViewFeedControlButton(feedElementTableViewCell: FeedElementTableViewCell, supplierView: UserSeriesSupplierView)
}

class FeedElementTableViewCell: UITableViewCell, EpisodeSubjectViewDelegate, SupplierViewDelegate {
    
    var feedElementSubjectView: FeedElementSubjectView! //main view
    var feedElementSupplierView: FeedElementSupplierView! //top view
    
    var newlyReleasedEpisodeSupplierViewHeight: CGFloat = UserSeriesSupplierView.height
    var followingSubscriptionSupplierViewHieght: CGFloat = UserSeriesSupplierView.height
    var followingRecommendationSupplierViewHeight: CGFloat = UserSeriesSupplierView.height
    
    weak var delegate: FeedElementTableViewCellDelegate?
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
    }
    
    func setupWithFeedElement(feedElement: FeedElement) {
        
        var heightConstraint: CGFloat!
        
        switch feedElement.context {
        case .followingRecommendation:
            guard let user = feedElement.supplier as? User, let episode = feedElement.subject as? Episode else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: [user])
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = EpisodeSubjectView(episode: episode)
            (feedElementSubjectView as! EpisodeSubjectView).delegate = self
            heightConstraint = followingRecommendationSupplierViewHeight
        case .followingSubscription:
            guard let user = feedElement.supplier as? User, let series = feedElement.subject as? Series else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: [user])
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = SeriesSubjectView() //TODO: implement
//            (feedElementSubjectView as! SeriesSubjectView).delegate = self
            heightConstraint = followingSubscriptionSupplierViewHieght
        case .newlyReleasedEpisode:
            guard let series = feedElement.supplier as? Series, let episode = feedElement.subject as? Episode else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: series)
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = EpisodeSubjectView(episode: episode)<commit_msg>revert file<commit_after>//
//  FeedElementTableViewCell.swift
//  Podcast
//
//  Created by <NAME> on 10/7/17.
//  Copyright © 2017 Cornell App Development. All rights reserved.
//

import UIKit
import SnapKit

protocol FeedElementTableViewCellDelegate: class {
    func feedElementTableViewCellDidPressEpisodeSubjectViewMoreButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewPlayPauseButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewBookmarkButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressEpisodeSubjectViewTagButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView, index: Int)
    func feedElementTableViewCellDidPressEpisodeSubjectViewRecommendedButton(feedElementTableViewCell: FeedElementTableViewCell, episodeSubjectView: EpisodeSubjectView)
    func feedElementTableViewCellDidPressSupplierViewFeedControlButton(feedElementTableViewCell: FeedElementTableViewCell, supplierView: UserSeriesSupplierView)
}

class FeedElementTableViewCell: UITableViewCell, EpisodeSubjectViewDelegate, SupplierViewDelegate {
    
    var feedElementSubjectView: FeedElementSubjectView! //main view
    var feedElementSupplierView: FeedElementSupplierView! //top view
    
    var newlyReleasedEpisodeSupplierViewHeight: CGFloat = UserSeriesSupplierView.height
    var followingSubscriptionSupplierViewHieght: CGFloat = UserSeriesSupplierView.height
    var followingRecommendationSupplierViewHeight: CGFloat = UserSeriesSupplierView.height
    
    weak var delegate: FeedElementTableViewCellDelegate?
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
    }
    
    func setupWithFeedElement(feedElement: FeedElement) {
        
        var heightConstraint: CGFloat!
        
        switch feedElement.context {
        case .followingRecommendation:
            guard let user = feedElement.supplier as? User, let episode = feedElement.subject as? Episode else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: [user])
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = EpisodeSubjectView(episode: episode)
            (feedElementSubjectView as! EpisodeSubjectView).delegate = self
            heightConstraint = followingRecommendationSupplierViewHeight
        case .followingSubscription:
            guard let user = feedElement.supplier as? User, let series = feedElement.subject as? Series else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: [user])
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = SeriesSubjectView() //TODO: implement
            //(feedElementSubjectView as! SeriesSubjectView).delegate = self
            heightConstraint = followingSubscriptionSupplierViewHieght
        case .newlyReleasedEpisode:
            guard let series = feedElement.supplier as? Series, let episode = feedElement.subject as? Episode else { return }
            feedElementSupplierView = UserSeriesSupplierView(supplier: series)
            (feedElementSupplierView as! UserSeriesSupplierView).delegate = self
            feedElementSubjectView = EpisodeSubjectView(episode: episode)
{'fraction_non_alphanumeric': 0.054614964500273075, 'fraction_numerical': 0.0024576734025122883, 'mean_word_length': 4.704828660436137, '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': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3383758', 'n_tokens_mistral': 1837, 'n_tokens_neox': 1765, 'n_words': 388}