README.md in ProMotion-0.2.0 vs README.md in ProMotion-0.3.0
- old
+ new
@@ -1,10 +1,14 @@
-# ProMotion - A new way to organize RubyMotion apps.
+# ProMotion - A new way to easily build RubyMotion apps.
ProMotion introduces a new object called "Screens". Screens have a one-to-one relationship
-with your app's screens and can (usually) take the place of view controllers.
+with your app's designed screens.
+Check out the tutorial here: http://www.clearsightstudio.com/insights/ruby-motion-promotion-tutorial
+
+Sample app here: https://github.com/jamonholmgren/promotion-tutorial
+
Typical app file structure:
app/
screens/
photos/
@@ -12,22 +16,21 @@
show_photo_screen.rb
edit_photo_screen.rb
home_screen.rb
settings_screen.rb
models/
- view_controllers/
views/
app_delegate.rb
## Usage
Loading your home screen:
```ruby
# In /app/app_delegate.rb (note that AppDelegate extends ProMotion::AppDelegateParent)
class AppDelegate < ProMotion::AppDelegateParent
- def on_load(options)
+ def on_load(app, options)
open_screen MyHomeScreen.new(nav_bar: true)
end
end
```
@@ -49,21 +52,35 @@
# Refresh the data if you want
end
end
```
-Creating a tabbed bar:
+Creating a tabbed bar from a screen (this has to be done inside a screen -- it won't work
+in your app_delegate.rb). This will set the tab bar as the root view controller for your app,
+so keep that in mind.
+NOTE: It needs to be done in the on_appear or afterward, not the `on_load` or
+`will_appear`. We will likely fix this in the future, but for now that's a restriction.
+
```ruby
-def on_load(options)
- @home = MyHomeScreen.new(nav_bar: true)
- @settings = SettingsScreen.new
- @contact = ContactScreen.new(nav_bar: true)
- open_tab_bar @home, @settings, @contact
+def on_appear
+ @home ||= MyHomeScreen.new(nav_bar: true)
+ @settings ||= SettingsScreen.new
+ @contact ||= ContactScreen.new(nav_bar: true)
+ @tab_bar ||= open_tab_bar @home, @settings, @contact
end
```
+For each screen that belongs to the tab bar, you need to set the tab name and icon in the files.
+In this example, we would need add the following to the three files (my_home_screen.rb, settings_screen.rb, contact_screen.rb):
+
+```ruby
+def on_opened
+ set_tab_bar_item title: "Tab Name Goes Here", icon: "tab_icon.png" # in resources folder
+end
+```
+
Any view item (UIView, UIButton, etc) can be used with add_element.
The second argument is a hash of settings that get applied to the
element before it is dropped into the view.
```ruby
@@ -167,11 +184,11 @@
}
```
You can create sectioned table screens easily. TableScreen, SectionedTableScreen, GroupedTableScreen.
This is loosely based on [motion-table](https://github.com/clearsightstudio/motion-table) (there are a
-few minor differences).
+few minor differences). We will eventually combine the two.
```ruby
class SettingsScreen < ProMotion::GroupedTableScreen
title "Settings"
@@ -207,9 +224,21 @@
# Your table cells, when tapped, will execute the corresponding actions and pass in arguments:
def edit_profile(arguments)
# ...
end
end
+```
+
+You can provide remotely downloaded images for cells by including the CocoaPod "SDWebImage" in
+your Rakefile and doing this:
+
+```ruby
+ cells: [
+ {
+ title: "Cell with image",
+ remoteImage: { url: "http://placekitten.com/200/300", placeholder: "some-local-image" }
+ }
+ ]
```
# Reference
(not comprehensive yet...working on this)