CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Aug 2017 |
SwiftSwift Version | 3.1 |
SPMSupports SPM | ✗ |
Maintained by Abel Ernesto Sanchez Ali.
View Builder Project is a XML document base declarative way for building any user interface in iOS. With is own built-in layout engine.
You can easily:
Documents are handled with performance in mind. They are cached and automatically evicted by default. Having concepts like mutability that help to optimize string parsing.
To start will be cool to watch this video.
Creating some resources
<?xml version="1.1" encoding="UTF-8"?>
<d:Content xmlns:d="@framework" xmlns="com.apple.UIKit">
<d:Resources>
<d:Item name="font" value="d:Font(name: AvenirNext-Regular, size:14)"/>
<d:Item name="color" value="d:Color(#FEFEFE)"/>
<d:Item name="text" value="This is a text"/>
</d:Resources>
</d:Content>
Some sample view Defining a scrollable section that will contain a label
<?xml version="1.1" encoding="UTF-8"?>
<d:Content xmlns:d="@framework" xmlns="com.apple.UIKit">
<d:ScrollPanel backgroundColor="d:Color(White)" contentInset="d:EdgeInsets(0)" directionalLockEnabled="true">
<UILabel d:name="contentLabel" numberOfLines="0" margin="d:EdgeInsets(8)" maximumSize="d:Size(2048, -1)"/>
</d:ScrollPanel>
</d:Content>
Using some of those resources is very easy
<?xml version="1.1" encoding="UTF-8"?>
<d:Content xmlns:d="@framework" xmlns="com.apple.UIKit">
<d:Resources path="d:PathFromBundle(SomeResources.xml)"/>
<UILabel text="@text" font="@font" textColor="@color"/>
</d:Content>
How I get all that from code
let path = Constants.bundle.path(forResource: "SampleView.xml")!
let view = DocumentBuilder.shared.load(path)
Having references to any object in document will be like
All named nodes could be accessed using documentReferences
attached property.
let label = container.documentReferences!["contentLabel"] as! UILabel
ViewBuilder is provided with a built-in layout engine. Comparing layouts could be very hard but having some metrics will be helpful to understand what work better to you.
Here some existing layout engines compared together with our PanelLayout:
AutoLayout | ManualLayout | LayoutKit | PanelLayout | |
---|---|---|---|---|
Productivity | 5 | 1 | 4 | 5 |
Performance | 2 | 5 | 5 | 5 |
Learning | 3 | 5 | 3 | 4 |
Readability | 1 | 3 | 3 | 5 |
Flexibility | 3 | 5 | 3 | 5 |
Is important to hightlight that those numbers are not proportional to results
MIT
Free Software, Hell Yeah!