GithubHelp home page GithubHelp logo

rocry / layoutkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkedinattic/layoutkit

0.0 3.0 2.0 6.63 MB

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

Home Page: http://layoutkit.org

License: Apache License 2.0

Swift 93.78% Objective-C 4.85% Ruby 0.42% Shell 0.95%

layoutkit's Introduction

LayoutKit

CocoaPods GitHub release Build Status codecov CocoaPods

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.

Motivation

LinkedIn created LayoutKit because we have found that Auto Layout is not performant enough for complicated view hierarchies in scrollable views. For more background, read the blog post.

Benefits

LayoutKit has many benefits over using Auto Layout:

  • Fast: LayoutKit is as fast as manual layout code and is significantly faster than Auto Layout.
  • Asynchronous: Layouts can be computed in a background thread so user interactions are not interrupted.
  • Declarative: Layouts are declared with immutable data structures. This makes layout code easier to develop, document, code review, test, debug, profile, and maintain.
  • Cacheable: Layout results are immutable data structures so they can be precomputed in the background and cached to increase user perceived performance.

LayoutKit also provides benefits that make it as easy to use as Auto Layout:

  • UIKit friendly: LayoutKit produces UIViews and also provides an adapter that makes it easy to use with UITableView and UICollectionView.
  • Internationalization: LayoutKit automatically adjusts view frames for right-to-left languages.
  • Swift: LayoutKit can be used in Swift applications and playgrounds.
  • Tested and production ready: LayoutKit is covered by unit tests and is being used inside of recent versions of the LinkedIn and LinkedIn Job Search iOS apps.
  • Open-source: Not a black box like Auto Layout.
  • Apache License (v2): Your lawyers will be happy that there are no patent shenanigans.

Hello world

let image = SizeLayout<UIImageView>(width: 50, height: 50, config: { imageView in
    imageView.image = UIImage(named: "earth.jpg")
})

let label = LabelLayout(text: "Hello World!", alignment: .center)

let stack = StackLayout(
    axis: .horizontal,
    spacing: 4,
    sublayouts: [image, label])

let insets = UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 8)
let helloWorld = InsetLayout(insets: insets, sublayout: stack)
helloWorld.arrangement().makeViews(in: rootView)

Hello world example layout

Limitations

We have found LayoutKit to be a useful tool, but you should be aware of what it is not.

  • LayoutKit is not a constraint based layout system. If you wish to express a constraint between views, then those views need to be children of a single layout that implements code to enforce that constraint.
  • LayoutKit is not flexbox, but you may find similarities.

Installation

LayoutKit can be installed with CocoaPods or Carthage.

CocoaPods

Add this to your Podspec:

pod 'LayoutKit'

Then run pod install.

Carthage

Add this to your Cartfile:

github "linkedin/LayoutKit"

Then run carthage update.

Documentation

Now you are ready to start building UI.

layoutkit's People

Contributors

dgattey avatar e-liu avatar franciscoamado avatar inamiy avatar jingwei-huang1 avatar langxxx avatar muukii avatar nicksnyder avatar nixzhu avatar pgherveou avatar readmecritic avatar rocry avatar sol88 avatar staguer avatar thekirankumar avatar vargon avatar ynop avatar

Watchers

 avatar  avatar  avatar

Forkers

ibenjamin langxxx

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.