<commit_before>//
//  BasicClueViewController.swift
//  Charles
//
//  Created by <NAME> on 6/16/17.
//  Copyright © 2017 Zero Mu, LLC. All rights reserved.
//

import Foundation
import UIKit

/******************************************************/
/*******************///MARK: A basic clue is one with up to 5 paragraphs that appear in order, with a title.  Presented to user over time to help them understand the game.
/******************************************************/

class BasicClueViewController: UIViewController {
    
    @IBOutlet weak var dismissButton: UIButton!
    
    @IBOutlet weak var stackView: UIStackView!
    @IBOutlet weak var clueTitle: UILabel!
    
    @IBOutlet weak var part1: UILabel!
    @IBOutlet weak var part1ImageView: UIImageView!
    @IBOutlet weak var part2: UILabel!
    @IBOutlet weak var part2ImageView: UIImageView!
    @IBOutlet weak var part3: UILabel!
    @IBOutlet weak var part3ImageView: UIImageView!
    
    var clue: Clue!
    
    var delayDismissButton = true
    
    var didLayout = false
    
    var overrideTextColor: UIColor? = nil
    var overrideGoldenRatio = false
    var overrideStackViewDistribution: UIStackViewDistribution? = nil
    
    var numNilSections = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        if delayDismissButton {
            dismissButton.isHidden = true
            dismissButton.isEnabled = true
            dismissButton.alpha = 0
        } else {
            dismissButton.isHidden = false
            dismissButton.isEnabled = true
            dismissButton.alpha = 1
        }
        
        //view.backgroundColor = .clear
        //view.isOpaque = false
        
        
        
        //self.preferredContentSize = CGSize(width: 100, height: 150)
        
    }
    
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        
        if let newDistribution = overrideStackViewDistribution {
            stackView.distribution = newDistribution
        }
        
        loadClue(clue: clue)
        
        if !didLayout {
            
            let width:CGFloat = self.view.bounds.width * 0.92
            let height:CGFloat = width * 1.618 //golden ratio
            
            let adjustedHeight:CGFloat
            
            if overrideGoldenRatio {
            
            let heightToRemove = CGFloat(numNilSections) * (height * (1.0/6.0)) - 100
                //allows some versions to get smaller
                //remove 1/6 - height of title and top bottom margins of the height for every nil section
                adjustedHeight = height - heightToRemove
            } else {
                adjustedHeight = height
            }
            
            
            self.view.superview!.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) //dim the background to focus on the modal
            let screen = self.view.superview!.bounds
            let frame = CGRect(x: 0, y: 0, width: width, height: adjustedHeight)
            let x = (screen.size.width - frame.size.width) * 0.5
            let y = (screen.size.height - frame.size.height) * 0.5
            let mainFrame = CGRect(x: x, y: y, width: frame.size.width, height: frame.size.height)
            
            self.view.frame = mainFrame
            
            didLayout = true
        }
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
//        if let part1Image = part1ImageView {
//            part1Image.roundCorners(with: 3)
//        }
//        if let part2Image = part2ImageView {
//            part2Image.roundCorners(with: 3)
//        }
//        if let part3Image = part3ImageView {
//            part3Image.roundCorners(with: 3)
//        }
        //stackView.roundCorners(with: 4)
       
        let radius = dismissButton.bounds.width / 2
        self.view.roundCorners(with: radius)<commit_msg>replaced the dim background of the modal clue to a blur effect<commit_after>//
//  BasicClueViewController.swift
//  Charles
//
//  Created by <NAME> on 6/16/17.
//  Copyright © 2017 Zero Mu, LLC. All rights reserved.
//

import Foundation
import UIKit

/******************************************************/
/*******************///MARK: A basic clue is one with up to 5 paragraphs that appear in order, with a title.  Presented to user over time to help them understand the game.
/******************************************************/

class BasicClueViewController: UIViewController {
    
    @IBOutlet weak var dismissButton: UIButton!
    
    @IBOutlet weak var stackView: UIStackView!
    @IBOutlet weak var clueTitle: UILabel!
    
    @IBOutlet weak var part1: UILabel!
    @IBOutlet weak var part1ImageView: UIImageView!
    @IBOutlet weak var part2: UILabel!
    @IBOutlet weak var part2ImageView: UIImageView!
    @IBOutlet weak var part3: UILabel!
    @IBOutlet weak var part3ImageView: UIImageView!
    
    var clue: Clue!
    
    var delayDismissButton = true
    
    var didLayout = false
    
    var overrideTextColor: UIColor? = nil
    var overrideGoldenRatio = false
    var overrideStackViewDistribution: UIStackViewDistribution? = nil
    
    var numNilSections = 0
    
    var blurEffectView = UIVisualEffectView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
        if delayDismissButton {
            dismissButton.isHidden = true
            dismissButton.isEnabled = true
            dismissButton.alpha = 0
        } else {
            dismissButton.isHidden = false
            dismissButton.isEnabled = true
            dismissButton.alpha = 1
        }
        
        //view.backgroundColor = .clear
        //view.isOpaque = false
        
        
        
        //self.preferredContentSize = CGSize(width: 100, height: 150)
        
    }
    
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        
        if let newDistribution = overrideStackViewDistribution {
            stackView.distribution = newDistribution
        }
        
        loadClue(clue: clue)
        
        if !didLayout {
            
            let width:CGFloat = self.view.bounds.width * 0.92
            let height:CGFloat = width * 1.618 //golden ratio
            
            let adjustedHeight:CGFloat
            
            if overrideGoldenRatio {
            
            let heightToRemove = CGFloat(numNilSections) * (height * (1.0/6.0)) - 100
                //allows some versions to get smaller
                //remove 1/6 - height of title and top bottom margins of the height for every nil section
                adjustedHeight = height - heightToRemove
            } else {
                adjustedHeight = height
            }
            
            
            self.view.superview!.backgroundColor = .clear //UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) //dim the background to focus on the modal
            let screen = self.view.superview!.bounds
            let frame = CGRect(x: 0, y: 0, width: width, height: adjustedHeight)
            let x = (screen.size.width - frame.size.width) * 0.5
            let y = (screen.size.height - frame.size.height) * 0.5
            let mainFrame = CGRect(x: x, y: y, width: frame.size.width, height: frame.size.height)
            
            self.view.frame = mainFrame
            
            //add a blur layer to background.
            //add blur effect
            let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
            blurEffectView = UIVisualEffectView(effect: blurEffect)
            blurEffectView.frame = self.view.superview!.bounds
            blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            
            self.view.superview!.insertSubview(blurEffectView, belowSubview: self.view)
            
            didLayout = true
        }
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        blurEffectView.removeFromSuperview()
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
//        if let part1Image = part1ImageView {
//            part1Image.roundCorners(with: 3)
//        }
//        if let part2Image = part2ImageView {
//            part2Image.roundCorners(with: 3)
//        }
//        if let part3Image = part3ImageView {
//            part3Image.roundCorners(with: 3)
//        }
        //stackView.roundCorners(with: 4)
       
        let radius = dismissButton.bounds.width / 2
        self.view.roundCorners(with: radius)
{'fraction_non_alphanumeric': 0.10681293302540416, 'fraction_numerical': 0.015242494226327945, 'mean_word_length': 1.8518274613105037, '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': '958175', 'n_tokens_mistral': 2473, 'n_tokens_neox': 2337, 'n_words': 635}