<commit_before>//
//  Created by <NAME> on 03/05/16.
//  Copyright © 2016 Blurred Software SL. All rights reserved.
//

import UIKit
import Cartography
import Deferred
import BSWFoundation

public typealias ProfileEditionHandler = Void -> Void

public enum ClassicProfileEditKind {
    case NonEditable
    case Editable(UIBarButtonItem, ProfileEditionHandler)
}

public protocol ClassicProfileViewModel {
    var photos: [Photo] { get }
    var titleInfo: NSAttributedString { get }
    var detailsInfo: NSAttributedString { get }
    var extraInfo: [NSAttributedString] { get }
    var editKind: ClassicProfileEditKind { get }
}

public class ClassicProfileViewController: ScrollableStackViewController, AsyncViewModelPresenter {
    
    public var dataProvider: Future<Result<ClassicProfileViewModel>>!
    let photoGallery = PhotoGalleryView()
    let titleLabel = UILabel.unlimitedLinesLabel()
    let detailsLabel = UILabel.unlimitedLinesLabel()
    let bioLabel = UILabel.unlimitedLinesLabel()
    let separatorView: UIView = {
        let view = UIView()
        constrain(view) { view in
            view.height == 1
            view.width == 30
        }
        view.backgroundColor = UIColor.lightGrayColor()
        return view
    }()
    
    var navBarBehaviour: NavBarTransparentBehavior?
    
    override public func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = UIColor.whiteColor()

        //This is set to false in order to layout the image below the transparent navBar
        automaticallyAdjustsScrollViewInsets = false
        if let tabBar = tabBarController?.tabBar {
            scrollableStackView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: CGRectGetHeight(tabBar.frame), right: 0)
        }
        
        //This is the transparent navBar behaviour
        if let navBar = self.navigationController?.navigationBar {
            navBarBehaviour = NavBarTransparentBehavior(navBar: navBar, scrollView: scrollableStackView)
        }
        
        //Add the photoGallery
        photoGallery.delegate = self
        scrollableStackView.addArrangedSubview(photoGallery)
        constrain(photoGallery, scrollableStackView) { photoGallery, scrollableStackView in
            photoGallery.height == 280
            photoGallery.width == scrollableStackView.width
        }
        
        let layoutMargins = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
        scrollableStackView.addArrangedSubview(titleLabel, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(detailsLabel, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(separatorView, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(bioLabel, layoutMargins: layoutMargins)
    }
    
    override public func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        navBarBehaviour?.setNavBar(toState: .Regular)
    }<commit_msg>Change the ClassicProfileEditKind type<commit_after>//
//  Created by <NAME> on 03/05/16.
//  Copyright © 2016 Blurred Software SL. All rights reserved.
//

import UIKit
import Cartography
import Deferred
import BSWFoundation

public enum ClassicProfileEditKind {
    case NonEditable
    case Editable(UIBarButtonItem)
}

public protocol ClassicProfileViewModel {
    var photos: [Photo] { get }
    var titleInfo: NSAttributedString { get }
    var detailsInfo: NSAttributedString { get }
    var extraInfo: [NSAttributedString] { get }
}

public class ClassicProfileViewController: ScrollableStackViewController, AsyncViewModelPresenter {
    
    public var dataProvider: Future<Result<ClassicProfileViewModel>>!
    public var editKind: ClassicProfileEditKind = .NonEditable
    let photoGallery = PhotoGalleryView()
    let titleLabel = UILabel.unlimitedLinesLabel()
    let detailsLabel = UILabel.unlimitedLinesLabel()
    let bioLabel = UILabel.unlimitedLinesLabel()
    let separatorView: UIView = {
        let view = UIView()
        constrain(view) { view in
            view.height == 1
            view.width == 30
        }
        view.backgroundColor = UIColor.lightGrayColor()
        return view
    }()
    
    var navBarBehaviour: NavBarTransparentBehavior?
    
    override public func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = UIColor.whiteColor()

        //This is set to false in order to layout the image below the transparent navBar
        automaticallyAdjustsScrollViewInsets = false
        if let tabBar = tabBarController?.tabBar {
            scrollableStackView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: CGRectGetHeight(tabBar.frame), right: 0)
        }
        
        //This is the transparent navBar behaviour
        if let navBar = self.navigationController?.navigationBar {
            navBarBehaviour = NavBarTransparentBehavior(navBar: navBar, scrollView: scrollableStackView)
        }
        
        //Add the photoGallery
        photoGallery.delegate = self
        scrollableStackView.addArrangedSubview(photoGallery)
        constrain(photoGallery, scrollableStackView) { photoGallery, scrollableStackView in
            photoGallery.height == 280
            photoGallery.width == scrollableStackView.width
        }
        
        let layoutMargins = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
        scrollableStackView.addArrangedSubview(titleLabel, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(detailsLabel, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(separatorView, layoutMargins: layoutMargins)
        scrollableStackView.addArrangedSubview(bioLabel, layoutMargins: layoutMargins)
        
        //Add the rightBarButtonItem
        switch editKind {
        case .Editable(let barButton):
            navigationItem.rightBarButtonItem = barButton
        default:
            break
        }
    }
    
    override public func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        navBarBehaviour?.setNavBar(toState: .Regular)
    }
{'fraction_non_alphanumeric': 0.06966878773046174, 'fraction_numerical': 0.007505302659487682, 'mean_word_length': 3.0785096473719227, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5448380', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1650, 'n_words': 404}