From ce96dc05bd3e040ba41825f86cf9f64d47ca8be3 Mon Sep 17 00:00:00 2001 From: Daniel Jabbour Date: Tue, 13 Aug 2013 19:18:34 -0700 Subject: [PATCH 1/4] Updating Tabs :icon attribute to accept UIImage --- lib/ProMotion/containers/tabs.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 From 450f9ec13742376e784d7034482862057d5949c1 Mon Sep 17 00:00:00 2001 From: David Hersey Date: Thu, 15 Aug 2013 17:46:37 -0400 Subject: [PATCH 2/4] support for open(Screen, animated:false) with nav_bar --- lib/ProMotion/screen/screen_navigation.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 2bfedb339ebb459457467e1caa8fd59287d9b66e Mon Sep 17 00:00:00 2001 From: David Hersey Date: Sat, 17 Aug 2013 15:27:42 -0400 Subject: [PATCH 3/4] added functional tests for animation support for navigation controller push --- .ruby-version | 2 +- Gemfile.lock | 2 +- app/screens/basic_screen.rb | 12 ++ spec/functional/func_screen_spec.rb | 191 ++++++++++++++++------------ 4 files changed, 121 insertions(+), 86 deletions(-) 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/Gemfile.lock b/Gemfile.lock index 6d2c601..cdfedb3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ProMotion (1.0.2) + ProMotion (1.0.3) GEM remote: https://rubygems.org/ 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/spec/functional/func_screen_spec.rb b/spec/functional/func_screen_spec.rb index a747529..d6324fb 100644 --- a/spec/functional/func_screen_spec.rb +++ b/spec/functional/func_screen_spec.rb @@ -14,100 +14,123 @@ describe "ProMotion::Screen functional" do @root_screen = nil end - it "should have a navigation bar" do - view("Functional").should.be.kind_of UINavigationItemView - end - - it "should allow setting a left nav bar button" do - @root_screen.set_nav_bar_button :left, title: "Cool", action: :triggered_button - tap("Cool") - @root_screen.button_was_triggered.should.be.true - end - - it "should allow setting a right nav bar button" do - @root_screen.set_nav_bar_button :right, title: "Cool2", action: :triggered_button - tap("Cool2") - @root_screen.button_was_triggered.should.be.true - end - - it "should allow opening another screen in the same nav bar and have a back button that is operational" do - @root_screen.open BasicScreen + # it "should have a navigation bar" do + # view("Functional").should.be.kind_of UINavigationItemView + # end + # + # it "should allow setting a left nav bar button" do + # @root_screen.set_nav_bar_button :left, title: "Cool", action: :triggered_button + # tap("Cool") + # @root_screen.button_was_triggered.should.be.true + # end + # + # it "should allow setting a right nav bar button" do + # @root_screen.set_nav_bar_button :right, title: "Cool2", action: :triggered_button + # tap("Cool2") + # @root_screen.button_was_triggered.should.be.true + # end + # + # it "should allow opening another screen in the same nav bar and have a back button that is operational" do + # @root_screen.open BasicScreen + # + # wait 0.5 do + # + # view("Basic").should.be.kind_of UINavigationItemView + # view("Functional").should.be.kind_of UINavigationItemButtonView + # + # tap("Functional") + # wait 0.5 do + # view("Functional").should.be.kind_of UINavigationItemView + # end + # + # end + # + # end + it "should push another screen with animation by default" do + basic = @root_screen.open BasicScreen wait 0.5 do - - view("Basic").should.be.kind_of UINavigationItemView - view("Functional").should.be.kind_of UINavigationItemButtonView - - tap("Functional") - wait 0.5 do - view("Functional").should.be.kind_of UINavigationItemView - end - + 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 - @root_screen.open_modal @basic - - wait 0.6 do - - view("Basic").should.be.kind_of UINavigationItemView - @basic.close - - wait 0.6 do - @basic = nil - view("Functional").should.be.kind_of UINavigationItemView - 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 fire the will_present, on_present, will_dismiss, and on_dismiss_methods" do - @presented_screen = PresentScreen.new - @root_screen.open @presented_screen - wait 0.6 do - @presented_screen.will_present_fired.should == true - @presented_screen.on_present_fired.should == true - - @presented_screen.will_dismiss_fired.should.not == true - @presented_screen.on_dismiss_fired.should.not == true - - @presented_screen.reset - - @presented_screen.close - wait 0.6 do - @presented_screen.will_dismiss_fired.should == true - @presented_screen.on_dismiss_fired.should == true - - @presented_screen.will_present_fired.should.not == true - @presented_screen.on_present_fired.should.not == true - - @presented_screen = nil - 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 pop to the root view controller" do - @root_vc = @controller.navigation_controller.visibleViewController - @controller.navigation_controller.viewControllers.count.should == 1 - @controller.open BasicScreen.new - wait 0.6 do - @controller.open BasicScreen.new - wait 0.6 do - @controller.open BasicScreen.new - wait 0.6 do - @controller.navigation_controller.viewControllers.count.should == 4 - @controller.close to_screen: :root - wait 0.6 do - @controller.navigation_controller.viewControllers.count.should == 1 - @controller.navigation_controller.topViewController.should == @root_vc - end - end - end - end - end + + # it "should allow opening and closing a modal screen" do + # @basic = BasicScreen.new(nav_bar: true) + # wait 0.1 do + # @root_screen.open_modal @basic + # + # wait 0.6 do + # + # view("Basic").should.be.kind_of UINavigationItemView + # @basic.close + # + # wait 0.6 do + # @basic = nil + # view("Functional").should.be.kind_of UINavigationItemView + # end + # + # end + # end + # end + # + # it "should fire the will_present, on_present, will_dismiss, and on_dismiss_methods" do + # @presented_screen = PresentScreen.new + # @root_screen.open @presented_screen + # wait 0.6 do + # @presented_screen.will_present_fired.should == true + # @presented_screen.on_present_fired.should == true + # + # @presented_screen.will_dismiss_fired.should.not == true + # @presented_screen.on_dismiss_fired.should.not == true + # + # @presented_screen.reset + # + # @presented_screen.close + # wait 0.6 do + # @presented_screen.will_dismiss_fired.should == true + # @presented_screen.on_dismiss_fired.should == true + # + # @presented_screen.will_present_fired.should.not == true + # @presented_screen.on_present_fired.should.not == true + # + # @presented_screen = nil + # end + # end + # end + # + # it "should pop to the root view controller" do + # @root_vc = @controller.navigation_controller.visibleViewController + # @controller.navigation_controller.viewControllers.count.should == 1 + # @controller.open BasicScreen.new + # wait 0.6 do + # @controller.open BasicScreen.new + # wait 0.6 do + # @controller.open BasicScreen.new + # wait 0.6 do + # @controller.navigation_controller.viewControllers.count.should == 4 + # @controller.close to_screen: :root + # wait 0.6 do + # @controller.navigation_controller.viewControllers.count.should == 1 + # @controller.navigation_controller.topViewController.should == @root_vc + # end + # end + # end + # end + # end end From 6b0e56ae186c749903ed463c7a1424c7914069a8 Mon Sep 17 00:00:00 2001 From: David Hersey Date: Sat, 17 Aug 2013 15:27:42 -0400 Subject: [PATCH 4/4] added functional tests for animation support for navigation controller push --- .ruby-version | 2 +- Gemfile.lock | 2 +- app/screens/basic_screen.rb | 12 ++++++ spec/functional/func_screen_spec.rb | 57 ++++++++++++++++++++--------- 4 files changed, 54 insertions(+), 19 deletions(-) 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/Gemfile.lock b/Gemfile.lock index 6d2c601..cdfedb3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ProMotion (1.0.2) + ProMotion (1.0.3) GEM remote: https://rubygems.org/ 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/spec/functional/func_screen_spec.rb b/spec/functional/func_screen_spec.rb index a747529..90dbcc2 100644 --- a/spec/functional/func_screen_spec.rb +++ b/spec/functional/func_screen_spec.rb @@ -17,79 +17,102 @@ describe "ProMotion::Screen functional" do it "should have a navigation bar" do view("Functional").should.be.kind_of UINavigationItemView end - + it "should allow setting a left nav bar button" do @root_screen.set_nav_bar_button :left, title: "Cool", action: :triggered_button tap("Cool") @root_screen.button_was_triggered.should.be.true end - + it "should allow setting a right nav bar button" do @root_screen.set_nav_bar_button :right, title: "Cool2", action: :triggered_button tap("Cool2") @root_screen.button_was_triggered.should.be.true end - + it "should allow opening another screen in the same nav bar and have a back button that is operational" do @root_screen.open BasicScreen - + wait 0.5 do - + view("Basic").should.be.kind_of UINavigationItemView view("Functional").should.be.kind_of UINavigationItemButtonView - + tap("Functional") wait 0.5 do view("Functional").should.be.kind_of UINavigationItemView 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 @root_screen.open_modal @basic - + wait 0.6 do - + view("Basic").should.be.kind_of UINavigationItemView @basic.close - + wait 0.6 do @basic = nil view("Functional").should.be.kind_of UINavigationItemView end - + end end end - + it "should fire the will_present, on_present, will_dismiss, and on_dismiss_methods" do @presented_screen = PresentScreen.new @root_screen.open @presented_screen wait 0.6 do @presented_screen.will_present_fired.should == true @presented_screen.on_present_fired.should == true - + @presented_screen.will_dismiss_fired.should.not == true @presented_screen.on_dismiss_fired.should.not == true - + @presented_screen.reset - + @presented_screen.close wait 0.6 do @presented_screen.will_dismiss_fired.should == true @presented_screen.on_dismiss_fired.should == true - + @presented_screen.will_present_fired.should.not == true @presented_screen.on_present_fired.should.not == true - + @presented_screen = nil end end end - + it "should pop to the root view controller" do @root_vc = @controller.navigation_controller.visibleViewController @controller.navigation_controller.viewControllers.count.should == 1