GithubHelp home page GithubHelp logo

wangshengjia / leego Goto Github PK

View Code? Open in Web Editor NEW
966.0 966.0 46.0 2.99 MB

Declarative, configurable & highly reusable UI development as making Lego bricks.

License: MIT License

Swift 98.72% Ruby 1.08% Objective-C 0.20%
autolayout component-driven declarative-ui ios swift uiview

leego's Introduction

Yo πŸ‘‹ I'm victor.

Having coffee at Citymapper, keep learning.

Startup, tech, product, food. Talk to me.

Living in London, regularly back to Paris and Shanghai.

  • πŸ“š Learning
  • πŸ— Building
  • 🍜 Ramen!
  • πŸ’» ε†™δ»£η οΌŒδ½†ζ˜―ζ›΄ηˆ±εšδΊ§ε“
  • πŸ’€ ε•Š η¨‹εΊε‘˜δΉ‹θ€»!

Have fun.

leego's People

Contributors

basthomas avatar igormuzyka avatar jackieqi avatar onevcat avatar readmecritic avatar wangshengjia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leego's Issues

Refactor Layout to use declarative NSLayoutAnchor

With the NSLayoutAnchor, we can now use it to avoid the layout format language. Imagine, in your function that defines layout, we could pass the view and return an array of objects. Like this:

let title = "title".build(UILabel.self).style([.numberOfLines(0), .text("test")])
let subtitle = "subtitle".build(UILabel.self).style([.numberOfLines(0), .text("subtitle")])

let brick = "details".build().bricks(title) { container, title in
    return [
        title.centerXAnchor.constraint(equalTo: container.centerXAnchor),
        title.centerYAnchor.constraint(equalTo: container.centerYAnchor),
    ]
}

However, this approach will require some refactoring. I can volunteer, if you want :)

Brick.bricks field shares ambiguous name with methods.

In Xcode 9.4.1 (Swift 4.1.2) if you try to get the child bricks for a Brick instance, the compiler complains: Ambiguous reference to member 'bricks(_:layout:)'

Example (using code from DetailsViewController in the Demo App):

let title = "title".build(UILabel.self).style([.numberOfLines(0), .text("Lorem Ipsum is simply dummy text of the printing industry")])
let description = "description".build(UILabel.self).style([.textColor(UIColor.lightGray), .numberOfLines(0), .font(UIFont.systemFont(ofSize: 14)), .text("Lorem Ipsum has been the industry's standard dummy text ever since the 1500s")])
let redBlock = "red".build().style(Style.redBlockStyle)
let greenBlock = "green".build().style(Style.greenBlockStyle)
let blueBlock = "blue".build(UIImageView.self).style(Style.blueBlockStyle + [Appearance.custom(["shadowColor": UIColor.brown, "shadowOpacity": Float(1.0)])])

let blocks = Brick.union("blocks", bricks: [
    redBlock.height(50),
    greenBlock.height(80),
    blueBlock.height(30)],
    axis: .horizontal, align: .top, distribution: .fillEqually, metrics: LayoutMetrics(10, 10, 10, 10, 10, 10)).style(Style.blocksStyle)

Then call add the line:

print(blocks.blocks.count) //Generates compiler error: Ambiguous reference to member 'bricks(_:layout:)'

Travis CI configuration needs to be updated

When making a pull request, the following error is generated by Travis CI and the build fails:
❌ β€œUse Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

Mixed view components

Hello Wang,

Nice work there, congrats! I was playing around w/ Leego for some time and wondering what's the best approach to integrate e.g. UICollectionView inside table view cell (for carousal) and may be some dynamic image carousals mixed w/ static cells.

Are the explicit types in the README there deliberately?

eg.

import LeeGo

let titleBrick: Brick = "title".build(UILabel).style([.text("Showcase"), .backgroundColor(UIColor.lightGrayColor())])

could become

import LeeGo

let titleBrick: Brick = "title".build(UILabel).style([.text("Showcase"), .backgroundColor(.lightGrayColor())])

and

let bricks = ["red".build().style(Style.redBlockStyle).height(50),
 "green".build().style(Style.greenBlockStyle).height(80),
 "blue".build().style(Style.blueBlockStyle).height(30)]

let layout = Layout(bricks: bricks, axis: .Horizontal, align: .Top, distribution: .FillEqually, metrics: LayoutMetrics(10, 10, 10, 10, 10, 10))
let viewBrick = "view".build().style(Style.blocksStyle).bricks(bricks, layout: layout).height(100)

could become

let bricks = ["red".build().style(.redBlockStyle).height(50),
 "green".build().style(.greenBlockStyle).height(80),
 "blue".build().style(.blueBlockStyle).height(30)]

let layout = Layout(bricks: bricks, axis: .Horizontal, align: .Top, distribution: .FillEqually, metrics: LayoutMetrics(10, 10, 10, 10, 10, 10))
let viewBrick = "view".build().style(.blocksStyle).bricks(bricks, layout: layout).height(100)

But I understand if this was done intentionally; it is clearer and more easily readable (?) in the examples.

If this wasn't done deliberately, I'd gladly help using implicit type inference. :)

Component Action

Hi Wang,

Congrats on the great tool, nicely done !! I was wondering what's your plan for providing actions for components, like Button, swipe, tap, or anything? Blockable actions?

Brick.bricks is not publicly accessible

It would be nice to iterate over the child bricks like so:

  func update(_ targetView: UIView, with brick: Brick) {
        for child in brick.bricks {
            switch targetView {
            case let label as UILabel where brick == FooBrickBuilder.name:
                label.text = name
            case let label as UILabel where brick == FooBrickBuilder.address:
                label.text = address
            default:
                break
            }
        }
    }

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.