<commit_before>//
//  Kinieta.swift
//  Kinieta
//
//  Created by <NAME> on 31/08/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

protocol Kinieta {
    func move(_ dict: [String:Any], _ time: TimeInterval) -> Kinieta
}

class KinietaEngine {
    
    static let shared = KinietaEngine()
    
    private var displayLink: CADisplayLink?
    
    
    private var instances: [KinietaInstance] = []
    
    init() {
        
    }
    
    func add(_ instance: KinietaInstance) {
        
        instances.append(instance)
        
        if displayLink == nil {
            displayLink = CADisplayLink(target: self, selector: #selector(KinietaEngine.update(_:)))
            displayLink?.add(to: RunLoop.current, forMode: RunLoopMode.commonModes)
        }
    }
    
    @objc func update(_ displayLink: CADisplayLink) {
        
    }
}

class KinietaInstance: Kinieta {
    
    static var associatedKey = "KinietaAssociatedKey"
    enum State {
        case stopped
        case moving(start: TimeInterval)
        case waiting(time: TimeInterval)
    }
    var state: State = .stopped
    
    let view:UIView
    init(_ view:UIView) {
        self.view = view
    }
    
    var transformations = [Transformation]()
    
    // MARK: API
    
    
    func move(_ dict: [String:Any], _ time: TimeInterval) -> Kinieta {
        
        let m = Transformation(self.view, for: dict)
        
        transformations.append(m)
        
        return self
    }
    
    func snap(_ dict: [String:Any]) -> Kinieta {
        
        
        return self
    }
    
    func wait(_ time:TimeInterval) -> Kinieta {
        
        
        return self
    }
    
    
//    func group() -> Kinieta {
//        
//        
//    }
}

extension UIView: Kinieta {
    
    func move(_ dict: [String:Any], _ time: TimeInterval = 0.5) -> Kinieta {
        return KinietaInstance(self).move(dict, time)
    }
    
}<commit_msg>Simplified the class structure<commit_after>//
//  Kinieta.swift
//  Kinieta
//
//  Created by <NAME> on 31/08/2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit


class KinietaEngine {
    
    static let shared = KinietaEngine()
    
    private var displayLink: CADisplayLink?
    
    
    private var instances: [Kinieta] = []
    
    init() {
        
    }
    
    func add(_ instance: Kinieta) {
        
        instances.append(instance)
        
        if displayLink == nil {
            displayLink = CADisplayLink(target: self, selector: #selector(KinietaEngine.update(_:)))
            displayLink?.add(to: RunLoop.current, forMode: RunLoopMode.commonModes)
        }
    }
    
    @objc func update(_ displayLink: CADisplayLink) {
        
    }
}

class Kinieta {
    
    static var associatedKey = "KinietaAssociatedKey"
    
    let view:UIView
    init(_ view:UIView) {
        self.view = view
        KinietaEngine.shared.add(self)
    }
    
    var transformations = [Transformation]()
    
    // MARK: API
    
    
    func move(_ dict: [String:Any], _ time: TimeInterval) -> Kinieta {
        
        let m = Transformation(self.view, for: dict)
        
        transformations.append(m)
        
        return self
    }
    
    func snap(_ dict: [String:Any]) -> Kinieta {
        
        
        return self
    }
    
    func wait(_ time:TimeInterval) -> Kinieta {
        
        
        return self
    }
    
    
//    func group() -> Kinieta {
//        
//        
//    }
}

extension UIView {
    
    func move(_ dict: [String:Any], _ time: TimeInterval = 0.5) -> Kinieta {
        return Kinieta(self).move(dict, time)
    }
    
}
{'fraction_non_alphanumeric': 0.10628415300546448, 'fraction_numerical': 0.007650273224043716, 'mean_word_length': 1.6978629329403094, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '6304318', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1150, 'n_words': 259}