mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-05-24 09:13:24 +08:00
Adding support for open(Screen, animated: false) with specs
This commit is contained in:
@@ -1 +1 @@
|
||||
ruby-1.9.3-p392
|
||||
ruby-1.9.3-head
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
class BasicScreen < PM::Screen
|
||||
title "Basic"
|
||||
|
||||
attr_reader :animation_ts
|
||||
|
||||
def will_appear
|
||||
@will_appear_ts = NSDate.date
|
||||
end
|
||||
|
||||
def on_appear
|
||||
@on_appear_ts = NSDate.date
|
||||
@animation_ts = @on_appear_ts - @will_appear_ts
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -35,8 +35,10 @@ module ProMotion
|
||||
return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
|
||||
end
|
||||
|
||||
def create_tab_bar_icon_custom(title, image_name, tag)
|
||||
icon_image = UIImage.imageNamed(image_name)
|
||||
def create_tab_bar_icon_custom(title, icon_image, tag)
|
||||
if icon_image.is_a?(String)
|
||||
icon_image = UIImage.imageNamed(icon_image)
|
||||
end
|
||||
return UITabBarItem.alloc.initWithTitle(title, image:icon_image, tag:tag)
|
||||
end
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ module ProMotion
|
||||
present_view_controller_in_tab_bar_controller screen, args[:in_tab]
|
||||
|
||||
elsif self.navigation_controller
|
||||
push_view_controller screen
|
||||
push_view_controller screen, self.navigation_controller, args[:animated].nil? ? true : args[:animated]
|
||||
|
||||
else
|
||||
open_root_screen (screen.navigationController || screen)
|
||||
@@ -76,14 +76,14 @@ module ProMotion
|
||||
end
|
||||
end
|
||||
|
||||
def push_view_controller(vc, nav_controller=nil)
|
||||
def push_view_controller(vc, nav_controller=nil, animated=true)
|
||||
unless self.navigation_controller
|
||||
PM.logger.error "You need a nav_bar if you are going to push #{vc.to_s} onto it."
|
||||
end
|
||||
nav_controller ||= self.navigation_controller
|
||||
vc.first_screen = false if vc.respond_to?(:first_screen=)
|
||||
vc.navigation_controller = nav_controller if vc.respond_to?(:navigation_controller=)
|
||||
nav_controller.pushViewController(vc, animated: true)
|
||||
nav_controller.pushViewController(vc, animated: animated)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -50,8 +50,31 @@ describe "ProMotion::Screen functional" do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it "should push another screen with animation by default" do
|
||||
basic = @root_screen.open BasicScreen
|
||||
wait 0.5 do
|
||||
basic.animation_ts.should.be > 0.2
|
||||
end
|
||||
end
|
||||
|
||||
it "should push another screen with animation when animated: true" do
|
||||
basic = @root_screen.open BasicScreen, animated: true
|
||||
wait 0.5 do
|
||||
basic.animation_ts.should.be > 0.2
|
||||
end
|
||||
end
|
||||
|
||||
it "should push another screen without animation when animated: false" do
|
||||
basic = @root_screen.open BasicScreen, animated: false
|
||||
wait 0.5 do
|
||||
basic.animation_ts.should.be < 0.2
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it "should allow opening and closing a modal screen" do
|
||||
@basic = BasicScreen.new(nav_bar: true)
|
||||
wait 0.1 do
|
||||
|
||||
Reference in New Issue
Block a user