Git Product home page Git Product logo

rubymotion-pixatefreestyle's Introduction

#RubyMotion-PixateFreestyle

Pixate Freestyle gem for RubyMotion.

Requirements

Setup

  • Download the Pixate Freestyle Framework and copy the PixateFreestyle.framework folder into vendor directory (or alternatively just create a symbolic link). Create the vendor directory if it does not exist. You should have something like this.
$ ls vendor/PixateFreestyle.framework
/Headers/   PixateFreestyle   Resources/ Versions/
  • Edit the Rakefile of your RubyMotion project and add the following require lines.
require 'rubygems'
require 'motion-pixatefreestyle'
  • Still in the Rakefile, set up the framework variable in your application configuration block.
Motion::Project::App.setup do |app|
  # ...
  app.pixatefreestyle.framework = 'vendor/PixateFreestyle.framework'
end
  • Create the default.css in resources directory, or copy it from the pixate-blue theme.

Note: To install the motion-pixatefreestyle gem:

gem install motion-pixatefreestyle

Or see the RubyGems site.

Example

We'll take the Timer example that comes with RubyMotion and add Pixate and quickly style the application. Start by following the Setup steps above to add Pixate to the Timer project.

Type rake to make sure everything is good so far. You should see the Timer app running.

Timer

Add the CSS File

In the default.css file you added prior, let's add a simple entry:

	button {
		background-color: red;
	}

Rake again and you should see this:

Red Button

Let's pretty this button up with the following CSS:

	button {
		color            : #446620;
		background-color : linear-gradient(#87c44a, #b4da77);
		border-width     : 1px;
		border-color     : #84a254;
		border-radius    : 10px;
		font-size        : 15px;
		font-weight      : bold;
	}

Rake again and you should see this:

Green Button

Add a Styling ID

Lastly, let's change the background color. Let's add an ID to our background view. In the timer_controller.rb file, add the following line before the end of viewDidLoad:

	view.styleId = 'myView'

What's we've done here is add a styleId to the view so we can style it by name. Now add the following CSS after your button CSS that was already added:

	#myView {
		background-color: linear-gradient(#000000, #f2f4f6);
	}

Now you have a beautiful interface with just a few lines of CSS!

Final App

Real-time Updating

See this gist for an example of how to use the real-time updating features.

SASS

Pixate gem supports Sass to generate the stylesheet. Create the sass directory and default.scss with the rake pixatefreestyle:init command. Then, rake pixatefreestyle:sass command generates the stylesheet from default.scss.

You could specify the Sass output style through style environment variable. For example,

$ rake pixatefreestyle:sass style=compressed

You could use nested, expanded, compact and compressed as output style.

REPL

Pixate Freestyle gem provides a "style" method in REPL. You could change the stylesheet at the moment in REPL. For example,

(main)> style "button { color : blue; }"
(main)> style "button { background-color: red; border-radius: 20pt; }"

Mailing List & Twitter

Keep up with notifications and announcements by joining Pixate's mailing list and follow us on Twitter.

rubymotion-pixatefreestyle's People

Contributors

bobspace avatar forrestgrant avatar killion avatar mackato avatar pcolton avatar watson1978 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.