ProMotion 2.4.0 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78d4da42d437262fe73051ce835ad8753426509b
4
- data.tar.gz: eddb27a4dea01d3e8bca74b058516d7440a31f05
3
+ metadata.gz: dbb79124827dba0dbba2f548f6248c0773fbc7eb
4
+ data.tar.gz: 1f094cabe4fd3ad811e8dff4e282cf1c6579ee05
5
5
  SHA512:
6
- metadata.gz: db287d8260bf8fd89f2a2652e381ef11731694c81bec03cb0b0478286f5dbc70d22c919378e25679fe6bd4c180e77c826d22c6371a501c9817c5787d86900945
7
- data.tar.gz: d5a780fa6df0bd7daab53f072d6f063f4fffd3f1eb1f0dc4a00e3f546b0b5827dd625a9fa851e1d2a36ad89f1949197cd22aa984484001e9d7e9ddac8b9296a9
6
+ metadata.gz: 93e97236dc4b5f98582a976acfba276d5b1811e7d3a8e955f4ec799d0110d22bafa5c42caea1d7d4f205d9825590f1cb21611cb6fe7b97e68f04b30f6bb7f305
7
+ data.tar.gz: 7f51de66669f39a469f99a8c31aa2d540ba17ffcd792265b576a764fde5d769aa5c1b68af43ecc87869404342f31c58e625f3255f6ec4554f8c8340307f684cf
data/README.md CHANGED
@@ -69,16 +69,16 @@ end
69
69
 
70
70
  |Screens|Navigation Bars|Tab Bars|
71
71
  |---|---|---|
72
- |[![ProMotion Screen](https://f.cloud.github.com/assets/1479215/1534021/060aaaac-4c8f-11e3-903c-743e54252222.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20Screen/)|[![ProMotion Nav Bar](https://f.cloud.github.com/assets/1479215/1534077/db39aab6-4c8f-11e3-83f7-e03d52ac615d.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20Screen/#set_nav_bar_buttonside-args)|[![ProMotion Tabs](https://f.cloud.github.com/assets/1479215/1534115/9f4c4cd8-4c90-11e3-9285-96ac253facda.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20Tabs/)|
72
+ |[![ProMotion Screen](https://f.cloud.github.com/assets/1479215/1534021/060aaaac-4c8f-11e3-903c-743e54252222.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20Screen/)|[![ProMotion Nav Bar](https://f.cloud.github.com/assets/1479215/1534077/db39aab6-4c8f-11e3-83f7-e03d52ac615d.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20Screen/#set_nav_bar_buttonside-args)|[![ProMotion Tabs](https://f.cloud.github.com/assets/1479215/1534115/9f4c4cd8-4c90-11e3-9285-96ac253facda.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20Tabs/)|
73
73
 
74
74
  |Table Screens|Grouped Tables|Searchable|Refreshable|
75
75
  |---|---|---|---|
76
- |[![ProMotion TableScreen](https://f.cloud.github.com/assets/1479215/1534137/ed71e864-4c90-11e3-98aa-ed96049f5407.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20TableScreen/)|[![Grouped Table Screen](https://f.cloud.github.com/assets/1479215/1589973/61a48610-5281-11e3-85ac-abee99bf73ad.png)](https://gist.github.com/jamonholmgren/382a6cf9963c5f0b2248)|[![Searchable](https://f.cloud.github.com/assets/1479215/1534299/20cc05c6-4c93-11e3-92ca-9ee39c044457.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20TableScreen/#searchableplaceholder-placeholder-text)|[![Refreshable](https://f.cloud.github.com/assets/1479215/1534317/5a14ef28-4c93-11e3-8e9e-f8c08d8464f8.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20TableScreen/#refreshableoptions)|
76
+ |[![ProMotion TableScreen](https://f.cloud.github.com/assets/1479215/1534137/ed71e864-4c90-11e3-98aa-ed96049f5407.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20TableScreen/)|[![Grouped Table Screen](https://f.cloud.github.com/assets/1479215/1589973/61a48610-5281-11e3-85ac-abee99bf73ad.png)](https://gist.github.com/jamonholmgren/382a6cf9963c5f0b2248)|[![Searchable](https://f.cloud.github.com/assets/1479215/1534299/20cc05c6-4c93-11e3-92ca-9ee39c044457.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20TableScreen/#searchableplaceholder-placeholder-text)|[![Refreshable](https://f.cloud.github.com/assets/1479215/1534317/5a14ef28-4c93-11e3-8e9e-f8c08d8464f8.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20TableScreen/#refreshableoptions)|
77
77
 
78
78
 
79
79
  |iPad SplitScreens|Map Screens|Web Screens|
80
80
  |---|---|---|
81
- |[![ProMotion SplitScreens](https://f.cloud.github.com/assets/1479215/1534507/0edb8dd4-4c96-11e3-9896-d4583d0ed161.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20SplitScreen/)|[![MapScreen](https://f.cloud.github.com/assets/1479215/1534628/f7dbf7e8-4c97-11e3-8817-4c2a58824771.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20MapScreen/)|[![ProMotion WebScreen](https://f.cloud.github.com/assets/1479215/1534631/ffe1b36a-4c97-11e3-8c8f-c7b14e26182d.png)](http://promotion.readthedocs.org/en/master/API%20Reference%20-%20ProMotion%20WebScreen/)|
81
+ |[![ProMotion SplitScreens](https://f.cloud.github.com/assets/1479215/1534507/0edb8dd4-4c96-11e3-9896-d4583d0ed161.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20SplitScreen/)|[![MapScreen](https://f.cloud.github.com/assets/1479215/1534628/f7dbf7e8-4c97-11e3-8817-4c2a58824771.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20MapScreen/)|[![ProMotion WebScreen](https://f.cloud.github.com/assets/1479215/1534631/ffe1b36a-4c97-11e3-8c8f-c7b14e26182d.png)](http://promotion.readthedocs.org/en/master/Reference/API%20Reference%20-%20ProMotion%20WebScreen/)|
82
82
 
83
83
  #### ...and much more.
84
84
 
@@ -31,7 +31,7 @@ class App
31
31
  def self.create(name)
32
32
  return puts "Usage: promotion new <appname>" unless name.to_s.length > 0
33
33
  info "Creating new ProMotion iOS app #{name}"
34
- sh "motion create --template=git://github.com/jamonholmgren/promotion-template.git #{name}"
34
+ sh "motion create --template=https://github.com/jamonholmgren/promotion-template.git #{name}"
35
35
  end
36
36
 
37
37
  description "Command line for ProMotion."
@@ -48,7 +48,7 @@ module ProMotion
48
48
 
49
49
  selected_tab_vc
50
50
  else
51
- PM.logger.error "Unable to open tab #{tab.to_s} -- not found."
51
+ mp "Unable to open tab #{tab.to_s} -- not found.", force_color: :red
52
52
  nil
53
53
  end
54
54
  end
@@ -38,10 +38,9 @@ module ProMotion
38
38
 
39
39
  # Usage: PM.logger.log("ERROR", "message here", :red)
40
40
  def log(label, message_text, color)
41
- # return if defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV == "test"
42
- color = COLORS[color] || COLORS[:default]
43
- $stderr.puts color[0] + NAME + "[#{label}] #{message_text}" + color[1]
44
- nil
41
+ show_deprecation_warning
42
+
43
+ mp "#{NAME}[#{label}] #{message_text}", force_color: color
45
44
  end
46
45
 
47
46
  def error(message)
@@ -64,6 +63,10 @@ module ProMotion
64
63
  log('INFO', message, :green) if self.levels.include?(:info)
65
64
  end
66
65
 
66
+ def show_deprecation_warning
67
+ mp "PM.logger.log has been deprecated. Please update to motion_print: https://github.com/OTGApps/motion_print", force_color: :yellow
68
+ end
69
+
67
70
  end
68
71
 
69
72
  module_function
@@ -37,7 +37,7 @@ module ProMotion
37
37
 
38
38
  # TODO: In PM 2.1+, entirely remove this deprecated method.
39
39
  def set_nav_bar_left_button(title, args={})
40
- PM.logger.deprecated "set_nav_bar_right_button and set_nav_bar_left_button have been removed. Use set_nav_bar_button :right/:left instead."
40
+ mp "set_nav_bar_right_button and set_nav_bar_left_button have been removed. Use set_nav_bar_button :right/:left instead.", force_color: :yellow
41
41
  end
42
42
  alias_method :set_nav_bar_right_button, :set_nav_bar_left_button
43
43
 
@@ -72,13 +72,13 @@ module ProMotion
72
72
  end
73
73
 
74
74
  def bar_button_item(button_type, args)
75
- return PM.logger.deprecated("`system_icon:` no longer supported. Use `system_item:` instead.") if args[:system_icon]
75
+ return mp("`system_icon:` no longer supported. Use `system_item:` instead.", force_color: :yellow) if args[:system_icon]
76
76
  return button_type if button_type.is_a?(UIBarButtonItem)
77
77
  return bar_button_item_system_item(args) if args[:system_item]
78
78
  return bar_button_item_image(button_type, args) if button_type.is_a?(UIImage)
79
79
  return bar_button_item_string(button_type, args) if button_type.is_a?(String)
80
80
  return bar_button_item_custom(button_type) if button_type.is_a?(UIView)
81
- PM.logger.error("Please supply a title string, a UIImage or :system.") && nil
81
+ mp("Please supply a title string, a UIImage or :system.", force_color: :red) && nil
82
82
  end
83
83
 
84
84
  def bar_button_item_image(img, args)
@@ -18,7 +18,7 @@ module ProMotion
18
18
  tab_bar_setup
19
19
  try :on_init
20
20
  try :screen_setup
21
- PM.logger.deprecated "In #{self.class.to_s}, #on_create has been deprecated and removed. Use #screen_init instead." if respond_to?(:on_create)
21
+ mp "In #{self.class.to_s}, #on_create has been deprecated and removed. Use #screen_init instead.", force_color: :yellow if respond_to?(:on_create)
22
22
  end
23
23
 
24
24
  def modal?
@@ -160,7 +160,7 @@ module ProMotion
160
160
  when :view then self.navigationItem.titleView = self.class.title
161
161
  when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(self.class.title)
162
162
  else
163
- PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.")
163
+ mp("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.", force_color: :yellow)
164
164
  end
165
165
  end
166
166
 
@@ -213,7 +213,7 @@ module ProMotion
213
213
  module ClassMethods
214
214
  def title(t=nil)
215
215
  if t && t.is_a?(String) == false
216
- PM.logger.deprecated "You're trying to set the title of #{self.to_s} to an instance of #{t.class.to_s}. In ProMotion 2+, you must use `title_image` or `title_view` instead."
216
+ mp "You're trying to set the title of #{self.to_s} to an instance of #{t.class.to_s}. In ProMotion 2+, you must use `title_image` or `title_view` instead.", force_color: :yellow
217
217
  return raise StandardError
218
218
  end
219
219
  @title = t if t
@@ -237,7 +237,7 @@ module ProMotion
237
237
 
238
238
  def status_bar(style=nil, args={})
239
239
  if NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance').nil?
240
- PM.logger.warn("status_bar will have no effect unless you set 'UIViewControllerBasedStatusBarAppearance' to false in your info.plist")
240
+ mp "status_bar will have no effect unless you set 'UIViewControllerBasedStatusBarAppearance' to false in your info.plist", force_color: :yellow
241
241
  end
242
242
  @status_bar_style = style
243
243
  @status_bar_animation = args[:animation] if args[:animation]
@@ -47,8 +47,7 @@ module ProMotion
47
47
  send_on_return(args)
48
48
 
49
49
  else
50
- PM.logger.warn "Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar."
51
-
50
+ mp "Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar.", force_color: :yellow
52
51
  end
53
52
  end
54
53
  alias :close :close_screen
@@ -62,13 +61,13 @@ module ProMotion
62
61
  self.parent_screen.send(:on_return)
63
62
  end
64
63
  elsif self.parent_screen.private_methods.include?(:on_return)
65
- PM.logger.warn "#{self.parent_screen.inspect} has an `on_return` method, but it is private and not callable from the closing screen."
64
+ mp "#{self.parent_screen.inspect} has an `on_return` method, but it is private and not callable from the closing screen.", force_color: :yellow
66
65
  end
67
66
  end
68
67
 
69
68
  def push_view_controller(vc, nav_controller=nil, animated=true)
70
69
  unless self.navigationController
71
- PM.logger.error "You need a nav_bar if you are going to push #{vc.to_s} onto it."
70
+ mp "You need a nav_bar if you are going to push #{vc.to_s} onto it.", force_color: :red
72
71
  end
73
72
  nav_controller ||= self.navigationController
74
73
  return if nav_controller.topViewController == vc
@@ -114,7 +113,7 @@ module ProMotion
114
113
 
115
114
  def open_in_tab(screen, tab_name)
116
115
  vc = open_tab(tab_name)
117
- return PM.logger.error("No tab bar item '#{tab_name}'") && nil unless vc
116
+ return mp("No tab bar item '#{tab_name}'", force_color: :red) && nil unless vc
118
117
  if vc.is_a?(UINavigationController)
119
118
  push_view_controller(screen, vc)
120
119
  else
@@ -25,8 +25,10 @@ module ProMotion
25
25
  elsif k.to_s.include?("_") # Snake case?
26
26
  set_attribute(element, camelize(k), v)
27
27
  else # Warn
28
- PM.logger.debug "set_attribute: #{element.inspect} does not respond to #{k}=."
29
- PM.logger.log("BACKTRACE", caller(0).join("\n"), :default) if PM.logger.level == :verbose
28
+ mp "set_attribute: #{element.inspect} does not respond to #{k}=.", force_color: :purple
29
+ # TODO - remove now, or when fully deprecated - there will be no verbose
30
+ # check when logger is removed
31
+ mp "BACKTRACE", caller(0).join("\n") if PM.logger.level == :verbose
30
32
  end
31
33
  element
32
34
  end
@@ -118,9 +120,9 @@ module ProMotion
118
120
 
119
121
  def get_attributes_from_symbol(attrs)
120
122
  return attrs if attrs.is_a?(Hash)
121
- PM.logger.error "#{attrs} styling method is not defined" unless self.respond_to?(attrs)
123
+ mp("#{attrs} styling method is not defined", force_color: :red) unless self.respond_to?(attrs)
122
124
  new_attrs = send(attrs)
123
- PM.logger.error "#{attrs} should return a hash" unless new_attrs.is_a?(Hash)
125
+ mp("#{attrs} should return a hash", force_color: :red) unless new_attrs.is_a?(Hash)
124
126
  new_attrs
125
127
  end
126
128
 
@@ -25,7 +25,7 @@ module ProMotion
25
25
  def check_deprecated_styles
26
26
  whitelist = [ :title, :subtitle, :image, :remote_image, :accessory, :selection_style, :action, :long_press_action, :arguments, :cell_style, :cell_class, :cell_identifier, :editing_style, :moveable, :search_text, :keep_selection, :height, :accessory_type, :style, :properties, :searchable ]
27
27
  if (data_cell.keys - whitelist).length > 0
28
- PM.logger.deprecated("In #{self.table_screen.class.to_s}#table_data, you should set :#{(data_cell.keys - whitelist).join(", :")} in a `properties:` hash. See TableScreen documentation.")
28
+ mp "In #{self.table_screen.class.to_s}#table_data, you should set :#{(data_cell.keys - whitelist).join(", :")} in a `properties:` hash. See TableScreen documentation.", force_color: :yellow
29
29
  end
30
30
  end
31
31
 
@@ -58,13 +58,13 @@ module ProMotion
58
58
  self.imageView.image = image unless image.nil?
59
59
  })
60
60
  elsif jm_image_cache?
61
- PM.logger.warning "'JMImageCache' is known to have issues with ProMotion. Please consider switching to 'SDWebImage'. 'JMImageCache' support will be deprecated in the next major version."
61
+ mp "'JMImageCache' is known to have issues with ProMotion. Please consider switching to 'SDWebImage'. 'JMImageCache' support will be deprecated in the next major version.", force_color: :yellow
62
62
  JMImageCache.sharedCache.imageForURL(data_cell[:remote_image][:url].to_url, completionBlock:proc { |downloaded_image|
63
63
  self.imageView.image = downloaded_image
64
64
  self.setNeedsLayout
65
65
  })
66
66
  else
67
- PM.logger.error "To use remote_image with TableScreen you need to include the CocoaPod 'SDWebImage'."
67
+ mp "To use remote_image with TableScreen you need to include the CocoaPod 'SDWebImage'.", force_color: :red
68
68
  end
69
69
 
70
70
  self.imageView.layer.masksToBounds = true
@@ -18,7 +18,7 @@ module ProMotion
18
18
  gesture_point = gesture.locationInView(pressed_table_view)
19
19
  index_path = pressed_table_view.indexPathForRowAtPoint(gesture_point)
20
20
  return unless index_path
21
- data_cell = self.promotion_table_data.cell(index_path: index_path)
21
+ data_cell = cell_at(index_path: index_path)
22
22
  return unless data_cell
23
23
  trigger_action(data_cell[:long_press_action], data_cell[:arguments], index_path) if data_cell[:long_press_action]
24
24
  end
@@ -41,7 +41,7 @@ module ProMotion
41
41
  if @refreshable_callback && self.respond_to?(@refreshable_callback)
42
42
  self.send(@refreshable_callback)
43
43
  else
44
- PM.logger.warn "You must implement the '#{@refreshable_callback}' method in your TableScreen."
44
+ mp "You must implement the '#{@refreshable_callback}' method in your TableScreen.", force_color: :yellow
45
45
  end
46
46
  end
47
47
  end
@@ -21,11 +21,10 @@ module ProMotion
21
21
  set_up_refreshable
22
22
  set_up_longpressable
23
23
  set_up_row_height
24
- set_up_accessibility
25
24
  end
26
25
 
27
26
  def check_table_data
28
- PM.logger.error "Missing #table_data method in TableScreen #{self.class.to_s}." unless self.respond_to?(:table_data)
27
+ mp("Missing #table_data method in TableScreen #{self.class.to_s}.", force_color: :red) unless self.respond_to?(:table_data)
29
28
  end
30
29
 
31
30
  def promotion_table_data
@@ -39,7 +38,7 @@ module ProMotion
39
38
  if view.is_a? UIView
40
39
  self.tableView.send(camelize("set_table_#{hf_view}_view:"), view)
41
40
  else
42
- PM.logger.warn "Table #{hf_view} view must be a UIView."
41
+ mp "Table #{hf_view} view must be a UIView.", force_color: :yellow
43
42
  end
44
43
  end
45
44
  end
@@ -73,7 +72,7 @@ module ProMotion
73
72
  if defined?(UIRefreshControl)
74
73
  self.make_refreshable(self.class.get_refreshable_params)
75
74
  else
76
- PM.logger.warn "To use the refresh control on < iOS 6, you need to include the CocoaPod 'CKRefreshControl'."
75
+ mp "To use the refresh control on < iOS 6, you need to include the CocoaPod 'CKRefreshControl'.", force_color: :yellow
77
76
  end
78
77
  end
79
78
  end
@@ -91,19 +90,6 @@ module ProMotion
91
90
  end
92
91
  end
93
92
 
94
- def editable?
95
- self.promotion_table_data.sections.each do |section|
96
- section[:cells].each do |cell|
97
- return true if [:insert,:delete].include?(cell[:editing_style])
98
- end
99
- end
100
- false
101
- end
102
-
103
- def set_up_accessibility
104
- self.extend(Editable) if editable?
105
- end
106
-
107
93
  def searching?
108
94
  self.promotion_table_data.filtered
109
95
  end
@@ -135,7 +121,7 @@ module ProMotion
135
121
  index_path = closest_parent(UITableView, table_cell).indexPathForCell(table_cell)
136
122
 
137
123
  if index_path
138
- data_cell = promotion_table_data.cell(section: index_path.section, index: index_path.row)
124
+ data_cell = cell_at(index_path: index_path)
139
125
  data_cell[:accessory][:arguments][:value] = switch.isOn if data_cell[:accessory][:arguments].is_a?(Hash)
140
126
  trigger_action(data_cell[:accessory][:action], data_cell[:accessory][:arguments], index_path) if data_cell[:accessory][:action]
141
127
  end
@@ -145,7 +131,7 @@ module ProMotion
145
131
  deletable_index_paths = []
146
132
  Array(index_paths).each do |index_path|
147
133
  delete_cell = false
148
- delete_cell = send(:on_cell_deleted, self.promotion_table_data.cell(index_path: index_path)) if self.respond_to?("on_cell_deleted:")
134
+ delete_cell = send(:on_cell_deleted, cell_at(index_path: index_path)) if self.respond_to?("on_cell_deleted:")
149
135
  unless delete_cell == false
150
136
  self.promotion_table_data.delete_cell(index_path: index_path)
151
137
  deletable_index_paths << index_path
@@ -176,6 +162,11 @@ module ProMotion
176
162
  !!isEditing
177
163
  end
178
164
 
165
+ # Returns the data cell
166
+ def cell_at(args = {})
167
+ self.promotion_table_data.cell(args)
168
+ end
169
+
179
170
  ########## Cocoa touch methods #################
180
171
  def numberOfSectionsInTableView(_)
181
172
  self.promotion_table_data.sections.length
@@ -200,42 +191,46 @@ module ProMotion
200
191
 
201
192
  def tableView(_, cellForRowAtIndexPath: index_path)
202
193
  params = index_path_to_section_index(index_path: index_path)
203
- data_cell = self.promotion_table_data.cell(section: params[:section], index: params[:index])
194
+ data_cell = cell_at(index: params[:index], section: params[:section])
204
195
  return UITableViewCell.alloc.init unless data_cell
205
196
  create_table_cell(data_cell)
206
197
  end
207
198
 
208
199
  def tableView(_, willDisplayCell: table_cell, forRowAtIndexPath: index_path)
209
- data_cell = self.promotion_table_data.cell(index_path: index_path)
200
+ data_cell = cell_at(index_path: index_path)
201
+ try :will_display_cell, table_cell, index_path
210
202
  table_cell.send(:will_display) if table_cell.respond_to?(:will_display)
211
203
  table_cell.send(:restyle!) if table_cell.respond_to?(:restyle!) # Teacup compatibility
212
204
  end
213
205
 
214
206
  def tableView(_, heightForRowAtIndexPath: index_path)
215
- (self.promotion_table_data.cell(index_path: index_path)[:height] || tableView.rowHeight).to_f
207
+ (cell_at(index_path: index_path)[:height] || tableView.rowHeight).to_f
216
208
  end
217
209
 
218
210
  def tableView(table_view, didSelectRowAtIndexPath: index_path)
219
- data_cell = self.promotion_table_data.cell(index_path: index_path)
211
+ data_cell = cell_at(index_path: index_path)
220
212
  table_view.deselectRowAtIndexPath(index_path, animated: true) unless data_cell[:keep_selection] == true
221
213
  trigger_action(data_cell[:action], data_cell[:arguments], index_path) if data_cell[:action]
222
214
  end
223
215
 
224
- def tableView(_, editingStyleForRowAtIndexPath: index_path)
216
+ def tableView(_, canEditRowAtIndexPath:index_path)
225
217
  data_cell = self.promotion_table_data.cell(index_path: index_path, unfiltered: true)
218
+ [:insert,:delete].include?(data_cell[:editing_style])
219
+ end
220
+
221
+ def tableView(_, editingStyleForRowAtIndexPath: index_path)
222
+ data_cell = cell_at(index_path: index_path, unfiltered: true)
226
223
  map_cell_editing_style(data_cell[:editing_style])
227
224
  end
228
225
 
229
- module Editable
230
- def tableView(_, commitEditingStyle: editing_style, forRowAtIndexPath: index_path)
231
- if editing_style == UITableViewCellEditingStyleDelete
232
- delete_row(index_path)
233
- end
226
+ def tableView(_, commitEditingStyle: editing_style, forRowAtIndexPath: index_path)
227
+ if editing_style == UITableViewCellEditingStyleDelete
228
+ delete_row(index_path)
234
229
  end
235
230
  end
236
231
 
237
232
  def tableView(_, canMoveRowAtIndexPath:index_path)
238
- data_cell = self.promotion_table_data.cell(index_path: index_path, unfiltered: true)
233
+ data_cell = cell_at(index_path: index_path, unfiltered: true)
239
234
 
240
235
  if (!data_cell[:moveable].nil? || data_cell[:moveable].is_a?(Symbol)) && data_cell[:moveable] != false
241
236
  true
@@ -245,7 +240,7 @@ module ProMotion
245
240
  end
246
241
 
247
242
  def tableView(_, targetIndexPathForMoveFromRowAtIndexPath:source_index_path, toProposedIndexPath:proposed_destination_index_path)
248
- data_cell = self.promotion_table_data.cell(index_path: source_index_path, unfiltered: true)
243
+ data_cell = cell_at(index_path: source_index_path, unfiltered: true)
249
244
 
250
245
  if data_cell[:moveable] == :section && source_index_path.section != proposed_destination_index_path.section
251
246
  source_index_path
@@ -267,7 +262,7 @@ module ProMotion
267
262
  }
268
263
  send(:on_cell_moved, args)
269
264
  else
270
- PM.logger.warn "Implement the on_cell_moved method in your PM::TableScreen to be notified when a user moves a cell."
265
+ mp "Implement the on_cell_moved method in your PM::TableScreen to be notified when a user moves a cell.", force_color: :yellow
271
266
  end
272
267
  end
273
268
 
@@ -283,7 +278,7 @@ module ProMotion
283
278
  end
284
279
 
285
280
  def deleteRowsAtIndexPaths(index_paths, withRowAnimation: animation)
286
- PM.logger.warn "ProMotion expects you to use 'delete_cell(index_paths, animation)'' instead of 'deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation)'."
281
+ mp "ProMotion expects you to use 'delete_cell(index_paths, animation)'' instead of 'deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation)'.", force_color: :yellow
287
282
  delete_row(index_paths, animation)
288
283
  end
289
284
 
@@ -343,6 +338,5 @@ module ProMotion
343
338
  def self.included(base)
344
339
  base.extend(TableClassMethods)
345
340
  end
346
-
347
341
  end
348
342
  end
@@ -1,7 +1,7 @@
1
1
  module ProMotion
2
2
  module TableBuilder
3
3
  def trigger_action(action, arguments, index_path)
4
- return PM.logger.info "Action not implemented: #{action.to_s}" unless self.respond_to?(action)
4
+ return mp("Action not implemented: #{action.to_s}", force_color: :green) unless self.respond_to?(action)
5
5
  case self.method(action).arity
6
6
  when 0 then self.send(action) # Just call the method
7
7
  when 2 then self.send(action, arguments, index_path) # Send arguments and index path
@@ -7,7 +7,7 @@ module TableClassMethods
7
7
  if height == :auto
8
8
  if UIDevice.currentDevice.systemVersion.to_f < 8.0
9
9
  height = args[:estimated] || 44.0
10
- PM.logger.warn "Using `row_height :auto` is not supported in iOS 7 apps. Setting to #{height}."
10
+ mp "Using `row_height :auto` is not supported in iOS 7 apps. Setting to #{height}.", force_color: :yellow
11
11
  else
12
12
  height = UITableViewAutomaticDimension
13
13
  end
@@ -51,14 +51,14 @@ module ProMotion
51
51
 
52
52
  def create_tab_bar_item(tab={})
53
53
  if tab[:system_icon] || tab[:icon]
54
- PM.logger.deprecated("`system_icon:` no longer supported. Use `system_item:` instead.") if tab[:system_icon]
55
- PM.logger.deprecated("`icon:` no longer supported. Use `item:` instead.") if tab[:icon]
54
+ mp("`system_icon:` no longer supported. Use `system_item:` instead.", force_color: :yellow) if tab[:system_icon]
55
+ mp("`icon:` no longer supported. Use `item:` instead.", force_color: :yellow) if tab[:icon]
56
56
  tab[:system_item] ||= tab[:system_icon]
57
57
  tab[:item] ||= tab[:icon]
58
58
  end
59
59
 
60
60
  unless tab[:system_item] || tab[:item]
61
- PM.logger.warn("You must provide either a `system_item:` or custom `item:` in `tab_bar_item`")
61
+ mp "You must provide either a `system_item:` or custom `item:` in `tab_bar_item`", force_color: :yellow
62
62
  abort
63
63
  end
64
64
 
@@ -1,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "2.4.0" unless defined?(ProMotion::VERSION)
2
+ VERSION = "2.4.1" unless defined?(ProMotion::VERSION)
3
3
  end
@@ -76,7 +76,7 @@ module ProMotion
76
76
  end
77
77
 
78
78
  def check_content_data
79
- PM.logger.error "Missing #content method in WebScreen #{self.class.to_s}." unless self.respond_to?(:content)
79
+ mp("Missing #content method in WebScreen #{self.class.to_s}.", force_color: :red) unless self.respond_to?(:content)
80
80
  end
81
81
 
82
82
  def html
@@ -18,32 +18,35 @@ describe "ProMotion::TestWebScreen functionality" do
18
18
  it "should have the proper html content" do
19
19
  file_name = "WebScreen.html"
20
20
 
21
- controller.set_content(file_name)
22
-
23
- @loaded_file = File.read(File.join(NSBundle.mainBundle.resourcePath, file_name))
24
- wait_for_change controller, 'is_load_finished' do
25
- controller.html.delete("\n").should == @loaded_file.delete("\n")
21
+ controller.mock!(:load_finished) do
22
+ loaded_file = File.read(File.join(NSBundle.mainBundle.resourcePath, file_name))
23
+ controller.html.delete("\n").should == loaded_file.delete("\n")
24
+ resume
26
25
  end
26
+ controller.set_content(file_name)
27
+ wait_max 8 {}
27
28
  end
28
29
 
29
30
  it "should allow you to navigate to a website" do
30
31
  stub_request(:get, "https://www.google.com/").
31
32
  to_return(body: %q{Google! <form action="/search">%}, content_type: "text/html")
32
33
 
33
- controller.open_url(NSURL.URLWithString("https://www.google.com/"))
34
- wait_for_change controller, 'is_load_finished' do
35
- controller.html.include?('<form action="/search"').should == true
34
+ controller.mock!(:load_finished) do
35
+ controller.html.should.include('<form action="/search"')
36
+ resume
36
37
  end
38
+ controller.open_url(NSURL.URLWithString("https://www.google.com/"))
39
+ wait_max 8 {}
37
40
  end
38
41
 
39
42
  it "should manipulate the webscreen contents with javascript" do
40
- controller.set_content('<h1 id="cool">Something Cool</h1>')
41
-
42
- wait_for_change controller, 'is_load_finished' do
43
+ controller.mock!(:load_finished) do
43
44
  controller.evaluate('document.getElementById("cool").innerHTML = "Changed"')
44
45
  controller.html.should =~ /<h1 id="cool">Changed<\/h1>/
46
+ resume
45
47
  end
46
-
48
+ controller.set_content('<h1 id="cool">Something Cool</h1>')
49
+ wait_max 8 {}
47
50
  end
48
51
 
49
52
  end
@@ -62,29 +62,6 @@ describe "table screens" do
62
62
  screen.view.rowHeight.should == 77
63
63
  screen.view.estimatedRowHeight.should == 77
64
64
  end
65
-
66
- it "sets up proper accessibility methods" do
67
- class NoneditableTableScreen < PM::TableScreen
68
- def on_load
69
- end
70
-
71
- def table_data
72
- [{
73
- title: "test",
74
- cells: [{ title: "Non-editable test" }]
75
- }]
76
- end
77
- end
78
-
79
- noneditable = NoneditableTableScreen.new
80
- noneditable.on_load
81
- noneditable.editable?.should==false
82
- index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
83
- lambda { noneditable.tableView(noneditable, commitEditingStyle: UITableViewCellEditingStyleDelete, forRowAtIndexPath: index_path) }.should.raise NoMethodError
84
- @screen.editable?.should == true
85
- @screen.should.respond_to(:"tableView:commitEditingStyle:forRowAtIndexPath")
86
- end
87
-
88
65
  end
89
66
 
90
67
  describe "search functionality" do
@@ -273,4 +250,3 @@ describe "table screens" do
273
250
  end
274
251
 
275
252
  end
276
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ProMotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamon Holmgren
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-13 00:00:00.000000000 Z
13
+ date: 2015-05-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: methadone
@@ -26,6 +26,20 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.7'
29
+ - !ruby/object:Gem::Dependency
30
+ name: motion_print
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
29
43
  - !ruby/object:Gem::Dependency
30
44
  name: webstub
31
45
  requirement: !ruby/object:Gem::Requirement
@@ -74,14 +88,14 @@ dependencies:
74
88
  requirements:
75
89
  - - ">="
76
90
  - !ruby/object:Gem::Version
77
- version: '10.0'
91
+ version: '0'
78
92
  type: :development
79
93
  prerelease: false
80
94
  version_requirements: !ruby/object:Gem::Requirement
81
95
  requirements:
82
96
  - - ">="
83
97
  - !ruby/object:Gem::Version
84
- version: '10.0'
98
+ version: '0'
85
99
  description: ProMotion is a fast way to get started building RubyMotion iOS apps.
86
100
  email:
87
101
  - jamon@clearsightstudio.com
@@ -146,7 +160,6 @@ files:
146
160
  - spec/unit/image_title_screen_spec.rb
147
161
  - spec/unit/image_view_title_screen_spec.rb
148
162
  - spec/unit/load_view_spec.rb
149
- - spec/unit/logger_spec.rb
150
163
  - spec/unit/main_spec.rb
151
164
  - spec/unit/screen_helpers_spec.rb
152
165
  - spec/unit/screen_module_spec.rb
@@ -186,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
199
  version: '0'
187
200
  requirements: []
188
201
  rubyforge_project:
189
- rubygems_version: 2.2.0
202
+ rubygems_version: 2.4.6
190
203
  signing_key:
191
204
  specification_version: 4
192
205
  summary: ProMotion is a fast way to get started building RubyMotion apps. Instead
@@ -206,7 +219,6 @@ test_files:
206
219
  - spec/unit/image_title_screen_spec.rb
207
220
  - spec/unit/image_view_title_screen_spec.rb
208
221
  - spec/unit/load_view_spec.rb
209
- - spec/unit/logger_spec.rb
210
222
  - spec/unit/main_spec.rb
211
223
  - spec/unit/screen_helpers_spec.rb
212
224
  - spec/unit/screen_module_spec.rb
@@ -1,68 +0,0 @@
1
- describe "logger functionality" do
2
-
3
- describe "basic logger" do
4
- it "should respond to PM.logger with a logger instance" do
5
- PM.logger.is_a?(PM::Logger).should == true
6
- end
7
-
8
- it "should allow setting the log level" do
9
- PM.logger.level = :warn
10
- PM.logger.level.should == :warn
11
- end
12
- end
13
-
14
- describe "testing levels" do
15
-
16
- before do
17
- PM.logger.stub! :log {|a, b, c| "It worked" }
18
- end
19
-
20
- after do
21
- PM.logger.level = :debug
22
- end
23
-
24
- it "should not log if level is set to :none" do
25
-
26
- PM.logger.stub! :log do |label, message_text, color|
27
- should.flunk "should not log if logging is turned off!"
28
- end
29
-
30
- PM.logger.level = :none
31
- PM.logger.warn("I'm giving you a warning that you should ignore.").should == nil
32
-
33
- end
34
-
35
- it "#error should log if set to :error level or above" do
36
-
37
- PM.logger.level = :error
38
- PM.logger.error("test message").should == "It worked"
39
-
40
- end
41
-
42
- it "#deprecated should log if set to :warn level or above" do
43
-
44
- PM.logger.level = :warn
45
- PM.logger.deprecated("test message").should == "It worked"
46
-
47
- end
48
- it "#warn should log if set to :warn level or above" do
49
-
50
- PM.logger.level = :warn
51
- PM.logger.warn("test message").should == "It worked"
52
-
53
- end
54
- it "#debug should log if set to :debug level or above" do
55
-
56
- PM.logger.level = :debug
57
- PM.logger.debug("test message").should == "It worked"
58
-
59
- end
60
- it "#info should log if set to :info level or above" do
61
-
62
- PM.logger.level = :info
63
- PM.logger.info("test message").should == "It worked"
64
-
65
- end
66
-
67
- end
68
- end