<commit_before>//
//  TLStickerPickerView.swift
//  TLStoryCamera
//
//  Created by GarryGuo on 2017/5/10.
//  Copyright © 2017年 GarryGuo. All rights reserved.
//

import UIKit

protocol TLStickerPickerViewDelegate: NSObjectProtocol {
    func stickerPickerDidSelectedStickers(img:UIImage) -> Void
    func stickerPickerHidden(view:TLStickerPickerView) -> Void
}

class TLStickerPickerView: UIVisualEffectView {
    fileprivate var handleView = UIView.init()
    
    fileprivate var handleBgView = UIView.init()
    
    fileprivate var collectionView:UICollectionView?
    
    public weak var delegate:TLStickerPickerViewDelegate?
    
    fileprivate var stickers:[UIImage] = {
        var array = [UIImage]()
        let plist = Bundle.main.path(forResource: "WBStoryStickers", ofType: "plist")
        if let p = plist, let stickers = NSArray.init(contentsOfFile: p) as? [[String:String]] {
            var i = 1
            for stickerDic in stickers {
                if let named = stickerDic["imageName"], let img = UIImage.imageWithStickers(named: named ) {
                    array.append(img)
                }
            }
        }
        return array
    }()
    
    fileprivate var pincheGesture:UIPanGestureRecognizer?
    
    fileprivate var beginPoint = CGPoint.zero
    
    fileprivate var offsetY:CGFloat = 0
    
    init(frame:CGRect) {
        super.init(effect: UIBlurEffect.init(style: .light))
        self.frame = frame
        
        let path = UIBezierPath.init(roundedRect: self.bounds, byRoundingCorners: [.topLeft,.topRight], cornerRadii: CGSize.init(width: 10, height: 10))
        let maskLayer = CAShapeLayer.init()
        maskLayer.frame = self.bounds
        maskLayer.path = path.cgPath
        
        let maskView = UIView(frame: self.bounds)
        maskView.backgroundColor = UIColor.black
        maskView.layer.mask = maskLayer
        self.mask = maskView
        
        let layout = UICollectionViewFlowLayout.init()
        layout.itemSize = CGSize.init(width: self.width / 3 - 20, height: self.width / 3)
        layout.minimumLineSpacing = 10
        layout.minimumInteritemSpacing = 10
        collectionView = UICollectionView.init(frame: self.bounds, collectionViewLayout: layout)
        collectionView!.backgroundColor = UIColor.clear
        collectionView!.delegate = self
        collectionView!.dataSource = self;
        collectionView!.contentInset = UIEdgeInsets.init(top: 20, left: 10, bottom: self.height - 380, right: 10)
        collectionView!.register(TLStickerCell.self, forCellWithReuseIdentifier: "cell")
        self.addSubview(collectionView!)
        
        self.addSubview(handleBgView)
        handleBgView.frame = CGRect.init(x: 0, y: 0, width: self.width, height: 30)
        handleBgView.isUserInteractionEnabled = true
        
        handleBgView.addSubview(handleView)
        handleView.bounds = CGRect.init(x: 0, y: 0, width: 40, height: 4)<commit_msg>+ fix stickerpicker display<commit_after>//
//  TLStickerPickerView.swift
//  TLStoryCamera
//
//  Created by GarryGuo on 2017/5/10.
//  Copyright © 2017年 GarryGuo. All rights reserved.
//

import UIKit

protocol TLStickerPickerViewDelegate: NSObjectProtocol {
    func stickerPickerDidSelectedStickers(img:UIImage) -> Void
    func stickerPickerHidden(view:TLStickerPickerView) -> Void
}

class TLStickerPickerView: UIVisualEffectView {
    fileprivate var handleView = UIView.init()
    
    fileprivate var handleBgView = UIView.init()
    
    fileprivate var collectionView:UICollectionView?
    
    public weak var delegate:TLStickerPickerViewDelegate?
    
    fileprivate var stickers:[UIImage] = {
        var array = [UIImage]()
        let plist = Bundle.main.path(forResource: "WBStoryStickers", ofType: "plist")
        if let p = plist, let stickers = NSArray.init(contentsOfFile: p) as? [[String:String]] {
            var i = 1
            for stickerDic in stickers {
                if let named = stickerDic["imageName"], let img = UIImage.imageWithStickers(named: named ) {
                    array.append(img)
                }
            }
        }
        return array
    }()
    
    fileprivate var pincheGesture:UIPanGestureRecognizer?
    
    fileprivate var beginPoint = CGPoint.zero
    
    fileprivate var offsetY:CGFloat = 0
    
    init(frame:CGRect) {
        super.init(effect: UIBlurEffect.init(style: .light))
        self.frame = frame
                
        let layout = UICollectionViewFlowLayout.init()
        layout.itemSize = CGSize.init(width: self.width / 3 - 20, height: self.width / 3)
        layout.minimumLineSpacing = 10
        layout.minimumInteritemSpacing = 10
        collectionView = UICollectionView.init(frame: self.bounds, collectionViewLayout: layout)
        collectionView!.backgroundColor = UIColor.clear
        collectionView!.delegate = self
        collectionView!.dataSource = self;
        collectionView!.contentInset = UIEdgeInsets.init(top: 20, left: 10, bottom: self.height - 380, right: 10)
        collectionView!.register(TLStickerCell.self, forCellWithReuseIdentifier: "cell")
        self.addSubview(collectionView!)
        
        self.addSubview(handleBgView)
        handleBgView.frame = CGRect.init(x: 0, y: 0, width: self.width, height: 30)
        handleBgView.isUserInteractionEnabled = true
        
        handleBgView.addSubview(handleView)
        handleView.bounds = CGRect.init(x: 0, y: 0, width: 40, height: 4)
{'fraction_non_alphanumeric': 0.09308705193855157, 'fraction_numerical': 0.014996342355523043, 'mean_word_length': 2.6754032258064515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6074844', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1609, 'n_words': 356}