class AnimatedCellTableViewController

Attributes

delegate_controller[RW]
height_of_cell[RW]
number_of_rows[RW]

Public Instance Methods

create_duplicate_view_from_cell(table_view, index_path) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 10
def create_duplicate_view_from_cell(table_view, index_path)
  cell = tableView(table_view, cellForRowAtIndexPath: index_path)
  view_position = get_cell_position_on_screen(table_view, index_path)
  view_dimensions = get_cell_dimensions(cell)
  cell.set_up_duplicate_cell_view(view_position, view_dimensions)
end
get_cell_dimensions(cell) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 72
def get_cell_dimensions(cell)
  cell.get_frame_size
end
get_cell_position_on_screen(table_view, index_path) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 68
def get_cell_position_on_screen(table_view, index_path)
  CGPointMake(table_view.contentOffset.x, self.height_of_cell * index_path.row - table_view.contentOffset.y)
end
hide_cell?(index) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 32
def hide_cell?(index)
  @hidden_cell_index == index
end
hide_table_view(duration) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 56
def hide_table_view(duration)
  UIView.animateWithDuration(duration,
                             animations: lambda{
                               self.tableView.alpha = 0
                             },
                             completion: lambda{|completion|
                               self.tableView.hidden = true
                               self.delegate_controller.after_hide_table_view
                             }
                             )
end
numberOfSectionsInTableView(table_view) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 81
def numberOfSectionsInTableView(table_view)
  1
end
show_hidden_cell() click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 27
def show_hidden_cell
  index_path = NSIndexPath.indexPathForRow(@hidden_cell_index, inSection: 0)
  toggle_cell_visibility(self.tableView, index_path)
end
show_table_view(duration) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 43
def show_table_view(duration)
  self.tableView.hidden = false
  UIView.animateWithDuration(duration,
                             animations: lambda{
                               self.tableView.alpha = 1
                             },
                             completion: lambda{|completion|
                               show_hidden_cell
                               self.delegate_controller.after_show_table_view
                             }
                             )
end
tableView(table_view, didSelectRowAtIndexPath: index_path) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 4
def tableView(table_view, didSelectRowAtIndexPath: index_path)
  duplicate_cell_view = create_duplicate_view_from_cell(table_view, index_path)
  toggle_cell_visibility(table_view, index_path)
  self.delegate_controller.cell_was_tapped(index_path.row, duplicate_cell_view)
end
toggle_cell_visibility(table_view, index_path) click to toggle source
# File lib/motion-animated-cell-table/animated_cell_table_view_controller.rb, line 36
def toggle_cell_visibility(table_view, index_path)
  cell = tableView(table_view, cellForRowAtIndexPath: index_path)
  cell.hidden = !cell.isHidden
  @hidden_cell_index = cell.isHidden ? index_path.row : nil
  self.tableView.reloadData
end