From ac177d82fbf3e8c445d690ef40b71ae4162f957e Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Fri, 28 Jun 2013 15:29:48 -0400 Subject: [PATCH] implemented and tested "close to_screen: :root" Also accepts other close parameters like animated:true|false --- lib/ProMotion/screen/screen_navigation.rb | 8 +++----- spec/functional/func_screen_spec.rb | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ProMotion/screen/screen_navigation.rb b/lib/ProMotion/screen/screen_navigation.rb index 0ecc0f0..9d8efbc 100644 --- a/lib/ProMotion/screen/screen_navigation.rb +++ b/lib/ProMotion/screen/screen_navigation.rb @@ -40,10 +40,6 @@ module ProMotion app_delegate.open_root_screen(screen) end - def pop_to_root(animated = false) - self.navigation_controller.popToRootViewControllerAnimated animated - end - def open_modal(screen, args = {}) open screen, args.merge({ modal: true }) end @@ -154,7 +150,9 @@ module ProMotion def close_nav_screen(args={}) args[:animated] = true unless args.has_key?(:animated) - if args[:to_screen] && args[:to_screen].is_a?(UIViewController) + if args[:to_screen] == :root + self.navigation_controller.popToRootViewControllerAnimated args[:animated] + elsif args[:to_screen] && args[:to_screen].is_a?(UIViewController) self.parent_screen = args[:to_screen] self.navigation_controller.popToViewController(args[:to_screen], animated: args[:animated]) else diff --git a/spec/functional/func_screen_spec.rb b/spec/functional/func_screen_spec.rb index be9bbc8..593e8b9 100644 --- a/spec/functional/func_screen_spec.rb +++ b/spec/functional/func_screen_spec.rb @@ -100,7 +100,7 @@ describe "ProMotion::Screen functional" do @controller.open BasicScreen.new wait 0.6 do @controller.navigation_controller.viewControllers.count.should == 4 - @controller.pop_to_root true + @controller.close to_screen: :root wait 0.6 do @controller.navigation_controller.viewControllers.count.should == 1 @controller.navigation_controller.topViewController.should == @root_vc