lib/ProMotion/screen/nav_bar_module.rb in ProMotion-2.7.1 vs lib/ProMotion/screen/nav_bar_module.rb in ProMotion-2.8.0
- old
+ new
@@ -46,23 +46,31 @@
alias_method :set_toolbar_buttons, :set_toolbar_items
alias_method :set_toolbar_button, :set_toolbar_items
def add_nav_bar(args = {})
args = self.class.get_nav_bar.merge(args)
- return unless args[:nav_bar]
+ return unless args[:nav_bar] || args[:nav_controller]
self.navigationController ||= begin
self.first_screen = true if self.respond_to?(:first_screen=)
- nav = (args[:nav_controller] || NavigationController).alloc.initWithRootViewController(self)
+ nav_controller_class = args[:nav_controller] || NavigationController
+ if nav_controller_class.is_a? Class
+ nav = nav_controller_class.alloc.initWithRootViewController(self)
+ else
+ nav = nav_controller_class
+ nav.setViewControllers([self], animated: false)
+ end
nav.setModalTransitionStyle(args[:transition_style]) if args[:transition_style]
nav.setModalPresentationStyle(args[:presentation_style]) if args[:presentation_style]
nav
end
self.navigationController.toolbarHidden = !args[:toolbar] unless args[:toolbar].nil?
end
- def view_will_appear(animated)
- if @screen_options && !@screen_options[:hide_nav_bar].nil?
- self.navigationController.setNavigationBarHidden(@screen_options[:hide_nav_bar], animated: false)
+ def update_nav_bar_visibility(animated)
+ return unless navigationController
+ hidden = @screen_options[:hide_nav_bar]
+ unless hidden.nil?
+ navigationController.setNavigationBarHidden(hidden, animated: animated)
end
end
private