ProMotion 2.0.0 → 2.0.1
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.
- checksums.yaml +4 -4
- data/lib/ProMotion/cocoatouch/navigation_controller.rb +9 -0
- data/lib/ProMotion/cocoatouch/tab_bar_controller.rb +25 -1
- data/lib/ProMotion/screen/nav_bar_module.rb +9 -3
- data/lib/ProMotion/screen/screen_module.rb +2 -2
- data/lib/ProMotion/stubs/dummy_image_view.rb +7 -0
- data/lib/ProMotion/table/data/table_data.rb +13 -16
- data/lib/ProMotion/table/extensions/longpressable.rb +1 -1
- data/lib/ProMotion/table/grouped_table_screen.rb +1 -0
- data/lib/ProMotion/table/table.rb +10 -14
- data/lib/ProMotion/table/table_utils.rb +13 -0
- data/lib/ProMotion/version.rb +1 -1
- data/spec/functional/func_screen_spec.rb +19 -0
- data/spec/functional/func_table_screen_spec.rb +0 -21
- data/spec/unit/image_title_screen.rb +12 -2
- data/spec/unit/screen_spec.rb +23 -0
- data/spec/unit/tab_bar_spec.rb +4 -1
- data/spec/unit/tables/table_module_spec.rb +14 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a3f842a22164f1646fa4c70c06717331c37b37
|
4
|
+
data.tar.gz: b71313bd4e58fd83a405e8741c264547b80e0f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309c74e1577110e7c0ab397fe120a367f77343b11f5cfb4813bd99e6f942f89d463eadc36fc143324c49b7fd428ba50191c896246a91dddb17f6d05048eac843
|
7
|
+
data.tar.gz: c0dbd687ecb04bdea39a131e9b8313da6b12ca5b3a83fc7ab8a6ee915b4efc8ead92fb10247c16613907167f83c877c441078b2da22408003ef5f0212f91ce62
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module ProMotion
|
2
2
|
class NavigationController < UINavigationController
|
3
|
+
|
4
|
+
def popViewControllerAnimated(animated)
|
5
|
+
if self.viewControllers[-2].respond_to? :on_back
|
6
|
+
self.viewControllers[-2].send(:on_back)
|
7
|
+
end
|
8
|
+
super animated
|
9
|
+
end
|
10
|
+
|
3
11
|
def shouldAutorotate
|
4
12
|
visibleViewController.shouldAutorotate
|
5
13
|
end
|
@@ -11,5 +19,6 @@ module ProMotion
|
|
11
19
|
def preferredInterfaceOrientationForPresentation
|
12
20
|
visibleViewController.preferredInterfaceOrientationForPresentation
|
13
21
|
end
|
22
|
+
|
14
23
|
end
|
15
24
|
end
|
@@ -34,7 +34,31 @@ module ProMotion
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def find_tab(tab_title)
|
37
|
-
|
37
|
+
viewControllers.find { |vc| vc.tabBarItem.title == tab_title }
|
38
|
+
end
|
39
|
+
|
40
|
+
# Cocoa touch methods below
|
41
|
+
|
42
|
+
def shouldAutorotate
|
43
|
+
current_view_controller_try(:shouldAutorotate)
|
44
|
+
end
|
45
|
+
|
46
|
+
def supportedInterfaceOrientations
|
47
|
+
current_view_controller_try(:supportedInterfaceOrientations)
|
48
|
+
end
|
49
|
+
|
50
|
+
def preferredInterfaceOrientationForPresentation
|
51
|
+
current_view_controller_try(:preferredInterfaceOrientationForPresentation)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def current_view_controller
|
57
|
+
selectedViewController || viewControllers.first
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_view_controller_try(method, *args)
|
61
|
+
current_view_controller.send(method, *args) if current_view_controller.respond_to?(method)
|
38
62
|
end
|
39
63
|
|
40
64
|
end
|
@@ -70,15 +70,21 @@ module ProMotion
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def bar_button_item_image(img, args)
|
73
|
-
UIBarButtonItem.alloc.initWithImage(img, style: map_bar_button_item_style(args[:style]), target: args[:target] || self, action: args[:action])
|
73
|
+
button = UIBarButtonItem.alloc.initWithImage(img, style: map_bar_button_item_style(args[:style]), target: args[:target] || self, action: args[:action])
|
74
|
+
button.setTintColor args[:tint_color] if args[:tint_color]
|
75
|
+
button
|
74
76
|
end
|
75
77
|
|
76
78
|
def bar_button_item_string(str, args)
|
77
|
-
UIBarButtonItem.alloc.initWithTitle(str, style: map_bar_button_item_style(args[:style]), target: args[:target] || self, action: args[:action])
|
79
|
+
button = UIBarButtonItem.alloc.initWithTitle(str, style: map_bar_button_item_style(args[:style]), target: args[:target] || self, action: args[:action])
|
80
|
+
button.setTintColor args[:tint_color] if args[:tint_color]
|
81
|
+
button
|
78
82
|
end
|
79
83
|
|
80
84
|
def bar_button_item_system_item(args)
|
81
|
-
UIBarButtonItem.alloc.initWithBarButtonSystemItem(map_bar_button_system_item(args[:system_item]), target: args[:target] || self, action: args[:action])
|
85
|
+
button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(map_bar_button_system_item(args[:system_item]), target: args[:target] || self, action: args[:action])
|
86
|
+
button.setTintColor args[:tint_color] if args[:tint_color]
|
87
|
+
button
|
82
88
|
end
|
83
89
|
|
84
90
|
def bar_button_item_custom(custom_view)
|
@@ -27,7 +27,7 @@ module ProMotion
|
|
27
27
|
case self.class.title_type
|
28
28
|
when :text then self.title = self.class.title
|
29
29
|
when :view then self.navigationItem.titleView = self.class.title
|
30
|
-
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(
|
30
|
+
when :image then self.navigationItem.titleView = UIImageView.alloc.initWithImage(self.class.title)
|
31
31
|
else
|
32
32
|
PM.logger.warn("title expects string, UIView, or UIImage, but #{self.class.title.class.to_s} given.")
|
33
33
|
end
|
@@ -178,7 +178,7 @@ module ProMotion
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def title_image(t)
|
181
|
-
@title = t
|
181
|
+
@title = t.is_a?(UIImage) ? t : UIImage.imageNamed(t)
|
182
182
|
@title_type = :image
|
183
183
|
end
|
184
184
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module ProMotion
|
2
2
|
class TableData
|
3
|
+
include ProMotion::Table::Utils
|
4
|
+
|
3
5
|
attr_accessor :data, :filtered_data, :search_string, :original_search_string, :filtered, :table_view
|
4
6
|
|
5
7
|
def initialize(data, table_view)
|
@@ -21,36 +23,23 @@ module ProMotion
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def cell(params={})
|
24
|
-
|
25
|
-
params[:section] = params[:index_path].section
|
26
|
-
params[:index] = params[:index_path].row
|
27
|
-
end
|
28
|
-
|
26
|
+
params = index_path_to_section_index(params)
|
29
27
|
table_section = self.section(params[:section])
|
30
28
|
c = table_section[:cells].at(params[:index].to_i)
|
31
29
|
set_data_cell_defaults c
|
32
30
|
end
|
33
31
|
|
34
32
|
def delete_cell(params={})
|
35
|
-
|
36
|
-
params[:section] = params[:index_path].section
|
37
|
-
params[:index] = params[:index_path].row
|
38
|
-
end
|
39
|
-
|
33
|
+
params = index_path_to_section_index(params)
|
40
34
|
table_section = self.section(params[:section])
|
41
35
|
table_section[:cells].delete_at(params[:index].to_i)
|
42
36
|
end
|
43
37
|
|
44
38
|
def search(search_string)
|
45
|
-
|
46
|
-
self.filtered = true
|
47
|
-
|
48
|
-
self.original_search_string = search_string
|
49
|
-
self.search_string = search_string.downcase.strip
|
39
|
+
start_searching(search_string)
|
50
40
|
|
51
41
|
self.data.compact.each do |section|
|
52
42
|
new_section = {}
|
53
|
-
new_section[:cells] = []
|
54
43
|
|
55
44
|
new_section[:cells] = section[:cells].map do |cell|
|
56
45
|
cell[:searchable] != false && "#{cell[:title]}\n#{cell[:search_text]}".downcase.strip.include?(self.search_string) ? cell : nil
|
@@ -99,5 +88,13 @@ module ProMotion
|
|
99
88
|
ident
|
100
89
|
end
|
101
90
|
|
91
|
+
private
|
92
|
+
|
93
|
+
def start_searching(search_string)
|
94
|
+
self.filtered_data = []
|
95
|
+
self.filtered = true
|
96
|
+
self.search_string = search_string.downcase.strip
|
97
|
+
self.original_search_string = search_string
|
98
|
+
end
|
102
99
|
end
|
103
100
|
end
|
@@ -17,7 +17,7 @@ module ProMotion
|
|
17
17
|
gesture_point = gesture.locationInView(table_view)
|
18
18
|
index_path = table_view.indexPathForRowAtPoint(gesture_point)
|
19
19
|
data_cell = self.promotion_table_data.cell(index_path: index_path)
|
20
|
-
trigger_action(data_cell[:long_press_action], data_cell[:arguments]) if data_cell[:long_press_action]
|
20
|
+
trigger_action(data_cell[:long_press_action], data_cell[:arguments], index_path) if data_cell[:long_press_action]
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -2,6 +2,7 @@ module ProMotion
|
|
2
2
|
class GroupedTableScreen < TableViewController
|
3
3
|
include ProMotion::ScreenModule
|
4
4
|
include ProMotion::Table
|
5
|
+
include ProMotion::Table::Utils # Workaround until https://hipbyte.freshdesk.com/support/tickets/2086 is fixed.
|
5
6
|
include ProMotion::GroupedTable
|
6
7
|
end
|
7
8
|
end
|
@@ -5,6 +5,7 @@ module ProMotion
|
|
5
5
|
include ProMotion::Table::Refreshable
|
6
6
|
include ProMotion::Table::Indexable
|
7
7
|
include ProMotion::Table::Longpressable
|
8
|
+
include ProMotion::Table::Utils
|
8
9
|
|
9
10
|
attr_reader :promotion_table_data
|
10
11
|
|
@@ -67,10 +68,14 @@ module ProMotion
|
|
67
68
|
@table_search_display_controller.searchResultsTableView.reloadData if searching?
|
68
69
|
end
|
69
70
|
|
70
|
-
def trigger_action(action, arguments)
|
71
|
+
def trigger_action(action, arguments, index_path)
|
71
72
|
return PM.logger.info "Action not implemented: #{action.to_s}" unless self.respond_to?(action)
|
72
|
-
|
73
|
-
self.
|
73
|
+
|
74
|
+
case self.method(action).arity
|
75
|
+
when 0 then self.send(action) # Just call the method
|
76
|
+
when 2 then self.send(action, arguments, index_path) # Send arguments and index path
|
77
|
+
else self.send(action, arguments) # Send arguments
|
78
|
+
end
|
74
79
|
end
|
75
80
|
|
76
81
|
def accessory_toggled_switch(switch)
|
@@ -79,9 +84,8 @@ module ProMotion
|
|
79
84
|
|
80
85
|
if index_path
|
81
86
|
data_cell = promotion_table_data.cell(section: index_path.section, index: index_path.row)
|
82
|
-
data_cell[:accessory][:arguments] ||= {}
|
83
87
|
data_cell[:accessory][:arguments][:value] = switch.isOn if data_cell[:accessory][:arguments].is_a?(Hash)
|
84
|
-
trigger_action(data_cell[:accessory][:action], data_cell[:accessory][:arguments]) if data_cell[:accessory][:action]
|
88
|
+
trigger_action(data_cell[:accessory][:action], data_cell[:accessory][:arguments], index_path) if data_cell[:accessory][:action]
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -106,14 +110,6 @@ module ProMotion
|
|
106
110
|
create_table_cell(data_cell)
|
107
111
|
end
|
108
112
|
|
109
|
-
def index_path_to_section_index(params)
|
110
|
-
if params[:index_path]
|
111
|
-
params[:section] = params[:index_path].section
|
112
|
-
params[:index] = params[:index_path].row
|
113
|
-
end
|
114
|
-
params
|
115
|
-
end
|
116
|
-
|
117
113
|
def create_table_cell(data_cell)
|
118
114
|
table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier]) || begin
|
119
115
|
table_cell = data_cell[:cell_class].alloc.initWithStyle(data_cell[:cell_style], reuseIdentifier:data_cell[:cell_identifier])
|
@@ -171,7 +167,7 @@ module ProMotion
|
|
171
167
|
def tableView(table_view, didSelectRowAtIndexPath:index_path)
|
172
168
|
data_cell = self.promotion_table_data.cell(index_path: index_path)
|
173
169
|
table_view.deselectRowAtIndexPath(index_path, animated: true) unless data_cell[:keep_selection] == true
|
174
|
-
trigger_action(data_cell[:action], data_cell[:arguments]) if data_cell[:action]
|
170
|
+
trigger_action(data_cell[:action], data_cell[:arguments], index_path) if data_cell[:action]
|
175
171
|
end
|
176
172
|
|
177
173
|
def tableView(table_view, editingStyleForRowAtIndexPath: index_path)
|
data/lib/ProMotion/version.rb
CHANGED
@@ -68,6 +68,25 @@ describe "ProMotion::Screen functionality" do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
it "should call the on_back method on the root controller when navigating back" do
|
72
|
+
@nav_screen = NavigationScreen.new nav_bar: true
|
73
|
+
@presented_screen = PresentScreen.new
|
74
|
+
@nav_screen.open @presented_screen
|
75
|
+
@presented_screen.close
|
76
|
+
@nav_screen.on_back_fired.should == true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should call the correct on_back method when nesting screens" do
|
80
|
+
@base_screen = NavigationScreen.new nav_bar: true
|
81
|
+
@child_screen = @base_screen.open NavigationScreen.new
|
82
|
+
@grandchild_screen = @child_screen.open NavigationScreen.new
|
83
|
+
|
84
|
+
# start closing
|
85
|
+
@grandchild_screen.close
|
86
|
+
@child_screen.on_back_fired.should == true
|
87
|
+
@child_screen.close
|
88
|
+
@base_screen.on_back_fired.should == true
|
89
|
+
end
|
71
90
|
|
72
91
|
it "should allow opening and closing a modal screen" do
|
73
92
|
@basic = BasicScreen.new(nav_bar: true)
|
@@ -99,27 +99,6 @@ describe "ProMotion::TableScreen functionality" do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
it "should call a method when the switch is flipped" do
|
103
|
-
table_screen.scroll_to_bottom
|
104
|
-
tap "switch_1"
|
105
|
-
wait 0.3 do
|
106
|
-
table_screen.tap_counter.should == 1
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should call the method with arguments when the switch is flipped and when the cell is tapped" do
|
111
|
-
table_screen.scroll_to_bottom
|
112
|
-
tap "switch_3"
|
113
|
-
wait 0.3 do
|
114
|
-
table_screen.tap_counter.should == 3
|
115
|
-
|
116
|
-
tap "Switch With Cell Tap, Switch Action And Parameters"
|
117
|
-
wait 0.3 do
|
118
|
-
table_screen.tap_counter.should == 13
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
102
|
it "should not crash if cell with editing_style is swiped left" do
|
124
103
|
Proc.new { flick("Just another deletable blank row", to: :left) }.should.not.raise(StandardError)
|
125
104
|
end
|
@@ -1,9 +1,19 @@
|
|
1
|
-
describe "ProMotion::Screen UIImage title" do
|
1
|
+
describe "ProMotion::Screen UIImage string title" do
|
2
2
|
def controller
|
3
3
|
@controller = ImageTitleScreen.new(nav_bar: true)
|
4
4
|
end
|
5
5
|
|
6
|
-
it "should allow an image title" do
|
6
|
+
it "should allow an image title as a String" do
|
7
|
+
controller.navigationItem.titleView.should.be.kind_of UIImageView
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "ProMotion::Screen UIImage title" do
|
12
|
+
def controller
|
13
|
+
@controller = UIImageTitleScreen.new(nav_bar: true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow an image title as a UIImage" do
|
7
17
|
controller.navigationItem.titleView.should.be.kind_of UIImageView
|
8
18
|
end
|
9
19
|
end
|
data/spec/unit/screen_spec.rb
CHANGED
@@ -268,3 +268,26 @@ describe "screen with toolbar" do
|
|
268
268
|
end
|
269
269
|
|
270
270
|
end
|
271
|
+
|
272
|
+
describe 'toolbar tinted buttons' do
|
273
|
+
before do
|
274
|
+
@screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true
|
275
|
+
@screen.on_load
|
276
|
+
end
|
277
|
+
|
278
|
+
it "creates string toolbar buttons with tint colors" do
|
279
|
+
@screen.set_toolbar_button([{title: "Testing Toolbar", tint_color: UIColor.redColor}])
|
280
|
+
@screen.navigationController.toolbar.items.first.tintColor.should == UIColor.redColor
|
281
|
+
end
|
282
|
+
|
283
|
+
it "creates image toolbar buttons with tint colors" do
|
284
|
+
@screen.set_toolbar_button([{image: UIImage.imageNamed("list"), tint_color: UIColor.redColor}])
|
285
|
+
@screen.navigationController.toolbar.items.first.tintColor.should == UIColor.redColor
|
286
|
+
end
|
287
|
+
|
288
|
+
it "creates system item toolbar buttons with tint colors" do
|
289
|
+
@screen.set_toolbar_button([{system_item: :reply, tint_color: UIColor.redColor}])
|
290
|
+
@screen.navigationController.toolbar.items.first.tintColor.should == UIColor.redColor
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
data/spec/unit/tab_bar_spec.rb
CHANGED
@@ -51,6 +51,8 @@ describe "PM::Table module" do
|
|
51
51
|
title: "Custom section title 1", title_view: CustomTitleView, cells: [ ]
|
52
52
|
},{
|
53
53
|
title: "Custom section title 2", title_view: CustomTitleView.new, title_view_height: 50, cells: [ ]
|
54
|
+
},{
|
55
|
+
title: "Action WIth Index Path Group", cells: [ cell_factory(title: "IndexPath Group 1", action: :tests_index_path) ]
|
54
56
|
}]
|
55
57
|
end
|
56
58
|
|
@@ -63,7 +65,7 @@ describe "PM::Table module" do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
it "should have the right number of sections" do
|
66
|
-
@subject.numberOfSectionsInTableView(@subject.table_view).should ==
|
68
|
+
@subject.numberOfSectionsInTableView(@subject.table_view).should == 7
|
67
69
|
end
|
68
70
|
|
69
71
|
it "should set the section titles" do
|
@@ -115,6 +117,17 @@ describe "PM::Table module" do
|
|
115
117
|
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:@custom_ip)
|
116
118
|
end
|
117
119
|
|
120
|
+
it "should return an NSIndexPath when the action has two parameters" do
|
121
|
+
ip = NSIndexPath.indexPathForRow(0, inSection: 6)
|
122
|
+
|
123
|
+
@subject.tableView(@subject.table_view, didSelectRowAtIndexPath:ip)
|
124
|
+
|
125
|
+
tapped_ip = @subject.got_index_path
|
126
|
+
tapped_ip.should.be.kind_of NSIndexPath
|
127
|
+
tapped_ip.section.should == 6
|
128
|
+
tapped_ip.row.should == 0
|
129
|
+
end
|
130
|
+
|
118
131
|
# TODO - make this test work when MacBacon supports long press gestures
|
119
132
|
# https://github.com/HipByte/RubyMotion/issues/160
|
120
133
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamon Holmgren
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: methadone
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/ProMotion/screen/screen.rb
|
114
114
|
- lib/ProMotion/screen/screen_module.rb
|
115
115
|
- lib/ProMotion/screen/screen_navigation.rb
|
116
|
+
- lib/ProMotion/stubs/dummy_image_view.rb
|
116
117
|
- lib/ProMotion/stubs/dummy_view.rb
|
117
118
|
- lib/ProMotion/styling/styling.rb
|
118
119
|
- lib/ProMotion/table/cell/table_view_cell_module.rb
|
@@ -125,6 +126,7 @@ files:
|
|
125
126
|
- lib/ProMotion/table/grouped_table_screen.rb
|
126
127
|
- lib/ProMotion/table/table.rb
|
127
128
|
- lib/ProMotion/table/table_screen.rb
|
129
|
+
- lib/ProMotion/table/table_utils.rb
|
128
130
|
- lib/ProMotion/tabs/tabs.rb
|
129
131
|
- lib/ProMotion/version.rb
|
130
132
|
- lib/ProMotion/web/web_screen.rb
|