<commit_before>//
//  ViewController.swift
//  AbstractViewExample
//
//  Created by <NAME> on 11/17/15.
//  Copyright © 2015 Nuudles. All rights reserved.
//

import UIKit
import AbstractView

class ViewController: UIViewController
{
	// MARK: - Private properties
	@IBOutlet private weak var abstractView: AbstractView!

	// MARK: - Private UI properties
	private lazy var backgroundButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Turn on background image", forState: .Normal)
		button.addTarget(self, action: Selector("toggleButtonTapped:"), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var visualEffectButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Light blur", forState: .Normal)
		button.addTarget(self, action: Selector("toggleButtonTapped:"), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var shapeButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Only circles", forState: .Normal)
		button.addTarget(self, action: Selector("toggleButtonTapped:"), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var paletteButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Blue palette", forState: .Normal)
		button.addTarget(self, action: Selector("toggleButtonTapped:"), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var shapeCountLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Shape Count: \(self.abstractView.shapeCount)"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var shapeCountSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = 0
		slider.maximumValue = 200
		slider.value = Float(self.abstractView.shapeCount)
		slider.addTarget(self, action: Selector("sliderValueChanged:"), forControlEvents: .ValueChanged)
		return slider
	}()
	private lazy var minShapeSizeLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Min Shape Size: None"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var minShapeSizeSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = -1
		slider.maximumValue = 300
		slider.value = -1
		slider.addTarget(self, action: Selector("sliderValueChanged:"), forControlEvents: .ValueChanged)
		return slider
	}()
	private lazy var maxShapeSizeLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Max Shape Size: None"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var maxShapeSizeSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = -1
		slider.maximumValue = 300
		slider.value = -1
		slider.addTarget(self, action: Selector("sliderValueChanged:"), forControlEvents: .ValueChanged)
		return slider
	}()

	private lazy var backgroundImageView: UIImageView =
	{
		let imageView = UIImageView(image: UIImage(named: "space-wallpaper-29"))
		imageView.contentMode = .ScaleAspectFill
		return imageView
	}()

	// MARK: - View methods
	override func viewDidLoad()
	{
		super.viewDidLoad()

		abstractView.contentView.addSubview(backgroundButton)
		abstractView.contentView.addSubview(visualEffectButton)
		abstractView.contentView.addSubview(shapeButton)
		abstractView.contentView.addSubview(paletteButton)
		abstractView.contentView.addSubview(shapeCountLabel)
		abstractView.contentView.addSubview(shapeCountSlider)
		abstractView.contentView.addSubview(minShapeSizeLabel)
		abstractView.contentView.addSubview(minShapeSizeSlider)
		abstractView.contentView.addSubview(maxShapeSizeLabel)
		abstractView.contentView.addSubview(maxShapeSizeSlider)

		abstractView.shapeInitializers = [OvalShape.circleShapeInitializer, OvalShape.ovalShapeInitializer, RectangleShape.squareShapeInitializer, RectangleShape.rectangleShapeInitializer, TriangleShape.triangleShapeInitializer, DiamondShape.diamondShapeInitializer, { (relativeFrame, _) in return ImageShape(relativeFrame: relativeFrame, image: UIImage(named: "sparkle")!) }]
	}

	override func viewDidLayoutSubviews()
	{
		super.viewDidLayoutSubviews()

		backgroundButton.frame = CGRect(x: 10, y: topLayoutGuide.length + 10, width: view.bounds.size.width - 20, height: 40)
		visualEffectButton.frame = CGRect(x: 10, y: backgroundButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		shapeButton.frame = CGRect(x: 10, y: visualEffectButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		paletteButton.frame = CGRect(x: 10, y: shapeButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		shapeCountLabel.frame = CGRect(x: 10, y: paletteButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		shapeCountSlider.frame = CGRect(x: 10, y: shapeCountLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: shapeCountSlider.bounds.size.height)
		minShapeSizeLabel.frame = CGRect(x: 10, y: shapeCountSlider.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		minShapeSizeSlider.frame = CGRect(x: 10, y: minShapeSizeLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: minShapeSizeSlider.bounds.size.height)
		maxShapeSizeLabel.frame = CGRect(x: 10, y: minShapeSizeSlider.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		maxShapeSizeSlider.frame = CGRect(x: 10, y: maxShapeSizeLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: maxShapeSizeSlider.bounds.size.height)
	}

	// MARK: - Button action methods
	func toggleButtonTapped(sender: UIButton)
	{
		sender.tag++
		switch (sender, sender.tag)
		{
		case (backgroundButton, 1):
			abstractView.backgroundView = backgroundImageView
			sender.setTitle("Turn off background image", forState: .Normal)
		case (backgroundButton, 2):
			abstractView.backgroundView = nil
			sender.setTitle("Turn on background image", forState: .Normal)
			sender.tag = 0

		case (visualEffectButton, 1):
			abstractView.visualEffect = UIBlurEffect(style: .Light)
			sender.setTitle("Dark blur", forState: .Normal)
		case (visualEffectButton, 2):
			abstractView.visualEffect = UIBlurEffect(style: .Dark)
			sender.setTitle("No visual effect", forState: .Normal)
		case (visualEffectButton, 3):
			abstractView.visualEffect = nil<commit_msg>Update Example for Xcode 7.3 warnings<commit_after>//
//  ViewController.swift
//  AbstractViewExample
//
//  Created by <NAME> on 11/17/15.
//  Copyright © 2015 Nuudles. All rights reserved.
//

import UIKit
import AbstractView

class ViewController: UIViewController
{
	// MARK: - Private properties
	@IBOutlet private weak var abstractView: AbstractView!

	// MARK: - Private UI properties
	private lazy var backgroundButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Turn on background image", forState: .Normal)
		button.addTarget(self, action: #selector(ViewController.toggleButtonTapped(_:)), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var visualEffectButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Light blur", forState: .Normal)
		button.addTarget(self, action: #selector(ViewController.toggleButtonTapped(_:)), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var shapeButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Only circles", forState: .Normal)
		button.addTarget(self, action: #selector(ViewController.toggleButtonTapped(_:)), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var paletteButton: UIButton =
	{
		let button = UIButton(type: UIButtonType.System)
		button.setTitle("Blue palette", forState: .Normal)
		button.addTarget(self, action: #selector(ViewController.toggleButtonTapped(_:)), forControlEvents: .TouchUpInside)
		return button
	}()
	private lazy var shapeCountLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Shape Count: \(self.abstractView.shapeCount)"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var shapeCountSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = 0
		slider.maximumValue = 200
		slider.value = Float(self.abstractView.shapeCount)
		slider.addTarget(self, action: #selector(ViewController.sliderValueChanged(_:)), forControlEvents: .ValueChanged)
		return slider
	}()
	private lazy var minShapeSizeLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Min Shape Size: None"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var minShapeSizeSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = -1
		slider.maximumValue = 300
		slider.value = -1
		slider.addTarget(self, action: #selector(ViewController.sliderValueChanged(_:)), forControlEvents: .ValueChanged)
		return slider
	}()
	private lazy var maxShapeSizeLabel: UILabel =
	{
		let label = UILabel()
		label.textAlignment = .Center
		label.text = "Max Shape Size: None"
		label.font = UIFont.systemFontOfSize(14)
		return label
	}()
	private lazy var maxShapeSizeSlider: UISlider =
	{
		let slider = UISlider()
		slider.minimumValue = -1
		slider.maximumValue = 300
		slider.value = -1
		slider.addTarget(self, action: #selector(ViewController.sliderValueChanged(_:)), forControlEvents: .ValueChanged)
		return slider
	}()

	private lazy var backgroundImageView: UIImageView =
	{
		let imageView = UIImageView(image: UIImage(named: "space-wallpaper-29"))
		imageView.contentMode = .ScaleAspectFill
		return imageView
	}()

	// MARK: - View methods
	override func viewDidLoad()
	{
		super.viewDidLoad()

		abstractView.contentView.addSubview(backgroundButton)
		abstractView.contentView.addSubview(visualEffectButton)
		abstractView.contentView.addSubview(shapeButton)
		abstractView.contentView.addSubview(paletteButton)
		abstractView.contentView.addSubview(shapeCountLabel)
		abstractView.contentView.addSubview(shapeCountSlider)
		abstractView.contentView.addSubview(minShapeSizeLabel)
		abstractView.contentView.addSubview(minShapeSizeSlider)
		abstractView.contentView.addSubview(maxShapeSizeLabel)
		abstractView.contentView.addSubview(maxShapeSizeSlider)

		abstractView.shapeInitializers = [OvalShape.circleShapeInitializer, OvalShape.ovalShapeInitializer, RectangleShape.squareShapeInitializer, RectangleShape.rectangleShapeInitializer, TriangleShape.triangleShapeInitializer, DiamondShape.diamondShapeInitializer, { (relativeFrame, _) in return ImageShape(relativeFrame: relativeFrame, image: UIImage(named: "sparkle")!) }]
	}

	override func viewDidLayoutSubviews()
	{
		super.viewDidLayoutSubviews()

		backgroundButton.frame = CGRect(x: 10, y: topLayoutGuide.length + 10, width: view.bounds.size.width - 20, height: 40)
		visualEffectButton.frame = CGRect(x: 10, y: backgroundButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		shapeButton.frame = CGRect(x: 10, y: visualEffectButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		paletteButton.frame = CGRect(x: 10, y: shapeButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 40)
		shapeCountLabel.frame = CGRect(x: 10, y: paletteButton.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		shapeCountSlider.frame = CGRect(x: 10, y: shapeCountLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: shapeCountSlider.bounds.size.height)
		minShapeSizeLabel.frame = CGRect(x: 10, y: shapeCountSlider.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		minShapeSizeSlider.frame = CGRect(x: 10, y: minShapeSizeLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: minShapeSizeSlider.bounds.size.height)
		maxShapeSizeLabel.frame = CGRect(x: 10, y: minShapeSizeSlider.frame.maxY + 10, width: view.bounds.size.width - 20, height: 15)
		maxShapeSizeSlider.frame = CGRect(x: 10, y: maxShapeSizeLabel.frame.maxY + 5, width: view.bounds.size.width - 20, height: maxShapeSizeSlider.bounds.size.height)
	}

	// MARK: - Button action methods
	func toggleButtonTapped(sender: UIButton)
	{
		sender.tag += 1
		switch (sender, sender.tag)
		{
		case (backgroundButton, 1):
			abstractView.backgroundView = backgroundImageView
			sender.setTitle("Turn off background image", forState: .Normal)
		case (backgroundButton, 2):
			abstractView.backgroundView = nil
			sender.setTitle("Turn on background image", forState: .Normal)
			sender.tag = 0

		case (visualEffectButton, 1):
			abstractView.visualEffect = UIBlurEffect(style: .Light)
			sender.setTitle("Dark blur", forState: .Normal)
		case (visualEffectButton, 2):
			abstractView.visualEffect = UIBlurEffect(style: .Dark)
			sender.setTitle("No visual effect", forState: .Normal)
		case (visualEffectButton, 3):
			abstractView.visualEffect = nil
{'fraction_non_alphanumeric': 0.11184108826712011, 'fraction_numerical': 0.017081465450610605, 'mean_word_length': 5.074647887323944, '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': '3734188', 'n_tokens_mistral': 4582, 'n_tokens_neox': 4074, 'n_words': 919}