ProMotion 2.6.1 → 2.7.0

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: 285951be59aa38255b60d3acdc23efa0f83ca46e
4
- data.tar.gz: 418446c809113d6c205700c16027b76ce3693e7b
3
+ metadata.gz: 3b3a0f91e4bc6d09696a8ccb696202025c9adeeb
4
+ data.tar.gz: 68b66d3740172a53ecfc45624212d370035f6626
5
5
  SHA512:
6
- metadata.gz: c38eb0c246499f5a5da54b9a08595b93b3d41feff71b8b9530d0e5e5d6def216354a471513b47adf6e948878133f9fc6dfcf6e65562c130166ac31922630029b
7
- data.tar.gz: 26b3153d167a39716c6c24253ba5bc47cf055e6457f6add54d8b2d7804d5baf8293112330cbce41db261eab0d69776ebc2f3f781cd867b2ff3321e6406ee61e4
6
+ metadata.gz: 7d827e3214b752ce5ddaecb6ecba7a0b249b4d98911bd29ee528047c4ab5bf8b03726886287623f5995ab745b46e959c3c53baab0d8004e65482294cb13a54df
7
+ data.tar.gz: 5f534e77735df0403e98862027ba9ce41e8d4ac30aff0d1d55c6821a7dd68606761d7df2e2f35a53b49153ca73b735eda0122882424f8d4a09e94cad6961d205
data/README.md CHANGED
@@ -4,7 +4,11 @@
4
4
  [![Build Status](https://img.shields.io/travis/infinitered/ProMotion.svg?style=flat)](https://travis-ci.org/infinitered/ProMotion)
5
5
  [![Code Climate](https://img.shields.io/codeclimate/github/infinitered/ProMotion.svg?style=flat)](https://codeclimate.com/github/infinitered/ProMotion)
6
6
 
7
- ProMotion is maintained by [Infinite Red](http://infinite.red), a web and mobile development company based in Portland, OR and San Francisco, CA.
7
+ ProMotion was created by [Infinite Red](http://infinite.red), a web and mobile development company based in Portland, OR and San Francisco, CA. While you're welcome to use ProMotion, please note that we rely on the community to maintain it. We are happy to merge pull requests and release new versions but are no longer driving primary development.
8
+
9
+ <img alt="apple presentation" src="https://cloud.githubusercontent.com/assets/1479215/26798290/c156fdb4-49e4-11e7-92b7-be24647a3474.png" width="350px" />
10
+
11
+ _Apple presenting on ProMotion, WWDC 2017_
8
12
 
9
13
  ## iPhone Apps, Ruby-style
10
14
 
@@ -144,6 +148,11 @@ welcoming to new RubyMotion developers. We don't mind newbie questions.
144
148
 
145
149
  The quickest way to get help is to join the [Motioneers Slack Group](http://motioneers.herokuapp.com). If you still need help, feel free to open an issue on GitHub. If we don't respond within a day, tweet us a link to the issue -- sometimes we get busy.
146
150
 
151
+ ## Premium Support
152
+
153
+ [ProMotion](https://github.com/infinitered/ProMotion), as an open source project, is free to use and always will be. [Infinite Red](https://infinite.red/) offers premium ProMotion support and general mobile app design/development services. Email us at [hello@infinite.red](mailto:hello@infinite.red) to get in touch with us for more details.
154
+
155
+
147
156
  # Contributing
148
157
 
149
158
  See [CONTRIBUTING.md](https://github.com/infinitered/ProMotion/blob/master/CONTRIBUTING.md).
@@ -151,9 +160,10 @@ See [CONTRIBUTING.md](https://github.com/infinitered/ProMotion/blob/master/CONTR
151
160
  ## Core Team
152
161
 
153
162
  * Jamon Holmgren: [@jamonholmgren](https://twitter.com/jamonholmgren)
154
- * Silas Matson: [@silasjmatson](https://twitter.com/silasjmatson)
163
+ * Andrew Havens: [@misbehavens](https://twitter.com/misbehavens)
155
164
  * Mark Rickert: [@markrickert](https://twitter.com/markrickert)
156
165
  * Ryan Linton: [@ryanlntn](https://twitter.com/ryanlntn)
166
+ * Silas Matson: [@silasjmatson](https://twitter.com/silasjmatson)
157
167
  * David Larrabee: [@squidpunch](https://twitter.com/squidpunch)
158
168
 
159
169
  ## Other Contributors
@@ -23,7 +23,10 @@ Motion::Project::App.setup do |app|
23
23
  "#{core_lib}/table/cell/table_view_cell_module.rb" => [ "#{core_lib}/styling/styling.rb" ],
24
24
  "#{core_lib}/cocoatouch/collection_view_cell.rb" => [ "#{core_lib}/collection/cell/collection_view_cell_module.rb" ],
25
25
  "#{core_lib}/collection/collection_screen.rb" => [
26
+ "#{core_lib}/cocoatouch/collection_view_controller.rb",
26
27
  "#{core_lib}/screen/screen_module.rb",
28
+ "#{core_lib}/collection/collection_builder.rb",
29
+ "#{core_lib}/collection/collection.rb",
27
30
  "#{core_lib}/collection/cell/collection_view_cell_module.rb",
28
31
  ],
29
32
  "#{core_lib}/collection/cell/collection_view_cell_module.rb" => [ "#{core_lib}/styling/styling.rb" ],
@@ -37,6 +40,7 @@ Motion::Project::App.setup do |app|
37
40
  "#{core_lib}/screen/screen.rb" => [ "#{core_lib}/screen/screen_module.rb" ],
38
41
  "#{core_lib}/screen/screen_navigation.rb" => [ "#{core_lib}/support/support.rb", ],
39
42
  "#{core_lib}/screen/screen_module.rb" => [
43
+ "#{core_lib}/styling/styling.rb",
40
44
  "#{core_lib}/tabs/tabs.rb",
41
45
  "#{core_lib}/screen/nav_bar_module.rb",
42
46
  "#{core_lib}/screen/screen_navigation.rb",
@@ -6,6 +6,12 @@ module ProMotion
6
6
  s
7
7
  end
8
8
 
9
+ def init
10
+ super.tap do
11
+ screen_init if respond_to?(:screen_init)
12
+ end
13
+ end
14
+
9
15
  def loadView
10
16
  self.respond_to?(:load_view) ? self.load_view : super
11
17
  end
@@ -6,6 +6,12 @@ module ProMotion
6
6
  s
7
7
  end
8
8
 
9
+ def init
10
+ super.tap do
11
+ screen_init if respond_to?(:screen_init)
12
+ end
13
+ end
14
+
9
15
  def loadView
10
16
  self.respond_to?(:load_view) ? self.load_view : super
11
17
  end
@@ -6,6 +6,12 @@ module ProMotion
6
6
  s
7
7
  end
8
8
 
9
+ def init
10
+ super.tap do
11
+ screen_init if respond_to?(:screen_init)
12
+ end
13
+ end
14
+
9
15
  def loadView
10
16
  self.respond_to?(:load_view) ? self.load_view : super
11
17
  end
@@ -12,7 +12,6 @@ module ProMotion
12
12
  end
13
13
 
14
14
  def application(application, didFinishLaunchingWithOptions:launch_options)
15
- apply_status_bar
16
15
  on_load application, launch_options
17
16
  # Requires 'ProMotion-push' gem.
18
17
  check_for_push_notification(launch_options) if respond_to?(:check_for_push_notification)
@@ -66,37 +65,43 @@ module ProMotion
66
65
  alias :open_screen :open
67
66
  alias :open_root_screen :open_screen
68
67
 
68
+ # DEPRECATED
69
69
  def status_bar?
70
- UIApplication.sharedApplication.statusBarHidden
70
+ mp "The default behavior of `status_bar?` has changed. Calling `status_bar?` on AppDelegate may not return the correct result.", force_color: :yellow
71
+ self.class.status_bar_style != :hidden
71
72
  end
72
73
 
73
- private
74
+ def status_bar_style
75
+ self.class.status_bar_style
76
+ end
74
77
 
75
- def apply_status_bar
76
- self.class.send(:apply_status_bar)
78
+ def status_bar_animation
79
+ self.class.status_bar_animation
77
80
  end
78
81
 
79
82
  public
80
83
 
81
84
  module ClassMethods
82
85
 
83
- def status_bar(visible = true, opts={})
84
- @status_bar_visible = visible
85
- @status_bar_opts = opts
86
+ def status_bar(visible = true, opts = {})
87
+ info_plist_setting = NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance')
88
+ if info_plist_setting == false && visible == false
89
+ mp "The default behavior of `status_bar` has changed. Calling `status_bar` will have no effect until you remove the 'UIViewControllerBasedStatusBarAppearance' setting from info_plist.", force_color: :yellow
90
+ end
91
+ @status_bar_style = case visible
92
+ when false then :hidden
93
+ when true then :default
94
+ else visible
95
+ end
96
+ @status_bar_animation = opts[:animation] || :default
86
97
  end
87
98
 
88
- def apply_status_bar
89
- @status_bar_visible = true if @status_bar_visible.nil?
90
- @status_bar_opts ||= { animation: :none }
91
- UIApplication.sharedApplication.setStatusBarHidden(!@status_bar_visible, withAnimation:status_bar_animation(@status_bar_opts[:animation]))
99
+ def status_bar_style
100
+ @status_bar_style
92
101
  end
93
102
 
94
- def status_bar_animation(opt)
95
- {
96
- fade: UIStatusBarAnimationFade,
97
- slide: UIStatusBarAnimationSlide,
98
- none: UIStatusBarAnimationNone
99
- }[opt] || UIStatusBarAnimationNone
103
+ def status_bar_animation
104
+ @status_bar_animation
100
105
  end
101
106
 
102
107
  def tint_color(c)
@@ -110,12 +115,10 @@ module ProMotion
110
115
  def get_tint_color
111
116
  @tint_color || nil
112
117
  end
113
-
114
118
  end
115
119
 
116
120
  def self.included(base)
117
121
  base.extend(ClassMethods)
118
122
  end
119
-
120
123
  end
121
124
  end
@@ -35,12 +35,6 @@ module ProMotion
35
35
  self.navigationItem.setRightBarButtonItems(buttons) if side == :right
36
36
  end
37
37
 
38
- # TODO: In PM 2.1+, entirely remove this deprecated method.
39
- def set_nav_bar_left_button(title, args={})
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
- end
42
- alias_method :set_nav_bar_right_button, :set_nav_bar_left_button
43
-
44
38
  def set_toolbar_items(buttons = [], animated = true)
45
39
  if buttons
46
40
  self.toolbarItems = Array(buttons).map{|b| b.is_a?(UIBarButtonItem) ? b : create_toolbar_button(b) }
@@ -81,7 +75,10 @@ module ProMotion
81
75
  def bar_button_item(button_type, args)
82
76
  return mp("`system_icon:` no longer supported. Use `system_item:` instead.", force_color: :yellow) if args[:system_icon]
83
77
  return button_type if button_type.is_a?(UIBarButtonItem)
84
- return bar_button_item_system_item(args) if args[:system_item]
78
+ if args[:system_item]
79
+ mp("Nav bar button specified both `system_item:` and `title:`. Title will be ignored.", force_color: :yellow) if args[:title]
80
+ return bar_button_item_system_item(args)
81
+ end
85
82
  return bar_button_item_image(button_type, args) if button_type.is_a?(UIImage)
86
83
  return bar_button_item_string(button_type, args) if button_type.is_a?(String)
87
84
  return bar_button_item_custom(button_type) if button_type.is_a?(UIView)
@@ -111,6 +108,7 @@ module ProMotion
111
108
  end
112
109
 
113
110
  def map_bar_button_system_item(symbol)
111
+ mp("Nav bar button stytem item `:page_curl` has been deprecated.", force_color: :yellow) if symbol == :page_curl
114
112
  {
115
113
  done: UIBarButtonSystemItemDone,
116
114
  cancel: UIBarButtonSystemItemCancel,
@@ -135,14 +133,15 @@ module ProMotion
135
133
  fast_forward: UIBarButtonSystemItemFastForward,
136
134
  undo: UIBarButtonSystemItemUndo,
137
135
  redo: UIBarButtonSystemItemRedo,
138
- page_curl: UIBarButtonSystemItemPageCurl
136
+ page_curl: UIBarButtonSystemItemPageCurl # DEPRECATED
139
137
  }[symbol] || UIBarButtonSystemItemDone
140
138
  end
141
139
 
142
140
  def map_bar_button_item_style(symbol)
141
+ mp("Nav bar button style `:bordered` has been deprecated.", force_color: :yellow) if symbol == :bordered
143
142
  {
144
143
  plain: UIBarButtonItemStylePlain,
145
- bordered: UIBarButtonItemStyleBordered,
144
+ bordered: UIBarButtonItemStyleBordered, # DEPRECATED
146
145
  done: UIBarButtonItemStyleDone
147
146
  }[symbol] || UIBarButtonItemStyleDone
148
147
  end
@@ -4,6 +4,7 @@ module ProMotion
4
4
  include ProMotion::ScreenNavigation
5
5
  include ProMotion::Styling
6
6
  include ProMotion::NavBarModule
7
+ include ProMotion::StatusBarModule
7
8
  include ProMotion::Tabs
8
9
  include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad || (UIDevice.currentDevice.systemVersion.to_i >= 8 )
9
10
 
@@ -41,7 +42,6 @@ module ProMotion
41
42
 
42
43
  def view_will_appear(animated)
43
44
  super
44
- resolve_status_bar
45
45
  self.will_appear
46
46
 
47
47
  self.will_present if isMovingToParentViewController
@@ -179,38 +179,12 @@ module ProMotion
179
179
  end
180
180
  end
181
181
 
182
- def resolve_status_bar
183
- case self.class.status_bar_type
184
- when :none
185
- status_bar_hidden true
186
- when :light
187
- status_bar_hidden false
188
- status_bar_style UIStatusBarStyleLightContent
189
- when :dark
190
- status_bar_hidden false
191
- status_bar_style UIStatusBarStyleDefault
192
- else
193
- return status_bar_hidden true if UIApplication.sharedApplication.isStatusBarHidden
194
- status_bar_hidden false
195
- global_style = NSBundle.mainBundle.objectForInfoDictionaryKey("UIStatusBarStyle")
196
- status_bar_style global_style ? Object.const_get(global_style) : UIStatusBarStyleDefault
197
- end
198
- end
199
-
200
182
  def add_nav_bar_buttons
201
183
  self.class.get_nav_bar_button.each do |button_args|
202
184
  set_nav_bar_button(button_args[:side], button_args)
203
185
  end
204
186
  end
205
187
 
206
- def status_bar_hidden(hidden)
207
- UIApplication.sharedApplication.setStatusBarHidden(hidden, withAnimation:self.class.status_bar_animation)
208
- end
209
-
210
- def status_bar_style(style)
211
- UIApplication.sharedApplication.setStatusBarStyle(style)
212
- end
213
-
214
188
  def apply_properties(args)
215
189
  reserved_args = [ :nav_bar, :hide_nav_bar, :hide_tab_bar, :animated, :close_all, :in_tab, :in_detail, :in_master, :to_screen, :toolbar ]
216
190
  set_attributes self, args.dup.delete_if { |k,v| reserved_args.include?(k) }
@@ -227,7 +201,6 @@ module ProMotion
227
201
  end
228
202
  end
229
203
 
230
- # Class methods
231
204
  module ClassMethods
232
205
  def title(t=nil)
233
206
  if t && t.is_a?(String) == false
@@ -253,22 +226,6 @@ module ProMotion
253
226
  @title_type = :view
254
227
  end
255
228
 
256
- def status_bar(style=nil, args={})
257
- if NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance').nil?
258
- mp "status_bar will have no effect unless you set 'UIViewControllerBasedStatusBarAppearance' to false in your info.plist", force_color: :yellow
259
- end
260
- @status_bar_style = style
261
- @status_bar_animation = args[:animation] if args[:animation]
262
- end
263
-
264
- def status_bar_type
265
- @status_bar_style || :default
266
- end
267
-
268
- def status_bar_animation
269
- @status_bar_animation || UIStatusBarAnimationSlide
270
- end
271
-
272
229
  def nav_bar(enabled, args={})
273
230
  @nav_bar_args = ({ nav_bar: enabled }).merge(args)
274
231
  end
@@ -291,7 +248,8 @@ module ProMotion
291
248
 
292
249
  def self.included(base)
293
250
  base.extend(ClassMethods)
294
- base.extend(TabClassMethods) # TODO: Is there a better way?
251
+ base.extend(StatusBarModule::ClassMethods)
252
+ base.extend(Tabs::ClassMethods)
295
253
  end
296
254
  end
297
255
  end
@@ -0,0 +1,77 @@
1
+ module ProMotion
2
+ module StatusBarModule
3
+ def preferredStatusBarStyle
4
+ styles = {
5
+ light: UIStatusBarStyleLightContent,
6
+ dark: UIStatusBarStyleDefault,
7
+ default: UIStatusBarStyleDefault
8
+ }
9
+ styles[self.class.status_bar_style || app.delegate.status_bar_style] || styles[:default]
10
+ end
11
+
12
+ def preferredStatusBarUpdateAnimation
13
+ animations = {
14
+ none: UIStatusBarAnimationNone,
15
+ fade: UIStatusBarAnimationFade,
16
+ slide: UIStatusBarAnimationSlide,
17
+ default: UIStatusBarAnimationFade
18
+ }
19
+ animations[self.class.status_bar_animation || app.delegate.status_bar_animation] || animations[:default]
20
+ end
21
+
22
+ def prefersStatusBarHidden
23
+ style = self.class.status_bar_style || app.delegate.status_bar_style
24
+ [:none, :hidden].include?(style)
25
+ end
26
+
27
+ def hide_status_bar(opts = {})
28
+ @previous_status_bar_style = self.class.status_bar_style
29
+ self.class.status_bar_style(:hidden)
30
+ update_status_bar_appearance(opts)
31
+ end
32
+
33
+ def show_status_bar(opts = {})
34
+ new_style = case @previous_status_bar_style
35
+ when nil, :hidden, :none
36
+ opts[:style] || app.delegate.status_bar_style || :default
37
+ else
38
+ @previous_status_bar_style
39
+ end
40
+ self.class.status_bar_style(new_style)
41
+ update_status_bar_appearance(opts)
42
+ end
43
+
44
+ def update_status_bar_appearance(opts = {})
45
+ if opts[:animated] == true
46
+ UIView.animateWithDuration(0.3, animations: -> { setNeedsStatusBarAppearanceUpdate })
47
+ else
48
+ setNeedsStatusBarAppearanceUpdate
49
+ end
50
+ end
51
+
52
+ module ClassMethods
53
+ def status_bar(style = nil, args = {})
54
+ info_plist_setting = NSBundle.mainBundle.objectForInfoDictionaryKey('UIViewControllerBasedStatusBarAppearance')
55
+ if info_plist_setting == false
56
+ mp "The default behavior of `status_bar` has changed. Calling `status_bar` will have no effect until you remove the 'UIViewControllerBasedStatusBarAppearance' setting from info_plist.", force_color: :yellow
57
+ end
58
+ @status_bar_style = style
59
+ @status_bar_animation = args[:animation] if args[:animation]
60
+ end
61
+
62
+ def status_bar_style(val = nil)
63
+ @status_bar_style = val if val
64
+ @status_bar_style
65
+ end
66
+
67
+ def status_bar_animation(val = nil)
68
+ @status_bar_animation = val if val
69
+ @status_bar_animation
70
+ end
71
+ end
72
+
73
+ def self.included(base)
74
+ base.extend(ClassMethods)
75
+ end
76
+ end
77
+ end
@@ -21,6 +21,7 @@ module ProMotion
21
21
 
22
22
  def layoutSubviews
23
23
  super
24
+ return unless data_cell
24
25
 
25
26
  # Support changing sizes of the image view
26
27
  if (data_cell[:image] && data_cell[:image].is_a?(Hash) && data_cell[:image][:size])
@@ -62,13 +63,25 @@ module ProMotion
62
63
  self.imageView.image = remote_placeholder
63
64
 
64
65
  if sd_web_image?
65
- @remote_image_operation = SDWebImageManager.sharedManager.downloadWithURL(data_cell[:remote_image][:url].to_url,
66
- options:SDWebImageRefreshCached,
67
- progress:nil,
68
- completed: -> image, error, cacheType, finished {
69
- self.imageView.image = image unless image.nil?
70
- self.setNeedsLayout
71
- })
66
+ if SDWebImageManager.sharedManager.respond_to?('downloadWithURL:options:progress:completed:')
67
+ # SDWebImage 3.x
68
+ @remote_image_operation = SDWebImageManager.sharedManager.downloadWithURL(data_cell[:remote_image][:url].to_url,
69
+ options:SDWebImageRefreshCached,
70
+ progress:nil,
71
+ completed: -> image, error, cacheType, finished {
72
+ self.imageView.image = image unless image.nil?
73
+ self.setNeedsLayout
74
+ })
75
+ else
76
+ # SDWebImage 4.x
77
+ @remote_image_operation = SDWebImageManager.sharedManager.loadImageWithURL(data_cell[:remote_image][:url].to_url,
78
+ options:SDWebImageRefreshCached | SDWebImageScaleDownLargeImages,
79
+ progress:nil,
80
+ completed: -> image, imageData, error, cacheType, finished, imageURL {
81
+ self.imageView.image = image unless image.nil?
82
+ self.setNeedsLayout
83
+ })
84
+ end
72
85
  elsif jm_image_cache?
73
86
  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
74
87
  JMImageCache.sharedCache.imageForURL(data_cell[:remote_image][:url].to_url, completionBlock:proc { |downloaded_image|
@@ -56,7 +56,7 @@ module ProMotion
56
56
  end
57
57
 
58
58
  def search(search_string)
59
- start_searching(search_string)
59
+ start_searching(search_string) # update the search string
60
60
 
61
61
  self.data.compact.each do |section|
62
62
  new_section = {}
@@ -78,20 +78,18 @@ module ProMotion
78
78
  self.filtered_data
79
79
  end
80
80
 
81
+ def start_searching(search_string = '')
82
+ self.filtered_data = []
83
+ self.filtered = true
84
+ self.search_string = search_string.downcase.strip
85
+ self.original_search_string = search_string
86
+ end
87
+
81
88
  def stop_searching
82
89
  self.filtered_data = []
83
90
  self.filtered = false
84
91
  self.search_string = false
85
92
  self.original_search_string = false
86
93
  end
87
-
88
- private
89
-
90
- def start_searching(search_string)
91
- self.filtered_data = []
92
- self.filtered = true
93
- self.search_string = search_string.downcase.strip
94
- self.original_search_string = search_string
95
- end
96
94
  end
97
95
  end
@@ -2,75 +2,77 @@ module ProMotion
2
2
  module Table
3
3
  module Searchable
4
4
 
5
- def make_searchable(params={})
5
+ def search_controller
6
+ @search_controller ||= UISearchController.alloc.initWithSearchResultsController(nil)
7
+ end
8
+
9
+ def make_searchable(params = {})
6
10
  params = set_searchable_param_defaults(params)
7
11
 
8
- search_bar = create_search_bar(params)
12
+ self.definesPresentationContext = true
13
+ search_controller.delegate = params[:delegate]
14
+ search_controller.searchResultsUpdater = params[:search_results_updater]
15
+ search_controller.hidesNavigationBarDuringPresentation = params[:hidesNavigationBarDuringPresentation]
16
+ search_controller.dimsBackgroundDuringPresentation = params[:obscuresBackgroundDuringPresentation] # iOS 8+ (not deprecated yet)
17
+ # search_controller.obscuresBackgroundDuringPresentation = params[:obscuresBackgroundDuringPresentation] # iOS 9.1+ recommends using this instead of dimsBackgroundDuringPresentation
9
18
 
10
- if params[:search_bar] && params[:search_bar][:placeholder]
11
- search_bar.placeholder = params[:search_bar][:placeholder]
19
+ search_bar = search_controller.searchBar
20
+ search_bar.delegate = params[:search_bar_delegate]
21
+ search_bar.autoresizingMask = UIViewAutoresizingFlexibleWidth
22
+ search_bar.placeholder = NSLocalizedString(params[:placeholder], nil) if params[:placeholder]
23
+ if params[:scopes]
24
+ @scopes = params[:scopes]
25
+ search_bar.scopeButtonTitles = @scopes
12
26
  end
27
+ tableView.tableHeaderView = search_bar
28
+ search_bar.sizeToFit
13
29
 
14
- @no_results_text = params[:search_bar][:no_results] if params[:search_bar][:no_results]
15
-
16
- @table_search_display_controller = UISearchDisplayController.alloc.initWithSearchBar(search_bar, contentsController: params[:content_controller])
17
- @table_search_display_controller.delegate = params[:delegate]
18
- @table_search_display_controller.searchResultsDataSource = params[:data_source]
19
- @table_search_display_controller.searchResultsDelegate = params[:search_results_delegate]
20
-
21
- self.tableView.tableHeaderView = search_bar
30
+ if params[:hide_initially]
31
+ tableView.contentOffset = CGPointMake(0, search_bar.frame.size.height)
32
+ end
22
33
  end
23
- alias :makeSearchable :make_searchable
24
34
 
25
35
  def set_searchable_param_defaults(params)
26
- params[:content_controller] ||= params[:contentController]
27
- params[:data_source] ||= params[:searchResultsDataSource]
28
- params[:search_results_delegate] ||= params[:searchResultsDelegate]
36
+ # support camelCase params
37
+ params[:search_results_updater] ||= params[:searchResultsUpdater]
29
38
 
30
- params[:frame] ||= CGRectMake(0, 0, 320, 44) # TODO: Don't hardcode this...
31
- params[:content_controller] ||= self
32
39
  params[:delegate] ||= self
33
- params[:data_source] ||= self
34
- params[:search_results_delegate] ||= self
35
- params
36
- end
40
+ params[:search_results_updater] ||= self
41
+ params[:search_bar_delegate] ||= self
37
42
 
38
- def create_search_bar(params)
39
- search_bar = UISearchBar.alloc.initWithFrame(params[:frame])
40
- search_bar.autoresizingMask = UIViewAutoresizingFlexibleWidth
41
- search_bar
42
- end
43
+ if params[:hidesNavigationBarDuringPresentation].nil?
44
+ params[:hidesNavigationBarDuringPresentation] = true
45
+ end
43
46
 
44
- def set_no_results_text(controller)
45
- Dispatch::Queue.main.async do
46
- controller.searchResultsTableView.subviews.each do |v|
47
- v.text = @no_results_text if v.is_a?(UILabel)
48
- end
49
- end if @no_results_text
47
+ if params[:obscuresBackgroundDuringPresentation].nil?
48
+ params[:obscuresBackgroundDuringPresentation] = false
49
+ end
50
+
51
+ params
50
52
  end
51
53
 
52
- ######### iOS methods, headless camel case #######
54
+ ######### UISearchControllerDelegate methods #######
53
55
 
54
- def searchDisplayController(controller, shouldReloadTableForSearchString:search_string)
55
- self.promotion_table_data.search(search_string)
56
- set_no_results_text(controller) if @no_results_text
57
- true
56
+ def willPresentSearchController(search_controller)
57
+ promotion_table_data.start_searching
58
+ search_controller.delegate.will_begin_search if search_controller.delegate.respond_to? "will_begin_search"
58
59
  end
59
60
 
60
- def searchDisplayControllerWillEndSearch(controller)
61
- self.promotion_table_data.stop_searching
62
- self.table_view.setScrollEnabled true
63
- self.table_view.reloadData
64
- @table_search_display_controller.delegate.will_end_search if @table_search_display_controller.delegate.respond_to? "will_end_search"
61
+ def willDismissSearchController(search_controller)
62
+ promotion_table_data.stop_searching
63
+ table_view.reloadData
64
+ search_controller.delegate.will_end_search if search_controller.delegate.respond_to? "will_end_search"
65
65
  end
66
66
 
67
- def searchDisplayControllerWillBeginSearch(controller)
68
- self.table_view.setScrollEnabled false
69
- @table_search_display_controller.delegate.will_begin_search if @table_search_display_controller.delegate.respond_to? "will_begin_search"
67
+ # UISearchResultsUpdating protocol method
68
+ def updateSearchResultsForSearchController(search_controller)
69
+ search_string = search_controller.searchBar.text
70
+ promotion_table_data.search(search_string) if searching?
71
+ update_table_data
70
72
  end
71
73
 
72
- def searchDisplayController(controller, didLoadSearchResultsTableView: tableView)
73
- tableView.rowHeight = self.table_view.rowHeight
74
+ def searchBar(search_bar, selectedScopeButtonIndexDidChange: selected_scope_index)
75
+ try :did_change_selected_scope, selected_scope_index
74
76
  end
75
77
  end
76
78
  end
@@ -50,10 +50,7 @@ module ProMotion
50
50
 
51
51
  def set_up_searchable
52
52
  if self.class.respond_to?(:get_searchable) && self.class.get_searchable
53
- self.make_searchable(content_controller: self, search_bar: self.class.get_searchable_params)
54
- if self.class.get_searchable_params[:hide_initially]
55
- self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height)
56
- end
53
+ self.make_searchable(self.class.get_searchable_params)
57
54
  end
58
55
  end
59
56
 
@@ -152,7 +149,6 @@ module ProMotion
152
149
  args = { index_paths: args } unless args.is_a?(Hash)
153
150
 
154
151
  self.update_table_view_data(self.table_data, args)
155
- self.promotion_table_data.search(search_string) if searching?
156
152
  end
157
153
 
158
154
  def toggle_edit_mode(animated = true)
@@ -105,7 +105,7 @@ module ProMotion
105
105
  @_tab_symbols[symbol] || symbol
106
106
  end
107
107
 
108
- module TabClassMethods
108
+ module ClassMethods
109
109
  def tab_bar_item(args={})
110
110
  @tab_bar_item = args
111
111
  end
@@ -116,8 +116,7 @@ module ProMotion
116
116
  end
117
117
 
118
118
  def self.included(base)
119
- base.extend(TabClassMethods)
119
+ base.extend(ClassMethods)
120
120
  end
121
-
122
121
  end
123
122
  end
@@ -1,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "2.6.1" unless defined?(ProMotion::VERSION)
2
+ VERSION = "2.7.0" unless defined?(ProMotion::VERSION)
3
3
  end
@@ -34,44 +34,6 @@ describe "screen properties" do
34
34
  HomeScreen.title.should != 'instance method'
35
35
  end
36
36
 
37
- it "should set the UIStatusBar style to :none" do
38
- @screen.class.status_bar :none
39
- @screen.view_will_appear(false)
40
- UIApplication.sharedApplication.isStatusBarHidden.should == true
41
- end
42
-
43
- it "should set the UIStatusBar style to :light" do
44
- @screen.class.status_bar :light
45
- @screen.view_will_appear(false)
46
- UIApplication.sharedApplication.isStatusBarHidden.should == false
47
- UIApplication.sharedApplication.statusBarStyle.should == UIStatusBarStyleLightContent
48
- end
49
-
50
- it "should set the UIStatusBar style to :dark" do
51
- UIApplication.sharedApplication.statusBarStyle = UIStatusBarStyleLightContent
52
- @screen.class.status_bar :dark
53
- @screen.view_will_appear(false)
54
- UIApplication.sharedApplication.isStatusBarHidden.should == false
55
- UIApplication.sharedApplication.statusBarStyle.should == UIStatusBarStyleDefault
56
- end
57
-
58
- it "should default to a global UIStatusBar style" do
59
- NSBundle.mainBundle.mock!(:objectForInfoDictionaryKey) do |key|
60
- "UIStatusBarStyleLightContent"
61
- end
62
- @screen.class.status_bar :default
63
- @screen.view_will_appear(false)
64
- UIApplication.sharedApplication.isStatusBarHidden.should == false
65
- UIApplication.sharedApplication.statusBarStyle.should == UIStatusBarStyleLightContent
66
- end
67
-
68
- it "should default to a hidden UIStatusBar if already hidden" do
69
- UIApplication.sharedApplication.setStatusBarHidden(true, withAnimation: UIStatusBarAnimationNone)
70
- @screen.class.status_bar :default
71
- @screen.view_will_appear(false)
72
- UIApplication.sharedApplication.isStatusBarHidden.should == true
73
- end
74
-
75
37
  it "should set the tab bar item with a system item" do
76
38
  @screen.set_tab_bar_item system_item: :contacts
77
39
  comparison = UITabBarItem.alloc.initWithTabBarSystemItem(UITabBarSystemItemContacts, tag: 0)
@@ -17,46 +17,53 @@ describe "Searchable table spec" do
17
17
  end
18
18
 
19
19
  it "should allow searching for all the 'New' states" do
20
- controller.searchDisplayController(controller, shouldReloadTableForSearchString:"New")
20
+ controller.willPresentSearchController(controller.search_controller)
21
+ controller.searching?.should == true
22
+ controller.search_controller.searchBar.text = "New"
23
+ controller.updateSearchResultsForSearchController(controller.search_controller)
21
24
  controller.tableView(controller.tableView, numberOfRowsInSection:0).should == 4
22
25
  end
23
26
 
24
27
  it "should allow ending searches" do
25
- controller.searchDisplayController(controller, shouldReloadTableForSearchString:"North")
28
+ controller.willPresentSearchController(controller.search_controller)
29
+ controller.search_controller.searchBar.text = "North"
30
+ controller.updateSearchResultsForSearchController(controller.search_controller)
26
31
  controller.tableView(controller.tableView, numberOfRowsInSection:0).should == 2
27
- controller.searchDisplayControllerWillEndSearch(controller)
32
+
33
+ controller.willDismissSearchController(controller.search_controller)
34
+ controller.search_controller.searchBar.text = ""
35
+ controller.updateSearchResultsForSearchController(controller.search_controller) # iOS calls this again
36
+ controller.searching?.should == false
28
37
  controller.tableView(controller.tableView, numberOfRowsInSection:0).should == 50
29
38
  end
30
39
 
31
40
  it "should expose the search_string variable and clear it properly" do
32
- controller.searchDisplayController(controller, shouldReloadTableForSearchString:"North")
41
+ controller.willPresentSearchController(controller.search_controller)
42
+ controller.search_controller.searchBar.text = "North"
43
+ controller.updateSearchResultsForSearchController(controller.search_controller)
33
44
 
34
45
  controller.search_string.should == "north"
35
46
  controller.original_search_string.should == "North"
36
47
 
37
- controller.searchDisplayControllerWillEndSearch(controller)
48
+ controller.willDismissSearchController(controller.search_controller)
49
+ controller.search_controller.searchBar.text = ""
50
+ controller.updateSearchResultsForSearchController(controller.search_controller) # iOS calls this again
38
51
 
39
52
  controller.search_string.should == false
40
53
  controller.original_search_string.should == false
41
54
  end
42
55
 
43
- it "should call the start and stop searching callbacks properly" do
44
- controller.will_begin_search_called.should == nil
45
- controller.will_end_search_called.should == nil
56
+ # FIXME: Can't figure out why this test passes in isolation, but fails when run after the other tests.
57
+ # it "should call the start and stop searching callbacks properly" do
58
+ # controller.will_begin_search_called.should == nil
59
+ # controller.will_end_search_called.should == nil
46
60
 
47
- controller.searchDisplayControllerWillBeginSearch(controller)
48
- controller.searchDisplayController(controller, shouldReloadTableForSearchString:"North")
49
- controller.will_begin_search_called.should == true
61
+ # controller.willPresentSearchController(controller.search_controller)
62
+ # controller.will_begin_search_called.should == true
50
63
 
51
- controller.searchDisplayControllerWillEndSearch(controller)
52
- controller.will_end_search_called.should == true
53
- end
54
-
55
- it "should set the row height of the search display to match the source table row height" do
56
- tableView = UITableView.alloc.init
57
- tableView.mock!(:rowHeight=)
58
- controller.searchDisplayController(controller, didLoadSearchResultsTableView: tableView)
59
- end
64
+ # controller.willDismissSearchController(controller.search_controller)
65
+ # controller.will_end_search_called.should == true
66
+ # end
60
67
 
61
68
  describe "custom search" do
62
69
  before do
@@ -70,8 +77,11 @@ describe "Searchable table spec" do
70
77
  end
71
78
 
72
79
  it "should allow searching for all the 'New' states using a custom search proc" do
73
- @stabby_controller.searchDisplayController(@stabby_controller, shouldReloadTableForSearchString:"New Stabby")
80
+ @stabby_controller.willPresentSearchController(@stabby_controller.search_controller)
81
+ @stabby_controller.search_controller.searchBar.text = "New Stabby"
82
+ @stabby_controller.updateSearchResultsForSearchController(@stabby_controller.search_controller)
74
83
  @stabby_controller.tableView(@stabby_controller.tableView, numberOfRowsInSection:0).should == 4
84
+
75
85
  rows = @stabby_controller.promotion_table_data.search("New stabby")
76
86
  rows.first[:cells].length.should == 4
77
87
  rows.first[:cells].each do |row|
@@ -81,7 +91,9 @@ describe "Searchable table spec" do
81
91
  end
82
92
 
83
93
  it "should allow searching for all the 'New' states using a symbol as a search proc" do
84
- @proc_controller.searchDisplayController(@proc_controller, shouldReloadTableForSearchString:"New Symbol")
94
+ @proc_controller.willPresentSearchController(@proc_controller.search_controller)
95
+ @proc_controller.search_controller.searchBar.text = "New Symbol"
96
+ @proc_controller.updateSearchResultsForSearchController(@proc_controller.search_controller)
85
97
  cell_count = @proc_controller.tableView(@proc_controller.tableView, numberOfRowsInSection:0)
86
98
  cell_count.should == 4
87
99
  rows = @proc_controller.promotion_table_data.search("New Symbol")
@@ -93,12 +105,16 @@ describe "Searchable table spec" do
93
105
  end
94
106
 
95
107
  it "custom searches empty with stabby proc if there is no match" do
96
- @stabby_controller.searchDisplayController(@stabby_controller, shouldReloadTableForSearchString:"Totally Bogus")
108
+ @stabby_controller.willPresentSearchController(@stabby_controller.search_controller)
109
+ @stabby_controller.search_controller.searchBar.text = "Totally Bogus"
110
+ @stabby_controller.updateSearchResultsForSearchController(@stabby_controller.search_controller)
97
111
  @stabby_controller.tableView(@stabby_controller.tableView, numberOfRowsInSection:0).should == 0
98
112
  end
99
113
 
100
114
  it "custom searches empty with symbol for proc if there is no match" do
101
- @proc_controller.searchDisplayController(@proc_controller, shouldReloadTableForSearchString:"Totally Bogus")
115
+ @proc_controller.willPresentSearchController(@proc_controller.search_controller)
116
+ @proc_controller.search_controller.searchBar.text = "Totally Bogus"
117
+ @proc_controller.updateSearchResultsForSearchController(@proc_controller.search_controller)
102
118
  @proc_controller.tableView(@proc_controller.tableView, numberOfRowsInSection:0).should == 0
103
119
  end
104
120
 
@@ -22,20 +22,6 @@ describe "table screen searchable functionality" do
22
22
  end
23
23
  screen = HiddenSearchScreen.new
24
24
  screen.on_load
25
- screen.tableView.contentOffset.should == CGPointMake(0,screen.searchDisplayController.searchBar.frame.size.height)
26
- end
27
-
28
- it "should display a custom message when there are no results" do
29
- table_screen = TableScreenSymbolSearchableNoResults.new
30
- table_screen.on_load
31
-
32
- table_screen.searchDisplayControllerWillBeginSearch(table_screen.searchDisplayController)
33
- table_screen.searchDisplayController(table_screen.searchDisplayController, shouldReloadTableForSearchString:"supercalifragilisticexpialidocious")
34
- table_screen.update_table_data
35
-
36
- results_label = table_screen.searchDisplayController.searchResultsTableView.subviews.detect{|v| v.is_a?(UILabel)}
37
- wait_for_change results_label, 'text' do
38
- results_label.text.should == "Nada!"
39
- end
25
+ screen.tableView.contentOffset.should == CGPointMake(0, screen.tableView.tableHeaderView.frame.size.height)
40
26
  end
41
27
  end
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.6.1
4
+ version: 2.7.0
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: 2016-10-14 00:00:00.000000000 Z
13
+ date: 2018-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: methadone
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '0.1'
77
+ version: '1.0'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '0.1'
84
+ version: '1.0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +138,7 @@ files:
138
138
  - lib/ProMotion/screen/screen.rb
139
139
  - lib/ProMotion/screen/screen_module.rb
140
140
  - lib/ProMotion/screen/screen_navigation.rb
141
+ - lib/ProMotion/screen/status_bar_module.rb
141
142
  - lib/ProMotion/stubs/dummy_image_view.rb
142
143
  - lib/ProMotion/stubs/dummy_view.rb
143
144
  - lib/ProMotion/styling/styling.rb
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
214
  version: '0'
214
215
  requirements: []
215
216
  rubyforge_project:
216
- rubygems_version: 2.5.1
217
+ rubygems_version: 2.6.13
217
218
  signing_key:
218
219
  specification_version: 4
219
220
  summary: ProMotion is a fast way to get started building RubyMotion apps. Instead
@@ -222,36 +223,36 @@ summary: ProMotion is a fast way to get started building RubyMotion apps. Instea
222
223
  more like Ruby and less like Objective-C. With a memorable, concise API and a friendly,
223
224
  helpful community, ProMotion is a great way to get started with iOS development.
224
225
  test_files:
225
- - spec/functional/func_screen_spec.rb
226
- - spec/functional/func_split_screen_spec.rb
227
- - spec/functional/func_table_screen_cell_spec.rb
228
- - spec/functional/func_table_screen_spec.rb
229
- - spec/functional/func_table_screen_updating_spec.rb
230
- - spec/functional/func_web_screen_spec.rb
231
- - spec/helpers/test_helper.rb
232
- - spec/unit/collection_screen_spec.rb
233
- - spec/unit/delegate_spec.rb
234
- - spec/unit/image_title_screen_spec.rb
235
- - spec/unit/image_view_title_screen_spec.rb
236
- - spec/unit/load_view_spec.rb
237
- - spec/unit/main_spec.rb
238
- - spec/unit/screen_helpers_spec.rb
239
- - spec/unit/screen_module_spec.rb
240
- - spec/unit/screen_spec.rb
241
- - spec/unit/searchable_table_spec.rb
242
- - spec/unit/split_screen_in_tab_bar_spec.rb
243
- - spec/unit/split_screen_open_screen_spec.rb
244
- - spec/unit/split_screen_spec.rb
245
226
  - spec/unit/support_spec.rb
246
- - spec/unit/tab_bar_spec.rb
247
- - spec/unit/tab_spec.rb
248
- - spec/unit/tables/table_indexable_spec.rb
227
+ - spec/unit/tables/table_utils_spec.rb
228
+ - spec/unit/tables/table_screen_spec.rb
249
229
  - spec/unit/tables/table_module_spec.rb
250
230
  - spec/unit/tables/table_refreshable_spec.rb
251
- - spec/unit/tables/table_screen_spec.rb
252
231
  - spec/unit/tables/table_searchable_spec.rb
253
- - spec/unit/tables/table_utils_spec.rb
232
+ - spec/unit/tables/table_indexable_spec.rb
254
233
  - spec/unit/tables/table_view_cell_spec.rb
234
+ - spec/unit/tab_bar_spec.rb
235
+ - spec/unit/searchable_table_spec.rb
236
+ - spec/unit/main_spec.rb
237
+ - spec/unit/image_title_screen_spec.rb
238
+ - spec/unit/screen_module_spec.rb
239
+ - spec/unit/screen_helpers_spec.rb
240
+ - spec/unit/split_screen_in_tab_bar_spec.rb
241
+ - spec/unit/screen_spec.rb
242
+ - spec/unit/image_view_title_screen_spec.rb
243
+ - spec/unit/delegate_spec.rb
244
+ - spec/unit/split_screen_spec.rb
245
+ - spec/unit/tab_spec.rb
246
+ - spec/unit/split_screen_open_screen_spec.rb
247
+ - spec/unit/web_spec.rb
255
248
  - spec/unit/view_helper_spec.rb
249
+ - spec/unit/load_view_spec.rb
250
+ - spec/unit/collection_screen_spec.rb
256
251
  - spec/unit/view_title_screen_spec.rb
257
- - spec/unit/web_spec.rb
252
+ - spec/helpers/test_helper.rb
253
+ - spec/functional/func_table_screen_updating_spec.rb
254
+ - spec/functional/func_screen_spec.rb
255
+ - spec/functional/func_table_screen_spec.rb
256
+ - spec/functional/func_split_screen_spec.rb
257
+ - spec/functional/func_table_screen_cell_spec.rb
258
+ - spec/functional/func_web_screen_spec.rb