lib/ProMotion/screen/screen_navigation.rb in ProMotion-2.7.1 vs lib/ProMotion/screen/screen_navigation.rb in ProMotion-2.8.0
- old
+ new
@@ -8,27 +8,28 @@
# Apply properties to instance
screen = set_up_screen_for_open(screen, args)
ensure_wrapper_controller_in_place(screen, args)
opened ||= open_in_split_screen(screen, args) if self.split_screen
- opened ||= open_root_screen(screen) if args[:close_all]
+ opened ||= open_root_screen(screen, args) if args[:close_all]
+ opened ||= replace_nav_stack([screen], args) if args[:replace_nav_stack]
opened ||= present_modal_view_controller(screen, args) if args[:modal]
opened ||= open_in_tab(screen, args[:in_tab]) if args[:in_tab]
opened ||= push_view_controller(screen, self.navigationController, !!args[:animated]) if self.navigationController
- opened ||= open_root_screen(screen.navigationController || screen)
+ opened ||= open_root_screen(screen.navigationController || screen, args)
screen
end
alias :open :open_screen
def open_in_split_screen(screen, args)
self.split_screen.detail_screen = screen if args[:in_detail]
self.split_screen.master_screen = screen if args[:in_master]
args[:in_detail] || args[:in_master]
end
- def open_root_screen(screen)
- app_delegate.open_root_screen(screen)
+ def open_root_screen(screen, args = {})
+ app_delegate.open_root_screen(screen, args)
end
def open_modal(screen, args = {})
open screen, args.merge({ modal: true })
end
@@ -73,19 +74,23 @@
return if nav_controller.topViewController == vc
vc.first_screen = false if vc.respond_to?(:first_screen=)
nav_controller.pushViewController(vc, animated: animated)
end
+ def replace_nav_stack(screens, args = {})
+ args[:animated] ||= true
+ navigationController.setViewControllers(screens, animated: !!args[:animated])
+ end
+
protected
def set_up_screen_for_open(screen, args={})
-
# Instantiate screen if given a class
- screen = screen.new if screen.respond_to?(:new)
+ screen = screen.new(args) if screen.respond_to?(:new)
# Store screen options
- screen.instance_variable_set(:@screen_options, args)
+ screen.screen_options.merge(args) if screen.respond_to?(:screen_options)
# Set parent
screen.parent_screen = self if screen.respond_to?(:parent_screen=)
# Set title & modal properties
@@ -94,14 +99,13 @@
# Hide bottom bar?
screen.hidesBottomBarWhenPushed = args[:hide_tab_bar] == true
# Wrap in a PM::NavigationController?
- screen.add_nav_bar(args) if args[:nav_bar] && screen.respond_to?(:add_nav_bar)
+ screen.add_nav_bar(args) if screen.respond_to?(:add_nav_bar)
# Return modified screen instance
screen
-
end
def ensure_wrapper_controller_in_place(screen, args={})
unless args[:close_all] || args[:modal] || args[:in_detail] || args[:in_master]
screen.navigationController ||= self.navigationController if screen.respond_to?("navigationController=")