lib/ProMotion/delegate/delegate_module.rb in ProMotion-2.7.1 vs lib/ProMotion/delegate/delegate_module.rb in ProMotion-2.8.0
- old
+ new
@@ -49,11 +49,11 @@
def ui_window
(defined?(Motion) && defined?(Motion::Xray) && defined?(Motion::Xray::XrayWindow)) ? Motion::Xray::XrayWindow : UIWindow
end
def open(screen, args={})
- screen = screen.new if screen.respond_to?(:new)
+ screen = set_up_screen_for_open(screen, args)
self.home_screen = screen
self.window ||= self.ui_window.alloc.initWithFrame(UIScreen.mainScreen.bounds)
self.window.rootViewController = (screen.navigationController || screen)
@@ -62,9 +62,30 @@
screen
end
alias :open_screen :open
alias :open_root_screen :open_screen
+
+ def set_up_screen_for_open(screen, args={})
+ # Instantiate screen if given a class
+ screen = screen.new(args) if screen.respond_to?(:new)
+
+ # Store screen options
+ screen.screen_options.merge(args) if screen.respond_to?(:screen_options)
+
+ # Set title & modal properties
+ screen.title = args[:title] if args[:title] && screen.respond_to?(:title=)
+ screen.modal = args[:modal] if args[:modal] && screen.respond_to?(:modal=)
+
+ # Hide bottom bar?
+ screen.hidesBottomBarWhenPushed = args[:hide_tab_bar] == true
+
+ # Wrap in a PM::NavigationController?
+ screen.add_nav_bar(args) if screen.respond_to?(:add_nav_bar)
+
+ # Return modified screen instance
+ screen
+ end
# DEPRECATED
def status_bar?
mp "The default behavior of `status_bar?` has changed. Calling `status_bar?` on AppDelegate may not return the correct result.", force_color: :yellow
self.class.status_bar_style != :hidden