motion-table 0.1.6 → 0.1.7
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/README.md +6 -11
- data/lib/motion-table/searchable_table.rb +17 -6
- data/lib/motion-table/sectioned_table.rb +30 -12
- data/lib/motion-table/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
|
@@ -45,9 +45,11 @@ class MyController < UITableViewController
|
|
|
45
45
|
title: "My App Settings",
|
|
46
46
|
cells: [{
|
|
47
47
|
title: "Be Awesome",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
subtitle: "Do so. Please."
|
|
49
|
+
image: {
|
|
50
|
+
image: UIImage.imageNamed("image"),
|
|
51
|
+
radius: 12
|
|
52
|
+
}
|
|
51
53
|
}, {
|
|
52
54
|
title: "Mute",
|
|
53
55
|
accessory: :switch,
|
|
@@ -68,12 +70,6 @@ class MyController < UITableViewController
|
|
|
68
70
|
# Implement your edit_profile view here
|
|
69
71
|
end
|
|
70
72
|
|
|
71
|
-
def save_being_awesome(args)
|
|
72
|
-
# Depending on whether the switch is on or off,
|
|
73
|
-
# args => { value: true } or
|
|
74
|
-
# args => { value: false }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
73
|
def save_mute(args)
|
|
78
74
|
# Depending on whether the switch is on or off,
|
|
79
75
|
# args => { value: true } or
|
|
@@ -87,7 +83,6 @@ end
|
|
|
87
83
|
```ruby
|
|
88
84
|
class MyController < UITableViewController
|
|
89
85
|
include MotionTable::PlainTable
|
|
90
|
-
inclued MotionTable::SearchableTable # For search capability
|
|
91
86
|
|
|
92
87
|
def viewDidLoad
|
|
93
88
|
super
|
|
@@ -108,7 +103,7 @@ class MyController < UITableViewController
|
|
|
108
103
|
}
|
|
109
104
|
]
|
|
110
105
|
|
|
111
|
-
self.makeSearchable # Will add search capability
|
|
106
|
+
self.makeSearchable # Will add search capability, nothing more needed :)
|
|
112
107
|
self.view = self.createTableViewFromData(@plain_table_view_data)
|
|
113
108
|
end
|
|
114
109
|
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
module MotionTable
|
|
2
2
|
module SearchableTable
|
|
3
|
-
def makeSearchable
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
def makeSearchable(params={})
|
|
4
|
+
params[:frame] ||= CGRectMake(0, 0, 320, 44)
|
|
5
|
+
params[:contentController] ||= self
|
|
6
|
+
params[:delegate] ||= self
|
|
7
|
+
params[:searchResultsDataSource] ||= self
|
|
8
|
+
params[:searchResultsDelegate] ||= self
|
|
9
|
+
|
|
10
|
+
searchBar = UISearchBar.alloc.initWithFrame(params[:frame])
|
|
11
|
+
if params[:searchBar] && params[:searchBar][:placeholder]
|
|
12
|
+
searchBar.placeholder = params[:searchBar][:placeholder]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
@contactsSearchDisplayController = UISearchDisplayController.alloc.initWithSearchBar(searchBar, contentsController: params[:contentController])
|
|
16
|
+
@contactsSearchDisplayController.delegate = params[:delegate]
|
|
17
|
+
@contactsSearchDisplayController.searchResultsDataSource = params[:searchResultsDataSource]
|
|
18
|
+
@contactsSearchDisplayController.searchResultsDelegate = params[:searchResultsDelegate]
|
|
9
19
|
|
|
10
20
|
self.tableView.tableHeaderView = searchBar
|
|
11
21
|
end
|
|
@@ -33,6 +43,7 @@ module MotionTable
|
|
|
33
43
|
|
|
34
44
|
def searchDisplayControllerWillEndSearch(controller)
|
|
35
45
|
@mt_table_view_groups = @original_data.clone
|
|
46
|
+
@original_data = nil
|
|
36
47
|
end
|
|
37
48
|
|
|
38
49
|
def searchDisplayControllerWillBeginSearch(controller)
|
|
@@ -30,28 +30,47 @@ module MotionTable
|
|
|
30
30
|
def tableView(tableView, titleForHeaderInSection:section)
|
|
31
31
|
return sectionAtIndex(section)[:title]
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
# Set table_data_index if you want the right hand index column (jumplist)
|
|
35
|
+
def sectionIndexTitlesForTableView(tableView)
|
|
36
|
+
self.table_data_index if respond_to? :table_data_index
|
|
37
|
+
end
|
|
38
|
+
|
|
33
39
|
|
|
34
40
|
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
|
35
41
|
dataCell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
|
42
|
+
dataCell[:cellStyle] ||= UITableViewCellStyleDefault
|
|
36
43
|
|
|
37
44
|
cellIdentifier = "Cell"
|
|
38
45
|
|
|
39
46
|
tableCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
|
|
40
47
|
unless tableCell
|
|
41
|
-
tableCell = UITableViewCell.alloc.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
tableCell = UITableViewCell.alloc.initWithStyle(dataCell[:cellStyle], reuseIdentifier:cellIdentifier)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
tableCell.accessoryView = dataCell[:accessoryView] if dataCell[:accessoryView]
|
|
52
|
+
|
|
53
|
+
if dataCell[:accessory] && dataCell[:accessory] == :switch
|
|
54
|
+
switchView = UISwitch.alloc.initWithFrame(CGRectZero)
|
|
55
|
+
switchView.addTarget(self, action: "accessoryToggledSwitch:", forControlEvents:UIControlEventValueChanged);
|
|
56
|
+
switchView.on = true if dataCell[:accessoryDefault]
|
|
57
|
+
tableCell.accessoryView = switchView
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if dataCell[:subtitle]
|
|
61
|
+
tableCell.detailTextLabel.text = dataCell[:subtitle]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if dataCell[:image]
|
|
66
|
+
tableCell.imageView.layer.masksToBounds = true
|
|
67
|
+
tableCell.imageView.image = dataCell[:image][:image]
|
|
68
|
+
tableCell.imageView.layer.cornerRadius = dataCell[:image][:radius] if dataCell[:image][:radius]
|
|
50
69
|
end
|
|
70
|
+
|
|
51
71
|
tableCell.text = dataCell[:title]
|
|
52
72
|
return tableCell
|
|
53
73
|
end
|
|
54
|
-
|
|
55
74
|
def sectionAtIndex(index)
|
|
56
75
|
@mt_table_view_groups.at(index)
|
|
57
76
|
end
|
|
@@ -79,12 +98,11 @@ module MotionTable
|
|
|
79
98
|
end
|
|
80
99
|
|
|
81
100
|
def triggerAction(action, arguments)
|
|
82
|
-
$stderr.puts "Action: #{action.to_s} and args #{arguments.to_s}"
|
|
83
101
|
if self.respond_to?(action)
|
|
84
102
|
expectedArguments = self.method(action).arity
|
|
85
103
|
if expectedArguments == 0
|
|
86
104
|
self.send(action)
|
|
87
|
-
elsif expectedArguments == 1
|
|
105
|
+
elsif expectedArguments == 1 || expectedArguments == -1
|
|
88
106
|
self.send(action, arguments)
|
|
89
107
|
else
|
|
90
108
|
MotionTable::Console.log("MotionTable warning: #{action} expects #{expectedArguments} arguments. Maximum number of required arguments for an action is 1.", withColor: MotionTable::Console::RED_COLOR)
|
data/lib/motion-table/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: motion-table
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
|
|
15
15
|
from a UITableViewController. Simply include in the module in your controller.
|