Skip to content

A RubyMotion library that facilitates the animation of cells tapped in a table

License

Notifications You must be signed in to change notification settings

multunus/motion-animated-cell-table

Repository files navigation

iOS (RubyMotion) Animated Cell Table Controller

Code Climate

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 for their super awesome placeholder images.

Sample Implementation

Usage

Installation

Add this line to your application's Gemfile:

gem 'motion-animated-cell-table'

And then execute:

bundle

Or install it yourself as:

gem install motion-animated-cell-table

Sample App

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.

Using in your app

There are a two things that you need to set up first:

  1. A table cell and its corresponding view (you can also use the default iOS cell)
  2. A duplicate view for the cell (the one that gets popped out)

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.

Let's call the table cell CustomCell, its view CustomCellView and the duplicate view DuplicateCustomCellView. Now, here's how you can use the library:

  1. Initialize the table view controller:

table = AnimatedCellTableViewController.new ```

  1. 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:

table.delegate_controller = <DELEGATE_CONTROLLER> table.height_of_cell = <HEIGHT_OF_INDIVIDUAL_CELL> table.number_of_rows = <NUMBER_OF_ROWS_REQUIRED> ```

  1. There are delegate methods for creating the individual cells and deciding what to do when a cell is tapped.

def cell_was_tapped index, duplicate_cell_view # index is the position of the cell in the table # duplicate_cell_view is the duplicate view returned from the set_up_duplicate_cell_view method end ruby def create_reusable_cell index, reusable_identifier # this is simply a wrapper over the standard cellForRowAtIndexPath method # index is the position the cell needs to be created in and can be used for the data selection # reusable_identifier is the iOS table reuse identifier end ```

  1. In addition to these fundamental methods, there are two more methods that can be used to show and hide the table:

table.show_table_view(duration) # duration is in seconds ruby table.hide_table_view(duration) # duration is in seconds ```

  1. 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.

def after_show_table_view end ruby def after_hide_table_view end ```

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

iOS (RubyMotion) Animated Cell Table Controller is Copyright (c) 2016 Multunus Software Pvt. Ltd. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About

multunus

iOS (RubyMotion) Animated Cell Table Controller is maintained and funded by Multunus Software Pvt. Ltd. The names and logos for Multunus are trademarks of Multunus Software Pvt. Ltd.

We love open source software! See our other projects or hire us to help build your product.

About

A RubyMotion library that facilitates the animation of cells tapped in a table

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages