mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-06-01 19:49:13 +08:00
Merge branch 'master' of https://github.com/sxross/ProMotion
Conflicts: lib/ProMotion/screens/_screen_module.rb
This commit is contained in:
@@ -50,7 +50,9 @@ http://www.clearsightstudio.com/insights/tutorial-make-youtube-video-app-rubymot
|
||||
|
||||
## Sample Apps
|
||||
|
||||
[https://github.com/jamonholmgren/promotion-tutorial](https://github.com/jamonholmgren/promotion-tutorial)
|
||||
This is pretty bare-bones, but we'll be building it out as we go along.
|
||||
|
||||
[https://github.com/jamonholmgren/promotion-demo](https://github.com/jamonholmgren/promotion-demo)
|
||||
|
||||
## Apps Built With ProMotion
|
||||
|
||||
@@ -250,6 +252,8 @@ set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemS
|
||||
set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
```
|
||||
|
||||
If you pass an instance of a `UIImage`, the `UIBarButton` will automatically display with that image instead of text. *Don't forget retina and landscape versions of your image!*
|
||||
|
||||
## Opening and closing screens
|
||||
|
||||
If the user taps something and you want to open a new screen, it's easy. Just use `open` and pass in the screen class
|
||||
@@ -290,7 +294,6 @@ class ProfileScreen < ProMotion::Screen
|
||||
self.user # => some_user instance
|
||||
end
|
||||
end
|
||||
|
||||
```
|
||||
|
||||
Closing a screen is as easy as can be.
|
||||
@@ -570,12 +573,14 @@ end
|
||||
<td>set_nav_bar_left_button(title, args = {})</td>
|
||||
<td>
|
||||
Set a left nav bar button.<br />
|
||||
`title` can be a `String` or a `UIImage`.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>set_nav_bar_right_button(title, args = {})</td>
|
||||
<td>
|
||||
Set a right nav bar button.<br />
|
||||
`title` can be a `String` or a `UIImage`.
|
||||
<img src="http://i.imgur.com/whbkc.png" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
2
Rakefile
2
Rakefile
@@ -1,5 +1,5 @@
|
||||
$:.unshift("/Library/RubyMotion/lib")
|
||||
require 'motion/project'
|
||||
require 'motion/project/template/ios'
|
||||
require 'bundler/gem_tasks'
|
||||
Bundler.setup
|
||||
Bundler.require
|
||||
|
||||
@@ -78,8 +78,10 @@ module ProMotion
|
||||
args[:target] ||= self
|
||||
args[:action] ||= nil
|
||||
|
||||
if args[:system_icon]
|
||||
button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action])
|
||||
button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action]) if args[:system_icon]
|
||||
|
||||
if args[:title].is_a?(UIImage)
|
||||
button = UIBarButtonItem.alloc.initWithImage(args[:title], style: args[:style], target: args[:target], action: args[:action])
|
||||
else
|
||||
button = UIBarButtonItem.alloc.initWithTitle(args[:title], style: args[:style], target: args[:target], action: args[:action])
|
||||
end
|
||||
|
||||
BIN
resources/list.png
Executable file
BIN
resources/list.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 104 B |
@@ -4,10 +4,10 @@ class HomeScreen < ProMotion::Screen
|
||||
|
||||
def on_load
|
||||
set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
|
||||
set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
set_nav_bar_left_button UIImage.imageNamed("list.png"), action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
end
|
||||
|
||||
def on_return(args={})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,25 +35,39 @@ describe "screen helpers" do
|
||||
@screen.add_to @subview, sub_subview, { backgroundColor: UIColor.redColor }
|
||||
@subview.subviews.last.backgroundColor.should == UIColor.redColor
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
describe "nav bar buttons" do
|
||||
|
||||
|
||||
before do
|
||||
@screen = HomeScreen.new(nav_bar: true)
|
||||
end
|
||||
|
||||
|
||||
it "should add a left nav bar button" do
|
||||
@screen.set_nav_bar_left_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
|
||||
@screen.navigationItem.leftBarButtonItem.class.should == UIBarButtonItem
|
||||
end
|
||||
|
||||
|
||||
it "should add a right nav bar button" do
|
||||
@screen.set_nav_bar_right_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
@screen.navigationItem.rightBarButtonItem.class.should == UIBarButtonItem
|
||||
end
|
||||
|
||||
|
||||
it "should add an image right nav bar button" do
|
||||
image = UIImage.imageNamed("list.png")
|
||||
@screen.set_nav_bar_right_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
@screen.navigationItem.rightBarButtonItem.image.class.should == UIImage
|
||||
@screen.navigationItem.rightBarButtonItem.image.should == image
|
||||
end
|
||||
|
||||
it "should add an image left nav bar button" do
|
||||
image = UIImage.imageNamed("list.png")
|
||||
@screen.set_nav_bar_left_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
|
||||
@screen.navigationItem.leftBarButtonItem.image.class.should == UIImage
|
||||
@screen.navigationItem.leftBarButtonItem.image.should == image
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "screen navigation" do
|
||||
|
||||
Reference in New Issue
Block a user