Class: HorizontalTableContainerCell

Inherits:
UITableViewCell
  • Object
show all
Includes:
ControlVariables
Defined in:
lib/motion-horizontal-scroll/horizontal_table_container_cell.rb

Constant Summary

Constants included from ControlVariables

ControlVariables::CELL_BACKGROUND_COLOR, ControlVariables::CELL_HEIGHT, ControlVariables::CELL_WIDTH, ControlVariables::HORIZONTAL_VIEW_SELECTED_BACKGROUND_COLOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delegateObject

Returns the value of attribute delegate.



4
5
6
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 4

def delegate
  @delegate
end

#horizontal_table_viewObject

Returns the value of attribute horizontal_table_view.



4
5
6
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 4

def horizontal_table_view
  @horizontal_table_view
end

#items_listObject

Returns the value of attribute items_list.



4
5
6
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 4

def items_list
  @items_list
end

#vertical_row_offsetObject

Returns the value of attribute vertical_row_offset.



4
5
6
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 4

def vertical_row_offset
  @vertical_row_offset
end

Instance Method Details

#get_horizontal_table_view_frameObject



67
68
69
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 67

def get_horizontal_table_view_frame
  [get_origin_before_transformation, [CELL_HEIGHT + vertical_row_offset, Device.screen.width]]
end

#get_origin_before_transformationObject



59
60
61
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 59

def get_origin_before_transformation
  [60 - vertical_row_offset, -60 + vertical_row_offset]
end

#get_reusable_cell(table_view) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 75

def get_reusable_cell table_view
  cell = table_view.dequeueReusableCellWithIdentifier(BasicTableViewCellWithTitle.name)
  if cell.nil?
    cell = BasicTableViewCellWithTitle.alloc.initWithFrame(CGRectMake(0, 0, CELL_WIDTH, CELL_HEIGHT + vertical_row_offset))
  end
  cell
end

#get_wrapping_scroll_view_frameObject



63
64
65
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 63

def get_wrapping_scroll_view_frame
  [[0,0],[Device.screen.width, CELL_HEIGHT + vertical_row_offset]]
end

#reload_contentObject



71
72
73
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 71

def reload_content
  self.horizontal_table_view.reloadData
end

#set_dimensions_with_row_offsetObject



26
27
28
29
30
31
32
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 26

def set_dimensions_with_row_offset
  @scroll_view = setup_background_scroll_view
  self.backgroundColor = UIColor.clearColor
  self.horizontal_table_view = setup_horizontal_tableview
  @scroll_view.addSubview(self.horizontal_table_view)
  self.addSubview @scroll_view
end

#setup_background_scroll_viewObject



34
35
36
37
38
39
40
41
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 34

def setup_background_scroll_view
  scroll_view = UIScrollView.alloc.initWithFrame(get_wrapping_scroll_view_frame)
  scroll_view.contentSize = CGSizeMake(Device.screen.width, CELL_HEIGHT + vertical_row_offset)
  scroll_view.bounces = true
  scroll_view.alwaysBounceHorizontal = true
  scroll_view.backgroundColor = UIColor.clearColor
  scroll_view
end

#setup_horizontal_tableviewObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 43

def setup_horizontal_tableview
  horizontal_table_view = UITableView.alloc.initWithFrame(get_horizontal_table_view_frame)
  horizontal_table_view.transform = CGAffineTransformMakeRotation( - (Math::PI * 0.5))
  horizontal_table_view.rowHeight = CELL_WIDTH
  horizontal_table_view.showsVerticalScrollIndicator = false
  horizontal_table_view.showsHorizontalScrollIndicator = false
  horizontal_table_view.backgroundColor = UIColor.clearColor
  horizontal_table_view.separatorStyle = UITableViewCellSeparatorStyleSingleLine
  horizontal_table_view.separatorColor = UIColor.clearColor
  horizontal_table_view.dataSource = self
  horizontal_table_view.bounces = true
  horizontal_table_view.delegate = self
  horizontal_table_view.alwaysBounceVertical = true
  horizontal_table_view
end

#tableView(table_view, didSelectRowAtIndexPath: index_path) ⇒ Object



6
7
8
# File 'lib/motion-horizontal-scroll/horizontal_table_container_cell.rb', line 6

def tableView(table_view, numberOfRowsInSection: section)
  self.items_list.count
end