Skip to content

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

License

Notifications You must be signed in to change notification settings

draveness/Mineral

Repository files navigation

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)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published