lib/ProMotion/screen/screen_module.rb in ProMotion-2.6.1 vs lib/ProMotion/screen/screen_module.rb in ProMotion-2.7.0

- old
+ new

@@ -2,10 +2,11 @@ module ScreenModule include ProMotion::Support include ProMotion::ScreenNavigation include ProMotion::Styling include ProMotion::NavBarModule + include ProMotion::StatusBarModule include ProMotion::Tabs include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad || (UIDevice.currentDevice.systemVersion.to_i >= 8 ) attr_reader :parent_screen attr_accessor :first_screen, :modal, :split_screen @@ -39,11 +40,10 @@ self.send(:on_load) if self.respond_to?(:on_load) end def view_will_appear(animated) super - resolve_status_bar self.will_appear self.will_present if isMovingToParentViewController end def will_appear; end @@ -177,42 +177,16 @@ else mp("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.", force_color: :yellow) end end - def resolve_status_bar - case self.class.status_bar_type - when :none - status_bar_hidden true - when :light - status_bar_hidden false - status_bar_style UIStatusBarStyleLightContent - when :dark - status_bar_hidden false - status_bar_style UIStatusBarStyleDefault - else - return status_bar_hidden true if UIApplication.sharedApplication.isStatusBarHidden - status_bar_hidden false - global_style = NSBundle.mainBundle.objectForInfoDictionaryKey("UIStatusBarStyle") - status_bar_style global_style ? Object.const_get(global_style) : UIStatusBarStyleDefault - end - end - def add_nav_bar_buttons self.class.get_nav_bar_button.each do |button_args| set_nav_bar_button(button_args[:side], button_args) end end - def status_bar_hidden(hidden) - UIApplication.sharedApplication.setStatusBarHidden(hidden, withAnimation:self.class.status_bar_animation) - end - - def status_bar_style(style) - UIApplication.sharedApplication.setStatusBarStyle(style) - end - 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, :toolbar ] set_attributes self, args.dup.delete_if { |k,v| reserved_args.include?(k) } end @@ -225,11 +199,10 @@ unless self.is_a?(UIViewController) raise StandardError.new("ERROR: Screens must extend UIViewController or a subclass of UIViewController.") end end - # Class methods module ClassMethods def title(t=nil) if t && t.is_a?(String) == false mp "You're trying to set the title of #{self.to_s} to an instance of #{t.class.to_s}. In ProMotion 2+, you must use `title_image` or `title_view` instead.", force_color: :yellow return raise StandardError @@ -251,26 +224,10 @@ def title_view(t) @title = t @title_type = :view end - def status_bar(style=nil, args={}) - if NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance').nil? - mp "status_bar will have no effect unless you set 'UIViewControllerBasedStatusBarAppearance' to false in your info.plist", force_color: :yellow - end - @status_bar_style = style - @status_bar_animation = args[:animation] if args[:animation] - end - - def status_bar_type - @status_bar_style || :default - end - - def status_bar_animation - @status_bar_animation || UIStatusBarAnimationSlide - end - def nav_bar(enabled, args={}) @nav_bar_args = ({ nav_bar: enabled }).merge(args) end def get_nav_bar @@ -289,9 +246,10 @@ end end def self.included(base) base.extend(ClassMethods) - base.extend(TabClassMethods) # TODO: Is there a better way? + base.extend(StatusBarModule::ClassMethods) + base.extend(Tabs::ClassMethods) end end end