GithubHelp home page GithubHelp logo

thefrontiergroup / motion-layout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qrush/motion-layout

1.0 5.0 0.0 155 KB

A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art inspired format strings to build your app's layout!

License: MIT License

Ruby 100.00%

motion-layout's Introduction

motion-layout

A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art inspired format strings to build your app's layout!

Installation

Add this line to your application's Gemfile:

gem 'motion-layout'

And then execute:

bundle

Or install it yourself as:

gem install motion-layout

Then in your Rakefile:

require 'motion-layout'

Usage

Using AutoLayout is a way to put UI elements in your iPhone app without using Interface Builder, and without being very specific about pixel sizes, locations, etc. The layout strings are ASCII inspired, and Apple's documentation on the Visual Format Language is a necessary read and reference.

Here's an example of Motion::Layout usage from inside of Basecamp for iPhone on a UITableView's tableFooterView:

Motion::Layout.new do |layout|
  layout.view self.view.tableFooterView
  layout.subviews "switch" => @switch, "help" => @help
  layout.vertical "|-15-[switch]-10-[help(==switch)]-15-|"
  layout.horizontal "|-10-[switch]-10-|"
  layout.horizontal "|-10-[help]-10-|"
end

And here's an example you can run right inside this repo, the Time app converted to use Auto Layout from the RubyMotionSamples repo:

Motion::Layout.new do |layout|
  layout.view view
  layout.subviews state: @state, action: @action
  layout.metrics "top" => 200, "margin" => 20, "height" => 40
  layout.vertical "|-top-[state(==height)]-margin-[action(==height)]"
  layout.horizontal "|-margin-[state]-margin-|"
  layout.horizontal "|-margin-[action]-margin-|"
end

TODO

  • Support finer grained constraints
  • Better debugging messages
  • More examples

Contributing

I couldn't figure out how to test this automatically. Run bundle to get the gems you need, and then rake to generate a RubyMotion app in the iOS simulator

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT. See LICENSE.

motion-layout's People

Contributors

qrush avatar seanlilmateus avatar

Stargazers

Luke Schoen avatar

Watchers

Matt Lambie avatar Tony Issakov avatar Jordan Maguire avatar Greg Tangey avatar James Cloos 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.