GithubHelp home page GithubHelp logo

carabina / flexboxlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexdrone/flexboxswfit_deprecated

0.0 1.0 0.0 397 KB

Port of Facebook's css-layout to Swift

License: MIT License

Swift 90.80% Objective-C 4.82% C 4.38%

flexboxlayout's Introduction

FlexboxLayout

Carthage compatible Build ![Platform](https://img.shields.io/badge/platform-ios | osx -lightgrey.svg?style=flat) Build

Port of Facebook's [css-layout](facebook css layout) to Swift + UIView extension.

GitHub Logo

This dynamic layout is expressed in code in the following declarative fashion:

     
let defaultMargin: Inset = (8.0, 8.0, 8.0, 8.0, 8.0, 8.0)

self.treeView = UIView().configure({ (view, style) in
   view.backgroundColor = UIColor.a
   style.minDimensions = (320, 420)
   style.flex = 1
   style.alignSelf = .Stretch
   
}, children: [
   
   UIView().configure({ (view, style) in
       style.flex = 1
       style.alignSelf = .Stretch
       style.flexDirection = .Column

   }, children: [
   
       UIView().configure({ (view, style) in
           view.backgroundColor = UIColor.b
           view.hidden = self.toggle
           style.minDimensions = (128, 44)
           style.justifyContent = .Center
           style.alignSelf = .Stretch
           style.margin = defaultMargin
       }),
       
       UIView().configure({ (view, style) in
           view.backgroundColor = UIColor.c
           style.minDimensions = (44,44)
           style.flexDirection = .Row
           style.flex = 1
           style.margin = defaultMargin

           }, children: [
               
               UIView().configure({ (view, style) in
                   view.backgroundColor = UIColor.d
                   style.flex = 0.4
                   style.margin = defaultMargin
               }),
               
               UIView().configure({ (view, style) in
                   view.backgroundColor = UIColor.e
                   style.flex = 0.6
                   style.margin = defaultMargin
               })
           ]),
       
       UIButton().configure({ (view, style) in
           view.backgroundColor = UIColor.f
           view.setTitle("Press me", forState: .Normal)
           style.minDimensions = (94,44)
           style.justifyContent = .FlexEnd
           style.alignSelf = .FlexEnd
           style.margin = defaultMargin
       })
       
   ]),
   
   UILabel().configure({ (label, style) -> Void in
       label.backgroundColor = UIColor.g
       label.numberOfLines = 0
       label.text = "Lorem Lorem ipsum..."
       style.margin = defaultMargin
   })
])

self.view.addSubview(self.treeView!)

Checkout the Demo project for further info.

flexboxlayout's People

Contributors

alexdrone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.