<commit_before>//
//  NewGalleryViewController.swift
//  ImageViewer
//
//  Created by <NAME> on 01/07/2016.
//  Copyright © 2016 MailOnline. All rights reserved.
//

import UIKit

public class NewGalleryViewController: UIPageViewController {

    //VIEWS
    let overlayView = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
    
    /// CONFIGURATION
    private var spineDividerWidth: Float = 10
    
    init(startIndex: Int, itemsDatasource: GalleryItemsDatasource, displacedViewsDatasource: GalleryDisplacedViewsDatasource? = nil, configuration: GalleryConfiguration = []) {
        
        super.init(transitionStyle: UIPageViewControllerTransitionStyle.Scroll,
                   navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal,
                   options: [UIPageViewControllerOptionInterPageSpacingKey : NSNumber(float: spineDividerWidth)])
        
        
        configureInitialImageController(itemsDatasource, displacedViewsDatasource: displacedViewsDatasource, configuration: configuration)
    }

    @available(*, unavailable)
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func configureInitialImageController(itemsDatasource: GalleryItemsDatasource, displacedViewsDatasource: GalleryDisplacedViewsDatasource? = nil, configuration: GalleryConfiguration = []) {
        
        let initialImageController = GalleryItemViewController(itemsDatasource: itemsDatasource, displacedViewsDatasource: displacedViewsDatasource, configuration: configuration)
        
        self.setViewControllers([initialImageController], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
        
        
        self.modalPresentationStyle = .OverFullScreen
    }
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        
        view.addSubview(overlayView)
        view.sendSubviewToBack(overlayView)
        
        overlayView.alpha = 0
        overlayView.contentView.backgroundColor = UIColor.blackColor()
        
        let transparencySCrubber = UISlider(frame: CGRect(origin: CGPoint(x: 20, y: 200), size: CGSize(width: 250, height: 40)))
        transparencySCrubber.minimumValue = 0
        transparencySCrubber.maximumValue = 1000
        transparencySCrubber.value = 0
        transparencySCrubber.addTarget(self, action: #selector(transparencyValueChanged), forControlEvents: UIControlEvents.ValueChanged)
        view.addSubview(transparencySCrubber)
    }
    
    public override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        overlayView.frame = view.bounds
    }
    
    func transparencyValueChanged(sender: UISlider) {
        
        let blurMin:Float = 0
        let blurMax: Float = 500
        let blurScopedValue = max(min(sender.value, blurMax), blurMin) - blurMin
        let blurRange = blurMax - blurMin
        let blurAlpha = CGFloat(blurScopedValue / blurRange)
        
        let contentMin:Float = 0
        let contentMax: Float = 1000
        let contentScope = max(min(sender.value, contentMax), contentMin) - contentMin
        let contentRange = contentMax - contentMin
        let contentAlpha = CGFloat(contentScope / contentRange)

        overlayView.alpha = blurAlpha
        overlayView.contentView.alpha = contentAlpha

    }
}<commit_msg>Managed to do continuous blur.<commit_after>//
//  NewGalleryViewController.swift
//  ImageViewer
//
//  Created by <NAME> on 01/07/2016.
//  Copyright © 2016 MailOnline. All rights reserved.
//

import UIKit

public class NewGalleryViewController: UIPageViewController {

    //VIEWS
    let overlayView = UIVisualEffectView(effect: nil)
    
    /// CONFIGURATION
    private var spineDividerWidth: Float = 10
    
    init(startIndex: Int, itemsDatasource: GalleryItemsDatasource, displacedViewsDatasource: GalleryDisplacedViewsDatasource? = nil, configuration: GalleryConfiguration = []) {
        
        super.init(transitionStyle: UIPageViewControllerTransitionStyle.Scroll,
                   navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal,
                   options: [UIPageViewControllerOptionInterPageSpacingKey : NSNumber(float: spineDividerWidth)])
        
        configureInitialImageController(itemsDatasource, displacedViewsDatasource: displacedViewsDatasource, configuration: configuration)
    }

    @available(*, unavailable)
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func configureInitialImageController(itemsDatasource: GalleryItemsDatasource, displacedViewsDatasource: GalleryDisplacedViewsDatasource? = nil, configuration: GalleryConfiguration = []) {
        
        let initialImageController = GalleryItemViewController(itemsDatasource: itemsDatasource, displacedViewsDatasource: displacedViewsDatasource, configuration: configuration)
        
        self.setViewControllers([initialImageController], direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil)
        
        
        self.modalPresentationStyle = .OverFullScreen
    }
    
    override public func viewDidLoad() {
        super.viewDidLoad()
        
        view.addSubview(overlayView)
        view.sendSubviewToBack(overlayView)
        
        overlayView.contentView.alpha = 0
        overlayView.contentView.backgroundColor = UIColor.blackColor()
        
        let transparencySCrubber = UISlider(frame: CGRect(origin: CGPoint(x: 20, y: 200), size: CGSize(width: 250, height: 40)))
        transparencySCrubber.minimumValue = 0
        transparencySCrubber.maximumValue = 1000
        transparencySCrubber.value = 0
        transparencySCrubber.addTarget(self, action: #selector(transparencyValueChanged), forControlEvents: UIControlEvents.ValueChanged)
        view.addSubview(transparencySCrubber)
    }

    public override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)

        overlayView.layer.speed = 0

        UIView.animateWithDuration(1) { 

            self.overlayView.effect = UIBlurEffect(style: .Light)
        }
    }
    
    public override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        overlayView.frame = view.bounds
    }
    
    func transparencyValueChanged(sender: UISlider) {
        
        let blurMin:Float = 0
        let blurMax: Float = 500
        let blurScopedValue = max(min(sender.value, blurMax), blurMin) - blurMin
        let blurRange = blurMax - blurMin
        let blurAlpha = CGFloat(blurScopedValue / blurRange)
        
        let contentMin:Float = 0
        let contentMax: Float = 800
        let contentScope = max(min(sender.value, contentMax), contentMin) - contentMin
        let contentRange = contentMax - contentMin
        let contentAlpha = CGFloat(contentScope / contentRange)

        overlayView.layer.timeOffset = CFTimeInterval(blurAlpha / 2)
        overlayView.contentView.alpha = contentAlpha

    }
}
{'fraction_non_alphanumeric': 0.07530968468468469, 'fraction_numerical': 0.011542792792792793, 'mean_word_length': 3.174500587544066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2395647', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1847, 'n_words': 382}