Class: ProMotion::Delegate

Inherits:
Object
  • Object
show all
Includes:
ScreenTabs, SplitScreen
Defined in:
lib/ProMotion/delegate.rb

Direct Known Subclasses

AppDelegateParent

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SplitScreen

#create_split_screen, #open_split_screen, #splitViewController, #split_screen_controller

Methods included from ScreenTabs

#create_tab_bar_icon, #create_tab_bar_icon_custom, #create_tab_bar_item, #open_tab, #open_tab_bar, #replace_current_item, #select, #tab_bar_controller

Instance Attribute Details

#windowObject

Returns the value of attribute window.



5
6
7
# File 'lib/ProMotion/delegate.rb', line 5

def window
  @window
end

Instance Method Details

#app_delegateObject



17
18
19
# File 'lib/ProMotion/delegate.rb', line 17

def app_delegate
  UIApplication.sharedApplication.delegate
end

#app_windowObject



21
22
23
# File 'lib/ProMotion/delegate.rb', line 21

def app_window
  self.app_delegate.window
end

#application(application, didFinishLaunchingWithOptions: launch_options) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/ProMotion/delegate.rb', line 7

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

#get_home_screenObject



54
55
56
# File 'lib/ProMotion/delegate.rb', line 54

def get_home_screen
  @home_screen
end

#has_home_screenObject



58
59
60
# File 'lib/ProMotion/delegate.rb', line 58

def has_home_screen
  @home_screen.nil? == false
end

#home(screen) ⇒ Object



25
26
27
28
# File 'lib/ProMotion/delegate.rb', line 25

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

#load_root_screen(new_screen) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/ProMotion/delegate.rb', line 30

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

#open_home_screenObject



49
50
51
52
# File 'lib/ProMotion/delegate.rb', line 49

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

#open_screen(screen, args = {}) ⇒ Object Also known as: open, open_root_screen



42
43
44
45
# File 'lib/ProMotion/delegate.rb', line 42

def open_screen(screen, args={})
  home(screen)
  open_home_screen
end

#ui_windowObject



38
39
40
# File 'lib/ProMotion/delegate.rb', line 38

def ui_window
  (defined?(Motion) && defined?(Motion::Xray) && defined?(Motion::Xray::XrayWindow)) ? Motion::Xray::XrayWindow : UIWindow
end