module ProMotion::StatusBarModule

Public Class Methods

included(base) click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 73
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

hide_status_bar(opts = {}) click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 27
def hide_status_bar(opts = {})
  @previous_status_bar_style = self.class.status_bar_style
  self.class.status_bar_style(:hidden)
  update_status_bar_appearance(opts)
end
preferredStatusBarStyle() click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 3
def preferredStatusBarStyle
  styles = {
    light: UIStatusBarStyleLightContent,
    dark: UIStatusBarStyleDefault,
    default: UIStatusBarStyleDefault
  }
  styles[self.class.status_bar_style || app.delegate.status_bar_style]  || styles[:default]
end
preferredStatusBarUpdateAnimation() click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 12
def preferredStatusBarUpdateAnimation
  animations = {
    none: UIStatusBarAnimationNone,
    fade: UIStatusBarAnimationFade,
    slide: UIStatusBarAnimationSlide,
    default: UIStatusBarAnimationFade
  }
  animations[self.class.status_bar_animation || app.delegate.status_bar_animation] || animations[:default]
end
prefersStatusBarHidden() click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 22
def prefersStatusBarHidden
  style = self.class.status_bar_style || app.delegate.status_bar_style
  [:none, :hidden].include?(style)
end
show_status_bar(opts = {}) click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 33
def show_status_bar(opts = {})
  new_style = case @previous_status_bar_style
              when nil, :hidden, :none
                opts[:style] || app.delegate.status_bar_style || :default
              else
                @previous_status_bar_style
              end
  self.class.status_bar_style(new_style)
  update_status_bar_appearance(opts)
end
update_status_bar_appearance(opts = {}) click to toggle source
# File lib/ProMotion/screen/status_bar_module.rb, line 44
def update_status_bar_appearance(opts = {})
  if opts[:animated] == true
    UIView.animateWithDuration(0.3, animations: -> { setNeedsStatusBarAppearanceUpdate })
  else
    setNeedsStatusBarAppearanceUpdate
  end
end