<commit_before>//
//  StackGrid.swift
//  StackGrid
//
//  Created by Jonas on 12/09/15.
//  Copyright © 2015 VFUC. All rights reserved.
//

import UIKit


/*
//MARK: Types
*/

struct TreeElement {
    var type: TreeElementType
    var child1ViewIndex, child2ViewIndex : Int?
    var set = false
    
    init(type: TreeElementType){
        self.type = type
    }
    
}

enum TreeElementType{
    case Node
    case Leaf
}







class StackGrid : UIView {
    
    /*
    //MARK: Properties
    */
    
    let rootNode: UIStackView = {
        let stackView = UIStackView()
        stackView.axis = .Vertical
        stackView.distribution = .FillEqually
        return stackView
        }()
    
    var tree = [TreeElement]()
    var views = [UIView]()
    
    
}<commit_msg>Root node is now properly pinning to edges of main view, added temporary testViews for testing (udontsay)<commit_after>//
//  StackGrid.swift
//  StackGrid
//
//  Created by Jonas on 12/09/15.
//  Copyright © 2015 VFUC. All rights reserved.
//

import UIKit


/*
//MARK: Types
*/

struct TreeElement {
    var type: TreeElementType
    var child1ViewIndex, child2ViewIndex : Int?
    var set = false
    
    init(type: TreeElementType){
        self.type = type
    }
    
}

enum TreeElementType{
    case Node
    case Leaf
}





/*
//MARK: - Class
*/

class StackGrid : UIView {
    
    /*
    //MARK: Properties
    */
    
    let rootNode: UIStackView = {
        let stackView = UIStackView()
        stackView.axis = .Vertical
        stackView.distribution = .FillEqually
        return stackView
        }()
    
    var tree = [TreeElement]()
    var views = [UIView]()
    
    
    
    
    
    /*
    //MARK: Methods
    */
    
    override func drawRect(rect: CGRect) {
        self.addSubview(rootNode)
        pinToEdges(rootNode)
    }
    
    
    func setGridViews(views: [UIView]) {
        let testView = UIView()
        testView.backgroundColor = UIColor.purpleColor()
        
        let testView2 = UIView()
        testView2.backgroundColor = UIColor.redColor()
        
        rootNode.addArrangedSubview(testView)
        rootNode.addArrangedSubview(testView2)
    }
    
    
    func pinToEdges(view: UIView) {
        view.translatesAutoresizingMaskIntoConstraints = false
        
        self.addConstraint(NSLayoutConstraint(
            item: view,
            attribute: .Left,
            relatedBy: .Equal,
            toItem: self,
            attribute: .Left,
            multiplier: 1,
            constant: 0))
        
        self.addConstraint(NSLayoutConstraint(
            item: view,
            attribute: .Right,
            relatedBy: .Equal,
            toItem: self,
            attribute: .Right,
            multiplier: 1,
            constant: 0))
        
        self.addConstraint(NSLayoutConstraint(
            item: view,
            attribute: .Top,
            relatedBy: .Equal,
            toItem: self,
            attribute: .Top,
            multiplier: 1,
            constant: 0))
        
        self.addConstraint(NSLayoutConstraint(
            item: view,
            attribute: .Bottom,
            relatedBy: .Equal,
            toItem: self,
            attribute: .Bottom,
            multiplier: 1,
            constant: 0))
    }
    
}
{'fraction_non_alphanumeric': 0.09420289855072464, 'fraction_numerical': 0.010567632850241546, 'mean_word_length': 1.58828125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5969693', 'n_tokens_mistral': 1018, 'n_tokens_neox': 977, 'n_words': 234}