lib/ProMotion/screen/screen_navigation.rb in ProMotion-1.0.4 vs lib/ProMotion/screen/screen_navigation.rb in ProMotion-1.1.0.rc1
- old
+ new
@@ -21,12 +21,12 @@
present_modal_view_controller screen, args[:animated]
elsif args[:in_tab] && self.tab_bar
present_view_controller_in_tab_bar_controller screen, args[:in_tab]
- elsif self.navigation_controller
- push_view_controller screen
+ elsif self.navigationController
+ push_view_controller screen, self.navigationController, args[:animated].nil? ? true : args[:animated]
else
open_root_screen (screen.navigationController || screen)
end
@@ -53,11 +53,11 @@
args[:animated] = true unless args.has_key?(:animated)
if self.modal?
close_modal_screen args
- elsif self.navigation_controller
+ elsif self.navigationController
close_nav_screen args
send_on_return(args) # TODO: this would be better implemented in a callback or view_did_disappear.
else
PM.logger.warn "Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar."
@@ -74,18 +74,17 @@
self.parent_screen.send(:on_return)
end
end
end
- def push_view_controller(vc, nav_controller=nil)
- unless self.navigation_controller
+ def push_view_controller(vc, nav_controller=nil, animated=true)
+ unless self.navigationController
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
+ nav_controller ||= self.navigationController
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
def set_up_screen_for_open(screen, args={})
@@ -111,11 +110,11 @@
end
def ensure_wrapper_controller_in_place(screen, args={})
unless args[:close_all] || args[:modal] || args[:in_detail] || args[:in_master]
- screen.navigation_controller ||= self.navigation_controller if screen.respond_to?("navigation_controller=")
+ screen.navigationController ||= self.navigationController
screen.tab_bar ||= self.tab_bar if screen.respond_to?("tab_bar=")
end
end
def present_modal_view_controller(screen, animated)
@@ -125,11 +124,10 @@
def present_view_controller_in_tab_bar_controller(screen, tab_name)
vc = open_tab tab_name
if vc
if vc.is_a?(UINavigationController)
- screen.navigation_controller = vc if screen.respond_to?("navigation_controller=")
push_view_controller(screen, vc)
else
# TODO: This should probably open the vc, shouldn't it?
# This isn't well tested and needs to work better.
self.tab_bar.selectedIndex = vc.tabBarItem.tag
@@ -148,15 +146,15 @@
end
def close_nav_screen(args={})
args[:animated] = true unless args.has_key?(:animated)
if args[:to_screen] == :root
- self.navigation_controller.popToRootViewControllerAnimated args[:animated]
+ self.navigationController.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])
+ self.navigationController.popToViewController(args[:to_screen], animated: args[:animated])
else
- self.navigation_controller.popViewControllerAnimated(args[:animated])
+ self.navigationController.popViewControllerAnimated(args[:animated])
end
end
end
end