Module: ProMotion::ScreenModule
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#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
ios_version, ios_version_greater?, ios_version_greater_eq?, ios_version_is?, ios_version_less?, ios_version_less_eq?
#add, #add_to, #bounds, #frame, #remove
Methods included from ViewHelper
#content_height, #frame_from_array, #objective_c_method_name, #set_attribute, #set_attributes, #set_easy_attributes
#app_delegate, #close_screen, #open_root_screen, #open_screen, #open_view_controller, #push_view_controller, #send_on_return
Instance Attribute Details
#first_screen ⇒ Object
Returns the value of attribute first_screen.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def first_screen
@first_screen
end
|
#modal ⇒ Object
Returns the value of attribute modal.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def modal
@modal
end
|
#parent_screen ⇒ Object
Returns the value of attribute parent_screen.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def parent_screen
@parent_screen
end
|
#split_screen ⇒ Object
Returns the value of attribute split_screen.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def split_screen
@split_screen
end
|
#tab_bar ⇒ Object
Returns the value of attribute tab_bar.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def tab_bar
@tab_bar
end
|
#tab_bar_item ⇒ Object
Returns the value of attribute tab_bar_item.
9
10
11
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 9
def tab_bar_item
@tab_bar_item
end
|
Class Method Details
.included(base) ⇒ Object
230
231
232
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 230
def self.included(base)
base.extend(ClassMethods)
end
|
Instance Method Details
#add_nav_bar ⇒ Object
60
61
62
63
64
65
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 60
def add_nav_bar
self.navigation_controller ||= begin
self.first_screen = true if self.respond_to?(:first_screen=)
NavigationController.alloc.initWithRootViewController(self)
end
end
|
#first_screen? ⇒ Boolean
108
109
110
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 108
def first_screen?
self.first_screen == true
end
|
#has_nav_bar? ⇒ Boolean
33
34
35
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 33
def has_nav_bar?
self.navigation_controller.nil? != true
end
|
#is_modal? ⇒ Boolean
29
30
31
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 29
def is_modal?
self.modal == true
end
|
#load_view_controller ⇒ Object
47
48
49
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 47
def load_view_controller
warn "[DEPRECATION] `load_view_controller` is deprecated and doesn't actually do anything anymore. You can safely remove it from your code."
end
|
#navigation_controller ⇒ Object
37
38
39
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 37
def navigation_controller
@navigation_controller ||= self.navigationController
end
|
#navigation_controller=(val) ⇒ Object
41
42
43
44
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 41
def navigation_controller=(val)
@navigation_controller = val
val
end
|
#on_appear ⇒ Object
131
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 131
def on_appear; end
|
#on_create(args = {}) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 11
def on_create(args = {})
unless self.is_a?(UIViewController)
raise StandardError.new("ERROR: Screens must extend UIViewController or a subclass of UIViewController.")
end
self.title = self.class.send(:get_title)
args.each do |k, v|
self.send("#{k}=", v) if self.respond_to?("#{k}=")
end
self.add_nav_bar if args[:nav_bar]
self.on_init if self.respond_to?(:on_init)
self.table_setup if self.respond_to?(:table_setup)
self
end
|
#on_disappear ⇒ Object
141
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 141
def on_disappear; end
|
#on_opened ⇒ Object
119
120
121
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 119
def on_opened
warn "[DEPRECATION] `on_opened` is deprecated. Please use `on_appear` instead."
end
|
#on_rotate ⇒ Object
170
171
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 170
def on_rotate
end
|
#refresh_tab_bar_item ⇒ Object
56
57
58
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 56
def refresh_tab_bar_item
self.tabBarItem = create_tab_bar_item(self.tab_bar_item) if self.tab_bar_item
end
|
If you call set_nav_bar_button with a nil title and system_icon: UIBarButtonSystemItemAdd (or any other system icon), the button is initialized with a barButtonSystemItem instead of a title.
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 79
def set_nav_bar_button(side, args={})
args[:style] ||= UIBarButtonItemStyleBordered
args[:target] ||= self
args[:action] ||= nil
button = case args[:title]
when String
UIBarButtonItem.alloc.initWithTitle(args[:title], style: args[:style], target: args[:target], action: args[:action])
when UIImage
UIBarButtonItem.alloc.initWithImage(args[:title], style: args[:style], target: args[:target], action: args[:action])
when Symbol, NilClass
UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action]) if args[:system_icon]
when UIBarButtonItem
args[:title]
else
PM.logger.error("Please supply a title string, a UIImage or :system.")
end
self.navigationItem.leftBarButtonItem = button if side == :left
self.navigationItem.rightBarButtonItem = button if side == :right
button
end
|
72
73
74
75
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 72
def set_nav_bar_left_button(title, args={})
args[:title] = title
set_nav_bar_button :left, args
end
|
67
68
69
70
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 67
def set_nav_bar_right_button(title, args={})
args[:title] = title
set_nav_bar_button :right, args
end
|
#set_tab_bar_item(args = {}) ⇒ Object
51
52
53
54
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 51
def set_tab_bar_item(args = {})
self.tab_bar_item = args
refresh_tab_bar_item
end
|
#set_view_controller(vc) ⇒ Object
113
114
115
116
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 113
def set_view_controller(vc)
warn "[DEPRECATION] `set_view_controller` is deprecated and discontinued. Please inherit from the UIViewController you wish to use and include ProMotion::ScreenViewController instead."
self
end
|
#should_autorotate ⇒ Object
166
167
168
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 166
def should_autorotate
true
end
|
#should_rotate(orientation) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 148
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
|
#supported_device_families ⇒ Object
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 194
def supported_device_families
NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].map do |m|
case m
when "1"
:iphone
when "2"
:ipad
end
end
end
|
#supported_device_family?(family) ⇒ Boolean
205
206
207
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 205
def supported_device_family?(family)
supported_device_families.include?(family)
end
|
#supported_orientation?(orientation) ⇒ Boolean
173
174
175
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 173
def supported_orientation?(orientation)
NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].include?(orientation)
end
|
#supported_orientations ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 177
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_controller ⇒ Object
143
144
145
146
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 143
def view_controller
warn "[DEPRECATION] `view_controller` is deprecated, as screens are now UIViewController subclasses."
self
end
|
#view_controller=(vc) ⇒ Object
104
105
106
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 104
def view_controller=(vc)
set_view_controller(vc)
end
|
#view_did_appear(animated) ⇒ Object
128
129
130
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 128
def view_did_appear(animated)
self.on_appear
end
|
#view_did_disappear(animated) ⇒ Object
138
139
140
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 138
def view_did_disappear(animated)
self.on_disappear
end
|
#view_did_load ⇒ Object
118
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 118
def view_did_load; end
|
#view_will_appear(animated) ⇒ Object
123
124
125
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 123
def view_will_appear(animated)
self.will_appear
end
|
#view_will_disappear(animated) ⇒ Object
133
134
135
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 133
def view_will_disappear(animated)
self.will_disappear
end
|
#will_appear ⇒ Object
126
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 126
def will_appear; end
|
#will_disappear ⇒ Object
136
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 136
def will_disappear; end
|
#will_rotate(orientation, duration) ⇒ Object
163
164
|
# File 'lib/ProMotion/screens/_screen_module.rb', line 163
def will_rotate(orientation, duration)
end
|