diff --git a/.ruby-version b/.ruby-version index 2aaf252..d72af3d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-1.9.3-p392 +ruby-1.9.3-head diff --git a/app/screens/basic_screen.rb b/app/screens/basic_screen.rb index 4b12492..cf62686 100644 --- a/app/screens/basic_screen.rb +++ b/app/screens/basic_screen.rb @@ -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 diff --git a/lib/ProMotion/containers/tabs.rb b/lib/ProMotion/containers/tabs.rb index 40dfab2..c1133ac 100644 --- a/lib/ProMotion/containers/tabs.rb +++ b/lib/ProMotion/containers/tabs.rb @@ -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 diff --git a/lib/ProMotion/screen/screen_navigation.rb b/lib/ProMotion/screen/screen_navigation.rb index 115ba0d..a0dc362 100644 --- a/lib/ProMotion/screen/screen_navigation.rb +++ b/lib/ProMotion/screen/screen_navigation.rb @@ -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 diff --git a/spec/functional/func_screen_spec.rb b/spec/functional/func_screen_spec.rb index d9e4c5a..d0eeb8f 100644 --- a/spec/functional/func_screen_spec.rb +++ b/spec/functional/func_screen_spec.rb @@ -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