Module: ProMotion::ScreenModule
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Attributes included from Tabs
#tab_bar, #tab_bar_item
Class Method Summary
collapse
Instance Method Summary
collapse
#create_split_screen, #open_split_screen, #splitViewController, #split_screen_controller
Methods included from Tabs
#create_tab_bar_icon, #create_tab_bar_icon_custom, #create_tab_bar_item, #map_tab_symbol, #open_tab, #open_tab_bar, #refresh_tab_bar_item, #replace_current_item, #set_tab_bar_badge, #set_tab_bar_item
#camel_case, #convert_symbol, #objective_c_method_name
Methods included from Styling
#add, #add_to, #closest_parent, #content_height, #hex_color, #remove, #rgb_color, #rgba_color, #set_attribute, #set_attributes, #set_easy_attributes, #view_or_self
#app_delegate, #close_screen, #open_modal, #open_root_screen, #open_screen, #push_view_controller, #send_on_return
Instance Attribute Details
#first_screen ⇒ Object
Returns the value of attribute first_screen.
8
9
10
|
# File 'lib/ProMotion/screen/screen_module.rb', line 8
def first_screen
@first_screen
end
|
#modal ⇒ Object
Returns the value of attribute modal.
8
9
10
|
# File 'lib/ProMotion/screen/screen_module.rb', line 8
def modal
@modal
end
|
#parent_screen ⇒ Object
Returns the value of attribute parent_screen.
8
9
10
|
# File 'lib/ProMotion/screen/screen_module.rb', line 8
def parent_screen
@parent_screen
end
|
#split_screen ⇒ Object
Returns the value of attribute split_screen.
8
9
10
|
# File 'lib/ProMotion/screen/screen_module.rb', line 8
def split_screen
@split_screen
end
|
Class Method Details
.included(base) ⇒ Object
271
272
273
274
|
# File 'lib/ProMotion/screen/screen_module.rb', line 271
def self.included(base)
base.extend(ClassMethods)
base.extend(TabClassMethods)
end
|
Instance Method Details
#add_nav_bar(args = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/ProMotion/screen/screen_module.rb', line 48
def add_nav_bar(args = {})
self.navigation_controller ||= begin
self.first_screen = true if self.respond_to?(:first_screen=)
nav = NavigationController.alloc.initWithRootViewController(self)
nav.setModalTransitionStyle(args[:transition_style]) if args[:transition_style]
nav.setModalPresentationStyle(args[:presentation_style]) if args[:presentation_style]
nav
end
end
|
TODO: Make this better. Not able to do image: “logo”, for example.
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/ProMotion/screen/screen_module.rb', line 86
def bar_button_item(button_type, args)
case button_type
when UIBarButtonItem
button_type
when UIImage
UIBarButtonItem.alloc.initWithImage(button_type, style: args[:style], target: args[:target], action: args[:action])
when String
UIBarButtonItem.alloc.initWithTitle(button_type, style: args[:style], target: args[:target], action: args[:action])
else
if args[:system_item]
UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_item], target: args[:target], action: args[:action])
else
PM.logger.error("Please supply a title string, a UIImage or :system.")
nil
end
end
end
|
#bounds ⇒ Object
204
205
206
|
# File 'lib/ProMotion/screen/screen_module.rb', line 204
def bounds
return self.view_or_self.bounds
end
|
#first_screen? ⇒ Boolean
104
105
106
|
# File 'lib/ProMotion/screen/screen_module.rb', line 104
def first_screen?
self.first_screen == true
end
|
#frame ⇒ Object
208
209
210
|
# File 'lib/ProMotion/screen/screen_module.rb', line 208
def frame
return self.view_or_self.frame
end
|
212
213
214
215
216
217
218
219
|
# File 'lib/ProMotion/screen/screen_module.rb', line 212
def map_bar_button_item_style(symbol)
symbol = {
plain: UIBarButtonItemStylePlain,
bordered: UIBarButtonItemStyleBordered,
done: UIBarButtonItemStyleDone
}[symbol] if symbol.is_a?(Symbol)
symbol || UIBarButtonItemStyleBordered
end
|
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/ProMotion/screen/screen_module.rb', line 221
def map_bar_button_system_item(symbol)
{
done: UIBarButtonSystemItemDone,
cancel: UIBarButtonSystemItemCancel,
edit: UIBarButtonSystemItemEdit,
save: UIBarButtonSystemItemSave,
add: UIBarButtonSystemItemAdd,
flexible_space: UIBarButtonSystemItemFlexibleSpace,
fixed_space: UIBarButtonSystemItemFixedSpace,
compose: UIBarButtonSystemItemCompose,
reply: UIBarButtonSystemItemReply,
action: UIBarButtonSystemItemAction,
organize: UIBarButtonSystemItemOrganize,
bookmarks: UIBarButtonSystemItemBookmarks,
search: UIBarButtonSystemItemSearch,
refresh: UIBarButtonSystemItemRefresh,
stop: UIBarButtonSystemItemStop,
camera: UIBarButtonSystemItemCamera,
trash: UIBarButtonSystemItemTrash,
play: UIBarButtonSystemItemPlay,
pause: UIBarButtonSystemItemPause,
rewind: UIBarButtonSystemItemRewind,
fast_forward: UIBarButtonSystemItemFastForward,
undo: UIBarButtonSystemItemUndo,
redo: UIBarButtonSystemItemRedo,
page_curl: UIBarButtonSystemItemPageCurl
}[symbol] || UIBarButtonSystemItemDone
end
|
#modal? ⇒ Boolean
31
32
33
|
# File 'lib/ProMotion/screen/screen_module.rb', line 31
def modal?
self.modal == true
end
|
#nav_bar? ⇒ Boolean
35
36
37
|
# File 'lib/ProMotion/screen/screen_module.rb', line 35
def nav_bar?
!!self.navigation_controller
end
|
#navigation_controller ⇒ Object
39
40
41
|
# File 'lib/ProMotion/screen/screen_module.rb', line 39
def navigation_controller
@navigation_controller ||= self.navigationController
end
|
#navigation_controller=(val) ⇒ Object
43
44
45
46
|
# File 'lib/ProMotion/screen/screen_module.rb', line 43
def navigation_controller=(val)
@navigation_controller = val
val
end
|
#on_appear ⇒ Object
123
|
# File 'lib/ProMotion/screen/screen_module.rb', line 123
def on_appear; end
|
#on_create(args = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ProMotion/screen/screen_module.rb', line 10
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)
self.tab_bar_item = self.class.send(:get_tab_bar_item)
self.refresh_tab_bar_item if self.tab_bar_item
args.each { |k, v| self.send("#{k}=", v) if self.respond_to?("#{k}=") }
self.add_nav_bar(args) if args[:nav_bar]
self.navigationController.toolbarHidden = !args[:toolbar] unless args[:toolbar].nil?
self.screen_setup
self.on_init if self.respond_to?(:on_init)
self
end
|
#on_disappear ⇒ Object
139
|
# File 'lib/ProMotion/screen/screen_module.rb', line 139
def on_disappear; end
|
#on_dismiss ⇒ Object
140
|
# File 'lib/ProMotion/screen/screen_module.rb', line 140
def on_dismiss; end
|
#on_present ⇒ Object
124
|
# File 'lib/ProMotion/screen/screen_module.rb', line 124
def on_present; end
|
#on_rotate ⇒ Object
164
165
|
# File 'lib/ProMotion/screen/screen_module.rb', line 164
def on_rotate
end
|
#screen_setup ⇒ Object
28
29
|
# File 'lib/ProMotion/screen/screen_module.rb', line 28
def screen_setup
end
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/ProMotion/screen/screen_module.rb', line 68
def set_nav_bar_button(side, args={})
args[:style] = map_bar_button_item_style(args[:style])
args[:target] ||= self
args[:action] ||= nil
args[:system_item] ||= args[:system_icon]
args[:system_item] = map_bar_button_system_item(args[:system_item]) if args[:system_item] && args[:system_item].is_a?(Symbol)
button_type = args[:image] || args[:button] || args[:system_item] || args[:title] || "Button"
button = bar_button_item button_type, args
self.navigationItem.leftBarButtonItem = button if side == :left
self.navigationItem.rightBarButtonItem = button if side == :right
button
end
|
63
64
65
66
|
# File 'lib/ProMotion/screen/screen_module.rb', line 63
def set_nav_bar_left_button(title, args={})
args[:title] = title
set_nav_bar_button :left, args
end
|
58
59
60
61
|
# File 'lib/ProMotion/screen/screen_module.rb', line 58
def set_nav_bar_right_button(title, args={})
args[:title] = title
set_nav_bar_button :right, args
end
|
#should_autorotate ⇒ Object
160
161
162
|
# File 'lib/ProMotion/screen/screen_module.rb', line 160
def should_autorotate
true
end
|
#should_rotate(orientation) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/ProMotion/screen/screen_module.rb', line 142
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
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/ProMotion/screen/screen_module.rb', line 188
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
200
201
202
|
# File 'lib/ProMotion/screen/screen_module.rb', line 200
def supported_device_family?(family)
supported_device_families.include?(family)
end
|
#supported_orientation?(orientation) ⇒ Boolean
167
168
169
|
# File 'lib/ProMotion/screen/screen_module.rb', line 167
def supported_orientation?(orientation)
NSBundle.mainBundle.infoDictionary["UISupportedInterfaceOrientations"].include?(orientation)
end
|
#supported_orientations ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/ProMotion/screen/screen_module.rb', line 171
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
118
119
120
121
122
|
# File 'lib/ProMotion/screen/screen_module.rb', line 118
def view_did_appear(animated)
self.on_appear
self.on_present if isMovingToParentViewController
end
|
#view_did_disappear(animated) ⇒ Object
134
135
136
137
138
|
# File 'lib/ProMotion/screen/screen_module.rb', line 134
def view_did_disappear(animated)
self.on_disappear
self.on_dismiss if isMovingFromParentViewController
end
|
#view_did_load ⇒ Object
108
|
# File 'lib/ProMotion/screen/screen_module.rb', line 108
def view_did_load; end
|
#view_will_appear(animated) ⇒ Object
110
111
112
113
114
|
# File 'lib/ProMotion/screen/screen_module.rb', line 110
def view_will_appear(animated)
self.will_appear
self.will_present if isMovingToParentViewController
end
|
#view_will_disappear(animated) ⇒ Object
126
127
128
129
130
|
# File 'lib/ProMotion/screen/screen_module.rb', line 126
def view_will_disappear(animated)
self.will_disappear
self.will_dismiss if isMovingFromParentViewController
end
|
#will_appear ⇒ Object
115
|
# File 'lib/ProMotion/screen/screen_module.rb', line 115
def will_appear; end
|
#will_disappear ⇒ Object
131
|
# File 'lib/ProMotion/screen/screen_module.rb', line 131
def will_disappear; end
|
#will_dismiss ⇒ Object
132
|
# File 'lib/ProMotion/screen/screen_module.rb', line 132
def will_dismiss; end
|
#will_present ⇒ Object
116
|
# File 'lib/ProMotion/screen/screen_module.rb', line 116
def will_present; end
|
#will_rotate(orientation, duration) ⇒ Object
157
158
|
# File 'lib/ProMotion/screen/screen_module.rb', line 157
def will_rotate(orientation, duration)
end
|