ProMotion 0.7.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/.gitignore +2 -1
  2. data/.travis.yml +1 -1
  3. data/ProMotion.gemspec +2 -0
  4. data/README.md +51 -449
  5. data/Rakefile +11 -1
  6. data/app/screens/basic_screen.rb +0 -24
  7. data/lib/ProMotion/cocoatouch/{NavigationController.rb → navigation_controller.rb} +0 -0
  8. data/lib/ProMotion/cocoatouch/split_view_controller.rb +29 -0
  9. data/lib/ProMotion/cocoatouch/tab_bar_controller.rb +43 -0
  10. data/lib/ProMotion/cocoatouch/{TableViewCell.rb → table_view_cell.rb} +0 -1
  11. data/lib/ProMotion/cocoatouch/{TableViewController.rb → table_view_controller.rb} +0 -0
  12. data/lib/ProMotion/cocoatouch/{ViewController.rb → view_controller.rb} +6 -1
  13. data/lib/ProMotion/{screen_helpers → containers}/split_screen.rb +0 -2
  14. data/lib/ProMotion/containers/tabs.rb +95 -0
  15. data/lib/ProMotion/delegate/delegate.rb +2 -13
  16. data/lib/ProMotion/delegate/{delegate_helper.rb → delegate_module.rb} +29 -16
  17. data/lib/ProMotion/delegate/delegate_notifications.rb +17 -8
  18. data/lib/ProMotion/delegate/delegate_parent.rb +11 -0
  19. data/lib/ProMotion/extensions/conversions.rb +20 -0
  20. data/lib/ProMotion/{helpers/logger.rb → logger.rb} +0 -0
  21. data/lib/ProMotion/map/map_screen.rb +6 -0
  22. data/lib/ProMotion/map/map_screen_annotation.rb +56 -0
  23. data/lib/ProMotion/map/map_screen_module.rb +207 -0
  24. data/lib/ProMotion/{push_notifications → push_notification}/push_notification.rb +13 -6
  25. data/lib/ProMotion/{screens → screen}/screen.rb +1 -1
  26. data/lib/ProMotion/{screens/_screen_module.rb → screen/screen_module.rb} +76 -51
  27. data/lib/ProMotion/{screen_helpers → screen}/screen_navigation.rb +8 -12
  28. data/lib/ProMotion/{screens/_tables → table/cell}/table_view_cell_module.rb +18 -27
  29. data/lib/ProMotion/table/data/table_data.rb +98 -0
  30. data/lib/ProMotion/table/extensions/indexable.rb +9 -0
  31. data/lib/ProMotion/table/extensions/refreshable.rb +45 -0
  32. data/lib/ProMotion/table/extensions/searchable.rb +61 -0
  33. data/lib/ProMotion/table/grouped_table.rb +9 -0
  34. data/lib/ProMotion/table/grouped_table_screen.rb +6 -0
  35. data/lib/ProMotion/table/table.rb +312 -0
  36. data/lib/ProMotion/table/table_screen.rb +6 -0
  37. data/lib/ProMotion/{screens/_compatibility → thirdparty}/formotion_screen.rb +18 -5
  38. data/lib/ProMotion/version.rb +1 -1
  39. data/lib/ProMotion/view/styling.rb +137 -0
  40. data/lib/ProMotion/web/web_screen.rb +6 -0
  41. data/lib/ProMotion/web/web_screen_module.rb +155 -0
  42. data/resources/WebScreen.html +6 -0
  43. data/resources/test.jpeg +0 -0
  44. data/spec/functional/func_map_screen_spec.rb +105 -0
  45. data/spec/functional/func_screen_spec.rb +54 -7
  46. data/spec/functional/func_searchable_table_spec.rb +1 -1
  47. data/spec/functional/func_tab_bar_spec.rb +78 -0
  48. data/spec/functional/func_table_screen_spec.rb +61 -14
  49. data/spec/functional/func_web_screen_spec.rb +51 -0
  50. data/spec/helpers/map_screen.rb +51 -0
  51. data/spec/helpers/present_screen.rb +26 -0
  52. data/spec/helpers/tab_screen.rb +4 -0
  53. data/spec/helpers/table_screen.rb +12 -3
  54. data/spec/helpers/table_screen_formotion.rb +25 -0
  55. data/spec/helpers/table_screen_indexable.rb +13 -0
  56. data/spec/helpers/test_delegate.rb +28 -0
  57. data/spec/helpers/web_screen.rb +22 -0
  58. data/spec/unit/delegate_spec.rb +53 -4
  59. data/spec/unit/map_spec.rb +48 -0
  60. data/spec/unit/screen_helpers_spec.rb +24 -16
  61. data/spec/unit/screen_spec.rb +22 -18
  62. data/spec/unit/split_screen_in_tab_bar_spec.rb +2 -2
  63. data/spec/unit/split_screen_open_screen_spec.rb +15 -10
  64. data/spec/unit/split_screen_spec.rb +2 -2
  65. data/spec/unit/tab_spec.rb +41 -0
  66. data/spec/unit/tables/formotion_screen_spec.rb +16 -0
  67. data/spec/unit/tables/table_indexable_spec.rb +12 -0
  68. data/spec/unit/tables/table_module_spec.rb +24 -9
  69. data/spec/unit/tables/table_screen_spec.rb +1 -1
  70. data/spec/unit/tables/table_view_cell_spec.rb +9 -8
  71. data/spec/unit/view_helper_spec.rb +2 -2
  72. data/spec/unit/web_spec.rb +106 -0
  73. metadata +96 -35
  74. data/lib/ProMotion/cocoatouch/SplitViewController.rb +0 -23
  75. data/lib/ProMotion/helpers/console.rb +0 -29
  76. data/lib/ProMotion/helpers/measure_helper.rb +0 -20
  77. data/lib/ProMotion/helpers/system_helper.rb +0 -29
  78. data/lib/ProMotion/helpers/view_helper.rb +0 -82
  79. data/lib/ProMotion/screen_helpers/screen_elements.rb +0 -36
  80. data/lib/ProMotion/screen_helpers/screen_tabs.rb +0 -95
  81. data/lib/ProMotion/screens/_table_screen_module.rb +0 -47
  82. data/lib/ProMotion/screens/_tables/_refreshable_table.rb +0 -45
  83. data/lib/ProMotion/screens/_tables/_searchable_table.rb +0 -60
  84. data/lib/ProMotion/screens/_tables/_sectioned_table.rb +0 -5
  85. data/lib/ProMotion/screens/_tables/_table.rb +0 -169
  86. data/lib/ProMotion/screens/_tables/grouped_table.rb +0 -16
  87. data/lib/ProMotion/screens/_tables/plain_table.rb +0 -17
  88. data/lib/ProMotion/screens/_tables/table_data.rb +0 -175
  89. data/lib/ProMotion/screens/behaves_like_screen.rb +0 -10
  90. data/lib/ProMotion/screens/table_screen.rb +0 -16
  91. data/spec/unit/ios_version_spec.rb +0 -28
@@ -0,0 +1,6 @@
1
+ module ProMotion
2
+ class MapScreen < ViewController
3
+ include ProMotion::ScreenModule
4
+ include ProMotion::MapScreenModule
5
+ end
6
+ end
@@ -0,0 +1,56 @@
1
+ module ProMotion
2
+ class MapScreenAnnotation
3
+
4
+ #Creates the new crime object
5
+ def initialize(params = {})
6
+ @params = params
7
+ set_defaults
8
+
9
+ unless @params[:latitude] && @params[:longitude]
10
+ PM.logger.error("You are required to specify :latitude and :longitude for annotations.")
11
+ return nil
12
+ end
13
+ @coordinate = CLLocationCoordinate2D.new(@params[:latitude], @params[:longitude])
14
+ end
15
+
16
+ def set_defaults
17
+ @params = {
18
+ title: "Title",
19
+ pin_color: MKPinAnnotationColorRed,
20
+ identifier: "Annotation-#{@params[:pin_color]}",
21
+ show_callout: true,
22
+ animates_drop: false
23
+ }.merge(@params)
24
+ end
25
+
26
+ def title
27
+ @params[:title]
28
+ end
29
+
30
+ def subtitle
31
+ @params[:subtitle] ||= nil
32
+ end
33
+
34
+ def coordinate
35
+ @coordinate
36
+ end
37
+
38
+ def cllocation
39
+ CLLocation.alloc.initWithLatitude(@params[:latitude], longitude:@params[:longitude])
40
+ end
41
+
42
+ def setCoordinate(new_coordinate);
43
+ if new_coordinate.is_a? Hash
44
+ @coordinate = CLLocationCoordinate2D.new(new_coordinate[:latitude], new_coordinate[:longitude])
45
+ else
46
+ @coordinate = new_coordinate
47
+ end
48
+ end
49
+
50
+ # Allows for retrieving your own custom values on the annotation
51
+ def annotation_params
52
+ @params
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,207 @@
1
+ module ProMotion
2
+ module MapScreenModule
3
+ attr_accessor :mapview
4
+
5
+ def screen_setup
6
+ check_mapkit_included
7
+ self.mapview ||= add MKMapView.new, {
8
+ frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height),
9
+ resize: [ :width, :height ],
10
+ delegate: self
11
+ }
12
+
13
+ check_annotation_data
14
+ @promotion_annotation_data = []
15
+ set_up_start_position
16
+ end
17
+
18
+ def view_will_appear(animated)
19
+ super
20
+ update_annotation_data
21
+ end
22
+
23
+ def check_mapkit_included
24
+ PM.logger.error "You must add MapKit and CoreLocation to your project's frameworks in the Rakefile." unless defined?(CLLocationCoordinate2D)
25
+ end
26
+
27
+ def check_annotation_data
28
+ PM.logger.error "Missing #annotation_data method in MapScreen #{self.class.to_s}." unless self.respond_to?(:annotation_data)
29
+ end
30
+
31
+ def update_annotation_data
32
+ clear_annotations
33
+ add_annotations annotation_data
34
+ end
35
+
36
+ def map
37
+ self.mapview
38
+ end
39
+
40
+ def center
41
+ self.mapview.centerCoordinate
42
+ end
43
+
44
+ def center=(params={})
45
+ PM.logger.error "Missing #:latitude property in call to #center=." unless params[:latitude]
46
+ PM.logger.error "Missing #:longitude property in call to #center=." unless params[:longitude]
47
+ params[:animated] = true
48
+
49
+ # Set the new region
50
+ self.mapview.setCenterCoordinate(
51
+ CLLocationCoordinate2D.new(params[:latitude], params[:longitude]),
52
+ animated:params[:animated]
53
+ )
54
+ end
55
+
56
+ def annotations
57
+ @promotion_annotation_data
58
+ end
59
+
60
+ def select_annotation(annotation, animated=true)
61
+ self.mapview.selectAnnotation(annotation, animated:animated)
62
+ end
63
+
64
+ def select_annotation_at(annotation_index, animated=true)
65
+ select_annotation(annotations[annotation_index], animated:animated)
66
+ end
67
+
68
+ def selected_annotations
69
+ self.mapview.selectedAnnotations
70
+ end
71
+
72
+ def deselect_annotations(animated=false)
73
+ unless selected_annotations.nil?
74
+ selected_annotations.each do |annotation|
75
+ self.mapview.deselectAnnotation(annotation, animated:animated)
76
+ end
77
+ end
78
+ end
79
+
80
+ def add_annotation(annotation)
81
+ @promotion_annotation_data << MapScreenAnnotation.new(annotation)
82
+ self.mapview.addAnnotation @promotion_annotation_data.last
83
+ end
84
+
85
+ def add_annotations(annotations)
86
+ @promotion_annotation_data = Array(annotations).map{|a| MapScreenAnnotation.new(a)}
87
+ self.mapview.addAnnotations @promotion_annotation_data
88
+ end
89
+
90
+ def clear_annotations
91
+ @promotion_annotation_data.each do |a|
92
+ self.mapview.removeAnnotation(a)
93
+ end
94
+ @promotion_annotation_data = []
95
+ end
96
+
97
+ def mapView(mapView, viewForAnnotation:annotation)
98
+ identifier = annotation.annotation_params[:identifier]
99
+ if view = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
100
+ view.annotation = annotation
101
+ else
102
+ #Set the pin properties
103
+ view = MKPinAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier)
104
+ view.canShowCallout = annotation.annotation_params[:show_callout]
105
+ view.animatesDrop = annotation.annotation_params[:animates_drop]
106
+ view.pinColor = annotation.annotation_params[:pin_color]
107
+ end
108
+ view
109
+ end
110
+
111
+ def set_start_position(params={})
112
+ params[:latitude] ||= 37.331789
113
+ params[:longitude] ||= -122.029620
114
+ params[:radius] ||= 10
115
+
116
+ meters_per_mile = 1609.344
117
+
118
+ initialLocation = CLLocationCoordinate2D.new(params[:latitude], params[:longitude])
119
+ region = MKCoordinateRegionMakeWithDistance(initialLocation, params[:radius] * meters_per_mile, params[:radius] * meters_per_mile)
120
+ self.mapview.setRegion(region, animated:false)
121
+ end
122
+
123
+ def set_up_start_position
124
+ if self.class.respond_to?(:get_start_position) && self.class.get_start_position
125
+ self.set_start_position self.class.get_start_position_params
126
+ end
127
+ end
128
+
129
+ # TODO: Why is this so complex?
130
+ def zoom_to_fit_annotations(animated=true)
131
+ #Don't attempt the rezoom of there are no pins
132
+ return if annotations.count == 0
133
+
134
+ #Set some crazy boundaries
135
+ topLeft = CLLocationCoordinate2D.new(-90, 180)
136
+ bottomRight = CLLocationCoordinate2D.new(90, -180)
137
+
138
+ #Find the bounds of the pins
139
+ annotations.each do |a|
140
+ topLeft.longitude = [topLeft.longitude, a.coordinate.longitude].min
141
+ topLeft.latitude = [topLeft.latitude, a.coordinate.latitude].max
142
+ bottomRight.longitude = [bottomRight.longitude, a.coordinate.longitude].max
143
+ bottomRight.latitude = [bottomRight.latitude, a.coordinate.latitude].min
144
+ end
145
+
146
+ #Find the bounds of all the pins and set the mapView
147
+ coord = CLLocationCoordinate2D.new(
148
+ topLeft.latitude - (topLeft.latitude - bottomRight.latitude) * 0.5,
149
+ topLeft.longitude + (bottomRight.longitude - topLeft.longitude) * 0.5
150
+ )
151
+
152
+ # Add some padding to the edges
153
+ span = MKCoordinateSpanMake(
154
+ ((topLeft.latitude - bottomRight.latitude) * 1.075).abs,
155
+ ((bottomRight.longitude - topLeft.longitude) * 1.075).abs
156
+ )
157
+
158
+ region = MKCoordinateRegionMake(coord, span)
159
+ fits = self.mapview.regionThatFits(region);
160
+
161
+ self.mapview.setRegion(fits, animated:animated)
162
+ end
163
+
164
+ def set_region(region, animated=true)
165
+ self.mapview.setRegion(region, animated:animated)
166
+ end
167
+
168
+ def region(params)
169
+ return nil unless params.is_a? Hash
170
+
171
+ params[:coordinate] = CLLocationCoordinate2D.new(params[:coordinate][:latitude], params[:coordinate][:longitude]) if params[:coordinate].is_a? Hash
172
+ params[:span] = MKCoordinateSpanMake(params[:span][0], params[:span][1]) if params[:span].is_a? Array
173
+
174
+ if params[:coordinate] && params[:span]
175
+ MKCoordinateRegionMake( params[:coordinate], params[:span] )
176
+ end
177
+ end
178
+
179
+ def look_up_address(args={}, &callback)
180
+ args[:address] = args if args.is_a? String # Assume if a string is passed that they want an address
181
+
182
+ geocoder = CLGeocoder.new
183
+ return geocoder.geocodeAddressDictionary(args[:address], completionHandler: callback) if args[:address].is_a?(Hash)
184
+ return geocoder.geocodeAddressString(args[:address].to_s, completionHandler: callback) unless args[:region]
185
+ return geocoder.geocodeAddressString(args[:address].to_s, inRegion:args[:region].to_s, completionHandler: callback) if args[:region]
186
+ end
187
+
188
+ module MapClassMethods
189
+ def start_position(params={})
190
+ @start_position_params = params
191
+ @start_position = true
192
+ end
193
+
194
+ def get_start_position_params
195
+ @start_position_params ||= nil
196
+ end
197
+
198
+ def get_start_position
199
+ @start_position ||= false
200
+ end
201
+ end
202
+ def self.included(base)
203
+ base.extend(MapClassMethods)
204
+ end
205
+
206
+ end
207
+ end
@@ -31,20 +31,27 @@ module ProMotion
31
31
  aps["sound"] if aps
32
32
  end
33
33
 
34
+ def method_missing(meth, *args, &block)
35
+ aps[meth.to_s] || aps[meth.to_sym] || self.notification[meth.to_s] || self.notification[meth.to_sym] || super
36
+ end
37
+
34
38
  # For testing from the REPL
35
39
  # > PM::PushNotification.simulate alert: "My test message", badge: 4
36
40
  def self.simulate(args = {})
37
- UIApplication.sharedApplication.delegate.on_push_notification self.fake_notification(args)
41
+ UIApplication.sharedApplication.delegate.on_push_notification self.fake_notification(args), args[:launched]
38
42
  end
39
43
 
40
44
  def self.fake_notification(args = {})
41
45
  self.new({
42
46
  "aps" => {
43
- "alert" => args[:alert] || "Test Push Notification",
44
- "badge" => args[:badge] || 2,
45
- "sound" => args[:sound] || "default"
46
- }
47
- })
47
+ "alert" => args.delete(:alert) || "Test Push Notification",
48
+ "badge" => args.delete(:badge) || 2,
49
+ "sound" => args.delete(:sound) || "default"
50
+ },
51
+ "channels" => args.delete(:channels) || [
52
+ "channel_name"
53
+ ]
54
+ }.merge(args))
48
55
  end
49
56
 
50
57
  end
@@ -1,7 +1,7 @@
1
1
  module ProMotion
2
2
  class Screen < ViewController
3
3
  # You can inherit a screen from any UIViewController if you include the ScreenModule
4
- # Just make sure to implement the Obj-C methods in cocoatouch/ViewController.rb.
4
+ # Just make sure to implement the Obj-C methods in cocoatouch/view_controller.rb.
5
5
  include ProMotion::ScreenModule
6
6
  end
7
7
  end
@@ -1,12 +1,11 @@
1
1
  module ProMotion
2
2
  module ScreenModule
3
3
  include ProMotion::ScreenNavigation
4
- include ProMotion::ScreenElements
5
- include ProMotion::SystemHelper
6
- include ProMotion::ScreenTabs
4
+ include ProMotion::Styling
5
+ include ProMotion::Tabs
7
6
  include ProMotion::SplitScreen if NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].include?("2")
8
7
 
9
- attr_accessor :parent_screen, :first_screen, :tab_bar_item, :tab_bar, :modal, :split_screen
8
+ attr_accessor :parent_screen, :first_screen, :modal, :split_screen
10
9
 
11
10
  def on_create(args = {})
12
11
  unless self.is_a?(UIViewController)
@@ -14,32 +13,25 @@ module ProMotion
14
13
  end
15
14
 
16
15
  self.title = self.class.send(:get_title)
16
+ self.tab_bar_item = self.class.send(:get_tab_bar_item)
17
+ self.refresh_tab_bar_item if self.tab_bar_item
17
18
 
18
- args.each do |k, v|
19
- self.send("#{k}=", v) if self.respond_to?("#{k}=")
20
- end
19
+ args.each { |k, v| self.send("#{k}=", v) if self.respond_to?("#{k}=") }
21
20
 
22
21
  self.add_nav_bar(args) if args[:nav_bar]
23
22
  self.navigationController.toolbarHidden = !args[:toolbar] unless args[:toolbar].nil?
23
+ self.screen_setup
24
24
  self.on_init if self.respond_to?(:on_init)
25
- self.table_setup if self.respond_to?(:table_setup)
26
25
  self
27
26
  end
28
27
 
29
- def is_modal?
30
- PM.logger.deprecated "`is_modal?` is deprecated. Use `modal?`."
31
- modal?
28
+ def screen_setup
32
29
  end
33
30
 
34
31
  def modal?
35
32
  self.modal == true
36
33
  end
37
34
 
38
- def has_nav_bar?
39
- PM.logger.deprecated "`has_nav_bar? is deprecated. Use `nav_bar?`."
40
- nav_bar?
41
- end
42
-
43
35
  def nav_bar?
44
36
  !!self.navigation_controller
45
37
  end
@@ -53,20 +45,6 @@ module ProMotion
53
45
  val
54
46
  end
55
47
 
56
- # [DEPRECATED]
57
- def load_view_controller
58
- PM.logger.deprecated "`load_view_controller` is deprecated and doesn't actually do anything anymore. You can safely remove it from your code."
59
- end
60
-
61
- def set_tab_bar_item(args = {})
62
- self.tab_bar_item = args
63
- refresh_tab_bar_item
64
- end
65
-
66
- def refresh_tab_bar_item
67
- self.tabBarItem = create_tab_bar_item(self.tab_bar_item) if self.tab_bar_item
68
- end
69
-
70
48
  def add_nav_bar(args = {})
71
49
  self.navigation_controller ||= begin
72
50
  self.first_screen = true if self.respond_to?(:first_screen=)
@@ -88,10 +66,13 @@ module ProMotion
88
66
  end
89
67
 
90
68
  def set_nav_bar_button(side, args={})
91
- args[:style] ||= UIBarButtonItemStyleBordered
69
+ args[:style] = map_bar_button_item_style(args[:style])
92
70
  args[:target] ||= self
93
71
  args[:action] ||= nil
94
- button_type = args[:image] || args[:button] || args[:system_icon] || args[:title] || "Button"
72
+ args[:system_item] ||= args[:system_icon] # backwards compatibility
73
+ args[:system_item] = map_bar_button_system_item(args[:system_item]) if args[:system_item] && args[:system_item].is_a?(Symbol)
74
+
75
+ button_type = args[:image] || args[:button] || args[:system_item] || args[:title] || "Button"
95
76
 
96
77
  button = bar_button_item button_type, args
97
78
 
@@ -100,7 +81,8 @@ module ProMotion
100
81
 
101
82
  button
102
83
  end
103
-
84
+
85
+ # TODO: Make this better. Not able to do image: "logo", for example.
104
86
  def bar_button_item(button_type, args)
105
87
  case button_type
106
88
  when UIBarButtonItem
@@ -110,8 +92,8 @@ module ProMotion
110
92
  when String
111
93
  UIBarButtonItem.alloc.initWithTitle(button_type, style: args[:style], target: args[:target], action: args[:action])
112
94
  else
113
- if args[:system_icon]
114
- UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action])
95
+ if args[:system_item]
96
+ UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_item], target: args[:target], action: args[:action])
115
97
  else
116
98
  PM.logger.error("Please supply a title string, a UIImage or :system.")
117
99
  nil
@@ -119,47 +101,43 @@ module ProMotion
119
101
  end
120
102
  end
121
103
 
122
- # [DEPRECATED]
123
- def view_controller=(vc)
124
- set_view_controller(vc)
125
- end
126
-
127
104
  def first_screen?
128
105
  self.first_screen == true
129
106
  end
130
107
 
131
- # [DEPRECATED]
132
- def set_view_controller(vc)
133
- PM.logger.deprecated "`set_view_controller` is deprecated and discontinued. Please inherit from the UIViewController you wish to use and include ProMotion::ScreenViewController instead."
134
- self
135
- end
136
-
137
108
  def view_did_load; end
138
109
 
139
110
  def view_will_appear(animated)
140
111
  self.will_appear
112
+
113
+ self.will_present if isMovingToParentViewController
141
114
  end
142
115
  def will_appear; end
116
+ def will_present; end
143
117
 
144
118
  def view_did_appear(animated)
145
119
  self.on_appear
120
+
121
+ self.on_present if isMovingToParentViewController
146
122
  end
147
123
  def on_appear; end
124
+ def on_present; end
148
125
 
149
126
  def view_will_disappear(animated)
150
127
  self.will_disappear
128
+
129
+ self.will_dismiss if isMovingFromParentViewController
151
130
  end
152
131
  def will_disappear; end
132
+ def will_dismiss; end
153
133
 
154
134
  def view_did_disappear(animated)
155
135
  self.on_disappear
156
- end
157
- def on_disappear; end
158
136
 
159
- def view_controller
160
- PM.logger.deprecated "`view_controller` is deprecated, as screens are now UIViewController subclasses."
161
- self
137
+ self.on_dismiss if isMovingFromParentViewController
162
138
  end
139
+ def on_disappear; end
140
+ def on_dismiss; end
163
141
 
164
142
  def should_rotate(orientation)
165
143
  case orientation
@@ -223,6 +201,52 @@ module ProMotion
223
201
  supported_device_families.include?(family)
224
202
  end
225
203
 
204
+ def bounds
205
+ return self.view_or_self.bounds
206
+ end
207
+
208
+ def frame
209
+ return self.view_or_self.frame
210
+ end
211
+
212
+ def map_bar_button_item_style(symbol)
213
+ symbol = {
214
+ plain: UIBarButtonItemStylePlain,
215
+ bordered: UIBarButtonItemStyleBordered,
216
+ done: UIBarButtonItemStyleDone
217
+ }[symbol] if symbol.is_a?(Symbol)
218
+ symbol || UIBarButtonItemStyleBordered
219
+ end
220
+
221
+ def map_bar_button_system_item(symbol)
222
+ {
223
+ done: UIBarButtonSystemItemDone,
224
+ cancel: UIBarButtonSystemItemCancel,
225
+ edit: UIBarButtonSystemItemEdit,
226
+ save: UIBarButtonSystemItemSave,
227
+ add: UIBarButtonSystemItemAdd,
228
+ flexible_space: UIBarButtonSystemItemFlexibleSpace,
229
+ fixed_space: UIBarButtonSystemItemFixedSpace,
230
+ compose: UIBarButtonSystemItemCompose,
231
+ reply: UIBarButtonSystemItemReply,
232
+ action: UIBarButtonSystemItemAction,
233
+ organize: UIBarButtonSystemItemOrganize,
234
+ bookmarks: UIBarButtonSystemItemBookmarks,
235
+ search: UIBarButtonSystemItemSearch,
236
+ refresh: UIBarButtonSystemItemRefresh,
237
+ stop: UIBarButtonSystemItemStop,
238
+ camera: UIBarButtonSystemItemCamera,
239
+ trash: UIBarButtonSystemItemTrash,
240
+ play: UIBarButtonSystemItemPlay,
241
+ pause: UIBarButtonSystemItemPause,
242
+ rewind: UIBarButtonSystemItemRewind,
243
+ fast_forward: UIBarButtonSystemItemFastForward,
244
+ undo: UIBarButtonSystemItemUndo,
245
+ redo: UIBarButtonSystemItemRedo,
246
+ page_curl: UIBarButtonSystemItemPageCurl
247
+ }[symbol] || UIBarButtonSystemItemDone
248
+ end
249
+
226
250
  # Class methods
227
251
  module ClassMethods
228
252
  def debug_mode
@@ -246,6 +270,7 @@ module ProMotion
246
270
 
247
271
  def self.included(base)
248
272
  base.extend(ClassMethods)
273
+ base.extend(TabClassMethods) # TODO: Is there a better way?
249
274
  end
250
275
  end
251
276
  end