ProMotion 0.7.3 → 0.7.4

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.
@@ -2,7 +2,7 @@ module ProMotion
2
2
  class MeasureHelper
3
3
  class << self
4
4
  def content_height(view)
5
- warn "[DEPRECATION] `MeasureHelper.content_height` is deprecated. Include the module `ScreenElements` to get access to this method (already included in Screen)."
5
+ PM.logger.deprecated "`MeasureHelper.content_height` is deprecated. Include the module `ScreenElements` to get access to this method (already included in Screen)."
6
6
 
7
7
  height = 0
8
8
  view.subviews.each do |subview|
@@ -17,4 +17,4 @@ module ProMotion
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -69,5 +69,14 @@ module ProMotion
69
69
  height
70
70
  end
71
71
 
72
+ def closest_parent(type)
73
+ # iterate up the view hierarchy to find the parent element of "type" containing this view
74
+ this_view = self.superview
75
+ while this_view != nil do
76
+ return this_view if this_view.is_a? type
77
+ this_view = this_view.superview
78
+ end
79
+ nil
80
+ end
72
81
  end
73
82
  end
@@ -126,7 +126,7 @@ module ProMotion
126
126
 
127
127
  # [DEPRECATED]
128
128
  def set_view_controller(vc)
129
- warn "[DEPRECATION] `set_view_controller` is deprecated and discontinued. Please inherit from the UIViewController you wish to use and include ProMotion::ScreenViewController instead."
129
+ PM.logger.deprecated "`set_view_controller` is deprecated and discontinued. Please inherit from the UIViewController you wish to use and include ProMotion::ScreenViewController instead."
130
130
  self
131
131
  end
132
132
 
@@ -153,7 +153,7 @@ module ProMotion
153
153
  def on_disappear; end
154
154
 
155
155
  def view_controller
156
- warn "[DEPRECATION] `view_controller` is deprecated, as screens are now UIViewController subclasses."
156
+ PM.logger.deprecated "`view_controller` is deprecated, as screens are now UIViewController subclasses."
157
157
  self
158
158
  end
159
159
 
@@ -14,23 +14,12 @@ module ProMotion
14
14
  end
15
15
  alias :makeRefreshable :make_refreshable
16
16
 
17
- ######### iOS methods, headless camel case #######
18
-
19
- # UIRefreshControl Delegates
20
- def refreshView(refresh)
21
- refresh.attributedTitle = NSAttributedString.alloc.initWithString(@refreshing)
22
- if @refreshable_callback && self.respond_to?(@refreshable_callback)
23
- self.send(@refreshable_callback)
24
- else
25
- PM.logger.warn "You must implement the '#{@refreshable_callback}' method in your TableScreen."
26
- end
27
- end
28
-
29
17
  def start_refreshing
30
18
  return unless @refresh_control
31
19
 
32
20
  @refresh_control.beginRefreshing
33
21
  end
22
+ alias :begin_refreshing :start_refreshing
34
23
 
35
24
  def end_refreshing
36
25
  return unless @refresh_control
@@ -38,5 +27,19 @@ module ProMotion
38
27
  @refresh_control.attributedTitle = NSAttributedString.alloc.initWithString(sprintf(@updated_format, Time.now.strftime(@updated_time_format)))
39
28
  @refresh_control.endRefreshing
40
29
  end
30
+ alias :stop_refreshing :end_refreshing
31
+
32
+ ######### iOS methods, headless camel case #######
33
+
34
+ # UIRefreshControl Delegates
35
+ def refreshView(refresh)
36
+ refresh.attributedTitle = NSAttributedString.alloc.initWithString(@refreshing)
37
+ if @refreshable_callback && self.respond_to?(@refreshable_callback)
38
+ self.send(@refreshable_callback)
39
+ else
40
+ PM.logger.warn "You must implement the '#{@refreshable_callback}' method in your TableScreen."
41
+ end
42
+ end
43
+
41
44
  end
42
45
  end
@@ -49,6 +49,7 @@ module ProMotion
49
49
  @promotion_table_data.stop_searching
50
50
  @promotion_table_data_data = nil
51
51
  self.table_view.setScrollEnabled true
52
+ self.table_view.reloadData
52
53
  end
53
54
 
54
55
  def searchDisplayControllerWillBeginSearch(controller)
@@ -73,11 +73,10 @@ module ProMotion
73
73
  index_path = table_cell.superview.indexPathForCell(table_cell)
74
74
 
75
75
  data_cell = cell_at_section_and_index(index_path.section, index_path.row)
76
- data_cell[:arguments] = {} unless data_cell[:arguments]
77
- data_cell[:arguments][:value] = switch.isOn if data_cell[:arguments].is_a? Hash
78
- data_cell[:accessory_action] ||= data_cell[:accessoryAction] # For legacy support
76
+ data_cell[:accessory][:arguments] = {} unless data_cell[:accessory][:arguments]
77
+ data_cell[:accessory][:arguments][:value] = switch.isOn if data_cell[:accessory][:arguments].is_a? Hash
79
78
 
80
- trigger_action(data_cell[:accessory_action], data_cell[:arguments]) if data_cell[:accessory_action]
79
+ trigger_action(data_cell[:accessory][:action], data_cell[:accessory][:arguments]) if data_cell[:accessory][:action]
81
80
  end
82
81
 
83
82
  def delete_row(index_paths, animation = nil)
@@ -102,8 +102,10 @@ module ProMotion
102
102
  background_color: :backgroundColor,
103
103
  selection_style: :selectionStyle,
104
104
  cell_class_attributes: :cellClassAttributes,
105
- accessory_view: :accessoryView,
105
+ accessory: :accessoryView,
106
+ accessory: :accessory_view,
106
107
  accessory_type: :accessoryType,
108
+ accessory_action: :accessoryAction,
107
109
  accessory_checked: :accessoryDefault,
108
110
  remote_image: :remoteImage,
109
111
  subviews: :subViews
@@ -117,13 +119,13 @@ module ProMotion
117
119
 
118
120
  mappings.each_pair do |n, old|
119
121
  if data_cell[old]
120
- warn "[DEPRECATION] `:#{old}` is deprecated in TableScreens. Use `:#{n}`"
122
+ PM.logger.deprecated "`:#{old}` is deprecated in TableScreens. Use `:#{n}`"
121
123
  data_cell[n] = data_cell[old]
122
124
  end
123
125
  end
124
126
 
125
127
  if data_cell[:styles] && data_cell[:styles][:textLabel]
126
- warn "[DEPRECATION] `:textLabel` is deprecated in TableScreens. Use `:label`"
128
+ PM.logger.deprecated "`:textLabel` is deprecated in TableScreens. Use `:label`"
127
129
  data_cell[:styles][:label] = data_cell[:styles][:textLabel]
128
130
  end
129
131
 
@@ -24,7 +24,9 @@ module ProMotion
24
24
  end
25
25
 
26
26
  def set_cell_attributes
27
- set_attributes self, data_cell.dup.tap{ |h| h.delete(:image) }
27
+ data_cell_attributes = data_cell.dup
28
+ [:image, :accessory_action].each { |k| data_cell_attributes.delete(k) }
29
+ set_attributes self, data_cell_attributes
28
30
  self
29
31
  end
30
32
 
@@ -41,16 +43,25 @@ module ProMotion
41
43
  end
42
44
 
43
45
  def set_accessory_view
44
- if data_cell[:accessory_view]
45
- self.accessoryView = data_cell[:accessory_view]
46
- self.accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth
47
- end
48
-
49
- if data_cell[:accessory] && data_cell[:accessory] == :switch
46
+ # Legacy Support < 0.7.4
47
+ data_cell[:accessory] ||= data_cell[:accessory_view]
48
+ data_cell[:accessory] = {
49
+ view: data_cell[:accessory],
50
+ value: data_cell[:accessory_value],
51
+ action: data_cell[:accessory_action],
52
+ arguments: data_cell[:accessory_arguments]
53
+ } unless data_cell[:accessory].is_a? Hash
54
+ # End Legacy Support
55
+
56
+ if data_cell[:accessory][:view] == :switch
50
57
  switch_view = UISwitch.alloc.initWithFrame(CGRectZero)
51
- switch_view.addTarget(self, action: "accessory_toggled_switch:", forControlEvents:UIControlEventValueChanged)
52
- switch_view.on = true if data_cell[:accessory_checked]
58
+ switch_view.setAccessibilityLabel(data_cell[:accessory][:accessibility_label]) if data_cell[:accessory][:accessibility_label]
59
+ switch_view.addTarget(self.closest_parent(UITableView), action: "accessory_toggled_switch:", forControlEvents:UIControlEventValueChanged)
60
+ switch_view.on = true if data_cell[:accessory][:value]
53
61
  self.accessoryView = switch_view
62
+ elsif data_cell[:accessory][:view]
63
+ self.accessoryView = data_cell[:accessory][:view]
64
+ self.accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth
54
65
  end
55
66
 
56
67
  self
@@ -1,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "0.7.3" unless defined?(ProMotion::VERSION)
2
+ VERSION = "0.7.4" unless defined?(ProMotion::VERSION)
3
3
  end
@@ -1,66 +1,66 @@
1
1
  describe "ProMotion::Screen functional" do
2
2
  tests PM::Screen
3
-
3
+
4
4
  # Override controller to properly instantiate
5
5
  def controller
6
6
  rotate_device to: :portrait, button: :bottom
7
7
  @controller ||= FunctionalScreen.new(nav_bar: true)
8
8
  @controller.main_controller
9
9
  end
10
-
10
+
11
11
  after do
12
12
  @controller = nil
13
13
  end
14
-
14
+
15
15
  it "should have a navigation bar" do
16
16
  view("Functional").should.be.kind_of UINavigationItemView
17
17
  end
18
-
18
+
19
19
  it "should allow setting a left nav bar button" do
20
20
  @controller.set_nav_bar_button :left, title: "Cool", action: :triggered_button
21
21
  tap("Cool")
22
22
  @controller.button_was_triggered.should.be.true
23
23
  end
24
-
24
+
25
25
  it "should allow setting a right nav bar button" do
26
26
  @controller.set_nav_bar_button :right, title: "Cool2", action: :triggered_button
27
27
  tap("Cool2")
28
28
  @controller.button_was_triggered.should.be.true
29
29
  end
30
-
30
+
31
31
  it "should allow opening another screen in the same nav bar and have a back button that is operational" do
32
32
  @controller.open BasicScreen
33
-
33
+
34
34
  wait 0.5 do
35
-
35
+
36
36
  view("Basic").should.be.kind_of UINavigationItemView
37
37
  view("Functional").should.be.kind_of UINavigationItemButtonView
38
-
38
+
39
39
  tap("Functional")
40
40
  wait 0.5 do
41
41
  view("Functional").should.be.kind_of UINavigationItemView
42
42
  end
43
-
43
+
44
44
  end
45
45
  end
46
-
46
+
47
47
  it "should allow opening and closing a modal screen" do
48
48
  @basic = BasicScreen.new(nav_bar: true)
49
49
  wait 0.1 do
50
50
  @controller.open_modal @basic
51
-
51
+
52
52
  wait 0.6 do
53
-
53
+
54
54
  view("Basic").should.be.kind_of UINavigationItemView
55
55
  @basic.close
56
-
56
+
57
57
  wait 0.6 do
58
58
  @basic = nil
59
59
  view("Functional").should.be.kind_of UINavigationItemView
60
60
  end
61
-
61
+
62
62
  end
63
63
  end
64
64
  end
65
-
65
+
66
66
  end
@@ -0,0 +1,32 @@
1
+ describe "Searchable table spec" do
2
+ tests TableScreenSearchable
3
+
4
+ # Override controller to properly instantiate
5
+ def controller
6
+ @controller ||= TableScreenSearchable.new(nav_bar: true)
7
+ @controller.on_load
8
+ @controller.main_controller
9
+ end
10
+
11
+ it "should be rotated in portrait mode" do
12
+ rotate_device to: :portrait, button: :bottom
13
+ true.should == true
14
+ end
15
+
16
+ it "should show all 50 states" do
17
+ @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50
18
+ end
19
+
20
+ it "should allow searching for all the 'New' states" do
21
+ @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"New")
22
+ @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 4
23
+ end
24
+
25
+ it "should allow ending searches" do
26
+ @controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North")
27
+ @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 2
28
+ @controller.searchDisplayControllerWillEndSearch(@controller)
29
+ @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50
30
+ end
31
+
32
+ end
@@ -1,6 +1,6 @@
1
1
  describe "Split screen functional" do
2
2
  tests PM::SplitViewController
3
-
3
+
4
4
  # Override controller to properly instantiate
5
5
  def controller
6
6
  @app ||= TestDelegate.new
@@ -8,59 +8,59 @@ describe "Split screen functional" do
8
8
  @detail = DetailScreen.new(nav_bar: true)
9
9
  @controller ||= @app.create_split_screen @master, @detail
10
10
  end
11
-
11
+
12
12
  before do
13
13
  rotate_device to: :landscape, button: :right
14
14
  end
15
-
15
+
16
16
  after do
17
17
  rotate_device to: :portrait, button: :bottom
18
18
  end
19
-
19
+
20
20
  it "should allow opening a detail view from the master view" do
21
-
21
+
22
22
  @master.open BasicScreen.new(nav_bar: true), in_detail: true
23
-
23
+
24
24
  wait 0.75 do
25
25
  view("Master").should.be.kind_of UINavigationItemView
26
26
  view("Basic").should.be.kind_of UINavigationItemView
27
27
  views(UINavigationItemView).each { |v| v.title.should.not == "Detail" }
28
28
  end
29
-
29
+
30
30
  end
31
-
31
+
32
32
  it "should allow opening another view from the master view" do
33
-
33
+
34
34
  @master.open BasicScreen
35
-
35
+
36
36
  wait 0.75 do
37
37
  view("Basic").should.be.kind_of UINavigationItemView
38
38
  view("Detail").should.be.kind_of UINavigationItemView
39
39
  end
40
-
40
+
41
41
  end
42
-
42
+
43
43
  it "should allow opening a master view from the detail view" do
44
-
44
+
45
45
  @detail.open BasicScreen.new(nav_bar: true), in_master: true
46
-
46
+
47
47
  wait 0.75 do
48
48
  view("Basic").should.be.kind_of UINavigationItemView
49
49
  view("Detail").should.be.kind_of UINavigationItemView
50
50
  views(UINavigationItemView).each { |v| v.title.should.not == "Master" }
51
51
  end
52
-
52
+
53
53
  end
54
-
54
+
55
55
  it "should allow opening another view from the detail view" do
56
-
56
+
57
57
  @detail.open BasicScreen
58
-
58
+
59
59
  wait 0.75 do
60
60
  view("Basic").should.be.kind_of UINavigationItemView
61
61
  view("Master").should.be.kind_of UINavigationItemView
62
62
  end
63
-
63
+
64
64
  end
65
-
65
+
66
66
  end
@@ -49,4 +49,25 @@ describe "ProMotion::TestTableScreen functionality" do
49
49
  @controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 5
50
50
  end
51
51
 
52
+ it "should call a method when the switch is flipped" do
53
+ @controller.scroll_to_bottom
54
+ tap "switch_1"
55
+ @controller.tap_counter.should == 1
56
+ end
57
+
58
+ it "should call the method with arguments when the switch is flipped" do
59
+ @controller.scroll_to_bottom
60
+ tap "switch_2"
61
+ @controller.tap_counter.should == 3
62
+ end
63
+
64
+ it "should call the method with arguments when the switch is flipped and when the cell is tapped" do
65
+ @controller.scroll_to_bottom
66
+ tap "switch_3"
67
+ @controller.tap_counter.should == 3
68
+
69
+ tap "Switch With Cell Tap, Switch Action And Parameters"
70
+ @controller.tap_counter.should == 13
71
+ end
72
+
52
73
  end
@@ -1,20 +1,22 @@
1
1
  class TestTableScreen < ProMotion::SectionedTableScreen
2
2
 
3
+ attr_accessor :tap_counter
4
+
3
5
  def promotion_table_data
4
6
  @promotion_table_data
5
7
  end
6
8
 
7
9
  def on_load
8
- @tap_counter ||= 0
10
+ self.tap_counter = 0
9
11
  end
10
12
 
11
13
  def table_data
12
14
  @data ||= [{
13
15
  title: "Your Account",
14
16
  cells: [
15
- { title: "Increment", action: :increment_counter_by, arguments: { number: 3 } },
17
+ { title: "Increment", action: :increment_counter_by, arguments: {number: 3} },
16
18
  { title: "Add New Row", action: :add_tableview_row },
17
- { title: "Delete the row below", action: :delete_cell, arguments: {section: 0, row:3 } },
19
+ { title: "Delete the row below", action: :delete_cell, arguments: {section: 0, row:3} },
18
20
  { title: "Just another blank row" },
19
21
  { title: "Delete the row below with an animation", action: :delete_cell, arguments: {animated: true, section: 0, row:5 } },
20
22
  { title: "Just another blank row" }
@@ -23,16 +25,44 @@ class TestTableScreen < ProMotion::SectionedTableScreen
23
25
  title: "App Stuff",
24
26
  cells: [
25
27
  { title: "Increment One", action: :increment_counter },
26
- { title: "Feedback", remote_image: { url: "http://placekitten.com/100/100", placeholder: "some-local-image", size: 50, radius: 15 } }
28
+ { title: "Feedback", cell_identifier: "ImagedCell", remote_image: { url: "http://placekitten.com/100/100", placeholder: "some-local-image", size: 50, radius: 15 } }
27
29
  ]
28
30
  }, {
29
31
  title: "Image Tests",
30
32
  cells: [
31
- { title: "Image Test 1", image: {image: UIImage.imageNamed("list.png"), radius: 10} },
32
- { title: "Image Test 2", image: {image: "list.png"} },
33
- { title: "Image Test 3", image: UIImage.imageNamed("list.png") },
33
+ { title: "Image Test 1", cell_identifier: "ImagedCell", image: {image: UIImage.imageNamed("list.png"), radius: 10} },
34
+ { title: "Image Test 2", cell_identifier: "ImagedCell", image: {image: "list.png"} },
35
+ { title: "Image Test 3", cell_identifier: "ImagedCell", cell_identifier: "ImagedCell", image: UIImage.imageNamed("list.png") },
34
36
  { title: "Image Test 4", image: "list.png" },
35
37
  ]
38
+ }, {
39
+ title: "Cell Accessory Tests",
40
+ cells: [{
41
+ title: "Switch With Action",
42
+ accessory: {
43
+ view: :switch,
44
+ action: :increment_counter,
45
+ accessibility_label: "switch_1"
46
+ } ,
47
+ }, {
48
+ title: "Switch With Action And Parameters",
49
+ accessory: {
50
+ view: :switch,
51
+ action: :increment_counter_by,
52
+ arguments: { number: 3 },
53
+ accessibility_label: "switch_2"
54
+ } ,
55
+ }, {
56
+ title: "Switch With Cell Tap, Switch Action And Parameters",
57
+ accessory:{
58
+ view: :switch,
59
+ action: :increment_counter_by,
60
+ arguments: { number: 3 },
61
+ accessibility_label: "switch_3"
62
+ },
63
+ action: :increment_counter_by,
64
+ arguments: { number: 10 }
65
+ }]
36
66
  }]
37
67
  end
38
68
 
@@ -56,17 +86,25 @@ class TestTableScreen < ProMotion::SectionedTableScreen
56
86
  end
57
87
  end
58
88
 
59
- def increment_counter(args={})
60
- @tap_counter += 1
89
+ def increment_counter
90
+ self.tap_counter = self.tap_counter + 1
61
91
  end
62
92
 
63
93
  def increment_counter_by(args={})
64
- @tap_counter = @tap_counter + args[:number]
94
+ self.tap_counter = self.tap_counter + args[:number]
65
95
  end
66
96
 
67
- def tap_counter
68
- @tap_counter
97
+ def custom_accessory_view
98
+ set_attributes UIView.new, {
99
+ background_color: UIColor.orangeColor
100
+ }
69
101
  end
70
102
 
103
+ def scroll_to_bottom
104
+ if table_view.contentSize.height > table_view.frame.size.height
105
+ offset = CGPointMake(0, table_view.contentSize.height - table_view.frame.size.height)
106
+ table_view.setContentOffset(offset, animated:false)
107
+ end
108
+ end
71
109
 
72
110
  end
@@ -1,5 +1,62 @@
1
1
  class TableScreenSearchable < TestTableScreen
2
2
 
3
3
  searchable
4
+
5
+ def table_data
6
+ @search_table_data ||= [{
7
+ cells: [
8
+ { title: "Alabama" },
9
+ { title: "Alaska" },
10
+ { title: "Arizona" },
11
+ { title: "Arkansas" },
12
+ { title: "California" },
13
+ { title: "Colorado" },
14
+ { title: "Connecticut" },
15
+ { title: "Delaware" },
16
+ { title: "Florida" },
17
+ { title: "Georgia" },
18
+ { title: "Hawaii" },
19
+ { title: "Idaho" },
20
+ { title: "Illinois" },
21
+ { title: "Indiana" },
22
+ { title: "Iowa" },
23
+ { title: "Kansas" },
24
+ { title: "Kentucky" },
25
+ { title: "Louisiana" },
26
+ { title: "Maine" },
27
+ { title: "Maryland" },
28
+ { title: "Massachusetts" },
29
+ { title: "Michigan" },
30
+ { title: "Minnesota" },
31
+ { title: "Mississippi" },
32
+ { title: "Missouri" },
33
+ { title: "Montana" },
34
+ { title: "Nebraska" },
35
+ { title: "Nevada" },
36
+ { title: "New Hampshire" },
37
+ { title: "New Jersey" },
38
+ { title: "New Mexico" },
39
+ { title: "New York" },
40
+ { title: "North Carolina" },
41
+ { title: "North Dakota" },
42
+ { title: "Ohio" },
43
+ { title: "Oklahoma" },
44
+ { title: "Oregon" },
45
+ { title: "Pennsylvania" },
46
+ { title: "Rhode Island" },
47
+ { title: "South Carolina" },
48
+ { title: "South Dakota" },
49
+ { title: "Tennessee" },
50
+ { title: "Texas" },
51
+ { title: "Utah" },
52
+ { title: "Vermont" },
53
+ { title: "Virginia" },
54
+ { title: "Washington" },
55
+ { title: "West Virginia" },
56
+ { title: "Wisconsin" },
57
+ { title: "Wyoming" }
58
+ ]
59
+ }]
60
+ end
4
61
 
5
- end
62
+ end
@@ -1,9 +1,9 @@
1
1
  describe "PM::Table module" do
2
-
2
+
3
3
  def cell_factory(args={})
4
4
  { title: "Basic", action: :basic_cell_tapped, arguments: { id: 1 } }.merge!(args)
5
5
  end
6
-
6
+
7
7
  def custom_cell
8
8
  cell_factory({
9
9
  title: "Crazy Full Featured Cell",
@@ -22,7 +22,6 @@ describe "PM::Table module" do
22
22
  backgroundColor: UIColor.whiteColor
23
23
  },
24
24
  accessory: :switch, # currently only :switch is supported
25
- accessory_view: @some_accessory_view,
26
25
  accessory_type: UITableViewCellAccessoryCheckmark,
27
26
  accessory_checked: true, # whether it's "checked" or not
28
27
  image: { image: UIImage.imageNamed("something"), radius: 15 },
@@ -33,7 +32,7 @@ describe "PM::Table module" do
33
32
  subviews: [ @some_view, @some_other_view ] # arbitrary views added to the cell
34
33
  })
35
34
  end
36
-
35
+
37
36
  before do
38
37
  @subject = TestTableScreen.new
39
38
  @subject.mock! :table_data do
@@ -47,62 +46,62 @@ describe "PM::Table module" do
47
46
  title: "Table cell group 4", cells: [ custom_cell, cell_factory(title: "4-2"), cell_factory(title: "4-3"), cell_factory(title: "4-4") ]
48
47
  }]
49
48
  end
50
-
49
+
51
50
  @subject.on_load
52
-
51
+
53
52
  @ip = NSIndexPath.indexPathForRow(1, inSection: 2) # Cell 3-2
54
53
  @custom_ip = NSIndexPath.indexPathForRow(0, inSection: 3) # Cell "Crazy Full Featured Cell"
55
-
54
+
56
55
  @subject.update_table_data
57
56
  end
58
-
57
+
59
58
  it "should have the right number of sections" do
60
59
  @subject.numberOfSectionsInTableView(@subject.table_view).should == 4
61
60
  end
62
-
61
+
63
62
  it "should set the section titles" do
64
63
  @subject.tableView(@subject.table_view, titleForHeaderInSection:0).should == "Table cell group 1"
65
64
  @subject.tableView(@subject.table_view, titleForHeaderInSection:1).should == "Table cell group 2"
66
65
  @subject.tableView(@subject.table_view, titleForHeaderInSection:2).should == "Table cell group 3"
67
66
  @subject.tableView(@subject.table_view, titleForHeaderInSection:3).should == "Table cell group 4"
68
67
  end
69
-
68
+
70
69
  it "should create the right number of cells" do
71
70
  @subject.tableView(@subject.table_view, numberOfRowsInSection:0).should == 0
72
71
  @subject.tableView(@subject.table_view, numberOfRowsInSection:1).should == 1
73
72
  @subject.tableView(@subject.table_view, numberOfRowsInSection:2).should == 2
74
73
  @subject.tableView(@subject.table_view, numberOfRowsInSection:3).should == 4
75
74
  end
76
-
75
+
77
76
  it "should create the jumplist" do
78
77
  @subject.mock! :table_data_index, do
79
78
  Array("A".."Z")
80
79
  end
81
-
80
+
82
81
  @subject.sectionIndexTitlesForTableView(@subject.table_view).should == Array("A".."Z")
83
82
  end
84
-
83
+
85
84
  it "should return the proper cell" do
86
85
  cell = @subject.tableView(@subject.table_view, cellForRowAtIndexPath: @ip)
87
86
  cell.should.be.kind_of(UITableViewCell)
88
87
  cell.textLabel.text.should == "3-2"
89
88
  end
90
-
89
+
91
90
  it "should return the table's cell height if none is given" do
92
91
  @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@ip).should == 44.0 # Built-in default
93
92
  end
94
-
93
+
95
94
  it "should allow setting a custom cell height" do
96
95
  @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@custom_ip).should.be > 0.0
97
96
  @subject.tableView(@subject.table_view, heightForRowAtIndexPath:@custom_ip).should == custom_cell[:height].to_f
98
97
  end
99
-
98
+
100
99
  it "should trigger the right action on select and pass in the right arguments" do
101
100
  @subject.mock! :tapped_cell_1 do |args|
102
101
  args[:data].should == [ "lots", "of", "data" ]
103
102
  end
104
-
103
+
105
104
  @subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
106
105
  end
107
-
106
+
108
107
  end
@@ -15,6 +15,7 @@ describe "table screens" do
15
15
  @screen.tableView(@screen.tableView, numberOfRowsInSection:0).should == 6
16
16
  @screen.tableView(@screen.tableView, numberOfRowsInSection:1).should == 2
17
17
  @screen.tableView(@screen.tableView, numberOfRowsInSection:2).should == 4
18
+ @screen.tableView(@screen.tableView, numberOfRowsInSection:3).should == 3
18
19
  end
19
20
 
20
21
  it "should return a UITableViewCell" do
@@ -30,10 +31,8 @@ describe "table screens" do
30
31
  end
31
32
 
32
33
  it "should display all images properly no matter how they were initialized" do
33
- section = @screen.promotion_table_data.sections.count - 1 # All the cells we want to test are in the last section
34
-
35
- @screen.tableView(@screen.tableView, numberOfRowsInSection:section).times do |i|
36
- index_path = NSIndexPath.indexPathForRow(i, inSection: section)
34
+ @screen.tableView(@screen.tableView, numberOfRowsInSection:2).times do |i|
35
+ index_path = NSIndexPath.indexPathForRow(i, inSection:2)
37
36
 
38
37
  @screen.tableView(@screen.tableView, cellForRowAtIndexPath: index_path).imageView.should.be.kind_of UIImageView
39
38
 
@@ -1,5 +1,5 @@
1
1
  describe "PM::TableViewCellModule" do
2
-
2
+
3
3
  def custom_cell
4
4
  {
5
5
  title: "Crazy Full Featured Cell",
@@ -13,13 +13,12 @@ describe "PM::TableViewCellModule" do
13
13
  layer: { masks_to_bounds: true },
14
14
  background_color: UIColor.redColor,
15
15
  selection_style: UITableViewCellSelectionStyleGray,
16
- accessory: :switch, # currently only :switch is supported
17
- accessory_checked: true, # whether it's "checked" or not
16
+ accessory:{view: :switch, value: true}, # currently only :switch is supported
18
17
  image: { image: UIImage.imageNamed("list"), radius: 15 },
19
18
  subviews: [ UIView.alloc.initWithFrame(CGRectZero), UILabel.alloc.initWithFrame(CGRectZero) ] # arbitrary views added to the cell
20
19
  }
21
20
  end
22
-
21
+
23
22
  before do
24
23
  @screen = TestTableScreen.new
25
24
  button = UIButton.buttonWithType(UIButtonTypeRoundedRect).tap{|b| b.titleLabel.text = "ACC" }
@@ -29,47 +28,47 @@ describe "PM::TableViewCellModule" do
29
28
  { title: "", cells: [
30
29
  {title: "Test 1", accessory_type: UITableViewCellStateShowingEditControlMask },
31
30
  custom_cell,
32
- { title: "Test2", accessory_view: button } ] }
31
+ { title: "Test2", accessory: button } ] }
33
32
  ]
34
33
  end
35
-
34
+
36
35
  @screen.on_load
37
-
36
+
38
37
  custom_ip = NSIndexPath.indexPathForRow(1, inSection: 1) # Cell "Crazy Full Featured Cell"
39
-
38
+
40
39
  @screen.update_table_data
41
-
40
+
42
41
  @subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: custom_ip)
43
42
  end
44
-
43
+
45
44
  it "should be a PM::TableViewCell" do
46
45
  @subject.should.be.kind_of(PM::TableViewCell)
47
46
  end
48
-
47
+
49
48
  it "should have the right title" do
50
49
  @subject.textLabel.text.should == "Crazy Full Featured Cell"
51
50
  end
52
-
51
+
53
52
  it "should have the right subtitle" do
54
53
  @subject.detailTextLabel.text.should == "This is way too huge..."
55
54
  end
56
-
55
+
57
56
  it "should have the right re-use identifier" do
58
57
  @subject.reuseIdentifier.should == "Cell"
59
58
  end
60
-
59
+
61
60
  it "should set the layer.masksToBounds" do
62
61
  @subject.layer.masksToBounds.should == true
63
62
  end
64
-
63
+
65
64
  it "should set the background color" do
66
65
  @subject.backgroundView.backgroundColor.should == UIColor.redColor
67
66
  end
68
-
67
+
69
68
  it "should set the selection color style" do
70
69
  @subject.selectionStyle.should == UITableViewCellSelectionStyleGray
71
70
  end
72
-
71
+
73
72
  it "should set the accessory view to a switch" do
74
73
  @subject.accessoryView.should.be.kind_of(UISwitch)
75
74
  end
@@ -79,14 +78,14 @@ describe "PM::TableViewCellModule" do
79
78
  subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: ip)
80
79
  subject.accessoryView.should.be.kind_of(UIRoundedRectButton)
81
80
  end
82
-
81
+
83
82
  it "should set the accessory type to edit" do
84
83
  ip = NSIndexPath.indexPathForRow(0, inSection: 1)
85
84
  subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: ip)
86
85
  subject.accessoryView.should.be.nil
87
86
  subject.accessoryType.should == UITableViewCellStateShowingEditControlMask
88
87
  end
89
-
88
+
90
89
  it "should set an image with a radius" do
91
90
  @subject.imageView.should.be.kind_of(UIImageView)
92
91
  @subject.imageView.image.should == UIImage.imageNamed("list")
@@ -98,9 +97,9 @@ describe "PM::TableViewCellModule" do
98
97
  @subject.subviews[2].class.should == UIView
99
98
  @subject.subviews[3].class.should == UILabel
100
99
  end
101
-
102
-
103
-
100
+
101
+
102
+
104
103
  end
105
104
 
106
105
 
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.7.3
4
+ version: 0.7.4
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-06-06 00:00:00.000000000 Z
14
+ date: 2013-06-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: motion-stump
@@ -120,6 +120,7 @@ files:
120
120
  - lib/ProMotion/version.rb
121
121
  - resources/list.png
122
122
  - spec/functional/func_screen_spec.rb
123
+ - spec/functional/func_searchable_table_spec.rb
123
124
  - spec/functional/func_split_screen_spec.rb
124
125
  - spec/functional/func_table_screen_spec.rb
125
126
  - spec/helpers/basic_screen.rb
@@ -176,6 +177,7 @@ summary: ProMotion is a new way to organize RubyMotion apps. Instead of dealing
176
177
  Ruby and less like Objective-C.
177
178
  test_files:
178
179
  - spec/functional/func_screen_spec.rb
180
+ - spec/functional/func_searchable_table_spec.rb
179
181
  - spec/functional/func_split_screen_spec.rb
180
182
  - spec/functional/func_table_screen_spec.rb
181
183
  - spec/helpers/basic_screen.rb