motion-animated-cell-table 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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzkwZTFlMTY0YThjMTFhODExZWViZmFlNjYxYzdmOTY3NjQ2ZGVlMQ==
5
+ data.tar.gz: !binary |-
6
+ YTAwMDU4YjdjMTQ3NGFkNTNmZmZlMjUxMzBkM2U2YjA3OTY4YmU4Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTYxNGY1ZGRhZDQ0NDBjZjA1YTM5OGZhZGZmNDQxODQ1MWQxZWQzYTVlN2Zi
10
+ NjE1NjhkYjgzMjIzOTQzNTY1Y2Q3MWQxMGY1MWUyMDhmNWJmY2Y5ZDkyYzFl
11
+ N2MyYjhiNWM4NGIyMmNkZjcyMmIxYjI5ZTA5MmE2NjRjNzQ2MzU=
12
+ data.tar.gz: !binary |-
13
+ MmE2MWE0ODcwOGQyZDNkMmQyYTQyNTQ0ZTU1ZGYzYjQyNzA1MGRmYTc4YzMy
14
+ ZGFlYjllZDczZThlZWU3NGQ3NTA2NDFjYzFjMTg3MzdhZDI0YzJkNDNmYzU3
15
+ YWE1ZWRlZDBlZTc5NDQwYjEzYWY3MWY4YWRiMzhhOTJhZGI1ZGM=
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ vendor/
19
+ build/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in motion-animated-cell-table.gemspec
4
+ gem 'motion-animated-cell-table'
5
+ gem 'motion-linear-animate'
6
+ gem 'afmotion'
7
+ gem 'motion-facon'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jerry
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,92 @@
1
+ iOS (RubyMotion) Animated Cell Table Controller
2
+ ============================
3
+
4
+ This is a library that paves way for programmers to apply fancy animations on tapped cells. When a cell on a table is tapped, this library pops out the view of that cell. This view can be played around with as much as the imagination of the programmer lets him :). And there's more - there's a final means of wrapping it all up - placing the view back in its original slot! Check out the sample app to get a better picture. As always, hearty thanks to team [lorempixel](http://lorempixel.com/) for their super awesome placeholder images.
5
+
6
+ ![Sample Implementation](http://dl.dropboxusercontent.com/s/gbtm147szkgrd6b/animated_cell_sample.gif)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+ ```ruby
12
+ gem 'motion-animated-cell-table'
13
+ ```
14
+
15
+ And then execute:
16
+ ```ruby
17
+ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+ ```ruby
22
+ gem install motion-animated-cell-table
23
+ ```
24
+
25
+ ## Sample App
26
+
27
+ A sample app is included for reference. To get it up and running, simply clone the repository and run ```rake``` or ```rake device``` depending on whether you want to preview it in the simulator or device.
28
+
29
+
30
+ ## Usage
31
+
32
+ There are a two things that you need to set up first:
33
+ 1. A table cell and its corresponding view (you can also use the default iOS cell)
34
+ 2. A duplicate view for the cell (the one that gets popped out)
35
+
36
+ The table cell needs to implement a special method called ```set_up_duplicate_cell_view``` which accepts two parameters. The first is an instance of ```CGPoint``` that gives the x,y position of the cell on the screen and the second is an instance of ```CGSize``` that gives the dimensions of the cell. These two parameters can be used to construct the duplicate view and place it appropriately on the screen. Please refer to the sample app to get an exemplified version of this.
37
+
38
+ Let's call the table cell ```CustomCell```, its view ```CustomCellView``` and the duplicate view ```DuplicateCustomCellView```. Now, here's how you can use the library:
39
+
40
+ 1. Initialize the table view controller:
41
+ ```ruby
42
+ table = AnimatedCellTableViewController.new
43
+ ```
44
+
45
+ 2. There are very many attributes of the table you can set since it is ultimately a table view controller, but here are the are a few that need to be set mandatorily for the library - the delegate controller for the table, the height of the cells and the number of rows in the table:
46
+ ```ruby
47
+ table.delegate_controller = <DELEGATE_CONTROLLER>
48
+ table.height_of_cell = <HEIGHT_OF_INDIVIDUAL_CELL>
49
+ table.number_of_rows = <NUMBER_OF_ROWS_REQUIRED>
50
+ ```
51
+
52
+ 3. There are delegate methods for creating the individual cells and deciding what to do when a cell is tapped.
53
+ ```ruby
54
+ def cell_was_tapped index, duplicate_cell_view
55
+ # index is the position of the cell in the table
56
+ # duplicate_cell_view is the duplicate view returned from the set_up_duplicate_cell_view method
57
+ end
58
+ ```
59
+ ```ruby
60
+ def create_reusable_cell index, reusable_identifier
61
+ # this is simply a wrapper over the standard cellForRowAtIndexPath method
62
+ # index is the position the cell needs to be created in and can be used for the data selection
63
+ # reusable_identifier is the iOS table reuse identifier
64
+ end
65
+ ```
66
+
67
+ 4. In addition to these fundamental methods, there are two more methods that can be used to show and hide the table:
68
+ ```ruby
69
+ table.show_table_view(duration) # duration is in seconds
70
+ ```
71
+ ```ruby
72
+ table.hide_table_view(duration) # duration is in seconds
73
+ ```
74
+
75
+ 5. And there's more - an extra level of tweaking can be done using two more delegate methods. One is called after the ```show_table_view``` animation is complete and one after the ```hide_table_view``` animation is complete.
76
+
77
+ ```ruby
78
+ def after_show_table_view
79
+ end
80
+ ```
81
+ ```ruby
82
+ def after_hide_table_view
83
+ end
84
+ ```
85
+
86
+ ## Contributing
87
+
88
+ 1. Fork it ( http://github.com/multunus/motion-animated-cell-table/fork )
89
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
90
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
91
+ 4. Push to the branch (`git push origin my-new-feature`)
92
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+ require 'motion/project/template/ios'
4
+
5
+ begin
6
+ require 'bundler'
7
+ Bundler.require
8
+ rescue LoadError
9
+ end
10
+
11
+ Motion::Project::App.setup do |app|
12
+ # Use `rake config' to see complete project settings.
13
+ app.name = 'sample_animated_cell_app'
14
+ end
@@ -0,0 +1,8 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ @window.makeKeyAndVisible
5
+ @window.rootViewController = ScreenController.alloc.initWithNibName(nil, bundle: nil)
6
+ true
7
+ end
8
+ end
Binary file
@@ -0,0 +1,90 @@
1
+ class ScreenController < UIViewController
2
+ attr_accessor :table, :items_list
3
+
4
+ def viewDidLoad
5
+ super
6
+ populate_sample_data
7
+ set_up_initial_layout
8
+ @animator = MotionAnimator.new
9
+ end
10
+
11
+ def set_up_initial_layout
12
+ self.view.backgroundColor = UIColor.whiteColor
13
+ @table = set_up_table
14
+ @button = set_up_reverse_animator_button
15
+ hide_reverse_animator_button
16
+ self.view.addSubview(@table.view)
17
+ self.view.addSubview(@button)
18
+ end
19
+
20
+ def set_up_table
21
+ table = AnimatedCellTableViewController.new
22
+ table.height_of_cell = 60
23
+ table.number_of_rows = self.items_list.count
24
+ table.tableView.frame = self.view.bounds
25
+ table.delegate_controller = self
26
+ table.tableView.backgroundColor = UIColor.clearColor
27
+ table.tableView.separatorStyle = UITableViewCellSeparatorStyleNone
28
+ table
29
+ end
30
+
31
+ def set_up_reverse_animator_button
32
+ animator_button = UIButton.buttonWithType(UIButtonTypeCustom)
33
+ animator_button.layer.cornerRadius = 10.0
34
+ animator_button.addTarget(self, action: "perform_reverse_animation:", forControlEvents:UIControlEventTouchDown)
35
+ animator_button.backgroundColor = UIColor.blackColor
36
+ animator_button.setTitle("Reverse Animation", forState:UIControlStateNormal)
37
+ animator_button.frame = CGRectMake(80.0, 440.0, 160.0, 40.0)
38
+ animator_button
39
+ end
40
+
41
+ def cell_was_tapped index, duplicate_cell_view
42
+ @duplicate_cell_view = duplicate_cell_view
43
+ @original_view_position = @duplicate_cell_view.frame.origin
44
+ self.view.addSubview(@duplicate_cell_view)
45
+ self.view.bringSubviewToFront(@duplicate_cell_view)
46
+ @table.hide_table_view(0.3)
47
+ end
48
+
49
+ def create_reusable_cell index, reusable_identifier
50
+ custom_cell = CustomCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: reusable_identifier)
51
+ cell_dimensions = CGSizeMake(320, 60)
52
+ cell_position = CGPointMake(0, 0)
53
+ custom_cell.set_up_cell(cell_position, cell_dimensions, self.items_list[index])
54
+ custom_cell
55
+ end
56
+
57
+ def perform_reverse_animation sender
58
+ hide_reverse_animator_button
59
+ @animator.linear_animate(@duplicate_cell_view, to: @original_view_position, duration: 0.3, completion: nil)
60
+ @table.show_table_view(0.3)
61
+ end
62
+
63
+ def after_show_table_view
64
+ @duplicate_cell_view.removeFromSuperview
65
+ end
66
+
67
+ def after_hide_table_view
68
+ final_point = CGPointMake(0,0)
69
+ @animator.linear_animate(@duplicate_cell_view, to: final_point, duration: 0.3, completion: lambda{|completion| show_reverse_animator_button})
70
+ end
71
+
72
+ def show_reverse_animator_button
73
+ @button.alpha = 1
74
+ end
75
+
76
+ def hide_reverse_animator_button
77
+ @button.alpha = 0
78
+ end
79
+
80
+ def populate_sample_data
81
+ self.items_list = []
82
+ 10.times do |n|
83
+ self.items_list << "http://lorempixel.com/320/60/technics/#{n}"
84
+ end
85
+ end
86
+
87
+ def prefersStatusBarHidden
88
+ true
89
+ end
90
+ end
Binary file
@@ -0,0 +1,20 @@
1
+ class CustomCell < UITableViewCell
2
+ attr_reader :custom_cell_view
3
+
4
+ def set_up_cell(cell_position, cell_dimensions, image_url)
5
+ @custom_cell_view = CustomCellView.new
6
+ @custom_cell_view.set_up_view(cell_dimensions, image_url)
7
+ self.addSubview(@custom_cell_view)
8
+ end
9
+
10
+ def set_up_duplicate_cell_view(view_position, view_dimensions)
11
+ duplicate_custom_cell_view = DuplicateCustomCellView.new
12
+ image = @custom_cell_view.image_view.image
13
+ duplicate_custom_cell_view.set_up_view(view_position, view_dimensions, image)
14
+ duplicate_custom_cell_view
15
+ end
16
+
17
+ def get_frame_size
18
+ @custom_cell_view.frame.size
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ class CustomCellView < UIView
2
+ attr_reader :image_view
3
+
4
+ def set_up_view(cell_dimensions, image_url)
5
+ self.frame = CGRectMake(0, 0, cell_dimensions.width, cell_dimensions.height)
6
+ @image_view = set_up_image_view(cell_dimensions, image_url)
7
+ self.addSubview(@image_view)
8
+ end
9
+
10
+ def set_up_image_view(cell_dimensions, image_url)
11
+ image_view = UIImageView.alloc.initWithFrame(CGRectMake(0, 0, cell_dimensions.width, cell_dimensions.height))
12
+ image_view.setImageWithURL(NSURL.URLWithString(image_url))
13
+ image_view
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class DuplicateCustomCellView < UIView
2
+
3
+ def set_up_view(view_position, view_dimensions, image)
4
+ self.frame = CGRectMake(view_position.x, view_position.y, view_dimensions.width, view_dimensions.height)
5
+ image_view = set_up_image_view(view_dimensions, image)
6
+ self.addSubview(image_view)
7
+ end
8
+
9
+ def set_up_image_view(view_dimensions, image)
10
+ image_view = UIImageView.alloc.initWithFrame(CGRectMake(0, 0, view_dimensions.width, view_dimensions.height))
11
+ image_view.setImage image
12
+ image_view
13
+ end
14
+
15
+ end
@@ -0,0 +1,9 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ Dir.glob(File.join(File.dirname(__FILE__), "motion-animated-cell-table/*.rb")).each do |file|
7
+ app.files.unshift(file)
8
+ end
9
+ end
@@ -0,0 +1,89 @@
1
+ class AnimatedCellTableViewController < UITableViewController
2
+ attr_accessor :delegate_controller, :height_of_cell, :number_of_rows
3
+
4
+ def tableView(table_view, didSelectRowAtIndexPath: index_path)
5
+ duplicate_cell_view = create_duplicate_view_from_cell(table_view, index_path)
6
+ toggle_cell_visibility(table_view, index_path)
7
+ self.delegate_controller.cell_was_tapped(index_path.row, duplicate_cell_view)
8
+ end
9
+
10
+ def create_duplicate_view_from_cell(table_view, index_path)
11
+ cell = tableView(table_view, cellForRowAtIndexPath: index_path)
12
+ view_position = get_cell_position_on_screen(table_view, index_path)
13
+ view_dimensions = get_cell_dimensions(cell)
14
+ cell.set_up_duplicate_cell_view(view_position, view_dimensions)
15
+ end
16
+
17
+ def tableView(table_view, cellForRowAtIndexPath: index_path)
18
+ reusable_identifier = AnimatedCellTableViewController.name
19
+ cell = table_view.dequeueReusableCellWithIdentifier(reusable_identifier)
20
+ unless cell
21
+ cell = self.delegate_controller.create_reusable_cell(index_path.row, reusable_identifier)
22
+ end
23
+ cell.hidden = true if hide_cell?(index_path.row)
24
+ cell
25
+ end
26
+
27
+ def show_hidden_cell
28
+ index_path = NSIndexPath.indexPathForRow(@hidden_cell_index, inSection: 0)
29
+ toggle_cell_visibility(self.tableView, index_path)
30
+ end
31
+
32
+ def hide_cell?(index)
33
+ @hidden_cell_index == index
34
+ end
35
+
36
+ def toggle_cell_visibility(table_view, index_path)
37
+ cell = tableView(table_view, cellForRowAtIndexPath: index_path)
38
+ cell.hidden = !cell.isHidden
39
+ @hidden_cell_index = cell.isHidden ? index_path.row : nil
40
+ self.tableView.reloadData
41
+ end
42
+
43
+ def show_table_view(duration)
44
+ self.tableView.hidden = false
45
+ UIView.animateWithDuration(duration,
46
+ animations: lambda{
47
+ self.tableView.alpha = 1
48
+ },
49
+ completion: lambda{|completion|
50
+ show_hidden_cell
51
+ self.delegate_controller.after_show_table_view
52
+ }
53
+ )
54
+ end
55
+
56
+ def hide_table_view(duration)
57
+ UIView.animateWithDuration(duration,
58
+ animations: lambda{
59
+ self.tableView.alpha = 0
60
+ },
61
+ completion: lambda{|completion|
62
+ self.tableView.hidden = true
63
+ self.delegate_controller.after_hide_table_view
64
+ }
65
+ )
66
+ end
67
+
68
+ def get_cell_position_on_screen(table_view, index_path)
69
+ CGPointMake(table_view.contentOffset.x, self.height_of_cell * index_path.row - table_view.contentOffset.y)
70
+ end
71
+
72
+ def get_cell_dimensions(cell)
73
+ cell.get_frame_size
74
+ end
75
+
76
+ def tableView(table_view, numberOfRowsInSection: section)
77
+ return 0 if self.number_of_rows.nil?
78
+ self.number_of_rows
79
+ end
80
+
81
+ def numberOfSectionsInTableView(table_view)
82
+ 1
83
+ end
84
+
85
+ def tableView(tableView, heightForRowAtIndexPath: indexPath)
86
+ self.height_of_cell
87
+ end
88
+
89
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "motion-animated-cell-table"
7
+ spec.version = "1.0"
8
+ spec.authors = ["Multunus"]
9
+ spec.email = ["info@multunus.com"]
10
+ spec.summary = %q{A RubyMotion library that facilitates the animation of cells tapped in a table}
11
+ spec.description = %q{This library makes it easy to give the illusion of popping a cell out and placing it back on cell tap}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake"
22
+ end
Binary file
Binary file
Binary file
data/spec/.DS_Store ADDED
Binary file
@@ -0,0 +1,95 @@
1
+ describe AnimatedCellTableViewController do
2
+ extend Facon::SpecHelpers
3
+
4
+ before do
5
+ @table = AnimatedCellTableViewController.new
6
+ @screen = ScreenController.new
7
+ @screen.populate_sample_data
8
+ @screen.instance_variable_set(:@animator, MotionAnimator.new)
9
+ @table.delegate_controller = @screen
10
+ @table.height_of_cell = 30
11
+ end
12
+
13
+ it "should call the method in the delegate controller on cell tap" do
14
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
15
+ @table.delegate_controller.stub!(:cell_was_tapped)
16
+ @table.delegate_controller.should.receive(:cell_was_tapped) do |index, duplicate_cell_view|
17
+ index.class.should == Fixnum
18
+ duplicate_cell_view.class.should == DuplicateCustomCellView
19
+ end
20
+ @table.tableView(@table.tableView, didSelectRowAtIndexPath: index_path)
21
+ end
22
+
23
+ it "should call the cell creation/reuse method in the delegate" do
24
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
25
+ reusable_identifier = AnimatedCellTableViewController.name
26
+ @table.delegate_controller.should.receive(:create_reusable_cell)
27
+ @table.tableView(@table.tableView, cellForRowAtIndexPath: index_path)
28
+ end
29
+
30
+ it "should set the height of a cell" do
31
+ @table.height_of_cell = 40
32
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
33
+ cell_height = @table.tableView(@table.tableView, heightForRowAtIndexPath: index_path)
34
+ cell_height.should == 40
35
+ end
36
+
37
+ it "should hide the table view" do
38
+ @table.tableView.hidden = false
39
+ @table.tableView.alpha = 1
40
+ @table.delegate_controller.stub!(:after_hide_table_view)
41
+ @table.hide_table_view(0.0)
42
+ wait 0.1 do
43
+ @table.tableView.isHidden.should == true
44
+ @table.tableView.alpha.should == 0
45
+ end
46
+ end
47
+
48
+ it "should show the table view" do
49
+ @table.tableView.hidden = true
50
+ @table.tableView.alpha = 0
51
+ @table.stub!(:show_hidden_cell)
52
+ @table.delegate_controller.stub!(:after_show_table_view)
53
+ @table.show_table_view(0.0)
54
+ wait 0.1 do
55
+ @table.tableView.isHidden.should == false
56
+ @table.tableView.alpha.should == 1
57
+ end
58
+ end
59
+
60
+ it "should toggle the cell visibility at a particular index" do
61
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
62
+ cell = @table.tableView(@table.tableView, cellForRowAtIndexPath: index_path)
63
+ cell.hidden = false
64
+ @table.toggle_cell_visibility(@table.tableView, index_path)
65
+ cell = @table.tableView(@table.tableView, cellForRowAtIndexPath: index_path)
66
+ hidden_cell_index = @table.instance_variable_get(:@hidden_cell_index)
67
+ hidden_cell_index.should == index_path.row
68
+ cell.isHidden.should == true
69
+ end
70
+
71
+ it "should determine whether to hide a cell or not" do
72
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
73
+ cell = @table.tableView(@table.tableView, cellForRowAtIndexPath: index_path)
74
+ @table.instance_variable_set(:@hidden_cell_index, index_path.row)
75
+ @table.hide_cell?(index_path.row).should == true
76
+ end
77
+
78
+ it "should return the position the cell occupies on the screen" do
79
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
80
+ @table.height_of_cell = 40
81
+ computed_cell_position = @table.get_cell_position_on_screen(@table.tableView, index_path)
82
+ actual_x_origin = @table.tableView.frame.origin.x
83
+ actual_y_origin = @table.height_of_cell * index_path.row - @table.tableView.contentOffset.y
84
+ computed_cell_position.x.should == actual_x_origin
85
+ computed_cell_position.y.should == actual_y_origin
86
+ end
87
+
88
+ it "should return the dimensions of the cell" do
89
+ index_path = NSIndexPath.indexPathForRow(0, inSection: 0)
90
+ cell = @table.tableView(@table.tableView, cellForRowAtIndexPath: index_path)
91
+ computed_cell_dimensions = @table.get_cell_dimensions(cell)
92
+ computed_cell_dimensions.class.should == CGSize
93
+ end
94
+
95
+ end
@@ -0,0 +1,14 @@
1
+ describe CustomCell do
2
+ before do
3
+ @cell = CustomCell.new
4
+ end
5
+
6
+ it "should set up its view" do
7
+ position = CGPointMake(0,0)
8
+ dimensions = CGSizeMake(0,0)
9
+ image_url = "http://image.url"
10
+ @cell.set_up_cell(position, dimensions, image_url)
11
+ cell_view = @cell.instance_variable_get(:@custom_cell_view)
12
+ cell_view.class.should == CustomCellView
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ describe DuplicateCustomCellView do
2
+ before do
3
+ @duplicate_view = DuplicateCustomCellView.new
4
+ end
5
+
6
+ it "should set up the view" do
7
+ @duplicate_view.set_up_view(CGPointMake(0,0), CGSizeMake(0,0), UIImage.new)
8
+ @duplicate_view.subviews.count.should == 1
9
+ end
10
+
11
+ it "should set up an image view" do
12
+ image_view = @duplicate_view.set_up_image_view(CGSizeMake(0,0), UIImage.new)
13
+ image_view.class.should == UIImageView
14
+ end
15
+ end
data/spec/main_spec.rb ADDED
@@ -0,0 +1,9 @@
1
+ describe "Application 'sample_animated_cell_app'" do
2
+ before do
3
+ @app = UIApplication.sharedApplication
4
+ end
5
+
6
+ it "has one window" do
7
+ @app.windows.size.should == 1
8
+ end
9
+ end
@@ -0,0 +1,58 @@
1
+ describe ScreenController do
2
+ before do
3
+ @screen = ScreenController.new
4
+ @screen.items_list = []
5
+ end
6
+
7
+ it "should populate sample data initially" do
8
+ @screen.should.receive(:populate_sample_data)
9
+ @screen.view
10
+ end
11
+
12
+ it "should set_up_the initial_layout" do
13
+ @screen.set_up_initial_layout
14
+ table = @screen.instance_variable_get(:@table)
15
+ button = @screen.instance_variable_get(:@button)
16
+ table.class.should == AnimatedCellTableViewController
17
+ button.class.should == UIButton
18
+ end
19
+
20
+ it "should set up the table" do
21
+ table = @screen.set_up_table
22
+ table.class.should == AnimatedCellTableViewController
23
+ table.tableView.backgroundColor.should == UIColor.clearColor
24
+ table.tableView.separatorStyle.should == UITableViewCellSeparatorStyleNone
25
+ end
26
+
27
+ it "should set up the reverse animation button" do
28
+ button = @screen.set_up_reverse_animator_button
29
+ button.class.should == UIButton
30
+ button.backgroundColor.should == UIColor.blackColor
31
+ end
32
+
33
+ it "should create a reusable cell for the table" do
34
+ cell = @screen.create_reusable_cell 0, AnimatedCellTableViewController.name
35
+ cell.class.should == CustomCell
36
+ end
37
+
38
+ it "should show animation button" do
39
+ button = @screen.set_up_reverse_animator_button
40
+ @screen.instance_variable_set(:@button, button)
41
+ button.alpha = 0
42
+ @screen.show_reverse_animator_button
43
+ button.alpha.should == 1
44
+ end
45
+
46
+ it "should hide animation button" do
47
+ button = @screen.set_up_reverse_animator_button
48
+ @screen.instance_variable_set(:@button, button)
49
+ button.alpha = 1
50
+ @screen.hide_reverse_animator_button
51
+ button.alpha.should == 0
52
+ end
53
+
54
+ it "should populate sample data" do
55
+ @screen.populate_sample_data
56
+ @screen.items_list.count.should == 10
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-animated-cell-table
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Multunus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This library makes it easy to give the illusion of popping a cell out
42
+ and placing it back on cell tap
43
+ email:
44
+ - info@multunus.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - app/app_delegate.rb
55
+ - app/controllers/.DS_Store
56
+ - app/controllers/screen_controller.rb
57
+ - app/views/.DS_Store
58
+ - app/views/custom_cell.rb
59
+ - app/views/custom_cell_view.rb
60
+ - app/views/duplicate_custom_cell_view.rb
61
+ - lib/motion-animated-cell-table.rb
62
+ - lib/motion-animated-cell-table/.DS_Store
63
+ - lib/motion-animated-cell-table/animated_cell_table_view_controller.rb
64
+ - motion-animated-cell-table.gemspec
65
+ - resources/.DS_Store
66
+ - resources/Default-568h@2x.png
67
+ - resources/placeholder.jpeg
68
+ - spec/.DS_Store
69
+ - spec/animated_cell_table_view_controller_spec.rb
70
+ - spec/custom_cell_spec.rb
71
+ - spec/duplicate_cell_view_spec.rb
72
+ - spec/main_spec.rb
73
+ - spec/screen_controller_spec.rb
74
+ homepage: ''
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A RubyMotion library that facilitates the animation of cells tapped in a
98
+ table
99
+ test_files:
100
+ - spec/.DS_Store
101
+ - spec/animated_cell_table_view_controller_spec.rb
102
+ - spec/custom_cell_spec.rb
103
+ - spec/duplicate_cell_view_spec.rb
104
+ - spec/main_spec.rb
105
+ - spec/screen_controller_spec.rb