<commit_before>//
//  ProfileViewController.swift
//  Podcast
//
//  Created by <NAME> on 10/12/16.
//  Copyright © 2016 Cornell App Development. All rights reserved.
//

import UIKit
import NVActivityIndicatorView

class ExternalProfileViewController: ViewController, UITableViewDataSource, UITableViewDelegate, ProfileHeaderViewDelegate, RecommendedSeriesTableViewCellDelegate, RecommendedSeriesTableViewCellDataSource, RecommendedEpisodesOuterTableViewCellDelegate, RecommendedEpisodesOuterTableViewCellDataSource {
    
    var profileHeaderView: ProfileHeaderView!
    var miniHeader: ProfileMiniHeader!
    var profileTableView: UITableView!
    var backButton: UIButton!
    
    var loadingAnimation: NVActivityIndicatorView!
    
    let headerViewHeight = ProfileHeaderView.height
    let miniBarHeight = ProfileHeaderView.miniBarHeight
    let sectionHeaderHeight: CGFloat = 37

    let padding: CGFloat = 16
    let backButtonHeight: CGFloat = 21
    let backButtonWidth: CGFloat = 56
    let iPhoneXOffset: CGFloat = 10

    var scrollYOffset: CGFloat = 109
    
    let FooterHeight: CGFloat = 0
    var sectionNames = ["Subscriptions", "Recommended"]
    let sectionHeaderHeights: [CGFloat] = [52, 52]
    let sectionContentClasses: [AnyClass] = [RecommendedSeriesTableViewCell.self, RecommendedEpisodesOuterTableViewCell.self]
    let sectionContentIndentifiers = ["SeriesCell", "EpisodesCell"]
    var user: User?
    var favorites: [Episode] = []
    var subscriptions: [Series] = []
    
    convenience init(user: User) {
        self.init()
        self.user = user
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .paleGrey
        
        if UIScreen.main.nativeBounds.height == 2436 { scrollYOffset -= iPhoneXOffset }
        
        let profileHeaderEmptyFrame = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: ProfileHeaderView.profileAreaHeight))
        profileHeaderEmptyFrame.backgroundColor = .sea
        view.addSubview(profileHeaderEmptyFrame)
        
        profileTableView = UITableView(frame: .zero, style: .grouped)
        for (contentClass, identifier) in zip(sectionContentClasses, sectionContentIndentifiers) {
            profileTableView.register(contentClass.self, forCellReuseIdentifier: identifier)
        }
        profileTableView.delegate = self
        profileTableView.dataSource = self
        profileTableView.backgroundColor = .paleGrey
        profileTableView.rowHeight = UITableViewAutomaticDimension
        profileTableView.separatorStyle = .none
        profileTableView.showsVerticalScrollIndicator = false
        mainScrollView = profileTableView
        view.addSubview(profileTableView)
        profileTableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        let backgroundExtender = UIView(frame: CGRect(x: 0, y: 0-view.frame.height+20, width: view.frame.width, height: view.frame.height))
        backgroundExtender.backgroundColor = .sea
        profileTableView.addSubview(backgroundExtender)
        profileTableView.sendSubview(toBack: backgroundExtender)
        
        // Instantiate tableViewHeader and the minified header
        profileHeaderView = ProfileHeaderView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: headerViewHeight))
        profileTableView.tableHeaderView = profileHeaderView
        profileHeaderView.delegate = self
        
        miniHeader = ProfileMiniHeader(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: miniBarHeight))
        view.addSubview(miniHeader)
        
        backButton = UIButton(type: .custom)
        //backButton.frame = CGRect(x: padding, y: ProfileHeaderView.statusBarHeight + (ProfileHeaderView.miniBarHeight - ProfileHeaderView.statusBarHeight - backButtonHeight) / 2, width: backButtonWidth, height: backButtonHeight)
        backButton.setImage(UIImage(named: "backArrowLeft"), for: .normal)
        backButton.contentHorizontalAlignment = .left
        backButton.adjustsImageWhenHighlighted = true
        backButton.addTarget(self, action: #selector(didPressBackButton), for: .touchUpInside)
        view.addSubview(backButton)
        backButton.snp.makeConstraints { make in
            make.leading.equalToSuperview().inset(padding)
            make.top.equalToSuperview().inset(ProfileHeaderView.statusBarHeight + (ProfileHeaderView.miniBarHeight - ProfileHeaderView.statusBarHeight - backButtonHeight) / 2)
            make.width.equalTo(backButtonWidth)
            make.height.equalTo(backButtonHeight)
        }
        
        loadingAnimation = LoadingAnimatorUtilities.createLoadingAnimator()
        loadingAnimation.center = view.center
        view.addSubview(loadingAnimation)
        loadingAnimation.startAnimating()
        UIApplication.shared.statusBarStyle = .lightContent
        view.bringSubview(toFront: backButton)
        
        if let user = user {
            setUser(user: user)<commit_msg>shifted back button over and up<commit_after>//
//  ProfileViewController.swift
//  Podcast
//
//  Created by <NAME> on 10/12/16.
//  Copyright © 2016 Cornell App Development. All rights reserved.
//

import UIKit
import NVActivityIndicatorView

class ExternalProfileViewController: ViewController, UITableViewDataSource, UITableViewDelegate, ProfileHeaderViewDelegate, RecommendedSeriesTableViewCellDelegate, RecommendedSeriesTableViewCellDataSource, RecommendedEpisodesOuterTableViewCellDelegate, RecommendedEpisodesOuterTableViewCellDataSource {
    
    var profileHeaderView: ProfileHeaderView!
    var miniHeader: ProfileMiniHeader!
    var profileTableView: UITableView!
    var backButton: UIButton!
    
    var loadingAnimation: NVActivityIndicatorView!
    
    let headerViewHeight = ProfileHeaderView.height
    let miniBarHeight = ProfileHeaderView.miniBarHeight
    let sectionHeaderHeight: CGFloat = 37

    let padding: CGFloat = 20
    let backButtonHeight: CGFloat = 21
    let backButtonWidth: CGFloat = 56
    let iPhoneXOffset: CGFloat = 10

    var scrollYOffset: CGFloat = 109
    
    let FooterHeight: CGFloat = 0
    var sectionNames = ["Subscriptions", "Recommended"]
    let sectionHeaderHeights: [CGFloat] = [52, 52]
    let sectionContentClasses: [AnyClass] = [RecommendedSeriesTableViewCell.self, RecommendedEpisodesOuterTableViewCell.self]
    let sectionContentIndentifiers = ["SeriesCell", "EpisodesCell"]
    var user: User?
    var favorites: [Episode] = []
    var subscriptions: [Series] = []
    
    convenience init(user: User) {
        self.init()
        self.user = user
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .paleGrey
        
        if UIScreen.main.nativeBounds.height == 2436 { scrollYOffset -= iPhoneXOffset }
        
        let profileHeaderEmptyFrame = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: ProfileHeaderView.profileAreaHeight))
        profileHeaderEmptyFrame.backgroundColor = .sea
        view.addSubview(profileHeaderEmptyFrame)
        
        profileTableView = UITableView(frame: .zero, style: .grouped)
        for (contentClass, identifier) in zip(sectionContentClasses, sectionContentIndentifiers) {
            profileTableView.register(contentClass.self, forCellReuseIdentifier: identifier)
        }
        profileTableView.delegate = self
        profileTableView.dataSource = self
        profileTableView.backgroundColor = .paleGrey
        profileTableView.rowHeight = UITableViewAutomaticDimension
        profileTableView.separatorStyle = .none
        profileTableView.showsVerticalScrollIndicator = false
        mainScrollView = profileTableView
        view.addSubview(profileTableView)
        profileTableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        let backgroundExtender = UIView(frame: CGRect(x: 0, y: 0-view.frame.height+20, width: view.frame.width, height: view.frame.height))
        backgroundExtender.backgroundColor = .sea
        profileTableView.addSubview(backgroundExtender)
        profileTableView.sendSubview(toBack: backgroundExtender)
        
        // Instantiate tableViewHeader and the minified header
        profileHeaderView = ProfileHeaderView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: headerViewHeight))
        profileTableView.tableHeaderView = profileHeaderView
        profileHeaderView.delegate = self
        
        miniHeader = ProfileMiniHeader(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: miniBarHeight))
        view.addSubview(miniHeader)
        
        backButton = UIButton(type: .custom)
        //backButton.frame = CGRect(x: padding, y: ProfileHeaderView.statusBarHeight + (ProfileHeaderView.miniBarHeight - ProfileHeaderView.statusBarHeight - backButtonHeight) / 2, width: backButtonWidth, height: backButtonHeight)
        backButton.setImage(UIImage(named: "backArrowLeft"), for: .normal)
        backButton.contentHorizontalAlignment = .left
        backButton.adjustsImageWhenHighlighted = true
        backButton.addTarget(self, action: #selector(didPressBackButton), for: .touchUpInside)
        view.addSubview(backButton)
        backButton.snp.makeConstraints { make in
            make.leading.equalToSuperview().inset(padding)
            make.top.equalToSuperview().inset(UIApplication.shared.statusBarFrame.height + (miniBarHeight - UIApplication.shared.statusBarFrame.height - backButtonHeight) / 2)
            make.width.equalTo(backButtonWidth)
            make.height.equalTo(backButtonHeight)
        }
        
        loadingAnimation = LoadingAnimatorUtilities.createLoadingAnimator()
        loadingAnimation.center = view.center
        view.addSubview(loadingAnimation)
        loadingAnimation.startAnimating()
        UIApplication.shared.statusBarStyle = .lightContent
        view.bringSubview(toFront: backButton)
        
        if let user = user {
            setUser(user: user)
{'fraction_non_alphanumeric': 0.07898406374501991, 'fraction_numerical': 0.008764940239043825, 'mean_word_length': 3.3751633986928105, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006315', 'n_tokens_mistral': 2823, 'n_tokens_neox': 2679, 'n_words': 554}