Sha256: 5130d6cb32640964686644a2c5ab7e6341816d6e95e0b7c60165f3b33fcfd83d

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

module ProMotion
  class Delegate
    include ProMotion::ScreenTabs
    include ProMotion::SplitScreen if NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].include?("2") # Only with iPad
    attr_accessor :window

    def application(application, didFinishLaunchingWithOptions:launch_options)
      unless self.respond_to?(:on_load)
        PM.logger.error "Your AppDelegate (usually in app_delegate.rb) needs an on_load(application, options) method."
      end

      on_load(application, launch_options)

      true
    end

    def app_delegate
      UIApplication.sharedApplication.delegate
    end

    def app_window
      self.app_delegate.window
    end

    def home(screen)
      screen = screen.new if screen.respond_to?(:new)
      @home_screen = screen
    end

    def load_root_screen(new_screen)
      new_screen = new_screen.pm_main_controller

      self.window ||= self.ui_window.alloc.initWithFrame(UIScreen.mainScreen.bounds)
      self.window.rootViewController = new_screen
      self.window.makeKeyAndVisible
    end
    
    def ui_window
      (defined?(Motion) && defined?(Motion::Xray) && defined?(Motion::Xray::XrayWindow)) ? Motion::Xray::XrayWindow : UIWindow
    end

    def open_screen(screen, args={})
      home(screen)
      open_home_screen
    end
    alias :open :open_screen
    alias :open_root_screen :open_screen

    def open_home_screen
      get_home_screen.send(:on_load) if get_home_screen.respond_to?(:on_load)
      load_root_screen get_home_screen
    end

    def get_home_screen
      @home_screen
    end

    def has_home_screen
      @home_screen.nil? == false
    end
  end
  class AppDelegateParent < Delegate; end # For backwards compatibility
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ProMotion-0.6.5 lib/ProMotion/delegate.rb
ProMotion-0.6.4 lib/ProMotion/delegate.rb
ProMotion-0.6.3 lib/ProMotion/delegate.rb