motion-table 0.1.0

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/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .repl_history
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in motion-table.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 ClearSight Studio
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # MotionTable
2
+
3
+ MotionTable is a RubyMotion gem for easily building table views in iOS.
4
+
5
+ *This gem has not been published to rubygems.org*
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'motion-table', :git => 'git@github.com:clearsightstudio/motion-table.git'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install motion-table
20
+
21
+ ## Please Note
22
+
23
+ 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.
24
+
25
+ ## Usage
26
+
27
+ Include MotionTable in your controller and handle UITableViews Easily
28
+
29
+ ```ruby
30
+ class MyController < UITableViewController
31
+ include MotionTable::GroupedTable
32
+
33
+ def viewDidLoad
34
+ super
35
+ self.title = "Settings"
36
+
37
+ @grouped_table_view_data ||= [
38
+ {
39
+ title: "Your Account",
40
+ cells: [
41
+ { title: "Edit Profile", action: :edit_profile },
42
+ { title: "Log Out", action: :log_out },
43
+ ]
44
+ },
45
+ {
46
+ title: "My App",
47
+ cells: [
48
+ { title: "About", action: :something_here },
49
+ { title: "Feedback", action: :something_here }
50
+ ]
51
+ }
52
+ ]
53
+
54
+ self.view = self.createTableViewFromData(@grouped_table_view_data)
55
+ end
56
+
57
+ def log_out
58
+ # This will be called when the Log Out table cell is pressed
59
+ end
60
+
61
+ def edit_profile
62
+ # Implement your edit_profile view here
63
+ end
64
+ end
65
+ ```
66
+
67
+ [<img src="http://i.imgur.com/lCIU6.png">]
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ $:.unshift("/Library/RubyMotion/lib")
2
+ require 'motion/project'
3
+ require 'bundler'
4
+ Bundler.setup
@@ -0,0 +1,55 @@
1
+ module MotionTable
2
+ module GroupedTable
3
+ def createTableViewFromData(data)
4
+ @mt_table_view_groups = data
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
+ end
46
+ end
47
+
48
+ def tableView
49
+ @tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStyleGrouped)
50
+ @tableView.dataSource = self;
51
+ @tableView.delegate = self;
52
+ return @tableView
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module MotionTable
2
+ VERSION = "0.1.0" unless defined?(MotionTable::VERSION)
3
+ end
@@ -0,0 +1,11 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ require "motion-table/version"
6
+
7
+ Motion::Project::App.setup do |app|
8
+ Dir.glob(File.join(File.dirname(__FILE__), "motion-table/*.rb")).each do |file|
9
+ app.files.unshift(file)
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-table/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["ClearSight Studio"]
6
+ gem.email = ["contact@clearsightstudio.com"]
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."
9
+ gem.homepage = "https://github.com/clearsightstudio/motion-table"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "motion-table"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = MotionTable::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-table
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ClearSight Studio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
15
+ from a UITableViewController.
16
+ email:
17
+ - contact@clearsightstudio.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - lib/motion-table.rb
28
+ - lib/motion-table/grouped_table.rb
29
+ - lib/motion-table/version.rb
30
+ - motion-table.gemspec
31
+ homepage: https://github.com/clearsightstudio/motion-table
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.22
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: MotionTable is a RubyMotion gem that makes it easy to handle UITableViews
55
+ from a UITableViewController.
56
+ test_files: []
57
+ has_rdoc: