<commit_before>//
//  KCFloatingActionButtonItem.swift
//  KCFloatingActionButton-Sample
//
//  Created by LeeSunhyoup on 2015. 10. 5..
//  Copyright © 2015년 kciter. All rights reserved.
//

import UIKit

public enum FloatyItemLabelPositionType {
    case left
    case right
}

/**
 Floating Action Button Object's item.
 */
open class FloatyItem: UIView {

    // MARK: - Properties

    /**
     This object's button size.
     */
    open var size: CGFloat = 42 {
        didSet {
            self.frame = CGRect(x: 0, y: 0, width: size, height: size)
            titleLabel.frame.origin.y = self.frame.height/2-titleLabel.frame.size.height/2
            _iconImageView?.center = CGPoint(x: size/2, y: size/2) + imageOffset
            self.setNeedsDisplay()
        }
    }

    /**
     Button color.
     */
    open var buttonColor: UIColor = UIColor.white

    /**
     Title label color.
     */
    open var titleColor: UIColor = UIColor.white {
        didSet {
            titleLabel.textColor = titleColor
        }
    }

    /**
     Enable/disable shadow.
     */
    open var hasShadow: Bool = true

    /**
     Circle Shadow color.
     */
    open var circleShadowColor: UIColor = UIColor.black

    /**
     Title Shadow color.
     */
    open var titleShadowColor: UIColor = UIColor.black

    /**
     If you touch up inside button, it execute handler.
     */
    open var handler: ((FloatyItem) -> Void)? = nil

    open var imageOffset: CGPoint = CGPoint.zero
    open var imageSize: CGSize = CGSize(width: 25, height: 25) {
        didSet {
            _iconImageView?.frame = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
            _iconImageView?.center = CGPoint(x: size/2, y: size/2) + imageOffset
        }
    }

    /**
     Reference to parent
     */
    open weak var actionButton: Floaty?

    /**
     Shape layer of button.
     */
    fileprivate var circleLayer: CAShapeLayer = CAShapeLayer()

    /**
     If you keeping touch inside button, button overlaid with tint layer.
     */
    fileprivate var tintLayer: CAShapeLayer = CAShapeLayer()
    
    /**
     Item's title label position.
     deafult is left
     */
    open var titleLabelPosition: FloatyItemLabelPositionType = .left

    /**
     Item's title label.
     */
    var _titleLabel: UILabel? = nil
    open var titleLabel: UILabel {
        get {
            if _titleLabel == nil {
                _titleLabel = UILabel()<commit_msg>Added logic to move title from left to right and vice versa after item has been init<commit_after>//
//  KCFloatingActionButtonItem.swift
//  KCFloatingActionButton-Sample
//
//  Created by LeeSunhyoup on 2015. 10. 5..
//  Copyright © 2015년 kciter. All rights reserved.
//

import UIKit

public enum FloatyItemLabelPositionType {
    case left
    case right
}

/**
 Floating Action Button Object's item.
 */
open class FloatyItem: UIView {

    // MARK: - Properties

    /**
     This object's button size.
     */
    open var size: CGFloat = 42 {
        didSet {
            self.frame = CGRect(x: 0, y: 0, width: size, height: size)
            titleLabel.frame.origin.y = self.frame.height/2-titleLabel.frame.size.height/2
            _iconImageView?.center = CGPoint(x: size/2, y: size/2) + imageOffset
            self.setNeedsDisplay()
        }
    }

    /**
     Button color.
     */
    open var buttonColor: UIColor = UIColor.white

    /**
     Title label color.
     */
    open var titleColor: UIColor = UIColor.white {
        didSet {
            titleLabel.textColor = titleColor
        }
    }

    /**
     Enable/disable shadow.
     */
    open var hasShadow: Bool = true

    /**
     Circle Shadow color.
     */
    open var circleShadowColor: UIColor = UIColor.black

    /**
     Title Shadow color.
     */
    open var titleShadowColor: UIColor = UIColor.black

    /**
     If you touch up inside button, it execute handler.
     */
    open var handler: ((FloatyItem) -> Void)? = nil

    open var imageOffset: CGPoint = CGPoint.zero
    open var imageSize: CGSize = CGSize(width: 25, height: 25) {
        didSet {
            _iconImageView?.frame = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
            _iconImageView?.center = CGPoint(x: size/2, y: size/2) + imageOffset
        }
    }

    /**
     Reference to parent
     */
    open weak var actionButton: Floaty?

    /**
     Shape layer of button.
     */
    fileprivate var circleLayer: CAShapeLayer = CAShapeLayer()

    /**
     If you keeping touch inside button, button overlaid with tint layer.
     */
    fileprivate var tintLayer: CAShapeLayer = CAShapeLayer()
    
    /**
     Item's title label position.
     deafult is left
     */
    open var titleLabelPosition: FloatyItemLabelPositionType = .left {
        didSet {
            if(titleLabelPosition == .left) {
                titleLabel.frame.origin.x = -titleLabel.frame.size.width - 10
            } else { //titleLabel will be on right
                titleLabel.frame.origin.x = iconImageView.frame.origin.x + iconImageView.frame.size.width + 20
            }
        }
    }

    /**
     Item's title label.
     */
    var _titleLabel: UILabel? = nil
    open var titleLabel: UILabel {
        get {
            if _titleLabel == nil {
                _titleLabel = UILabel()
{'fraction_non_alphanumeric': 0.10164424514200299, 'fraction_numerical': 0.010837070254110613, 'mean_word_length': 1.9395936298736958, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4858032', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1601, 'n_words': 455}