lib/ProMotion/screen/screen_module.rb in ProMotion-2.2.2 vs lib/ProMotion/screen/screen_module.rb in ProMotion-2.3.0

- old
+ new

@@ -1,7 +1,8 @@ module ProMotion module ScreenModule + include ProMotion::Support include ProMotion::ScreenNavigation include ProMotion::Styling include ProMotion::NavBarModule include ProMotion::Tabs include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad @@ -11,10 +12,11 @@ def screen_init(args = {}) check_ancestry resolve_title apply_properties(args) add_nav_bar(args) if args[:nav_bar] + add_nav_bar_buttons tab_bar_setup try :on_init try :screen_setup PM.logger.deprecated "In #{self.class.to_s}, #on_create has been deprecated and removed. Use #screen_init instead." if respond_to?(:on_create) end @@ -44,10 +46,14 @@ status_bar_hidden false status_bar_style UIStatusBarStyleDefault end end + def add_nav_bar_buttons + set_nav_bar_button(self.class.get_nav_bar_button[:side], self.class.get_nav_bar_button) if self.class.get_nav_bar_button + end + def status_bar_hidden(hidden) UIApplication.sharedApplication.setStatusBarHidden(hidden, withAnimation:self.class.status_bar_animation) end def status_bar_style(style) @@ -164,14 +170,10 @@ def frame return self.view_or_self.frame end - def try(method, *args) - send(method, *args) if respond_to?(method) - end - private def apply_properties(args) reserved_args = [ :nav_bar, :hide_nav_bar, :hide_tab_bar, :animated, :close_all, :in_tab, :in_detail, :in_master, :to_screen ] set_attributes self, args.dup.delete_if { |k,v| reserved_args.include?(k) } @@ -226,9 +228,18 @@ @status_bar_style || :default end def status_bar_animation @status_bar_animation || UIStatusBarAnimationSlide + end + + def nav_bar_button(side, args={}) + @nav_bar_button_args = args + @nav_bar_button_args[:side] = side + end + + def get_nav_bar_button + @nav_bar_button_args end end def self.included(base) base.extend(ClassMethods)