Mineral Save

A library used to separate concerns from the original UIKit framework.

Project README

Mineral

A library used to separate concerns from the original UIKit framework.

http://draveness.me/mvx-view.html

Node

public class Node: Buildable {
    public internal(set) var view: UIView = UIView()
    
    @discardableResult 
    public func size(_ size: CGSize) -> Element {
        view.size = size
        return self
    }    
}

Container

An abstract protocol

public protocol Container {
    associatedtype RelationType
    func build(closure: () -> Node) -> Relation<RelationType>
}

AbsoluteContainer

let frame = Builder<AbsoluteContainer>.build.color(UIColor.lightGray).size(self.view.frame.size)
Builder<Node>.build.color(UIColor.white).size(50)
    .attachTo(frame).origin(10)
Builder<Node>.build.color(UIColor.red).size(50)
    .attachTo(frame).center(200, 300)

RelativeContainer

let constraint = Builder<RelativeContainer>.build.color(UIColor.lightGray).size(self.view.frame.size)

let node = Builder<Node>.build.color(UIColor.white).size(50)
    .attachTo(constraint)
    .left(constraint)
    .top(constraint, offset: 20).node

Builder<Node>.build.color(UIColor.red).size(50)
    .attachTo(constraint)
    .left(node.rlt.right)
    .centerY(node)

FlexContainer

let flexbox = Builder<FlexContainer>.build.color(UIColor.lightGray).size(self.view.frame.size) { container in
    Builder<Node>.build
        .color(UIColor.white)
        .size(100)
        .attachTo(container)
    Builder<Node>.build.color(UIColor.red).size(100).attachTo(container)
}

view.addSubview(flexbox.view)
Open Source Agenda is not affiliated with "Mineral" Project. README Source: draveness/Mineral
Stars
29
Open Issues
0
Last Commit
6 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating