Module: MotionPrime::CellSectionMixin

Extended by:
MotionSupport::Concern
Includes:
SectionWithContainerMixin
Included in:
BaseFieldSection, StaticFieldSection
Defined in:
motion-prime/sections/_cell_section_mixin.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SectionWithContainerMixin

#container_view, #load_container_with_elements

Instance Attribute Details

#pending_displayObject (readonly)

Returns the value of attribute pending_display.



9
10
11
# File 'motion-prime/sections/_cell_section_mixin.rb', line 9

def pending_display
  @pending_display
end

#tableObject



16
17
18
# File 'motion-prime/sections/_cell_section_mixin.rb', line 16

def table
  @table ||= options[:table].try(:weak_ref)
end

Instance Method Details

#cell_section_nameObject



30
31
32
33
34
35
36
# File 'motion-prime/sections/_cell_section_mixin.rb', line 30

def cell_section_name
  self.class.custom_cell_section_name || begin
    return name unless table
    table_name = table.name.gsub('_table', '')
    name.gsub("#{table_name}_", '')
  end
end

#cell_typeObject



24
25
26
27
28
# File 'motion-prime/sections/_cell_section_mixin.rb', line 24

def cell_type
  @cell_type ||= begin
    self.is_a?(BaseFieldSection) ? :field : :cell
  end
end

#container_boundsObject



38
39
40
# File 'motion-prime/sections/_cell_section_mixin.rb', line 38

def container_bounds
  @container_bounds ||= CGRectMake(0, 0, table.table_view.bounds.size.width, container_height)
end

#deallocObject



64
65
66
67
68
# File 'motion-prime/sections/_cell_section_mixin.rb', line 64

def dealloc
  # TODO: remove this when solve this problem: dealloc TableCells on TableView.reloadData (in case when reuseIdentifier has been used)
  container_view.section = nil if container_view.respond_to?(:setSection)
  super
end

#displayObject



59
60
61
62
# File 'motion-prime/sections/_cell_section_mixin.rb', line 59

def display
  @pending_display = false
  container_view.setNeedsDisplay
end

#init_container_element(options = {}) ⇒ Object



47
48
49
50
51
52
# File 'motion-prime/sections/_cell_section_mixin.rb', line 47

def init_container_element(options = {})
  options[:styles] ||= []
  options[:styles] = [:"#{table.name}_first_cell"] if table.data.first == self
  options[:styles] = [:"#{table.name}_last_cell"] if table.data.last == self
  super(options)
end

#pending_display!Object



54
55
56
57
# File 'motion-prime/sections/_cell_section_mixin.rb', line 54

def pending_display!
  @pending_display = true
  display unless table.decelerating
end

#render_container(options = {}, &block) ⇒ Object

should do nothing, because table section will care about it.



43
44
45
# File 'motion-prime/sections/_cell_section_mixin.rb', line 43

def render_container(options = {}, &block)
  block.call
end

#section_stylesObject



20
21
22
# File 'motion-prime/sections/_cell_section_mixin.rb', line 20

def section_styles
  @section_styles ||= table.try(:cell_section_styles, self) || {}
end