ProMotion 1.0.2 → 1.0.3
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.
- data/.travis.yml +1 -2
- data/LICENSE +2 -2
- data/ProMotion.gemspec +1 -0
- data/lib/ProMotion/containers/tabs.rb +1 -1
- data/lib/ProMotion/table/cell/table_view_cell_module.rb +10 -2
- data/lib/ProMotion/table/data/table_data.rb +6 -3
- data/lib/ProMotion/table/table.rb +14 -3
- data/lib/ProMotion/version.rb +1 -1
- data/lib/ProMotion/web/web_screen_module.rb +3 -2
- data/spec/functional/func_searchable_table_spec.rb +12 -0
- data/spec/unit/tables/table_view_cell_spec.rb +30 -5
- metadata +4 -3
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2013 Jamon Holmgren
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/ProMotion.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
utilities to make iOS development more like Ruby and less like Objective-C.
|
13
13
|
"
|
14
14
|
gem.homepage = "https://github.com/clearsightstudio/ProMotion"
|
15
|
+
gem.license = 'MIT'
|
15
16
|
|
16
17
|
gem.files = `git ls-files`.split($\)
|
17
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -50,7 +50,11 @@ module ProMotion
|
|
50
50
|
|
51
51
|
def set_subtitle
|
52
52
|
if data_cell[:subtitle] && self.detailTextLabel
|
53
|
-
|
53
|
+
if data_cell[:subtitle].is_a? NSAttributedString
|
54
|
+
self.detailTextLabel.attributedText = data_cell[:subtitle]
|
55
|
+
else
|
56
|
+
self.detailTextLabel.text = data_cell[:subtitle]
|
57
|
+
end
|
54
58
|
self.detailTextLabel.backgroundColor = UIColor.clearColor
|
55
59
|
self.detailTextLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth
|
56
60
|
end
|
@@ -135,7 +139,11 @@ module ProMotion
|
|
135
139
|
cell_title = data_cell[:title]
|
136
140
|
cell_title ||= ""
|
137
141
|
self.textLabel.backgroundColor = UIColor.clearColor
|
138
|
-
|
142
|
+
if cell_title.is_a? NSAttributedString
|
143
|
+
self.textLabel.attributedText = cell_title
|
144
|
+
else
|
145
|
+
self.textLabel.text = cell_title
|
146
|
+
end
|
139
147
|
end
|
140
148
|
|
141
149
|
self
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ProMotion
|
2
2
|
class TableData
|
3
|
-
attr_accessor :data, :filtered_data, :filtered, :table_view
|
3
|
+
attr_accessor :data, :filtered_data, :search_string, :original_search_string, :filtered, :table_view
|
4
4
|
|
5
5
|
def initialize(data, table_view)
|
6
6
|
self.data = data
|
@@ -45,14 +45,15 @@ module ProMotion
|
|
45
45
|
self.filtered_data = []
|
46
46
|
self.filtered = true
|
47
47
|
|
48
|
-
|
48
|
+
self.original_search_string = search_string
|
49
|
+
self.search_string = search_string.downcase.strip
|
49
50
|
|
50
51
|
self.data.compact.each do |section|
|
51
52
|
new_section = {}
|
52
53
|
new_section[:cells] = []
|
53
54
|
|
54
55
|
new_section[:cells] = section[:cells].map do |cell|
|
55
|
-
cell[:searchable] != false && "#{cell[:title]}\n#{cell[:search_text]}".downcase.strip.include?(search_string) ? cell : nil
|
56
|
+
cell[:searchable] != false && "#{cell[:title]}\n#{cell[:search_text]}".downcase.strip.include?(self.search_string) ? cell : nil
|
56
57
|
end.compact
|
57
58
|
|
58
59
|
if new_section[:cells] && new_section[:cells].length > 0
|
@@ -67,6 +68,8 @@ module ProMotion
|
|
67
68
|
def stop_searching
|
68
69
|
self.filtered_data = []
|
69
70
|
self.filtered = false
|
71
|
+
self.search_string = false
|
72
|
+
self.original_search_string = false
|
70
73
|
end
|
71
74
|
|
72
75
|
def set_data_cell_defaults(data_cell)
|
@@ -31,6 +31,9 @@ module ProMotion
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def set_up_table_view
|
34
|
+
# before access self.table_data, create UITableView and call on_load
|
35
|
+
table_view
|
36
|
+
|
34
37
|
self.view = self.create_table_view_from_data(self.table_data)
|
35
38
|
end
|
36
39
|
|
@@ -59,6 +62,14 @@ module ProMotion
|
|
59
62
|
@promotion_table_data.filtered
|
60
63
|
end
|
61
64
|
|
65
|
+
def original_search_string
|
66
|
+
@promotion_table_data.original_search_string
|
67
|
+
end
|
68
|
+
|
69
|
+
def search_string
|
70
|
+
@promotion_table_data.search_string
|
71
|
+
end
|
72
|
+
|
62
73
|
def update_table_view_data(data)
|
63
74
|
create_table_view_from_data(data) unless @promotion_table_data
|
64
75
|
@promotion_table_data.data = data
|
@@ -242,9 +253,9 @@ module ProMotion
|
|
242
253
|
PM.logger.warn "ProMotion expects you to use 'delete_cell(index_paths, animation)'' instead of 'deleteRowsAtIndexPaths(index_paths, withRowAnimation:animation)'."
|
243
254
|
delete_row(index_paths, animation)
|
244
255
|
end
|
245
|
-
|
256
|
+
|
246
257
|
protected
|
247
|
-
|
258
|
+
|
248
259
|
def map_row_animation_symbol(symbol)
|
249
260
|
symbol ||= UITableViewRowAnimationAutomatic
|
250
261
|
{
|
@@ -288,7 +299,7 @@ module ProMotion
|
|
288
299
|
def get_refreshable_params
|
289
300
|
@refreshable_params ||= nil
|
290
301
|
end
|
291
|
-
|
302
|
+
|
292
303
|
# Indexable
|
293
304
|
def indexable(params = {})
|
294
305
|
@indexable_params = params
|
data/lib/ProMotion/version.rb
CHANGED
@@ -100,10 +100,11 @@ module ProMotion
|
|
100
100
|
alias :reload :refresh
|
101
101
|
|
102
102
|
def open_in_chrome(inRequest)
|
103
|
-
# Add pod 'OpenInChrome' to your Rakefile if you want links to open in
|
103
|
+
# Add pod 'OpenInChrome' to your Rakefile if you want links to open in Google Chrome for users.
|
104
|
+
# This will fall back to Safari if the user doesn't have Chrome installed.
|
104
105
|
chrome_controller = OpenInChromeController.sharedInstance
|
105
106
|
return open_in_safari(inRequest) unless chrome_controller.isChromeInstalled
|
106
|
-
chrome_controller.
|
107
|
+
chrome_controller.openInChrome(inRequest.URL)
|
107
108
|
end
|
108
109
|
|
109
110
|
def open_in_safari(inRequest)
|
@@ -29,4 +29,16 @@ describe "Searchable table spec" do
|
|
29
29
|
@controller.tableView(@controller.tableView, numberOfRowsInSection:0).should == 50
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should expose the search_string variable and clear it properly" do
|
33
|
+
@controller.searchDisplayController(@controller, shouldReloadTableForSearchString:"North")
|
34
|
+
|
35
|
+
@controller.search_string.should == "north"
|
36
|
+
@controller.original_search_string.should == "North"
|
37
|
+
|
38
|
+
@controller.searchDisplayControllerWillEndSearch(@controller)
|
39
|
+
|
40
|
+
@controller.search_string.should == false
|
41
|
+
@controller.original_search_string.should == false
|
42
|
+
end
|
43
|
+
|
32
44
|
end
|
@@ -19,26 +19,43 @@ describe "PM::TableViewCellModule" do
|
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
|
+
def attributed_cell
|
23
|
+
{
|
24
|
+
title: NSMutableAttributedString.alloc.initWithString("Attributed Title"),
|
25
|
+
subtitle: NSMutableAttributedString.alloc.initWithString("Attributed Subtitle"),
|
26
|
+
cell_style: UITableViewCellStyleSubtitle
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
22
30
|
before do
|
23
31
|
@screen = TestTableScreen.new
|
24
32
|
button = UIButton.buttonWithType(UIButtonTypeRoundedRect).tap{|b| b.titleLabel.text = "ACC" }
|
25
33
|
@screen.mock! :table_data do
|
26
34
|
[
|
27
|
-
{
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
{
|
36
|
+
title: "", cells: []
|
37
|
+
},
|
38
|
+
{
|
39
|
+
title: "",
|
40
|
+
cells: [
|
41
|
+
{ title: "Test 1", accessory_type: UITableViewCellStateShowingEditControlMask },
|
42
|
+
custom_cell,
|
43
|
+
{ title: "Test2", accessory: { view: button } },
|
44
|
+
attributed_cell
|
45
|
+
]
|
46
|
+
}
|
32
47
|
]
|
33
48
|
end
|
34
49
|
|
35
50
|
@screen.on_load
|
36
51
|
|
37
52
|
@custom_ip = NSIndexPath.indexPathForRow(1, inSection: 1) # Cell "Crazy Full Featured Cell"
|
53
|
+
@attributed_ip = NSIndexPath.indexPathForRow(3, inSection: 1) # Attributed Cell
|
38
54
|
|
39
55
|
@screen.update_table_data
|
40
56
|
|
41
57
|
@subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: @custom_ip)
|
58
|
+
@attributed_subject = @screen.tableView(@screen.table_view, cellForRowAtIndexPath: @attributed_ip)
|
42
59
|
end
|
43
60
|
|
44
61
|
it "should be a PM::TableViewCell" do
|
@@ -49,6 +66,14 @@ describe "PM::TableViewCellModule" do
|
|
49
66
|
@subject.textLabel.text.should == "Crazy Full Featured Cell"
|
50
67
|
end
|
51
68
|
|
69
|
+
it "should allow attributed title" do
|
70
|
+
@attributed_subject.textLabel.attributedText.mutableString.should == "Attributed Title"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should allow attributed subtitle" do
|
74
|
+
@attributed_subject.detailTextLabel.attributedText.mutableString.should == "Attributed Subtitle"
|
75
|
+
end
|
76
|
+
|
52
77
|
it "should have the right subtitle" do
|
53
78
|
@subject.detailTextLabel.text.should == "This is way too huge..."
|
54
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
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-
|
14
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: webstub
|
@@ -197,7 +197,8 @@ files:
|
|
197
197
|
- spec/unit/view_helper_spec.rb
|
198
198
|
- spec/unit/web_spec.rb
|
199
199
|
homepage: https://github.com/clearsightstudio/ProMotion
|
200
|
-
licenses:
|
200
|
+
licenses:
|
201
|
+
- MIT
|
201
202
|
post_install_message:
|
202
203
|
rdoc_options: []
|
203
204
|
require_paths:
|