<commit_before>//
// Created by <NAME> on 2/19/20.
//

import Foundation

public protocol CSHasLayoutProtocol {
    func updateLayout() -> Self
    @discardableResult
    func layout<View: UIView>(_ view: View, function: @escaping (View) -> Void) -> View
}

public protocol CSLayoutItemProtocol {
    var isVisibleToLayout: Bool { get }
}

public extension CSHasLayoutProtocol where Self: UIView {
    static func wrap(fixed leftView: UIView, margin: CGFloat = 0, sizedToFit rightView: UIView) -> Self {
        Self.construct().also { container in
            container.layout(container.add(view: leftView).from(left: 0)) {
                $0.centeredVertical()
            }
            container.layout(container.add(view: rightView).fromPrevious(left: margin)) {
                $0.resizeToFit().centeredVertical()
            }
        }.resizeToFit()
    }

    func wrap(fixed leftView: UIView, margin: CGFloat = 0, sizedToFit rightView: UIView) -> UIView {
        CSView.wrap(fixed: leftView, margin: margin, sizedToFit: rightView)
    }

    static func wrap(flexible leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> Self {
        Self.construct().also { container in
            container.layout(container.add(view: leftView).from(left: 0)) {
                $0.width((container.width - margin) / 2).heightToFit()
            }
            container.layout(container.add(view: rightView)) {
                $0.fromPrevious(left: margin).width((container.width - margin) / 2).heightToFit()
            }
        }
    }

    func wrap(flexible leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> CSView {
        CSView.wrap(flexible: leftView, margin: margin, flexible: rightView)
    }

    static func wrap(flexible leftView: UIView, margin: CGFloat = 0, fixed rightView: UIView) -> Self {
        Self.construct().also { container in
            container.add(view: rightView).from(right: 0).centeredVertical()
            container.layout(container.add(view: leftView).from(left: 0).fill(to: rightView, right: margin)) {
                $0.heightToFit().centeredVertical()
            }
        }.resizeToFit()
    }

    func wrap(flexible leftView: UIView, margin: CGFloat = 0, fixed rightView: UIView) -> CSView {
        CSView.wrap(flexible: leftView, margin: margin, fixed: rightView)
    }
}<commit_msg>no message<commit_after>//
// Created by <NAME> on 2/19/20.
//

import Foundation

public protocol CSHasLayoutProtocol {
    func updateLayout() -> Self
    @discardableResult
    func layout<View: UIView>(_ view: View, function: @escaping (View) -> Void) -> View
}

public protocol CSLayoutItemProtocol {
    var isVisibleToLayout: Bool { get }
}

public extension CSHasLayoutProtocol where Self: UIView {
    static func row(fixed leftView: UIView, margin: CGFloat = 0, sizedToFit rightView: UIView) -> Self {
        Self.construct().also { container in
            container.layout(container.add(view: leftView).from(left: 0)) {
                $0.centeredVertical()
            }
            container.layout(container.add(view: rightView).fromPrevious(left: margin)) {
                $0.resizeToFit().centeredVertical()
            }
        }.resizeToFit()
    }

    func row(fixed leftView: UIView, margin: CGFloat = 0, sizedToFit rightView: UIView) -> UIView {
        CSView.row(fixed: leftView, margin: margin, sizedToFit: rightView)
    }

    static func row(flexible leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> Self {
        Self.construct().also { container in
            container.layout(container.add(view: leftView).from(left: 0)) {
                $0.width((container.width - margin) / 2).heightToFit()
            }
            container.layout(container.add(view: rightView)) {
                $0.fromPrevious(left: margin).width((container.width - margin) / 2).heightToFit()
            }
        }
    }

    func row(flexible leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> CSView {
        CSView.row(flexible: leftView, margin: margin, flexible: rightView)
    }

    static func row(flexible leftView: UIView, margin: CGFloat = 0, fixed rightView: UIView) -> Self {
        Self.construct().also { container in
            container.add(view: rightView).from(right: 0).centeredVertical()
            container.layout(container.add(view: leftView).from(left: 0).fill(to: rightView, right: margin)) {
                $0.heightToFit().centeredVertical()
            }
        }.resizeToFit()
    }

    func row(flexible leftView: UIView, margin: CGFloat = 0, fixed rightView: UIView) -> CSView {
        CSView.row(flexible: leftView, margin: margin, fixed: rightView)
    }

    static func row(fixed leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> Self {
        Self.construct(defaultSize: true).also { container in
            container.add(view: leftView).from(left: 0).centeredVertical()
            container.layout(container.add(view: rightView).fromPrevious(left: margin).fillTo(right: 0)) {
                $0.heightToFit().centeredVertical()
            }
        }.resizeToFit()
    }

    func wrap(fixed leftView: UIView, margin: CGFloat = 0, flexible rightView: UIView) -> CSView {
        CSView.row(fixed: leftView, margin: margin, flexible: rightView)
    }

    static func column(top topView: UIView, margin: CGFloat = 0, bottom bottomView: UIView) -> Self {
        Self.construct(defaultSize: true).also { container in
            container.layout(container.add(view: topView).from(top: 0).matchParentWidth()) {
                $0.heightToFit()
            }
            container.layout(container.add(view: bottomView).matchParentWidth()) {
                $0.fromPrevious(top: margin).heightToFit()
            }
        }.resizeToFit()
    }
}
{'fraction_non_alphanumeric': 0.12259945130315501, 'fraction_numerical': 0.009087791495198902, 'mean_word_length': 2.6524733876017534, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 28, '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': '2977692', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1671, 'n_words': 400}