<commit_before>//
//  PhotoPopupView.swift
//  EventBlank
//
//  Created by <NAME> on 8/23/15.
//  Copyright (c) 2015 Underplot ltd. All rights reserved.
//

import UIKit
import Haneke

class PhotoPopupView: UIView {

    static func showImage(image: UIImage, inView: UIView) {
        let popup = PhotoPopupView()
        inView.addSubview(popup)
        
        popup.photo = image
    }

    static func showImageWithUrl(url: NSURL, inView: UIView) {
        let popup = PhotoPopupView()
        inView.addSubview(popup)
        
        popup.photoUrl = url
    }
    
    var photoUrl: NSURL! {
        didSet {
            imgView.hnk_setImageFromURL(photoUrl)
        }
    }
    
    var photo: UIImage! {
        didSet {
            imgView.image = photo
        }
    }
    
    var imgView: UIImageView!
    
    override func didMoveToSuperview() {
        super.didMoveToSuperview()
        
        if superview == nil {
            return
        }
        
        frame = superview!.bounds
        
        //add background
        let backdrop = UIView(frame: bounds)
        backdrop.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
        addSubview(backdrop)
        
        //spinner
        let spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        spinner.center = center
        spinner.startAnimating()
        backdrop.addSubview(spinner)
        
        //add image view
        imgView = UIImageView()
        imgView.frame = CGRectInset(bounds, 20, 40)
        imgView.layer.cornerRadius = 10
        imgView.clipsToBounds = true
        imgView.contentMode = .ScaleAspectFit
        imgView.alpha = 0
        backdrop.addSubview(imgView)<commit_msg>* fixed spinner size and color<commit_after>//
//  PhotoPopupView.swift
//  EventBlank
//
//  Created by <NAME> on 8/23/15.
//  Copyright (c) 2015 Underplot ltd. All rights reserved.
//

import UIKit
import Haneke

class PhotoPopupView: UIView {

    static func showImage(image: UIImage, inView: UIView) {
        let popup = PhotoPopupView()
        inView.addSubview(popup)
        
        popup.photo = image
    }

    static func showImageWithUrl(url: NSURL, inView: UIView) {
        let popup = PhotoPopupView()
        inView.addSubview(popup)
        
        popup.photoUrl = url
    }
    
    var photoUrl: NSURL! {
        didSet {
            imgView.hnk_setImageFromURL(photoUrl)
        }
    }
    
    var photo: UIImage! {
        didSet {
            imgView.image = photo
        }
    }
    
    var imgView: UIImageView!
    
    override func didMoveToSuperview() {
        super.didMoveToSuperview()
        
        if superview == nil {
            return
        }
        
        frame = superview!.bounds
        
        //add background
        let backdrop = UIView(frame: bounds)
        backdrop.backgroundColor = UIColor(white: 0.0, alpha: 0.8)
        addSubview(backdrop)
        
        //spinner
        let spinner = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        spinner.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge
        spinner.center = center
        spinner.startAnimating()
        spinner.backgroundColor = UIColor.whiteColor()
        spinner.layer.masksToBounds = true
        spinner.layer.cornerRadius = 5
        backdrop.addSubview(spinner)
        
        //add image view
        imgView = UIImageView()
        imgView.frame = CGRectInset(bounds, 20, 40)
        imgView.layer.cornerRadius = 10
        imgView.clipsToBounds = true
        imgView.contentMode = .ScaleAspectFit
        imgView.alpha = 0
        backdrop.addSubview(imgView)
{'fraction_non_alphanumeric': 0.08805201842319155, 'fraction_numerical': 0.015442969384990518, 'mean_word_length': 1.8531684698608963, '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': '2891287', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1128, 'n_words': 246}