All Projects → abelsanchezali → ViewBuilder

abelsanchezali / ViewBuilder

Licence: MIT license
Fully document based declarative way for building UI with a custom and more performant layout.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to ViewBuilder

Flexlayout
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.
Stars: ✭ 1,342 (+9485.71%)
Mutual labels:  layout-engine
Panda
Panda is an asynchronous render and layout framework which can be used to achieve high performance tableview.
Stars: ✭ 177 (+1164.29%)
Mutual labels:  layout-engine
datalake-etl-pipeline
Simplified ETL process in Hadoop using Apache Spark. Has complete ETL pipeline for datalake. SparkSession extensions, DataFrame validation, Column extensions, SQL functions, and DataFrame transformations
Stars: ✭ 39 (+178.57%)
Mutual labels:  xml-parsing
Pinlayout
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Stars: ✭ 1,870 (+13257.14%)
Mutual labels:  layout-engine
Mesh
A toolkit for Kinetic Web Typography
Stars: ✭ 167 (+1092.86%)
Mutual labels:  layout-engine
Komponents Deprecated
📦 React-inspired UIKit Components - ⚠️ Deprecated
Stars: ✭ 202 (+1342.86%)
Mutual labels:  layout-engine
Ordnung
The 1kb alternative to Isotope
Stars: ✭ 79 (+464.29%)
Mutual labels:  layout-engine
Bonmot
Beautiful, easy attributed strings in Swift
Stars: ✭ 3,182 (+22628.57%)
Mutual labels:  xml-parsing
D3 Layout Narrative
A d3 layout for creating XKCD style narrative charts
Stars: ✭ 168 (+1100%)
Mutual labels:  layout-engine
TableDisentangler
Functional and structural analysis of tables in research papers (Table disentangling)
Stars: ✭ 21 (+50%)
Mutual labels:  xml-parsing
Grandalf
graph and drawing algorithms framework
Stars: ✭ 135 (+864.29%)
Mutual labels:  layout-engine
Muuri React
The layout engine for React
Stars: ✭ 163 (+1064.29%)
Mutual labels:  layout-engine
Core Layout
Flexbox & CSS-style Layout in Swift.
Stars: ✭ 215 (+1435.71%)
Mutual labels:  layout-engine
Nehan.js
Latest version -> https://github.com/tategakibunko/nehan
Stars: ✭ 119 (+750%)
Mutual labels:  layout-engine
dsm
Declarative Stream Mapping (DSM) is a stream de/serializer library for XML and JSON. DSM allows you to make custom parsing, filtering, transforming, aggregating, grouping on any JSON or XML document at stream time(read only once).
Stars: ✭ 23 (+64.29%)
Mutual labels:  xml-parsing
Emeus
Constraint-based layout manager for GTK+
Stars: ✭ 84 (+500%)
Mutual labels:  layout-engine
Render
UIKit a-là SwiftUI.framework [min deployment target iOS10]
Stars: ✭ 2,150 (+15257.14%)
Mutual labels:  layout-engine
Swiftrichstring
👩‍🎨 Elegant Attributed String composition in Swift sauce
Stars: ✭ 2,744 (+19500%)
Mutual labels:  xml-parsing
xgen
XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
Stars: ✭ 153 (+992.86%)
Mutual labels:  xml-parsing
nmap-formatter
A tool that allows you to convert NMAP results to html, csv, json, markdown, graphviz (dot). Simply put it's nmap converter.
Stars: ✭ 129 (+821.43%)
Mutual labels:  xml-parsing

ViewBuilder

View Builder Project is a XML document based declarative way for building an user interface in iOS. With is own built-in layout engine.

Features

  • First fully declarative XML documents for building any objects in iOS.
  • Custom layout engine, 4X more performant than autolayout.
  • Built-in support for Resources, Styles, View Templates and more.
  • Gradients and SVG Vector Graphics support.

You can easily:

  • Have all your resources and reuse them anywhere.
  • Define object styles that you can freely apply.
  • Having view templates will help you to be more productive.
  • Use any custom object in your documents and extend document language.

Documents are handled with performance in mind. They are cached and automatically evicted by default. Having concepts like mutability help to optimize string parsing.

Examples

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

How to create a UIViewController binded to a document

Since UIViewController.loadView() function handle custom view creations. We only need to override this function, but remember never calling it's super implementation.

override func loadView() {
  view = DocumentBuilder.shared.load(Bundle.main.path(forResource: "View", ofType: "xml")!)
}

in Objective-C:

- (void) loadView {
    self.view = [[DocumentBuilder shared] loadView:[[NSBundle mainBundle] pathForResource: @"View" ofType: @"xml"] options: nil];
}

How to create a custom view from a document

Could be done in several ways. One is as we show before to load a view from a document insert this as a child view and access it's named element from documentReferences property.

Another approach is to create a subview class and load it using UIView.loadFromDocument extension.

public class CustomView: StackPanel {
    init() {
        super.init(frame: CGRect.zero)
        initialize()
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initialize()
    }

    private func initialize() {
        loadFromDocument(Bundle.main.path(forResource: "CustomView", ofType: "xml")!)
    }
}

and define it's content in a document:

<?xml version="1.1" encoding="UTF-8"?>
<d:Content xmlns:d="@framework" xmlns="com.apple.UIKit" xmlns:m="@document">
    <d:StackPanel backgroundColor="d:Color(#CCCCCC)"
                  borderColor="d:Color(#EEEEEE)"
                  borderWidth="1.0"
                  shadowOpacity="0.5"
                  shadowOffset="d:Size(0,0)"
                  shadowRadius="4"
                  cornerRadius="8">
        <UILabel numberOfLines="0"
                 text="This is a text on screen using an UILabel"
                 textAlignment="d:TextAlignment(Center)"
                 horizontalAlignment="d:Alignment(Stretch)"
                 margin="d:EdgeInsets(8)"/>
        <UIButton title="d:StringForState(Tap me)"
                  horizontalAlignment="d:Alignment(Center)"
                  margin="d:EdgeInsets(8)"/>
    </d:StackPanel>
</d:Content>

It's important to mention that content node should be same type as CustomView parent class StackPanel.

Layout Engine

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.

  • Productivity - How much effort is needed to build and define UI elements.
  • Performance - How faster is done the measurement/layout/rendering process.
  • Learning Curve - How easy to learn and to use is that technology.
  • Readability - How easy is to review, it's diff compatible, etc.
  • Flexibility - How easy is to modify, customize and extend.

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

Document

Extension

Cocoapods

Adding dependency will be just including ViewBuilder pod. Remember to add use_frameworks to podfile since ViewBuilder is implemented as a framework in swift.

use_frameworks!

  pod 'ViewBuilder', '~> 0.0.1'

Todos

  • Write MORE Tests
  • And so much more

License

MIT

Free Software, Hell Yeah!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].