RedPotion
We believe iPhone development should be clean, scalable, and fast with a language that developers not only enjoy, but actively choose. With the advent of Ruby for iPhone development the RubyMotion community has combined and tested the most active and powerful gems into a single package called RedPotion
RedPotion combines RMQ, ProMotion, CDQ, AFMotion, MotionPrint and MORE!. It also adds new features to better integrate RMQ with ProMotion. The goal is simply to choose standard libraries and promote best practices, allowing you to develop iOS apps in record time.
=========
The makers of RMQ at InfiniteRed and the creators of ProMotion at ClearSight as well as David Larrabee have teamed up to create the ultimate RubyMotion library.
ProMotion for screens and RMQ for styles, animations, traversing, events, etc.
Plugins and Add-ons
You can use both RMQ Plugins and ProMotion Add-ons
Quick start
gem install redpotion
potion create my_app
bundle
rake pod:install
rake
Installation
gem install redpotion
If you use rbenv
rbenv rehash
add it to your Gemfile
:
gem 'redpotion'
Do NOT use RedPotion from github, we don't know why, but it will throw exceptions if you do; we're currently investigating why.
New generators to integrate RMQ & ProMotion nicely
Our new generators allow you to create your ProMotion screen and stylesheet template to let you hit the ground running. Currently the following RedPotion generators exist:
potion create screen foo
potion create table_screen foo
potion create view foo
# All rmq generators work with the potion command as well
potion create model foo
potion create shared foo
potion create lib foo
# rmq controller generators also still exist
# but screens are preferred to get the redpotion value
potion create controller foo
potion create collection_view_controller foos
potion create table_view_controller
# RedPotion includes CDQ and afmotion by default, if you don't need these gems
# we have provided command line tasks to remove either of them
potion remove cdq
potion remove afmotion
New features for RMQ
find
is aliased to rmq
so you can use it for a more natural reading code:
find.all.hide
find(my_view).children.nudge(right: 10)
You can use app
directly in code, which is the same as rmq.app
So you also get window, device, and delegate from that.
app.device
app.window
app.delegate
You can use the following in a UIView or Screen or UIViewController without prefacing it with rmq
:
append
append!
prepend
prepend!
create
create!
build
build!
on
apply_style
reapply_styles
style
color
image
stylesheet
stylesheet=
Stylesheet in your screens
You can specify the stylesheet in your screen like so:
class HomeScreen < PM::Screen
title "RedPotion"
stylesheet HomeStylesheet
def on_load
end
end
rmq_build can now be called on_load
You can use either rmq_build or on_load, they do exactly the same thing. You can only use one or the other. on_load
is preferred as it matches the screen's onload.
class Section < UIView
def on_load
apply_style :section
append(UIButton, :section_button).on(:touch) do
mp "Button touched"
end
end
end
Remote image loading for UIImageView styler
You can set remote_image
to a URL string or an instance of NSURL
and it will automatically fetch the image and set the image (with caching) using the power of JMImageCache.
class MyStylesheet < ApplicationStylesheet
def my_ui_image_view(st)
# placeholder_image= is just an alias to image=
# Set the placeholder image you want from your resources directory
st.placeholder_image = image.resource("my_placeholder")
# Set the remote URL. It will be applied to the UIImageView
# when downloaded or retrieved from the local cache.
st.remote_image = "http://www.rubymotion.com/img/rubymotion-logo.png"
# or st.remote_image = NSURL.urlWithString(...)
end
end
In order to use this feature, you must add the JMIMageCache
cocoapod to your project:
app.pods do
pod 'JMImageCache'
end
New features for ProMotion
ProMotion 2.2.0 added on_load and on_styled to match RedPotion
RedPotion specific features
UIColor has a with
method. Allowing you to build a color from an existing color easily
# for example that time you want your existing color, but with a slight change
color.my_custom_color.with(a: 0.5)
Full listing of Gems and Pods for RedPotion
Gems
- RMQ
- ProMotion
- CDQ
- AFMotion
- motion_print
- motion-cocoapods
- (DEV) webstub
- (DEV) newclear
Pods
Contributing
- Create an issue in GitHub to make sure your PR will be accepted.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request