<commit_before>//
//  GameViewController.swift
//  DYLive
//
//  Created by 渠晓友 on 2017/4/28.
//  Copyright © 2017年 xiaoyouPrince. All rights reserved.
//

import UIKit


private let kEdgeMargin : CGFloat = 10
private let kItemW : CGFloat = ( kScreenW - 2 * kEdgeMargin) / 3
private let kItemH : CGFloat = kItemW * 6 / 5
private let kHeaderViewH : CGFloat = 50
private let kGameViewH : CGFloat = 90

private let kGameCellID = "GameCellID"
private let kHeaderViewID = "kHeaderViewID"


class GameViewController: BaceViewController {
    
    // MARK: - gameVM
    fileprivate lazy var gameVM : GameViewModel = GameViewModel()
    // MARK: - 懒加载collectionView
    fileprivate lazy var collectionView : UICollectionView = {[unowned self] in
        
        // 1.创建layout
        let layout = UICollectionViewFlowLayout()
        layout.itemSize = CGSize(width: kItemW, height: kItemH)
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        layout.sectionInset = UIEdgeInsetsMake(0, kEdgeMargin, 0, kEdgeMargin)
        layout.headerReferenceSize = CGSize(width: kScreenW, height: kHeaderViewH)
        
        
        // 2.创建collectionView
        let collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: layout)
        collectionView.dataSource = self
        collectionView.backgroundColor = UIColor.white
        collectionView.autoresizingMask = [.flexibleHeight,.flexibleWidth]
        collectionView.register(UINib(nibName: "CollectionGameCell", bundle: nil), forCellWithReuseIdentifier: kGameCellID)
        collectionView.register(UINib(nibName: "CollectionHeaderView", bundle:nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: kHeaderViewID)
        
        return collectionView
        
    }()
    fileprivate lazy var gameView : RecommendGameView = {
    
        let gameView = RecommendGameView.creatGameView()
        gameView.frame = CGRect(x: 0, y: -kGameViewH, width: kScreenW, height: kGameViewH)
        return gameView
        
    }()
    fileprivate lazy var topHeaderView : CollectionHeaderView = {
    
        let topHeaderView = CollectionHeaderView.creatHeaderView()
        topHeaderView.frame = CGRect(x: 0, y: -(kHeaderViewH + kGameViewH), width: kScreenW, height: kHeaderViewH)
        
        topHeaderView.iconImageView.image = UIImage(named: "Img_orange")
        topHeaderView.nameLabel.text = "常见"
        topHeaderView.moreBtn.isHidden = true
        
        return topHeaderView
    }()
    

    override func viewDidLoad() {
        super.viewDidLoad()
        

        buildUI()

        loadData()
    }
    

}


// MARK: - 创建UI
extension GameViewController{
    
    internal func buildUI(){
        
        view.addSubview(collectionView)
        collectionView.addSubview(topHeaderView)
        collectionView.addSubview(gameView)
        collectionView.contentInset = UIEdgeInsetsMake(kGameViewH + kHeaderViewH, 0, kGameViewH + kHeaderViewH, 0)
        
    }
    
}

// MARK: - loadData<commit_msg>统一方法<commit_after>//
//  GameViewController.swift
//  DYLive
//
//  Created by 渠晓友 on 2017/4/28.
//  Copyright © 2017年 xiaoyouPrince. All rights reserved.
//

import UIKit


private let kEdgeMargin : CGFloat = 10
private let kItemW : CGFloat = ( kScreenW - 2 * kEdgeMargin) / 3
private let kItemH : CGFloat = kItemW * 6 / 5
private let kHeaderViewH : CGFloat = 50
private let kGameViewH : CGFloat = 90

private let kGameCellID = "GameCellID"
private let kHeaderViewID = "kHeaderViewID"


class GameViewController: BaceViewController {
    
    // MARK: - gameVM
    fileprivate lazy var gameVM : GameViewModel = GameViewModel()
    // MARK: - 懒加载collectionView
    fileprivate lazy var collectionView : UICollectionView = {[unowned self] in
        
        // 1.创建layout
        let layout = UICollectionViewFlowLayout()
        layout.itemSize = CGSize(width: kItemW, height: kItemH)
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        layout.sectionInset = UIEdgeInsetsMake(0, kEdgeMargin, 0, kEdgeMargin)
        layout.headerReferenceSize = CGSize(width: kScreenW, height: kHeaderViewH)
        
        
        // 2.创建collectionView
        let collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: layout)
        collectionView.dataSource = self
        collectionView.backgroundColor = UIColor.white
        collectionView.autoresizingMask = [.flexibleHeight,.flexibleWidth]
        collectionView.register(UINib(nibName: "CollectionGameCell", bundle: nil), forCellWithReuseIdentifier: kGameCellID)
        collectionView.register(UINib(nibName: "CollectionHeaderView", bundle:nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: kHeaderViewID)
        
        return collectionView
        
    }()
    fileprivate lazy var gameView : RecommendGameView = {
    
        let gameView = RecommendGameView.creatGameView()
        gameView.frame = CGRect(x: 0, y: -kGameViewH, width: kScreenW, height: kGameViewH)
        return gameView
        
    }()
    fileprivate lazy var topHeaderView : CollectionHeaderView = {
    
        let topHeaderView = CollectionHeaderView.creatHeaderView()
        topHeaderView.frame = CGRect(x: 0, y: -(kHeaderViewH + kGameViewH), width: kScreenW, height: kHeaderViewH)
        
        topHeaderView.iconImageView.image = UIImage(named: "Img_orange")
        topHeaderView.nameLabel.text = "常见"
        topHeaderView.moreBtn.isHidden = true
        
        return topHeaderView
    }()
    

    override func viewDidLoad() {
        super.viewDidLoad()
        

        buildUI()

        loadData()
    }
    

}


// MARK: - 创建UI
extension GameViewController{
    
    override func buildUI(){
        
        
        super.contentView = collectionView
        
        
        view.addSubview(collectionView)
        collectionView.addSubview(topHeaderView)
        collectionView.addSubview(gameView)
        collectionView.contentInset = UIEdgeInsetsMake(kGameViewH + kHeaderViewH, 0, kGameViewH + kHeaderViewH, 0)
        
        
        super.buildUI()
        
    }
    
}

// MARK: - loadData
{'fraction_non_alphanumeric': 0.0831323363884869, 'fraction_numerical': 0.009969448464383341, 'mean_word_length': 2.7515078407720144, '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': '6646146', 'n_tokens_mistral': 1958, 'n_tokens_neox': 1867, 'n_words': 398}