ProMotion 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,7 +39,7 @@ ProMotion is a RubyMotion gem that makes iOS development more like Ruby and less
39
39
  - [Working on Features](#working-on-features)
40
40
  - [Submitting a Pull Request](#submitting-a-pull-request)
41
41
  - [Primary Contributors](#primary-contributors)
42
-
42
+
43
43
  # Tutorials
44
44
 
45
45
  http://www.clearsightstudio.com/insights/ruby-motion-promotion-tutorial
@@ -50,20 +50,25 @@ http://www.clearsightstudio.com/insights/tutorial-make-youtube-video-app-rubymot
50
50
 
51
51
  ## Sample Apps
52
52
 
53
- [https://github.com/jamonholmgren/promotion-tutorial](https://github.com/jamonholmgren/promotion-tutorial)
53
+ This is pretty bare-bones, but we'll be building it out as we go along.
54
+
55
+ [https://github.com/jamonholmgren/promotion-demo](https://github.com/jamonholmgren/promotion-demo)
54
56
 
55
57
  ## Apps Built With ProMotion
56
58
 
57
59
  ### BigDay! Reminder App
58
- Check out the free [BigDay! Reminder app](https://itunes.apple.com/us/app/bigday!/id571756685?ls=1&mt=8) on the
60
+ Check out the free [BigDay! Reminder app](https://itunes.apple.com/us/app/bigday!/id571756685?ls=1&mt=8) on the
59
61
  App Store to see what's possible. ClearSight Studio built the app for Kijome Software, a small app investment company.
60
62
 
61
63
  ### TipCounter App
62
64
  [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!
63
65
 
66
+ ### Winston-Salem Crime Map
67
+ 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)!
68
+
64
69
  # Getting Started
65
70
 
66
- ProMotion is designed to be as intuitive and Ruby-like as possible. For example, here is a
71
+ ProMotion is designed to be as intuitive and Ruby-like as possible. For example, here is a
67
72
  typical app folder structure:
68
73
 
69
74
  app/
@@ -108,7 +113,7 @@ gem "ProMotion", "~> 0.6.0"
108
113
 
109
114
  Run `bundle install` in Terminal to install ProMotion.
110
115
 
111
- Go into your app/app_delegate.rb file and add the following:
116
+ Go into your app/app_delegate.rb file and replace everything with the following:
112
117
 
113
118
  ```ruby
114
119
  class AppDelegate < ProMotion::Delegate
@@ -118,6 +123,9 @@ class AppDelegate < ProMotion::Delegate
118
123
  end
119
124
  ```
120
125
 
126
+ Make sure you remove the `didFinishLoadingWithOptions` method or call `super` in it. Otherwise
127
+ ProMotion won't get set up and `on_load` won't be called.
128
+
121
129
  Create a folder in `/app` named `screens`. Create a file in that folder named `home_screen.rb`.
122
130
 
123
131
  Now drop in this code:
@@ -125,7 +133,7 @@ Now drop in this code:
125
133
  ```ruby
126
134
  class HomeScreen < ProMotion::Screen
127
135
  title "Home"
128
-
136
+
129
137
  def will_appear
130
138
  set_attributes self.view, {
131
139
  backgroundColor: UIColor.whiteColor
@@ -165,12 +173,12 @@ class HomeScreen < ProMotion::Screen
165
173
  def on_load
166
174
  # Load data
167
175
  end
168
-
176
+
169
177
  def will_appear
170
178
  # Set up the elements in your view with add
171
179
  @label ||= add UILabel.alloc.initWithFrame(CGRectMake(5, 5, 20, 20))
172
180
  end
173
-
181
+
174
182
  def on_appear
175
183
  # Everything's loaded and visible
176
184
  end
@@ -209,18 +217,18 @@ def on_load(app, options)
209
217
  @home = MyHomeScreen.new(nav_bar: true)
210
218
  @settings = SettingsScreen.new
211
219
  @contact = ContactScreen.new(nav_bar: true)
212
-
220
+
213
221
  open_tab_bar @home, @settings, @contact
214
222
  end
215
223
  ```
216
224
 
217
- For each screen that belongs to the tab bar, you need to set the tab name and icon in the files.
225
+ For each screen that belongs to the tab bar, you need to set the tab name and icon in the files.
218
226
  In this example, we would need add the following to the three files (my_home_screen.rb, settings_screen.rb, contact_screen.rb):
219
227
 
220
228
  ```ruby
221
229
  def on_load
222
230
  set_tab_bar_item title: "Tab Name Goes Here", icon: "icons/tab_icon.png" # in resources/icons folder
223
-
231
+
224
232
  # or...
225
233
  set_tab_bar_item system_icon: UITabBarSystemItemContacts
226
234
  end
@@ -244,6 +252,14 @@ set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemS
244
252
  set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
245
253
  ```
246
254
 
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!*
256
+
257
+ If you pass `:system` for the title, then you can get a system item. E.g.:
258
+
259
+ ```ruby
260
+ set_nav_bar_right_button nil, action: :add_something, system_icon: UIBarButtonSystemItemAdd
261
+ ```
262
+
247
263
  ## Opening and closing screens
248
264
 
249
265
  If the user taps something and you want to open a new screen, it's easy. Just use `open` and pass in the screen class
@@ -284,7 +300,6 @@ class ProfileScreen < ProMotion::Screen
284
300
  self.user # => some_user instance
285
301
  end
286
302
  end
287
-
288
303
  ```
289
304
 
290
305
  Closing a screen is as easy as can be.
@@ -394,7 +409,7 @@ class SettingsScreen < ProMotion::GroupedTableScreen
394
409
  add_right_nav_button(label: "Save", action: :save)
395
410
  set_tab_bar_item(title: "Settings", icon: "settings.png")
396
411
  end
397
-
412
+
398
413
  # table_data is automatically called. Use this format in the return value.
399
414
  # It's an array of cell groups, each cell group consisting of a title and an array of cells.
400
415
  def table_data
@@ -418,10 +433,10 @@ class SettingsScreen < ProMotion::GroupedTableScreen
418
433
  def table_data_index
419
434
  # Ruby magic to make an alphabetical array of letters.
420
435
  # Try this in Objective-C and tell me you want to go back.
421
- return ("A".."Z").to_a
436
+ return ("A".."Z").to_a
422
437
  end
423
-
424
- # Your table cells, when tapped, will execute the corresponding actions
438
+
439
+ # Your table cells, when tapped, will execute the corresponding actions
425
440
  # and pass in the specified arguments.
426
441
  def edit_profile(args={})
427
442
  puts args[:id] # => 3
@@ -429,7 +444,7 @@ class SettingsScreen < ProMotion::GroupedTableScreen
429
444
  end
430
445
  ```
431
446
 
432
- You can provide remotely downloaded images for cells by including the CocoaPod "SDWebImage" in
447
+ You can provide remotely downloaded images for cells by including the CocoaPod "SDWebImage" in
433
448
  your Rakefile and doing this:
434
449
 
435
450
  ```ruby
@@ -444,9 +459,9 @@ your Rakefile and doing this:
444
459
  ## Using your own UIViewController
445
460
 
446
461
  Sometimes you want to inherit from a different UIViewController other than that provided by ProMotion,
447
- such as when using [Formotion](https://github.com/clayallsopp/formotion). **RubyMotion doesn't currently
448
- allow us to override built-in methods when including them as a module.** And we really need to override
449
- `viewDidLoad` and others.
462
+ such as when using [Formotion](https://github.com/clayallsopp/formotion). **RubyMotion doesn't currently
463
+ allow us to override built-in methods when including them as a module.** And we really need to override
464
+ `viewDidLoad` and others.
450
465
 
451
466
  Fortunately, there's a workaround for that.
452
467
 
@@ -470,15 +485,15 @@ class EventsScreen < Formotion::FormController # Can also be < UIViewController
470
485
  super
471
486
  self.view_did_appear(animated) if self.respond_to?("view_did_appear:")
472
487
  end
473
-
488
+
474
489
  def viewWillDisappear(animated)
475
490
  self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:")
476
491
  super
477
492
  end
478
-
493
+
479
494
  def viewDidDisappear(animated)
480
495
  self.view_did_disappear(animated) if self.respond_to?("view_did_disappear:")
481
- super
496
+ super
482
497
  end
483
498
 
484
499
  def shouldAutorotateToInterfaceOrientation(orientation)
@@ -492,7 +507,7 @@ class EventsScreen < Formotion::FormController # Can also be < UIViewController
492
507
  def willRotateToInterfaceOrientation(orientation, duration:duration)
493
508
  self.will_rotate(orientation, duration)
494
509
  end
495
-
510
+
496
511
  def didRotateFromInterfaceOrientation(orientation)
497
512
  self.on_rotate
498
513
  end
@@ -526,13 +541,13 @@ end
526
541
  Creates the tab that is shown in a tab bar item.<br />
527
542
  Arguments: <code>{ icon: "imagename", systemIcon: UISystemIconContacts, title: "tabtitle" }</code>
528
543
  </td>
529
- </tr>
544
+ </tr>
530
545
  <tr>
531
546
  <td>on_appear</td>
532
547
  <td>
533
548
  Callback for when the screen appears.<br />
534
549
  </td>
535
- </tr>
550
+ </tr>
536
551
  <tr>
537
552
  <td>will_appear</td>
538
553
  <td>
@@ -564,12 +579,14 @@ end
564
579
  <td>set_nav_bar_left_button(title, args = {})</td>
565
580
  <td>
566
581
  Set a left nav bar button.<br />
582
+ `title` can be a `String` or a `UIImage`.
567
583
  </td>
568
584
  </tr>
569
585
  <tr>
570
586
  <td>set_nav_bar_right_button(title, args = {})</td>
571
587
  <td>
572
588
  Set a right nav bar button.<br />
589
+ `title` can be a `String` or a `UIImage`.<br />
573
590
  <img src="http://i.imgur.com/whbkc.png" />
574
591
  </td>
575
592
  </tr>
@@ -600,7 +617,7 @@ end
600
617
  <pre><code>
601
618
  class SomeScreen
602
619
  title "Some screen"
603
-
620
+
604
621
  def on_load
605
622
  # ...
606
623
  end
@@ -721,9 +738,9 @@ end
721
738
  <tr>
722
739
  <td><pre><code>refreshable(
723
740
  callback: :on_refresh,
724
- pull_message: "Pull to refresh",
725
- refreshing: "Refreshing data…",
726
- updated_format: "Last updated at %s",
741
+ pull_message: "Pull to refresh",
742
+ refreshing: "Refreshing data…",
743
+ updated_format: "Last updated at %s",
727
744
  updated_time_format: "%l:%M %p"
728
745
  )</code></pre></td>
729
746
  <td>Class method to make the current table refreshable.
@@ -745,7 +762,7 @@ end</code></pre>
745
762
  <strong>Performance note...</strong> It's best to build this array in a different method
746
763
  and store it in something like <code>@table_data</code>. Then your <code>table_data</code>
747
764
  method just returns that.
748
-
765
+
749
766
  <pre><code>
750
767
  def table_data
751
768
  [{
@@ -760,7 +777,7 @@ def table_data
760
777
  arguments: { data: [ "lots", "of", "data" ] },
761
778
  action: :tapped_cell_1,
762
779
  height: 50, # manually changes the cell's height
763
- cell_style: UITableViewCellStyleSubtitle,
780
+ cell_style: UITableViewCellStyleSubtitle,
764
781
  cell_identifier: "Cell",
765
782
  cell_class: ProMotion::TableViewCell,
766
783
  masks_to_bounds: true,
@@ -776,7 +793,7 @@ def table_data
776
793
  accessory_checked: true, # whether it's "checked" or not
777
794
  image: { image: UIImage.imageNamed("something"), radius: 15 },
778
795
  remote_image: { # remote image, requires SDWebImage CocoaPod
779
- url: "http://placekitten.com/200/300", placeholder: "some-local-image",
796
+ url: "http://placekitten.com/200/300", placeholder: "some-local-image",
780
797
  size: 50, radius: 15
781
798
  },
782
799
  subviews: [ @some_view, @some_other_view ] # arbitrary views added to the cell
@@ -880,7 +897,7 @@ Opening a ticket is usually the best and we respond to those pretty quickly.
880
897
 
881
898
  # Contributing
882
899
 
883
- I'm very open to ideas. Tweet me with your ideas or open a ticket (I don't mind!)
900
+ I'm very open to ideas. Tweet me with your ideas or open a ticket (I don't mind!)
884
901
  and let's discuss.
885
902
 
886
903
  ## Working on Features
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  $:.unshift("/Library/RubyMotion/lib")
2
- require 'motion/project'
2
+ require 'motion/project/template/ios'
3
3
  require 'bundler/gem_tasks'
4
4
  Bundler.setup
5
5
  Bundler.require
@@ -10,10 +10,13 @@ module ProMotion
10
10
  screen.send(:on_load) if screen.respond_to?(:on_load)
11
11
  animated = args[:animated] || true
12
12
 
13
- return self.split_screen.detail_screen = screen if args[:in_detail] && self.split_screen
14
- return self.split_screen.master_screen = screen if args[:in_master] && self.split_screen
13
+ if args[:in_detail] && self.split_screen
14
+ self.split_screen.detail_screen = screen
15
15
 
16
- if args[:close_all]
16
+ elsif args[:in_master] && self.split_screen
17
+ self.split_screen.master_screen = screen
18
+
19
+ elsif args[:close_all]
17
20
  open_root_screen screen
18
21
 
19
22
  elsif args[:modal]
@@ -25,11 +28,8 @@ module ProMotion
25
28
  elsif self.navigation_controller
26
29
  push_view_controller screen
27
30
 
28
- elsif screen.respond_to?(:main_controller)
29
- open_view_controller screen.main_controller
30
-
31
31
  else
32
- open_view_controller screen
32
+ open_root_screen screen
33
33
 
34
34
  end
35
35
 
@@ -72,8 +72,9 @@ module ProMotion
72
72
  end
73
73
  end
74
74
 
75
- def open_view_controller(vc)
76
- app_delegate.load_root_view vc
75
+ def open_view_controller(screen)
76
+ PM.logger.deprecated "Use `open_root_screen` instead of the more ambiguous `open_view_controller`."
77
+ open_root_screen screen
77
78
  end
78
79
 
79
80
  def push_view_controller(vc, nav_controller=nil)
@@ -129,6 +130,8 @@ module ProMotion
129
130
  screen.navigation_controller = vc if screen.respond_to?("navigation_controller=")
130
131
  push_view_controller(screen, vc)
131
132
  else
133
+ # TODO: This should probably open the vc, shouldn't it?
134
+ # This isn't well tested and needs to work better.
132
135
  self.tab_bar.selectedIndex = vc.tabBarItem.tag
133
136
  end
134
137
 
@@ -6,13 +6,16 @@ module ProMotion
6
6
  include ProMotion::ScreenTabs
7
7
  include ProMotion::SplitScreen if NSBundle.mainBundle.infoDictionary["UIDeviceFamily"].include?("2")
8
8
 
9
- attr_accessor :parent_screen, :first_screen, :tab_bar_item, :tab_bar, :modal, :split_screen
9
+ attr_accessor :parent_screen, :first_screen, :tab_bar_item, :tab_bar, :modal, :split_screen, :title
10
10
 
11
11
  def on_create(args = {})
12
12
  unless self.is_a?(UIViewController)
13
13
  raise StandardError.new("ERROR: Screens must extend UIViewController or a subclass of UIViewController.")
14
14
  end
15
15
 
16
+
17
+ self.title = self.class.send(:get_title)
18
+
16
19
  args.each do |k, v|
17
20
  self.send("#{k}=", v) if self.respond_to?("#{k}=")
18
21
  end
@@ -70,13 +73,24 @@ module ProMotion
70
73
  args[:title] = title
71
74
  set_nav_bar_button :left, args
72
75
  end
73
-
76
+
77
+ # If you call set_nav_bar_button with a nil title and system_icon: UIBarButtonSystemItemAdd (or any other
78
+ # system icon), the button is initialized with a barButtonSystemItem instead of a title.
74
79
  def set_nav_bar_button(side, args={})
75
80
  args[:style] ||= UIBarButtonItemStyleBordered
76
81
  args[:target] ||= self
77
82
  args[:action] ||= nil
78
83
 
79
- button = UIBarButtonItem.alloc.initWithTitle(args[:title], style: args[:style], target: args[:target], action: args[:action])
84
+ button = case args[:title]
85
+ when String
86
+ UIBarButtonItem.alloc.initWithTitle(args[:title], style: args[:style], target: args[:target], action: args[:action])
87
+ when UIImage
88
+ UIBarButtonItem.alloc.initWithImage(args[:title], style: args[:style], target: args[:target], action: args[:action])
89
+ when Symbol, NilClass
90
+ UIBarButtonItem.alloc.initWithBarButtonSystemItem(args[:system_icon], target: args[:target], action: args[:action]) if args[:system_icon]
91
+ else
92
+ PM.logger.error("Please supply a title string, a UIImage or :system.")
93
+ end
80
94
 
81
95
  self.navigationItem.leftBarButtonItem = button if side == :left
82
96
  self.navigationItem.rightBarButtonItem = button if side == :right
@@ -124,15 +138,6 @@ module ProMotion
124
138
  end
125
139
  def on_disappear; end
126
140
 
127
- def title
128
- self.class.send(:get_title)
129
- end
130
-
131
- def title=(new_title)
132
- self.class.title = new_title
133
- super
134
- end
135
-
136
141
  def main_controller
137
142
  self.navigation_controller || self
138
143
  end
@@ -1,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "0.6.0" unless defined?(ProMotion::VERSION)
2
+ VERSION = "0.6.1" unless defined?(ProMotion::VERSION)
3
3
  end
Binary file
@@ -1,2 +1,3 @@
1
1
  class BasicScreen < ProMotion::Screen
2
+ title "Basic"
2
3
  end
@@ -0,0 +1,3 @@
1
+ class DetailScreen < PM::Screen
2
+ title "Detail"
3
+ end
@@ -4,10 +4,10 @@ class HomeScreen < ProMotion::Screen
4
4
 
5
5
  def on_load
6
6
  set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
7
- set_nav_bar_left_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
7
+ set_nav_bar_left_button UIImage.imageNamed("list.png"), action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
8
8
  end
9
9
 
10
10
  def on_return(args={})
11
11
  end
12
12
 
13
- end
13
+ end
@@ -0,0 +1,3 @@
1
+ class MasterScreen < PM::Screen
2
+ title "Master"
3
+ end
@@ -0,0 +1,55 @@
1
+ class ScreenModuleViewController < UIViewController
2
+ include PM::ScreenModule
3
+ title 'Test Title'
4
+
5
+ # Get rid of such hackiness when RubyMotion bug is fixed...
6
+
7
+ def self.new(args = {})
8
+ s = self.alloc.initWithNibName(nil, bundle:nil)
9
+ s.on_create(args) if s.respond_to?(:on_create)
10
+ s
11
+ end
12
+
13
+ def viewDidLoad
14
+ super
15
+ self.view_did_load if self.respond_to?(:view_did_load)
16
+ end
17
+
18
+ def viewWillAppear(animated)
19
+ super
20
+ self.view_will_appear(animated) if self.respond_to?("view_will_appear:")
21
+ end
22
+
23
+ def viewDidAppear(animated)
24
+ super
25
+ self.view_did_appear(animated) if self.respond_to?("view_did_appear:")
26
+ end
27
+
28
+ def viewWillDisappear(animated)
29
+ self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:")
30
+ super
31
+ end
32
+
33
+ def viewDidDisappear(animated)
34
+ if self.respond_to?("view_did_disappear:")
35
+ self.view_did_disappear(animated)
36
+ end
37
+ super
38
+ end
39
+
40
+ def shouldAutorotateToInterfaceOrientation(orientation)
41
+ self.should_rotate(orientation)
42
+ end
43
+
44
+ def shouldAutorotate
45
+ self.should_autorotate
46
+ end
47
+
48
+ def willRotateToInterfaceOrientation(orientation, duration:duration)
49
+ self.will_rotate(orientation, duration)
50
+ end
51
+
52
+ def didRotateFromInterfaceOrientation(orientation)
53
+ self.on_rotate
54
+ end
55
+ end
@@ -1,9 +1,4 @@
1
1
  class TestDelegate < ProMotion::Delegate
2
2
  def on_load(app, options)
3
3
  end
4
-
5
- # Hack to make RM 2.0 work.
6
- # Ref: http://hipbyte.myjetbrains.com/youtrack/issue/RM-136
7
- def dealloc
8
- end
9
4
  end
@@ -35,25 +35,39 @@ describe "screen helpers" do
35
35
  @screen.add_to @subview, sub_subview, { backgroundColor: UIColor.redColor }
36
36
  @subview.subviews.last.backgroundColor.should == UIColor.redColor
37
37
  end
38
-
38
+
39
39
  end
40
40
 
41
41
  describe "nav bar buttons" do
42
-
42
+
43
43
  before do
44
44
  @screen = HomeScreen.new(nav_bar: true)
45
45
  end
46
-
46
+
47
47
  it "should add a left nav bar button" do
48
48
  @screen.set_nav_bar_left_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
49
49
  @screen.navigationItem.leftBarButtonItem.class.should == UIBarButtonItem
50
50
  end
51
-
51
+
52
52
  it "should add a right nav bar button" do
53
53
  @screen.set_nav_bar_right_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
54
54
  @screen.navigationItem.rightBarButtonItem.class.should == UIBarButtonItem
55
55
  end
56
-
56
+
57
+ it "should add an image right nav bar button" do
58
+ image = UIImage.imageNamed("list.png")
59
+ @screen.set_nav_bar_right_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
60
+ @screen.navigationItem.rightBarButtonItem.image.class.should == UIImage
61
+ @screen.navigationItem.rightBarButtonItem.image.should == image
62
+ end
63
+
64
+ it "should add an image left nav bar button" do
65
+ image = UIImage.imageNamed("list.png")
66
+ @screen.set_nav_bar_left_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
67
+ @screen.navigationItem.leftBarButtonItem.image.class.should == UIImage
68
+ @screen.navigationItem.leftBarButtonItem.image.should == image
69
+ end
70
+
57
71
  end
58
72
 
59
73
  describe "screen navigation" do
@@ -143,20 +157,10 @@ describe "screen helpers" do
143
157
  @screen.open_screen BasicScreen
144
158
  end
145
159
 
146
- it "should open the main controller if no options are provided" do
147
- parent_screen = HomeScreen.new
148
- nav_controller = ProMotion::NavigationController.new
149
- new_screen = BasicScreen.new
150
- new_screen.stub! :main_controller, return: nav_controller
151
-
152
- parent_screen.mock!(:open_view_controller) { |vc| vc.should.be == nav_controller }
153
- parent_screen.open_screen new_screen
154
- end
155
-
156
- it "should open the provided view controller if no other conditions are met" do
160
+ it "should open the provided view controller as root view if no other conditions are met" do
157
161
  parent_screen = HomeScreen.new
158
162
  new_screen = BasicScreen.new
159
- parent_screen.mock!(:open_view_controller) { |vc| vc.should.be == new_screen }
163
+ parent_screen.mock!(:open_root_screen) { |vc| vc.should.be == new_screen }
160
164
  parent_screen.open_screen new_screen
161
165
  end
162
166
 
@@ -0,0 +1,13 @@
1
+ describe "PM::ScreenModule" do
2
+
3
+ before { @subject = ScreenModuleViewController.new }
4
+
5
+ it 'should have PM::ScreenModule in ancestors' do
6
+ @subject.class.ancestors.include?(PM::ScreenModule).should == true
7
+ end
8
+
9
+ it 'should have a title from class method #title' do
10
+ @subject.title.should == 'Test Title'
11
+ end
12
+
13
+ end
@@ -12,9 +12,18 @@ describe "screen properties" do
12
12
  HomeScreen.get_title.should == 'Home'
13
13
  end
14
14
 
15
- it "should let the instance reset the title" do
15
+ it "should set default title on new instances" do
16
+ @screen.title.should == "Home"
17
+ end
18
+
19
+ it "should let the instance set its title" do
20
+ @screen.title = "instance method"
21
+ @screen.title.should == 'instance method'
22
+ end
23
+
24
+ it "should not let the instance reset the default title" do
16
25
  @screen.title = "instance method"
17
- HomeScreen.get_title.should == 'instance method'
26
+ HomeScreen.get_title.should != 'instance method'
18
27
  end
19
28
 
20
29
  it "should store debug mode" do
@@ -73,10 +82,10 @@ describe "screen properties" do
73
82
  end
74
83
 
75
84
  it "-willRotateToInterfaceOrientation" do
76
- @screen.mock! :will_rotate do |orientation, duration|
85
+ @screen.mock! :will_rotate do |orientation, duration|
77
86
  orientation.should == UIInterfaceOrientationPortrait
78
87
  duration.should == 0.5
79
- end
88
+ end
80
89
  @screen.willRotateToInterfaceOrientation(UIInterfaceOrientationPortrait, duration: 0.5)
81
90
  end
82
91
 
@@ -108,4 +117,54 @@ describe "screen properties" do
108
117
 
109
118
  end
110
119
 
120
+ describe "bar button behavior" do
121
+ describe "system bar buttons" do
122
+ before do
123
+ @screen.set_nav_bar_right_button nil, action: :add_something, system_icon: UIBarButtonSystemItemAdd
124
+ end
125
+
126
+ it "has a right bar button item of the correct type" do
127
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
128
+ end
129
+
130
+ it "is an add button" do
131
+ @screen.navigationItem.rightBarButtonItem.action.should == :add_something
132
+ end
133
+ end
134
+
135
+ describe 'titled bar buttons' do
136
+ before do
137
+ @screen.set_nav_bar_right_button "Save", action: :save_something, style: UIBarButtonItemStyleDone
138
+ end
139
+
140
+ it "has a right bar button item of the correct type" do
141
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
142
+ end
143
+
144
+ it "has a right bar button item of the correct style" do
145
+ @screen.navigationItem.rightBarButtonItem.style.should == UIBarButtonItemStyleDone
146
+ end
147
+
148
+ it "is titled correctly" do
149
+ @screen.navigationItem.rightBarButtonItem.title.should == 'Save'
150
+ end
151
+ end
152
+
153
+ describe 'image bar buttons' do
154
+ before do
155
+ @image = UIImage.alloc.init
156
+ @screen.set_nav_bar_right_button @image, action: :save_something, style: UIBarButtonItemStyleDone
157
+ end
158
+
159
+ it "has a right bar button item of the correct type" do
160
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
161
+ end
162
+
163
+ it "is has the right image" do
164
+ @screen.navigationItem.rightBarButtonItem.title.should == nil
165
+ end
166
+ end
167
+
168
+ end
169
+
111
170
  end
@@ -10,6 +10,10 @@ describe "split screen in tab bar functionality" do
10
10
  @tab = @app.open_tab_bar @split_screen, HomeScreen, BasicScreen
11
11
  end
12
12
 
13
+ after do
14
+ @split_screen.delegate = nil # dereference to avoid memory issue
15
+ end
16
+
13
17
  it "should create a UISplitViewController" do
14
18
  @split_screen.is_a?(UISplitViewController).should == true
15
19
  end
@@ -46,4 +50,4 @@ describe "split screen in tab bar functionality" do
46
50
  @tab.viewControllers.first.should == @split_screen
47
51
  end
48
52
 
49
- end
53
+ end
@@ -10,6 +10,10 @@ describe "split screen `open` functionality" do
10
10
  @split_screen = @app.open_split_screen @master_screen, @detail_screen_1
11
11
  end
12
12
 
13
+ after do
14
+ @split_screen.delegate = nil # dereference to avoid memory issue
15
+ end
16
+
13
17
  it "should open a new screen in the detail view" do
14
18
  @master_screen.open @detail_screen_2, in_detail: true
15
19
  @split_screen.detail_screen.should == @detail_screen_2
@@ -43,4 +47,4 @@ describe "split screen `open` functionality" do
43
47
  home.navigation_controller.topViewController.should == child
44
48
  end
45
49
 
46
- end
50
+ end
@@ -3,12 +3,16 @@ describe "split screen functionality" do
3
3
  before do
4
4
  @app = TestDelegate.new
5
5
 
6
- @master_screen = HomeScreen.new nav_bar: true
7
- @detail_screen = BasicScreen.new # no nav_bar on this one
6
+ @master_screen = MasterScreen.new nav_bar: true
7
+ @detail_screen = DetailScreen.new # no nav_bar on this one
8
8
 
9
9
  @split_screen = @app.open_split_screen @master_screen, @detail_screen
10
10
  end
11
11
 
12
+ after do
13
+ @split_screen.delegate = nil # dereference to avoid memory issue
14
+ end
15
+
12
16
  it "should have created a split screen" do
13
17
  @split_screen.should != nil
14
18
  @split_screen.is_a?(UISplitViewController).should == true
@@ -22,14 +26,42 @@ describe "split screen functionality" do
22
26
  @app.window.rootViewController.should == @split_screen
23
27
  end
24
28
 
25
- it "should set the first viewController to HomeScreen" do
29
+ it "should set the first viewController to MasterScreen" do
26
30
  @split_screen.master_screen.should == @master_screen
27
31
  @split_screen.viewControllers.first.should == @master_screen.main_controller
28
32
  end
29
33
 
30
- it "should set the second viewController to BasicScreen" do
34
+ it "should set the second viewController to DetailScreen" do
31
35
  @split_screen.detail_screen.should == @detail_screen
32
36
  @split_screen.viewControllers.last.should == @detail_screen.main_controller
33
37
  end
34
38
 
35
- end
39
+ it "should set the title on both screens" do
40
+ @master_screen.class.send(:get_title).should == "Master"
41
+ @master_screen.title.should == "Master"
42
+ @detail_screen.class.send(:get_title).should == "Detail"
43
+ @detail_screen.title.should == "Detail"
44
+ end
45
+ end
46
+
47
+ # Regression test for https://github.com/clearsightstudio/ProMotion/issues/74
48
+ describe "split screen with UIViewControllers with ScreenModule" do
49
+
50
+ before do
51
+ @app = TestDelegate.new
52
+
53
+ @master_screen = ScreenModuleViewController.new
54
+ @detail_screen = DetailScreen.new(nav_bar: true)
55
+
56
+ @split_screen = @app.open_split_screen @master_screen, @detail_screen
57
+ end
58
+
59
+ it "should set the title on both screens" do
60
+ @master_screen.class.send(:get_title).should == "Test Title"
61
+ @master_screen.title.should == "Test Title"
62
+ @detail_screen.class.send(:get_title).should == "Detail"
63
+ @detail_screen.title.should == "Detail"
64
+ end
65
+
66
+ end
67
+
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: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-05-15 00:00:00.000000000 Z
14
+ date: 2013-05-17 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: ProMotion is a new way to easily build RubyMotion iOS apps.
17
17
  email:
@@ -62,9 +62,13 @@ files:
62
62
  - lib/ProMotion/screens/screen.rb
63
63
  - lib/ProMotion/screens/table_screen.rb
64
64
  - lib/ProMotion/version.rb
65
+ - resources/list.png
65
66
  - spec/helpers/basic_screen.rb
67
+ - spec/helpers/detail_screen.rb
66
68
  - spec/helpers/dummy_class.rb
67
69
  - spec/helpers/home_screen.rb
70
+ - spec/helpers/master_screen.rb
71
+ - spec/helpers/screen_module_view_controller.rb
68
72
  - spec/helpers/table_screen.rb
69
73
  - spec/helpers/table_screen_refreshable.rb
70
74
  - spec/helpers/table_screen_searchable.rb
@@ -73,6 +77,7 @@ files:
73
77
  - spec/logger_spec.rb
74
78
  - spec/main_spec.rb
75
79
  - spec/screen_helpers_spec.rb
80
+ - spec/screen_module_spec.rb
76
81
  - spec/screen_spec.rb
77
82
  - spec/split_screen_in_tab_bar_spec.rb
78
83
  - spec/split_screen_open_screen_spec.rb
@@ -108,8 +113,11 @@ summary: ProMotion is a new way to organize RubyMotion apps. Instead of dealing
108
113
  Ruby and less like Objective-C.
109
114
  test_files:
110
115
  - spec/helpers/basic_screen.rb
116
+ - spec/helpers/detail_screen.rb
111
117
  - spec/helpers/dummy_class.rb
112
118
  - spec/helpers/home_screen.rb
119
+ - spec/helpers/master_screen.rb
120
+ - spec/helpers/screen_module_view_controller.rb
113
121
  - spec/helpers/table_screen.rb
114
122
  - spec/helpers/table_screen_refreshable.rb
115
123
  - spec/helpers/table_screen_searchable.rb
@@ -118,6 +126,7 @@ test_files:
118
126
  - spec/logger_spec.rb
119
127
  - spec/main_spec.rb
120
128
  - spec/screen_helpers_spec.rb
129
+ - spec/screen_module_spec.rb
121
130
  - spec/screen_spec.rb
122
131
  - spec/split_screen_in_tab_bar_spec.rb
123
132
  - spec/split_screen_open_screen_spec.rb