Module: ProMotion::ScreenModule

Includes:
NavBarModule, ScreenNavigation, SplitScreen, Styling, Support, Tabs
Included in:
GroupedTableScreen, Screen, TableScreen, WebScreen
Defined in:
lib/ProMotion/screen/screen_module.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Attributes included from Tabs

#tab_bar, #tab_bar_item

Instance Method Summary collapse

Methods included from SplitScreen

#create_split_screen, #open_split_screen, #splitViewController

Methods included from Tabs

#create_tab_bar_item, #create_tab_bar_item_custom, #current_tag, #map_tab_symbol, #open_tab, #open_tab_bar, #refresh_tab_bar_item, #replace_current_item, #set_tab_bar_badge, #set_tab_bar_item

Methods included from NavBarModule

#add_nav_bar, #nav_bar?, #navigationController=, #navigation_controller, #navigation_controller=, #set_nav_bar_button, #set_nav_bar_buttons, #set_nav_bar_left_button, #set_toolbar_items

Methods included from Styling

#add, #add_to, #camelize, #closest_parent, #content_height, #content_max, #content_width, #hex_color, #remove, #rgb_color, #rgba_color, #set_attribute, #set_attributes, #view_or_self

Methods included from ScreenNavigation

#close_screen, #open_in_split_screen, #open_modal, #open_root_screen, #open_screen, #push_view_controller, #send_on_return

Methods included from Support

#app, #app_delegate, #app_window, #try

Instance Attribute Details

#first_screenObject

Returns the value of attribute first_screen.



10
11
12
# File 'lib/ProMotion/screen/screen_module.rb', line 10

def first_screen
  @first_screen
end

Returns the value of attribute modal.



10
11
12
# File 'lib/ProMotion/screen/screen_module.rb', line 10

def modal
  @modal
end

#parent_screenObject

Returns the value of attribute parent_screen.



10
11
12
# File 'lib/ProMotion/screen/screen_module.rb', line 10

def parent_screen
  @parent_screen
end

#split_screenObject

Returns the value of attribute split_screen.



10
11
12
# File 'lib/ProMotion/screen/screen_module.rb', line 10

def split_screen
  @split_screen
end

Instance Method Details

#add_nav_bar_buttonsObject



51
52
53
# File 'lib/ProMotion/screen/screen_module.rb', line 51

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

#boundsObject



167
168
169
# File 'lib/ProMotion/screen/screen_module.rb', line 167

def bounds
  return self.view_or_self.bounds
end

#first_screen?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/ProMotion/screen/screen_module.rb', line 67

def first_screen?
  self.first_screen == true
end

#frameObject



171
172
173
# File 'lib/ProMotion/screen/screen_module.rb', line 171

def frame
  return self.view_or_self.frame
end

#modal?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ProMotion/screen/screen_module.rb', line 24

def modal?
  self.modal == true
end

#on_appearObject



89
# File 'lib/ProMotion/screen/screen_module.rb', line 89

def on_appear; end

#on_disappearObject



105
# File 'lib/ProMotion/screen/screen_module.rb', line 105

def on_disappear; end

#on_dismissObject



106
# File 'lib/ProMotion/screen/screen_module.rb', line 106

def on_dismiss; end

#on_presentObject



90
# File 'lib/ProMotion/screen/screen_module.rb', line 90

def on_present; end

#on_rotateObject



130
131
# File 'lib/ProMotion/screen/screen_module.rb', line 130

def on_rotate
end

#resolve_status_barObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ProMotion/screen/screen_module.rb', line 38

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
  else
    status_bar_hidden false
    status_bar_style UIStatusBarStyleDefault
  end
end

#resolve_titleObject



28
29
30
31
32
33
34
35
36
# File 'lib/ProMotion/screen/screen_module.rb', line 28

def resolve_title
  case self.class.title_type
  when :text then self.title = self.class.title
  when :view then self.navigationItem.titleView = self.class.title
  when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(self.class.title)
  else
    PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.")
  end
end

#screen_init(args = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ProMotion/screen/screen_module.rb', line 12

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

#should_autorotateObject



126
127
128
# File 'lib/ProMotion/screen/screen_module.rb', line 126

def should_autorotate
  true
end

#should_rotate(orientation) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ProMotion/screen/screen_module.rb', line 108

def should_rotate(orientation)
  case orientation
  when UIInterfaceOrientationPortrait
    return supported_orientation?("UIInterfaceOrientationPortrait")
  when UIInterfaceOrientationLandscapeLeft
    return supported_orientation?("UIInterfaceOrientationLandscapeLeft")
  when UIInterfaceOrientationLandscapeRight
    return supported_orientation?("UIInterfaceOrientationLandscapeRight")
  when UIInterfaceOrientationPortraitUpsideDown
    return supported_orientation?("UIInterfaceOrientationPortraitUpsideDown")
  else
    false
  end
end

#status_bar_hidden(hidden) ⇒ Object



55
56
57
# File 'lib/ProMotion/screen/screen_module.rb', line 55

def status_bar_hidden(hidden)
  UIApplication.sharedApplication.setStatusBarHidden(hidden, withAnimation:self.class.status_bar_animation)
end

#status_bar_style(style) ⇒ Object



59
60
61
# File 'lib/ProMotion/screen/screen_module.rb', line 59

def status_bar_style(style)
  UIApplication.sharedApplication.setStatusBarStyle(style)
end

#supported_device_familiesObject



154
155
156
157
158
159
160
161
# File 'lib/ProMotion/screen/screen_module.rb', line 154

def supported_device_families
  NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].map do |m|
    {
      "1" => :iphone,
      "2" => :ipad
    }[m] || :unknown_device
  end
end

#supported_device_family?(family) ⇒ Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/ProMotion/screen/screen_module.rb', line 163

def supported_device_family?(family)
  supported_device_families.include?(family)
end

#supported_orientation?(orientation) ⇒ Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/ProMotion/screen/screen_module.rb', line 150

def supported_orientation?(orientation)
  NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].include?(orientation)
end

#supported_orientationsObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ProMotion/screen/screen_module.rb', line 133

def supported_orientations
  orientations = 0
  NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].each do |ori|
    case ori
    when "UIInterfaceOrientationPortrait"
      orientations |= UIInterfaceOrientationMaskPortrait
    when "UIInterfaceOrientationLandscapeLeft"
      orientations |= UIInterfaceOrientationMaskLandscapeLeft
    when "UIInterfaceOrientationLandscapeRight"
      orientations |= UIInterfaceOrientationMaskLandscapeRight
    when "UIInterfaceOrientationPortraitUpsideDown"
      orientations |= UIInterfaceOrientationMaskPortraitUpsideDown
    end
  end
  orientations
end

#view_did_appear(animated) ⇒ Object



84
85
86
87
88
# File 'lib/ProMotion/screen/screen_module.rb', line 84

def view_did_appear(animated)
  self.on_appear

  self.on_present if isMovingToParentViewController
end

#view_did_disappear(animated) ⇒ Object



100
101
102
103
104
# File 'lib/ProMotion/screen/screen_module.rb', line 100

def view_did_disappear(animated)
  self.on_disappear

  self.on_dismiss if isMovingFromParentViewController
end

#view_did_loadObject



71
72
73
# File 'lib/ProMotion/screen/screen_module.rb', line 71

def view_did_load
  self.send(:on_load) if self.respond_to?(:on_load)
end

#view_will_appear(animated) ⇒ Object



75
76
77
78
79
80
# File 'lib/ProMotion/screen/screen_module.rb', line 75

def view_will_appear(animated)
  resolve_status_bar
  self.will_appear

  self.will_present if isMovingToParentViewController
end

#view_will_disappear(animated) ⇒ Object



92
93
94
95
96
# File 'lib/ProMotion/screen/screen_module.rb', line 92

def view_will_disappear(animated)
  self.will_disappear

  self.will_dismiss if isMovingFromParentViewController
end

#will_appearObject



81
# File 'lib/ProMotion/screen/screen_module.rb', line 81

def will_appear; end

#will_disappearObject



97
# File 'lib/ProMotion/screen/screen_module.rb', line 97

def will_disappear; end

#will_dismissObject



98
# File 'lib/ProMotion/screen/screen_module.rb', line 98

def will_dismiss; end

#will_presentObject



82
# File 'lib/ProMotion/screen/screen_module.rb', line 82

def will_present; end

#will_rotate(orientation, duration) ⇒ Object



123
124
# File 'lib/ProMotion/screen/screen_module.rb', line 123

def will_rotate(orientation, duration)
end