motion-table 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -2
- data/lib/motion-table/console.rb +2 -0
- data/lib/motion-table/grouped_table.rb +2 -47
- data/lib/motion-table/plain_table.rb +12 -0
- data/lib/motion-table/sectioned_table.rb +55 -0
- data/lib/motion-table/version.rb +1 -1
- data/motion-table.gemspec +1 -1
- metadata +5 -3
data/README.md
CHANGED
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
MotionTable is a RubyMotion gem for easily building table views in iOS.
|
4
4
|
|
5
|
-
*RubyGems.org does not have the current version of this gem.*
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
8
|
Add this line to your application's Gemfile:
|
10
9
|
|
11
|
-
gem 'motion-table'
|
10
|
+
gem 'motion-table'
|
12
11
|
|
13
12
|
And then execute:
|
14
13
|
|
@@ -18,6 +17,10 @@ Or install it yourself as:
|
|
18
17
|
|
19
18
|
$ gem install motion-table
|
20
19
|
|
20
|
+
Alternatively, get the edge version:
|
21
|
+
|
22
|
+
gem 'motion-table', :git => 'git@github.com:clearsightstudio/motion-table.git'
|
23
|
+
|
21
24
|
## Please Note
|
22
25
|
|
23
26
|
We only have GroupedTables implemented at this point. We will be adding functionality, but if you need something else, fork it, add it and submit a pull request.
|
data/lib/motion-table/console.rb
CHANGED
@@ -3,6 +3,8 @@ module MotionTable
|
|
3
3
|
NAME = "MotionTable::Console"
|
4
4
|
DEFAULT_COLOR = [ '', '' ]
|
5
5
|
RED_COLOR = [ "\e[0;31m", "\e[0m" ] # Must be in double quotes
|
6
|
+
GREEN_COLOR = [ "\e[0;32m", "\e[0m" ]
|
7
|
+
PURPLE_COLOR = [ "\e[0;35m", "\e[0m" ]
|
6
8
|
|
7
9
|
class << self
|
8
10
|
def log(obj, actionNotImplemented:action)
|
@@ -1,52 +1,7 @@
|
|
1
1
|
module MotionTable
|
2
2
|
module GroupedTable
|
3
|
-
|
4
|
-
|
5
|
-
return tableView
|
6
|
-
end
|
7
|
-
|
8
|
-
def numberOfSectionsInTableView(tableView)
|
9
|
-
return @mt_table_view_groups.length
|
10
|
-
end
|
11
|
-
|
12
|
-
# Number of cells
|
13
|
-
def tableView(tableView, numberOfRowsInSection:section)
|
14
|
-
return sectionAtIndex(section)[:cells].length
|
15
|
-
end
|
16
|
-
|
17
|
-
def tableView(tableView, titleForHeaderInSection:section)
|
18
|
-
return sectionAtIndex(section)[:title]
|
19
|
-
end
|
20
|
-
|
21
|
-
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
22
|
-
cellIdentifier = "Cell"
|
23
|
-
|
24
|
-
cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
|
25
|
-
cell ||= UITableViewCell.alloc.initWithFrame(CGRectZero, reuseIdentifier:cellIdentifier)
|
26
|
-
|
27
|
-
row = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
28
|
-
cell.text = row[:title]
|
29
|
-
return cell
|
30
|
-
end
|
31
|
-
|
32
|
-
def sectionAtIndex(index)
|
33
|
-
@mt_table_view_groups.at(index)
|
34
|
-
end
|
35
|
-
|
36
|
-
def cellAtSectionAndIndex(section, index)
|
37
|
-
return sectionAtIndex(section)[:cells].at(index)
|
38
|
-
end
|
39
|
-
|
40
|
-
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
|
41
|
-
cell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
42
|
-
tableView.deselectRowAtIndexPath(indexPath, animated: true);
|
43
|
-
if self.respond_to?(cell[:action])
|
44
|
-
self.send(cell[:action])
|
45
|
-
else
|
46
|
-
MotionTable::Console.log(self, actionNotImplemented: cell[:action])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
3
|
+
include MotionTable::SectionedTable
|
4
|
+
|
50
5
|
def tableView
|
51
6
|
@tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStyleGrouped)
|
52
7
|
@tableView.dataSource = self;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module MotionTable
|
2
|
+
module PlainTable
|
3
|
+
include MotionTable::SectionedTable
|
4
|
+
|
5
|
+
def tableView
|
6
|
+
@tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStylePlain)
|
7
|
+
@tableView.dataSource = self;
|
8
|
+
@tableView.delegate = self;
|
9
|
+
return @tableView
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MotionTable
|
2
|
+
module SectionedTable
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.send :extend, MotionTable::SectionedTable
|
6
|
+
end
|
7
|
+
|
8
|
+
def createTableViewFromData(data)
|
9
|
+
@mt_table_view_groups = data
|
10
|
+
return tableView
|
11
|
+
end
|
12
|
+
|
13
|
+
def numberOfSectionsInTableView(tableView)
|
14
|
+
return @mt_table_view_groups.length
|
15
|
+
end
|
16
|
+
|
17
|
+
# Number of cells
|
18
|
+
def tableView(tableView, numberOfRowsInSection:section)
|
19
|
+
return sectionAtIndex(section)[:cells].length
|
20
|
+
end
|
21
|
+
|
22
|
+
def tableView(tableView, titleForHeaderInSection:section)
|
23
|
+
return sectionAtIndex(section)[:title]
|
24
|
+
end
|
25
|
+
|
26
|
+
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
27
|
+
cellIdentifier = "Cell"
|
28
|
+
|
29
|
+
cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
|
30
|
+
cell ||= UITableViewCell.alloc.initWithFrame(CGRectZero, reuseIdentifier:cellIdentifier)
|
31
|
+
|
32
|
+
row = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
33
|
+
cell.text = row[:title]
|
34
|
+
return cell
|
35
|
+
end
|
36
|
+
|
37
|
+
def sectionAtIndex(index)
|
38
|
+
@mt_table_view_groups.at(index)
|
39
|
+
end
|
40
|
+
|
41
|
+
def cellAtSectionAndIndex(section, index)
|
42
|
+
return sectionAtIndex(section)[:cells].at(index)
|
43
|
+
end
|
44
|
+
|
45
|
+
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
|
46
|
+
cell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
47
|
+
tableView.deselectRowAtIndexPath(indexPath, animated: true);
|
48
|
+
if self.respond_to?(cell[:action])
|
49
|
+
self.send(cell[:action])
|
50
|
+
else
|
51
|
+
MotionTable::Console.log(self, actionNotImplemented: cell[:action])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/motion-table/version.rb
CHANGED
data/motion-table.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["ClearSight Studio"]
|
6
6
|
gem.email = ["contact@clearsightstudio.com"]
|
7
7
|
gem.description = "MotionTable is a RubyMotion gem that makes it easy to handle UITableViews from a UITableViewController."
|
8
|
-
gem.summary = "MotionTable is a RubyMotion gem that makes it easy to handle UITableViews from a UITableViewController."
|
8
|
+
gem.summary = "MotionTable is a RubyMotion gem that makes it easy to handle UITableViews from a UITableViewController. Simply include in the module in your controller."
|
9
9
|
gem.homepage = "https://github.com/clearsightstudio/motion-table"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
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.3
|
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-08-
|
12
|
+
date: 2012-08-27 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.
|
@@ -28,6 +28,8 @@ files:
|
|
28
28
|
- lib/motion-table.rb
|
29
29
|
- lib/motion-table/console.rb
|
30
30
|
- lib/motion-table/grouped_table.rb
|
31
|
+
- lib/motion-table/plain_table.rb
|
32
|
+
- lib/motion-table/sectioned_table.rb
|
31
33
|
- lib/motion-table/version.rb
|
32
34
|
- motion-table.gemspec
|
33
35
|
- spec/console_spec.rb
|
@@ -56,7 +58,7 @@ rubygems_version: 1.8.22
|
|
56
58
|
signing_key:
|
57
59
|
specification_version: 3
|
58
60
|
summary: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
|
59
|
-
from a UITableViewController.
|
61
|
+
from a UITableViewController. Simply include in the module in your controller.
|
60
62
|
test_files:
|
61
63
|
- spec/console_spec.rb
|
62
64
|
- spec/grouped_table_spec.rb
|