<commit_before>import UIKit

class VOnboard:UIView, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout
{
    private weak var viewOptions:VOnboardOptions!
    private weak var controller:COnboard!
    private weak var collectionView:UICollectionView!
    private weak var labelDisclaimer:UILabel!
    private let kOptionsHeight:CGFloat = 36
    private let kDisclaimerHeight:CGFloat = 80
    
    convenience init(controller:COnboard)
    {
        self.init()
        backgroundColor = UIColor.white
        translatesAutoresizingMaskIntoConstraints = false
        clipsToBounds = true
        self.controller = controller
        
        let viewOptions:VOnboardOptions = VOnboardOptions(controller:controller)
        self.viewOptions = viewOptions
        
        let flow:UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        flow.headerReferenceSize = CGSize.zero
        flow.footerReferenceSize = CGSize.zero
        flow.minimumLineSpacing = 0
        flow.minimumInteritemSpacing = 0
        flow.scrollDirection = UICollectionViewScrollDirection.horizontal
        flow.sectionInset = UIEdgeInsets.zero
        
        let collectionView:UICollectionView = UICollectionView(frame:CGRect.zero, collectionViewLayout:flow)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.backgroundColor = UIColor.clear
        collectionView.clipsToBounds = true
        collectionView.showsVerticalScrollIndicator = false
        collectionView.showsHorizontalScrollIndicator = false
        collectionView.alwaysBounceHorizontal = true
        collectionView.isPagingEnabled = true
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(
            VOnboardCell.self,
            forCellWithReuseIdentifier:
            VOnboardCell.reusableIdentifier)
        self.collectionView = collectionView
        
        let labelDisclaimer:UILabel = UILabel()
        labelDisclaimer.isUserInteractionEnabled = false
        labelDisclaimer.translatesAutoresizingMaskIntoConstraints = false
        labelDisclaimer.backgroundColor = UIColor.clear
        labelDisclaimer.font = UIFont.regular(size:16)
        labelDisclaimer.textColor = UIColor(white:0.3, alpha:1)
        labelDisclaimer.numberOfLines = 0
        labelDisclaimer.textAlignment = NSTextAlignment.center
        labelDisclaimer.text = NSLocalizedString("VOnboard_labelDisclaimer", comment:"")
        self.labelDisclaimer = labelDisclaimer
        
        addSubview(collectionView)
        addSubview(labelDisclaimer)
        addSubview(viewOptions)
        
        let views:[String:UIView] = [
            "collectionView":collectionView,
            "viewOptions":viewOptions,
            "labelDisclaimer":labelDisclaimer]
        
        let metrics:[String:CGFloat] = [
            "optionsHeight":kOptionsHeight,
            "disclaimerHeight":kDisclaimerHeight]
        
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[collectionView]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[viewOptions]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-10-[labelDisclaimer]-10-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:
            "V:|-0-[collectionView]-0-[viewOptions(optionsHeight)]-0-[labelDisclaimer(disclaimerHeight)]-0-|",
            options:[],
            metrics:metrics,
            views:views))
    }
    
    override func layoutSubviews()
    {
        collectionView.contentOffset = CGPoint.zero
        collectionView.collectionViewLayout.invalidateLayout()
        super.layoutSubviews()
    }
    
    //MARK: private
    
    private func modelAtIndex(index:IndexPath) -> MOnboardItem
    {
        let item:MOnboardItem = controller.model.items[index.item]
        
        return item
    }
    
    //MARK: collectionView delegate
    
    func collectionView(_ collectionView:UICollectionView, layout collectionViewLayout:UICollectionViewLayout, sizeForItemAt indexPath:IndexPath) -> CGSize
    {
        let width:CGFloat = collectionView.bounds.maxX
        let height:CGFloat = collectionView.bounds.maxY<commit_msg>page controller<commit_after>import UIKit

class VOnboard:UIView, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout
{
    private weak var viewOptions:VOnboardOptions!
    private weak var controller:COnboard!
    private weak var collectionView:UICollectionView!
    private weak var labelDisclaimer:UILabel!
    private weak var pageController:UIPageControl!
    private let kOptionsHeight:CGFloat = 34
    private let kDisclaimerHeight:CGFloat = 70
    private let kPageControlHeight:CGFloat = 15
    
    convenience init(controller:COnboard)
    {
        self.init()
        backgroundColor = UIColor.white
        translatesAutoresizingMaskIntoConstraints = false
        clipsToBounds = true
        self.controller = controller
        
        let pageControl:UIPageControl = UIPageControl()
        pageControl.isUserInteractionEnabled = false
        pageControl.currentPageIndicatorTintColor = UIColor.complement
        pageControl.pageIndicatorTintColor = UIColor.complement.withAlphaComponent(0.2)
        pageControl.translatesAutoresizingMaskIntoConstraints = false
        pageControl.numberOfPages = controller.model.items.count
        pageControl.currentPage = 0
        self.pageController = pageControl
        
        let viewOptions:VOnboardOptions = VOnboardOptions(controller:controller)
        self.viewOptions = viewOptions
        
        let flow:UICollectionViewFlowLayout = UICollectionViewFlowLayout()
        flow.headerReferenceSize = CGSize.zero
        flow.footerReferenceSize = CGSize.zero
        flow.minimumLineSpacing = 0
        flow.minimumInteritemSpacing = 0
        flow.scrollDirection = UICollectionViewScrollDirection.horizontal
        flow.sectionInset = UIEdgeInsets.zero
        
        let collectionView:UICollectionView = UICollectionView(frame:CGRect.zero, collectionViewLayout:flow)
        collectionView.translatesAutoresizingMaskIntoConstraints = false
        collectionView.backgroundColor = UIColor.clear
        collectionView.clipsToBounds = true
        collectionView.showsVerticalScrollIndicator = false
        collectionView.showsHorizontalScrollIndicator = false
        collectionView.alwaysBounceHorizontal = true
        collectionView.isPagingEnabled = true
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(
            VOnboardCell.self,
            forCellWithReuseIdentifier:
            VOnboardCell.reusableIdentifier)
        self.collectionView = collectionView
        
        let labelDisclaimer:UILabel = UILabel()
        labelDisclaimer.isUserInteractionEnabled = false
        labelDisclaimer.translatesAutoresizingMaskIntoConstraints = false
        labelDisclaimer.backgroundColor = UIColor.clear
        labelDisclaimer.font = UIFont.regular(size:13)
        labelDisclaimer.textColor = UIColor(white:0.3, alpha:1)
        labelDisclaimer.numberOfLines = 0
        labelDisclaimer.textAlignment = NSTextAlignment.center
        labelDisclaimer.text = NSLocalizedString("VOnboard_labelDisclaimer", comment:"")
        self.labelDisclaimer = labelDisclaimer
        
        addSubview(collectionView)
        addSubview(labelDisclaimer)
        addSubview(viewOptions)
        addSubview(pageControl)
        
        let views:[String:UIView] = [
            "collectionView":collectionView,
            "viewOptions":viewOptions,
            "labelDisclaimer":labelDisclaimer,
            "pageControl":pageControl]
        
        let metrics:[String:CGFloat] = [
            "optionsHeight":kOptionsHeight,
            "disclaimerHeight":kDisclaimerHeight,
            "pageControlHeight":kPageControlHeight]
        
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[collectionView]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[viewOptions]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-10-[labelDisclaimer]-10-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:"H:|-0-[pageControl]-0-|",
            options:[],
            metrics:metrics,
            views:views))
        addConstraints(NSLayoutConstraint.constraints(
            withVisualFormat:
            "V:|-0-[collectionView]-0-[pageControl(pageControlHeight)]-5-[viewOptions(optionsHeight)]-0-[labelDisclaimer(disclaimerHeight)]-0-|",
            options:[],
            metrics:metrics,
            views:views))
    }
    
    override func layoutSubviews()
    {
        collectionView.contentOffset = CGPoint.zero
        collectionView.collectionViewLayout.invalidateLayout()
        super.layoutSubviews()
    }
    
    //MARK: private
    
    private func modelAtIndex(index:IndexPath) -> MOnboardItem
    {
        let item:MOnboardItem = controller.model.items[index.item]
        
        return item
    }
    
    //MARK: collectionView delegate
    
    func scrollViewDidScroll(_ scrollView:UIScrollView)
    {
        let width:CGFloat = scrollView.bounds.maxX
        let height:CGFloat = scrollView.bounds.maxY
        let width_2:CGFloat = width / 2.0
        let height_2:CGFloat = height / 2.0
        let offsetX:CGFloat = scrollView.contentOffset.x
        let compoundPos:CGFloat = width_2 + offsetX
        let point:CGPoint = CGPoint(x:offsetX, y:height_2)
        
        guard
            
            let indexPath:IndexPath = collectionView.indexPathForItem(at:point)
        
        else
        {
            return
        }
        
        let itemPath:Int = indexPath.item
        pageController.currentPage = itemPath
    }
    
    func collectionView(_ collectionView:UICollectionView, layout collectionViewLayout:UICollectionViewLayout, sizeForItemAt indexPath:IndexPath) -> CGSize
    {
        let width:CGFloat = collectionView.bounds.maxX
        let height:CGFloat = collectionView.bounds.maxY
{'fraction_non_alphanumeric': 0.07412884739809594, 'fraction_numerical': 0.005915518994361771, 'mean_word_length': 2.69031377899045, 'pattern_counts': {'":': 12, '<': 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': '3381843', 'n_tokens_mistral': 2806, 'n_tokens_neox': 2758, 'n_words': 434}