ProMotion 0.6.5 → 0.7.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 (56) hide show
  1. data/README.md +79 -502
  2. data/Rakefile +30 -0
  3. data/app/app_delegate.rb +3 -1
  4. data/lib/ProMotion.rb +1 -1
  5. data/lib/ProMotion/cocoatouch/TableViewCell.rb +5 -1
  6. data/lib/ProMotion/delegate/delegate.rb +16 -0
  7. data/lib/ProMotion/delegate/delegate_helper.rb +88 -0
  8. data/lib/ProMotion/delegate/delegate_notifications.rb +61 -0
  9. data/lib/ProMotion/helpers/console.rb +3 -3
  10. data/lib/ProMotion/helpers/logger.rb +15 -15
  11. data/lib/ProMotion/helpers/view_helper.rb +7 -5
  12. data/lib/ProMotion/push_notifications/push_notification.rb +51 -0
  13. data/lib/ProMotion/screen_helpers/screen_elements.rb +2 -2
  14. data/lib/ProMotion/screen_helpers/screen_navigation.rb +5 -1
  15. data/lib/ProMotion/screen_helpers/screen_tabs.rb +2 -2
  16. data/lib/ProMotion/screens/_compatibility/formotion_screen.rb +65 -0
  17. data/lib/ProMotion/screens/_screen_module.rb +33 -20
  18. data/lib/ProMotion/screens/_table_screen_module.rb +4 -4
  19. data/lib/ProMotion/{screen_helpers → screens}/_tables/_refreshable_table.rb +2 -2
  20. data/lib/ProMotion/{screen_helpers → screens}/_tables/_searchable_table.rb +27 -34
  21. data/lib/ProMotion/screens/_tables/_sectioned_table.rb +5 -0
  22. data/lib/ProMotion/screens/_tables/_table.rb +149 -0
  23. data/lib/ProMotion/screens/_tables/grouped_table.rb +16 -0
  24. data/lib/ProMotion/screens/_tables/plain_table.rb +17 -0
  25. data/lib/ProMotion/screens/_tables/table_data.rb +148 -0
  26. data/lib/ProMotion/screens/_tables/table_view_cell_module.rb +156 -0
  27. data/lib/ProMotion/screens/table_screen.rb +3 -2
  28. data/lib/ProMotion/version.rb +1 -1
  29. data/spec/functional/func_screen_spec.rb +66 -0
  30. data/spec/functional/func_split_screen_spec.rb +66 -0
  31. data/spec/functional/func_table_screen_spec.rb +52 -0
  32. data/spec/helpers/functional_screen.rb +15 -0
  33. data/spec/helpers/table_screen.rb +32 -8
  34. data/spec/helpers/table_screen_refreshable.rb +1 -1
  35. data/spec/helpers/table_screen_searchable.rb +1 -1
  36. data/spec/helpers/test_delegate.rb +2 -0
  37. data/spec/unit/delegate_spec.rb +38 -0
  38. data/spec/{ios_version_spec.rb → unit/ios_version_spec.rb} +0 -0
  39. data/spec/{logger_spec.rb → unit/logger_spec.rb} +0 -0
  40. data/spec/{main_spec.rb → unit/main_spec.rb} +0 -0
  41. data/spec/{screen_helpers_spec.rb → unit/screen_helpers_spec.rb} +14 -6
  42. data/spec/{screen_module_spec.rb → unit/screen_module_spec.rb} +0 -0
  43. data/spec/{screen_spec.rb → unit/screen_spec.rb} +21 -3
  44. data/spec/{split_screen_in_tab_bar_spec.rb → unit/split_screen_in_tab_bar_spec.rb} +0 -0
  45. data/spec/{split_screen_open_screen_spec.rb → unit/split_screen_open_screen_spec.rb} +0 -0
  46. data/spec/{split_screen_spec.rb → unit/split_screen_spec.rb} +0 -0
  47. data/spec/unit/tables/table_module_spec.rb +108 -0
  48. data/spec/unit/tables/table_screen_spec.rb +92 -0
  49. data/spec/unit/tables/table_view_cell_spec.rb +106 -0
  50. data/spec/{view_helper_spec.rb → unit/view_helper_spec.rb} +0 -0
  51. metadata +50 -29
  52. data/lib/ProMotion/delegate.rb +0 -63
  53. data/lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb +0 -270
  54. data/lib/ProMotion/screen_helpers/_tables/grouped_table.rb +0 -14
  55. data/lib/ProMotion/screen_helpers/_tables/plain_table.rb +0 -15
  56. data/spec/table_screen_spec.rb +0 -72
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ProMotion is a RubyMotion gem that makes iOS development more like Ruby and less like Objective-C.
6
6
 
7
+ Featured on the RubyMotion blog: [http://blog.rubymotion.com/post/50523137515/introducing-promotion-a-full-featured-rubymotion](http://blog.rubymotion.com/post/50523137515/introducing-promotion-a-full-featured-rubymotion)
8
+
7
9
  **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
8
10
 
9
11
  - [ProMotion ](#promotion-)
@@ -12,12 +14,10 @@ ProMotion is a RubyMotion gem that makes iOS development more like Ruby and less
12
14
  - [Screencasts](#screencasts)
13
15
  - [Sample Apps](#sample-apps)
14
16
  - [Apps Built With ProMotion](#apps-built-with-promotion)
15
- - [BigDay! Reminder App](#bigday-reminder-app)
16
- - [TipCounter App](#tipcounter-app)
17
17
  - [Getting Started](#getting-started)
18
18
  - [Setup](#setup)
19
19
  - [What's New?](#whats-new)
20
- - [Version 0.6](#version-06)
20
+ - [Version 0.7](#version-07)
21
21
  - [Usage](#usage)
22
22
  - [Creating a basic screen](#creating-a-basic-screen)
23
23
  - [Loading your first screen](#loading-your-first-screen)
@@ -29,11 +29,7 @@ ProMotion is a RubyMotion gem that makes iOS development more like Ruby and less
29
29
  - [Adding view elements](#adding-view-elements)
30
30
  - [Table Screens](#table-screens)
31
31
  - [Using your own UIViewController](#using-your-own-uiviewcontroller)
32
- - [Reference](#reference)
33
- - [Screen](#screen)
34
- - [TableScreen](#tablescreen)
35
- - [Logger](#logger)
36
- - [Console [deprecated]](#console-deprecated)
32
+ - [API Reference](#api-reference)
37
33
  - [Help](#help)
38
34
  - [Contributing](#contributing)
39
35
  - [Working on Features](#working-on-features)
@@ -57,15 +53,7 @@ source to pull from Github.
57
53
 
58
54
  ## Apps Built With ProMotion
59
55
 
60
- ### BigDay! Reminder App
61
- Check out the free [BigDay! Reminder app](https://itunes.apple.com/us/app/bigday!/id571756685?ls=1&mt=8) on the
62
- App Store to see what's possible. ClearSight Studio built the app for Kijome Software, a small app investment company.
63
-
64
- ### TipCounter App
65
- [TipCounter](http://www.tipcounterapp.com) was built by [Matt Brewer](https://github.com/macfanatic/) for bartenders and servers to easily track their tips. Used ProMotion and the development was a lot of fun!
66
-
67
- ### Winston-Salem Crime Map
68
- Have an interest in crime statistics and locations? Live in Winston-Salem, NC? This hyper-local and [open source](https://github.com/markrickert/WSCrime) RubyMotion app uses a mixture custom UIViewControllers and ProMotion for ease of attribute setting and adding views. Check it out [on the App Store](http://www.mohawkapps.com/winston-salem-crime-map/download/) or [fork it and contribute](https://github.com/markrickert/WSCrime)!
56
+ [View apps built with ProMotion (feel free to submit yours in a pull request!)](https://github.com/clearsightstudio/ProMotion/blob/master/PROMOTION_APPS.md)
69
57
 
70
58
  # Getting Started
71
59
 
@@ -108,7 +96,7 @@ Create a Gemfile and add the following lines:
108
96
 
109
97
  ```ruby
110
98
  source 'https://rubygems.org'
111
- gem "ProMotion", "~> 0.6.2"
99
+ gem "ProMotion", "~> 0.7.0"
112
100
  ```
113
101
 
114
102
  Run `bundle install` in Terminal to install ProMotion.
@@ -116,13 +104,18 @@ Run `bundle install` in Terminal to install ProMotion.
116
104
  Go into your app/app_delegate.rb file and replace everything with the following:
117
105
 
118
106
  ```ruby
119
- class AppDelegate < ProMotion::Delegate
107
+ class AppDelegate < PM::Delegate
120
108
  def on_load(app, options)
121
109
  open HomeScreen.new(nav_bar: true)
122
110
  end
123
111
  end
124
112
  ```
125
113
 
114
+ Note: You can use other keys in `on_load` when you open a new screen:
115
+
116
+ * `modal: ` [`true` | `false`]
117
+ * `toolbar:` [`true` | `false`]
118
+
126
119
  Make sure you remove the `didFinishLoadingWithOptions` method or call `super` in it. Otherwise
127
120
  ProMotion won't get set up and `on_load` won't be called.
128
121
 
@@ -131,7 +124,7 @@ Create a folder in `/app` named `screens`. Create a file in that folder named `h
131
124
  Now drop in this code:
132
125
 
133
126
  ```ruby
134
- class HomeScreen < ProMotion::Screen
127
+ class HomeScreen < PM::Screen
135
128
  title "Home"
136
129
 
137
130
  def will_appear
@@ -150,24 +143,28 @@ Run `rake`. You should now see the simulator open with your home screen and a na
150
143
 
151
144
  # What's New?
152
145
 
153
- ## Version 0.6
154
-
155
- * Will auto-detect if you've loaded [motion-xray](https://github.com/colinta/motion-xray) and enable it.
156
- * Added `open_split_screen` for iPad-supported apps (thanks @rheoli for your contributions to this)
157
- * Added `refreshable` to TableScreens (thanks to @markrickert) for pull-to-refresh support.
158
- * `ProMotion::AppDelegateParent` renamed to `ProMotion::Delegate` (`AppDelegateParent` is an alias)
159
- * `set_attributes` and `add` now apply nested attributes recursively
160
- * `set_attributes` and `add` now accept snake_case instead of camelCase methods (e.g., background_color)
161
- * Added `add_to` method for adding views to any parent view. `remove` works with this normally.
162
- * Deprecated Console.log and replaced with PM::Logger
163
- * Many improvements to how screens and navigation controllers are loaded, tests
146
+ ## Version 0.7
147
+
148
+ * Added [Teacup](https://github.com/rubymotion/teacup) support! Just specify `stylename:` in your `add:` or `set_attributes:` property hash.
149
+ * Added `PM::FormotionScreen` for easy [Formotion](https://github.com/clayallsopp/formotion) compatibility.
150
+ * Massive refactor of `PM::TableScreen` to make it more reliable and testable. Deprecated some old stuff in there.
151
+ * Made a new `TableViewCellModule` that makes it easy to set up custom cells.
152
+ * Refactored the `PM::Delegate` class to make it cleaner and more testable.
153
+ * Added `PM::PushNotification` class (this needs more work and testing) and some nice `PM::Delegate` methods for registering and handling them.
154
+ * `set_nav_bar_left_button` and `set_nav_bar_right_button` are now just `set_nav_bar_button`. See API reference.
155
+ * Speaking of API reference, [we now have one](https://github.com/clearsightstudio/ProMotion/wiki/_pages). We've moved the bulk of the info to the wiki.
156
+ * Added `open_modal` alias for `open @screen, modal: true`
157
+ * Added functional (interactive) tests and lots of unit tests. Run `rake spec:functional` or `rake spec:unit` to run them individually.
158
+ * Renamed `is_modal?` to `modal?`, `has_nav_bar?` to `nav_bar?` in screens.
159
+ * Removed MotionTable references.
160
+ * Lots of small improvements and bugfixes.
164
161
 
165
162
  # Usage
166
163
 
167
164
  ## Creating a basic screen
168
165
 
169
166
  ```ruby
170
- class HomeScreen < ProMotion::Screen
167
+ class HomeScreen < PM::Screen
171
168
  title "Home"
172
169
 
173
170
  def on_load
@@ -189,7 +186,7 @@ end
189
186
 
190
187
  ```ruby
191
188
  # In app/app_delegate.rb
192
- class AppDelegate < ProMotion::Delegate
189
+ class AppDelegate < PM::Delegate
193
190
  def on_load(app, options)
194
191
  open MyHomeScreen.new(nav_bar: true)
195
192
  end
@@ -200,7 +197,7 @@ end
200
197
 
201
198
  ```ruby
202
199
  # In app/app_delegate.rb
203
- class AppDelegate < ProMotion::Delegate
200
+ class AppDelegate < PM::Delegate
204
201
  def on_load(app, options)
205
202
  open_split_screen MenuScreen, DetailScreen
206
203
  end
@@ -244,26 +241,30 @@ end
244
241
 
245
242
  ## Add navigation bar buttons
246
243
 
247
- These two methods add the buttons to the top navigation bar of a screen. The `action:` lets you specify a method to
244
+ This method adds the buttons to the top navigation bar of a screen. The `action:` lets you specify a method to
248
245
  call when that button is tapped, and you can pass in a UIBarButton style using `type:`.
249
246
 
250
247
  ```ruby
251
- set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
252
- set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
248
+ set_nav_bar_button :right, title: "Save", action: :save_something, type: UIBarButtonItemStyleDone
249
+ set_nav_bar_button :left, title: "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
253
250
  ```
254
251
 
255
- If you pass an instance of a `UIImage`, the `UIBarButton` will automatically display with that image instead of text. *Don't forget retina and landscape versions of your image!*
252
+ You can pass in an image with `image:`. *Don't forget retina and landscape versions of your image!*
256
253
 
257
- If you pass `:system` for the title, then you can get a system item. E.g.:
254
+ ```ruby
255
+ set_nav_bar_button :left, image: UIImage.imageNamed("cancel-button"), action: :cancel_something
256
+ ```
257
+
258
+ You can also pass in a `system_icon` instead.
258
259
 
259
260
  ```ruby
260
- set_nav_bar_right_button nil, action: :add_something, system_icon: UIBarButtonSystemItemAdd
261
+ set_nav_bar_button :right, system_icon: UIBarButtonSystemItemAdd, action: :add_something
261
262
  ```
262
263
 
263
264
  Additionally, if you pass an instance of a `UIBarButtonItem`, the `UIBarButton` will automatically display that particular button item.
264
265
 
265
266
  ```ruby
266
- set_nav_bar_left_button self.editButtonItem
267
+ set_nav_bar_button :left, button: UIBarButtonItem.alloc.initWithCustomView(button)
267
268
  ```
268
269
 
269
270
  ## Opening and closing screens
@@ -286,12 +287,16 @@ You can also open a screen as a modal.
286
287
 
287
288
  ```ruby
288
289
  open SettingsScreen.new, modal: true
290
+
291
+ # Or... (this is equivalent)
292
+
293
+ open_modal SettingsScreen.new
289
294
  ```
290
295
 
291
296
  You can pass in arguments to other screens if they have accessors:
292
297
 
293
298
  ```ruby
294
- class HomeScreen < ProMotion::Screen
299
+ class HomeScreen < PM::Screen
295
300
  # ...
296
301
 
297
302
  def settings_button_tapped
@@ -299,7 +304,7 @@ class HomeScreen < ProMotion::Screen
299
304
  end
300
305
  end
301
306
 
302
- class ProfileScreen < ProMotion::Screen
307
+ class ProfileScreen < PM::Screen
303
308
  attr_accessor :user
304
309
 
305
310
  def on_load
@@ -320,7 +325,7 @@ end
320
325
  You can close a screen (modal or in a nav controller) and pass back arguments to the previous screen's "on_return" method:
321
326
 
322
327
  ```ruby
323
- class ItemScreen < ProMotion::Screen
328
+ class ItemScreen < PM::Screen
324
329
  # ...
325
330
  def save_and_close
326
331
  if @model.save
@@ -329,7 +334,7 @@ class ItemScreen < ProMotion::Screen
329
334
  end
330
335
  end
331
336
 
332
- class MainScreen < ProMotion::Screen
337
+ class MainScreen < PM::Screen
333
338
  # ...
334
339
  def on_return(args = {})
335
340
  if args[:model_saved]
@@ -345,7 +350,7 @@ It's common to want to open a screen in the same navigation controller if on iPh
345
350
  in a separate detail view when on iPad. Here's a good way to do that.
346
351
 
347
352
  ```ruby
348
- class MenuScreen < ProMotion::TableScreen
353
+ class MenuScreen < PM::TableScreen
349
354
  # ...
350
355
  def some_action
351
356
  open SomeScreen.new, in_detail: true
@@ -359,13 +364,13 @@ if it's available. If not, open normally. This also works for `in_master:`.
359
364
  ## Adding view elements
360
365
 
361
366
  Any view item (UIView, UIButton, custom UIView subclasses, etc) can be added to the current view with `add`.
362
- `add` accepts a second argument which is a hash of attributes that get applied to the element before it is
367
+ `add` accepts a second argument which is a hash of attributes that get applied to the element right after it is
363
368
  dropped into the view.
364
369
 
365
370
  `add(view, attr={})`
366
371
 
367
372
  ```ruby
368
- @label = add UILabel.new, {
373
+ add UILabel.new, {
369
374
  text: "This is awesome!",
370
375
  font: UIFont.systemFontOfSize(18),
371
376
  resize: [ :left, :right, :top, :bottom, :width, :height ], # autoresizingMask
@@ -374,10 +379,13 @@ dropped into the view.
374
379
  width: 20,
375
380
  height: 20
376
381
  }
382
+ ```
377
383
 
378
- @element = add UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
379
- backgroundColor: UIColor.whiteColor
380
- }
384
+ Using Teacup? Just provide a `stylename`.
385
+
386
+ ```ruby
387
+ @element = UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20))
388
+ add @element, stylename: :my_custom_view
381
389
  ```
382
390
 
383
391
  The `set_attributes` method is identical to add except that it does not add it to the current view.
@@ -387,9 +395,10 @@ use snake_case for Objective-C methods.
387
395
  `set_attributes(view, attr={})`
388
396
 
389
397
  ```ruby
390
- @element = set_attributes UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
398
+ set_attributes UIView.new, {
391
399
  # `background_color` is translated to `backgroundColor` automatically.
392
- background_color: UIColor.whiteColor
400
+ background_color: UIColor.whiteColor,
401
+ frame: CGRectMake(0, 0, 20, 20)
393
402
  }
394
403
  ```
395
404
 
@@ -398,7 +407,8 @@ You can use `add_to` to add a view to any other view, not just the main view.
398
407
  `add_to(parent_view, new_view, attr={})`
399
408
 
400
409
  ```ruby
401
- add_to @some_parent_view, UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
410
+ add_to @some_parent_view, UIView.new, {
411
+ frame: CGRectMake(0, 0, 20, 20),
402
412
  backgroundColor: UIColor.whiteColor
403
413
  }
404
414
  ```
@@ -408,7 +418,7 @@ add_to @some_parent_view, UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)),
408
418
  You can create sectioned table screens easily with TableScreen, SectionedTableScreen, and GroupedTableScreen.
409
419
 
410
420
  ```ruby
411
- class SettingsScreen < ProMotion::GroupedTableScreen
421
+ class SettingsScreen < PM::GroupedTableScreen
412
422
  title "Settings"
413
423
 
414
424
  def on_load
@@ -450,461 +460,27 @@ class SettingsScreen < ProMotion::GroupedTableScreen
450
460
  end
451
461
  ```
452
462
 
453
- You can provide remotely downloaded images for cells by including the CocoaPod "SDWebImage" in
454
- your Rakefile and doing this:
455
-
456
- ```ruby
457
- cells: [
458
- {
459
- title: "Cell with image",
460
- remote_image: { url: "http://placekitten.com/200/300", placeholder: "some-local-image" }
461
- }
462
- ]
463
- ```
464
-
465
463
  ## Using your own UIViewController
466
464
 
467
- Sometimes you want to inherit from a different UIViewController other than that provided by ProMotion,
468
- such as when using [Formotion](https://github.com/clayallsopp/formotion). **RubyMotion doesn't currently
469
- allow us to override built-in methods when including them as a module.** And we really need to override
470
- `viewDidLoad` and others.
471
-
472
- Fortunately, there's a workaround for that.
473
-
474
- ```ruby
475
- class EventsScreen < Formotion::FormController # Can also be < UIViewController
476
- include ProMotion::ScreenModule # Not TableScreenModule since we're using Formotion for that
477
-
478
- # Required functions for ProMotion to work properly
479
-
480
- def viewDidLoad
481
- super
482
- self.view_did_load if self.respond_to?(:view_did_load)
483
- end
484
-
485
- def viewWillAppear(animated)
486
- super
487
- self.view_will_appear(animated) if self.respond_to?("view_will_appear:")
488
- end
489
-
490
- def viewDidAppear(animated)
491
- super
492
- self.view_did_appear(animated) if self.respond_to?("view_did_appear:")
493
- end
494
-
495
- def viewWillDisappear(animated)
496
- self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:")
497
- super
498
- end
499
-
500
- def viewDidDisappear(animated)
501
- self.view_did_disappear(animated) if self.respond_to?("view_did_disappear:")
502
- super
503
- end
504
-
505
- def shouldAutorotateToInterfaceOrientation(orientation)
506
- self.should_rotate(orientation)
507
- end
508
-
509
- def shouldAutorotate
510
- self.should_autorotate
511
- end
465
+ ### [Usage: Formotion or other custom UIViewControllers](https://github.com/clearsightstudio/ProMotion/wiki/Usage:-Formotion-or-other-custom-UIViewControllers)
512
466
 
513
- def willRotateToInterfaceOrientation(orientation, duration:duration)
514
- self.will_rotate(orientation, duration)
515
- end
467
+ # API Reference
516
468
 
517
- def didRotateFromInterfaceOrientation(orientation)
518
- self.on_rotate
519
- end
520
- end
521
- ```
469
+ We've created a fairly comprehensive wiki with code examples, usage examples, and API reference.
522
470
 
523
- # Reference
524
-
525
- ## Screen
526
-
527
- <table>
528
- <tr>
529
- <th>Method</th>
530
- <th>Description</th>
531
- </tr>
532
- <tr>
533
- <td>is_modal?</td>
534
- <td>Returns if the screen was opened in a modal window.</td>
535
- </tr>
536
- <tr>
537
- <td>self</td>
538
- <td>Returns the Screen which is a subclass of UIViewController or UITableViewController</td>
539
- </tr>
540
- <tr>
541
- <td>has_nav_bar?</td>
542
- <td>Returns if the screen is contained in a navigation controller.</td>
543
- </tr>
544
- <tr>
545
- <td>set_tab_bar_item(args)</td>
546
- <td>
547
- Creates the tab that is shown in a tab bar item.<br />
548
- Arguments: <code>{ icon: "imagename", systemIcon: UISystemIconContacts, title: "tabtitle" }</code>
549
- </td>
550
- </tr>
551
- <tr>
552
- <td>on_appear</td>
553
- <td>
554
- Callback for when the screen appears.<br />
555
- </td>
556
- </tr>
557
- <tr>
558
- <td>will_appear</td>
559
- <td>
560
- Callback for before the screen appears.<br />
561
- This is a good place to put your view constructors, but be careful that
562
- you don't add things more than on subsequent screen loads.
563
- </td>
564
- </tr>
565
- <tr>
566
- <td>will_disappear</td>
567
- <td>
568
- Callback for before the screen disappears.<br />
569
- </td>
570
- </tr>
571
- <tr>
572
- <td>will_rotate(orientation, duration)</td>
573
- <td>
574
- Callback for before the screen rotates.<br />
575
- </td>
576
- </tr>
577
- <tr>
578
- <td>on_opened **Deprecated**</td>
579
- <td>
580
- Callback when screen is opened via a tab bar. Please don't use this, as it will be removed in the future<br />
581
- Use will_appear
582
- </td>
583
- </tr>
584
- <tr>
585
- <td>set_nav_bar_left_button(title, args = {})</td>
586
- <td>
587
- Set a left nav bar button.<br />
588
- `title` can be a `String` or a `UIImage`.
589
- </td>
590
- </tr>
591
- <tr>
592
- <td>set_nav_bar_right_button(title, args = {})</td>
593
- <td>
594
- Set a right nav bar button.<br />
595
- `title` can be a `String` or a `UIImage`.<br />
596
- <img src="http://i.imgur.com/whbkc.png" />
597
- </td>
598
- </tr>
599
- <tr>
600
- <td>should_autorotate</td>
601
- <td>
602
- (iOS 6) return true/false if screen should rotate.<br />
603
- Defaults to true.
604
- </td>
605
- </tr>
606
- <tr>
607
- <td>should_rotate(orientation)</td>
608
- <td>
609
- (iOS 5) Return true/false for rotation to orientation.<br />
610
- </td>
611
- </tr>
612
- <tr>
613
- <td>title</td>
614
- <td>
615
- Returns title of current screen.<br />
616
- </td>
617
- </tr>
618
- <tr>
619
- <td>title=(title)</td>
620
- <td>
621
- Sets title of current screen.<br />
622
- You can also set the title like this (not in a method, though):<br />
623
- <pre><code>
624
- class SomeScreen
625
- title "Some screen"
626
-
627
- def on_load
628
- # ...
629
- end
630
- end
631
- </code></pre>
632
- </td>
633
- </tr>
634
- <tr>
635
- <td>add(view, attrs = {})</td>
636
- <td>
637
- Adds the view to the screen after applying the attributes.<br />
638
- (alias: `add_element`, `add_view`)<br />
639
- Example:
640
- <code>
641
- add UIInputView.alloc.initWithFrame(CGRectMake(10, 10, 300, 40)), {
642
- backgroundColor: UIColor.grayColor
643
- }
644
- </code>
645
- </td>
646
- </tr>
647
- <tr>
648
- <td>remove(view)</td>
649
- <td>
650
- Removes the view from the superview and sets it to nil<br />
651
- (alias: `remove_element`, `remove_view`)
652
- </td>
653
- </tr>
654
- <tr>
655
- <td>bounds</td>
656
- <td>
657
- Accessor for self.view.bounds<br />
658
- </td>
659
- </tr>
660
- <tr>
661
- <td>frame</td>
662
- <td>
663
- Accessor for self.view.frame<br />
664
- </td>
665
- </tr>
666
- <tr>
667
- <td>view</td>
668
- <td>
669
- The main view for this screen.<br />
670
- </td>
671
- </tr>
672
- <tr>
673
- <td>ios_version</td>
674
- <td>
675
- Returns the iOS version that is running on the device<br />
676
- </td>
677
- </tr>
678
- <tr>
679
- <td>app_delegate</td>
680
- <td>
681
- Returns the AppDelegate<br />
682
- </td>
683
- </tr>
684
- <tr>
685
- <td>close(args = {})</td>
686
- <td>
687
- Closes the current screen, passes args back to the previous screen's <code>on_return</code> method<br />
688
- </td>
689
- </tr>
690
- <tr>
691
- <td>open_root_screen(screen)</td>
692
- <td>
693
- Closes all other open screens and opens <code>screen</code> as the root view controller.<br />
694
- </td>
695
- </tr>
696
- <tr>
697
- <td>open(screen, args = {})</td>
698
- <td>
699
- Pushes the screen onto the navigation stack or opens in a modal<br />
700
- Argument options:<br />
701
- <code>nav_bar: true|false</code><br />
702
- <code>hide_tab_bar: true|false</code><br />
703
- <code>modal: true|false</code><br />
704
- <code>close_all: true|false</code> (closes all open screens and opens as root...same as open_root_screen)<br />
705
- <code>animated: true:false</code> (currently only affects modals)<br />
706
- <code>in_tab: "Tab name"</code> (if you're in a tab bar)<br />
707
- Any accessors in <code>screen</code> can also be set in this hash.
708
- </td>
709
- </tr>
710
- <tr>
711
- <td>open_split_screen(master, detail)</td>
712
- <td>
713
- *iPad apps only*
714
- Opens a UISplitScreenViewController with the specified screens as the root view controller of the current app<br />
715
- </td>
716
- </tr>
717
- <tr>
718
- <td>open_tab_bar(*screens)</td>
719
- <td>
720
- Opens a UITabBarController with the specified screens as the root view controller of the current app<br />
721
- </td>
722
- </tr>
723
- <tr>
724
- <td>open_tab(tab)</td>
725
- <td>
726
- Opens the tab where the "string" title matches the passed in tab<br />
727
- </td>
728
- </tr>
729
- </table>
730
-
731
- ## TableScreen
732
-
733
- *Has all the methods of Screen*
734
-
735
- <table>
736
- <tr>
737
- <th>Method</th>
738
- <th>Description</th>
739
- </tr>
740
- <tr>
741
- <td>searchable(placeholder: "placeholder text")</td>
742
- <td>Class method to make the current table searchable.</td>
743
- </tr>
744
- <tr>
745
- <td><pre><code>refreshable(
746
- callback: :on_refresh,
747
- pull_message: "Pull to refresh",
748
- refreshing: "Refreshing data…",
749
- updated_format: "Last updated at %s",
750
- updated_time_format: "%l:%M %p"
751
- )</code></pre></td>
752
- <td>Class method to make the current table refreshable.
753
- <p>All parameters are optional. If you do not specify a a callback, it will assume you've implemented an <code>on_refresh</code> method in your tableview.</p>
754
- <pre><code>def on_refresh
755
- # Code to start the refresh
756
- end</code></pre>
757
- <p>And after you're done with your asyncronous process, call <code>end_refreshing</code> to collapse the refresh view and update the last refreshed time and then <code>update_table_data</code>.</p></td>
758
- <img src="https://f.cloud.github.com/assets/139261/472574/af268e52-b735-11e2-8b9b-a9245b421715.gif" />
759
- </tr>
760
- <tr>
761
- <td colspan="2">
762
- <h3>table_data</h3>
763
- Method that is called to get the table's cell data and build the table.<br />
764
- Example format using nearly all available options.<br />
765
- <strong>Note...</strong> if you're getting crazy deep into styling your table cells,
766
- you really should be subclassing them and specifying that new class in <code>:cell_class</code>
767
- and then providing <code>:cell_class_attributes</code> to customize it.<br /><br />
768
- <strong>Performance note...</strong> It's best to build this array in a different method
769
- and store it in something like <code>@table_data</code>. Then your <code>table_data</code>
770
- method just returns that.
771
-
772
- <pre><code>
773
- def table_data
774
- [{
775
- title: "Table cell group 1",
776
- cells: [{
777
- title: "Simple cell",
778
- action: :this_cell_tapped,
779
- arguments: { id: 4 }
780
- }, {
781
- title: "Crazy Full Featured Cell",
782
- subtitle: "This is way too huge..see note",
783
- arguments: { data: [ "lots", "of", "data" ] },
784
- action: :tapped_cell_1,
785
- height: 50, # manually changes the cell's height
786
- cell_style: UITableViewCellStyleSubtitle,
787
- cell_identifier: "Cell",
788
- cell_class: ProMotion::TableViewCell,
789
- masks_to_bounds: true,
790
- background_color: UIColor.whiteColor,
791
- selection_style: UITableViewCellSelectionStyleGray,
792
- cell_class_attributes: {
793
- # any Obj-C attributes to set on the cell
794
- backgroundColor: UIColor.whiteColor
795
- },
796
- accessory: :switch, # currently only :switch is supported
797
- accessory_view: @some_accessory_view,
798
- accessory_type: UITableViewCellAccessoryCheckmark,
799
- accessory_checked: true, # whether it's "checked" or not
800
- image: { image: UIImage.imageNamed("something"), radius: 15 },
801
- remote_image: { # remote image, requires SDWebImage CocoaPod
802
- url: "http://placekitten.com/200/300", placeholder: "some-local-image",
803
- size: 50, radius: 15
804
- },
805
- subviews: [ @some_view, @some_other_view ] # arbitrary views added to the cell
806
- }]
807
- }, {
808
- title: "Table cell group 2",
809
- cells: [{
810
- title: "Log out",
811
- action: :log_out
812
- }]
813
- }]
814
- end
815
- </code></pre>
816
- <img src="http://clearsightstudio.github.com/ProMotion/img/ProMotion/full-featured-table-screen.png" />
817
- </td>
818
- </tr>
819
- <tr>
820
- <td>update_table_data</td>
821
- <td>
822
- Causes the table data to be refreshed, such as when a remote data source has
823
- been downloaded and processed.<br />
824
- </td>
825
- </tr>
826
- </table>
827
-
828
- ## Logger
829
-
830
- *Accessible from ProMotion.logger or PM.logger ... you can also set a new logger by setting `PM.logger = MyLogger.new`*
831
-
832
- <table>
833
- <tr>
834
- <th>Method</th>
835
- <th>Description</th>
836
- </tr>
837
- <tr>
838
- <td>log(label, message_text, color)</td>
839
- <td>
840
- Output a colored console message.<br />
841
- Example: <code>PM.logger.log("TESTING", "This is red!", :red)</code>
842
- </td>
843
- </tr>
844
- <tr>
845
- <td>error(message)</td>
846
- <td>
847
- Output a red colored console error.<br />
848
- Example: <code>PM.logger.error("This is an error")</code>
849
- </td>
850
- </tr>
851
- <tr>
852
- <td>deprecated(message)</td>
853
- <td>
854
- Output a yellow colored console deprecated.<br />
855
- Example: <code>PM.logger.deprecated("This is a deprecation warning.")</code>
856
- </td>
857
- </tr>
858
- <tr>
859
- <td>warn(message)</td>
860
- <td>
861
- Output a yellow colored console warning.<br />
862
- Example: <code>PM.logger.warn("This is a warning")</code>
863
- </td>
864
- </tr>
865
- <tr>
866
- <td>debug(message)</td>
867
- <td>
868
- Output a purple colored console debug message.<br />
869
- Example: <code>PM.logger.debug(@some_var)</code>
870
- </td>
871
- </tr>
872
- <tr>
873
- <td>info(message)</td>
874
- <td>
875
- Output a green colored console info message.<br />
876
- Example: <code>PM.logger.info("This is an info message")</code>
877
- </td>
878
- </tr>
879
- </table>
880
-
881
- ## Console [deprecated]
882
-
883
- <table>
884
- <tr>
885
- <th>Method</th>
886
- <th>Description</th>
887
- </tr>
888
- <tr>
889
- <td>log(log, with_color:color)<br />
890
- [DEPRECATED] -- use Logger
891
- </td>
892
- <td>
893
- Class method to output a colored console message.<br />
894
- Example: <code>ProMotion::Console.log("This is red!", with_color: ProMotion::Console::RED_COLOR)</code>
895
- </td>
896
- </tr>
897
- </table>
471
+ ### [ProMotion API Reference](https://github.com/clearsightstudio/ProMotion/wiki/_pages)
898
472
 
899
473
  # Help
900
474
 
901
- If you need help, feel free to ping me on twitter @jamonholmgren or open a ticket on GitHub.
902
- Opening a ticket is usually the best and we respond to those pretty quickly.
475
+ If you need help, feel free to ping me on twitter [@jamonholmgren](http://twitter.com/jamonholmgren)
476
+ or open an issue on GitHub. Opening an issue is usually the best and we respond to those pretty quickly.
903
477
 
904
478
  # Contributing
905
479
 
906
480
  I'm very open to ideas. Tweet me with your ideas or open a ticket (I don't mind!)
907
- and let's discuss.
481
+ and let's discuss. **It's a good idea to run your idea by the committers before creating
482
+ a pull request.** We'll always consider your ideas carefully but not all ideas will be
483
+ incorporated.
908
484
 
909
485
  ## Working on Features
910
486
 
@@ -919,15 +495,16 @@ and let's discuss.
919
495
  1. Fork the project
920
496
  2. Create a feature branch
921
497
  3. Code
922
- 4. Update or create new specs
923
- 5. Make sure tests are passing by running `rake spec`
498
+ 4. Update or create new specs ** NOTE: your PR is far more likely to be merged if you include comprehensive tests! **
499
+ 5. Make sure tests are passing by running `rake spec` *(you can run functional and unit specs separately with `rake spec:functional` and `rake spec:unit`)*
924
500
  6. Submit pull request
925
- 7. Fame, adoration, kudos everywhere
501
+ 7. Make a million little nitpicky changes that @jamonholmgren wants
502
+ 8. Merged, then fame, adoration, kudos everywhere
926
503
 
927
504
  ## Primary Contributors
928
505
 
929
506
  * Jamon Holmgren: [@jamonholmgren](https://twitter.com/jamonholmgren)
930
507
  * Silas Matson: [@silasjmatson](https://twitter.com/silasjmatson)
931
508
  * Matt Brewer: [@macfanatic](https://twitter.com/macfanatic)
932
-
509
+ * [Many others](https://github.com/clearsightstudio/ProMotion/graphs/contributors)
933
510