65

GitHub - freshOS/Stevia: Healthy Autolayout Sugar

 5 years ago
source link: https://github.com/freshOS/Stevia
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Stevia

Documentation Language: Swift 2, 3 and 4 Platform: iOS 8+ Carthage compatible CocoaPods compatible Build Status codebeat badge License: MIT CocoaPods CocoaPods GitHub contributors GitHub tag

Drawing

Winner of Hacking with Swift Recommended award

You + Stevia = ?

  • ? Write concise, readable layouts
  • ?Reduce your maintenance time
  • ?Compose your styles, CSS-like
  • ? Plug Live reload and boost your iteration cycles

Reason - Example - Live Reload - Installation - Documentation

? Visual Layout Api

layout(
    100,
    |-email-| ~ 80,
    8,
    |-password-forgot-| ~ 80,
    >=20,
    |login| ~ 80,
    0
)

⛓ Chainable Api

email.top(100).left(8).right(8).width(200).height(44)
alignHorizontally(password, forgot)
image.fillContainer()
button.centerInContainer().size(50%)
equalWidths(email, password)
image.width(>=80)

? Equation-Based Api

email.Top == 100
password.CenterY == forgot.CenterY
login.Top >= password.Bottom + 20
login.Width == 75 % Width
(image.Height == 100).priority = UILayoutPriority(rawValue: 999)

All Generate native NSLayoutConstraints ?

?‍?Try it!

Stevia is part of freshOS iOS toolset. Try it in an example App ! Download Starter Project

? Reason

Because nothing holds more truth than pure code ?
Xibs and storyboards are heavy, hard to maintain, hard to merge.
They split the view concept into 2 separate files making debugging a nightmare
There must be a better way

How

By creating a tool that makes Auto layout code finally readable by a human being.
By coupling it with live code injection such as injectionForXcode we can design views in real time
View layout becomes fun, concise, maintainable and dare I say, beautiful ❤️

Login View Example

In the project folder, you can find an example of a typical login view laid out in both native and Stevia for you to understand and compare the two approaches.

As a spoiler alert, the number of characters goes from 2380 to 1239 ( ~ divided by 2)

Write Half the code that is actually 10X more expressive and maintainable !

? Live Reload

Live reload enables you to develop your views live without relaunching the app everytime.

Stevia + InjectionForXcode = #WhoNeedsReactNative?? ?

687474703a2f2f672e7265636f726469742e636f2f69366b5166544d4570672e676966

Just Cmd+S and you can dev live in the simulator !

Learn more about how to set up live reload here.

⚙️ Installation

Get started here.

? Documentation

You can find the full documentation here.

?‍? Contributors

YannickDot, S4cha, Damien, Snowcraft, Mathieu-o, Blaz Merela, Theophane Rupin, Jason Liang, liberty4me, Scott Bates, Sai, Mike Gallagher, WaterNotWords, Mick MacCallum

? Backers

Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f392f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f31392f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f6261636b65722f32392f6176617461722e737667

? Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site :)

68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f392f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f31392f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32302f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32312f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32322f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32332f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32342f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32352f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32362f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32372f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32382f6176617461722e737667 68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f66726573686f732f73706f6e736f722f32392f6176617461722e737667

Swift Version


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK