Module: MotionPrime::CellSectionMixin

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

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pending_displayObject (readonly)

Returns the value of attribute pending_display.



7
8
9
# File 'motion-prime/sections/_cell_section_mixin.rb', line 7

def pending_display
  @pending_display
end

#tableObject



13
14
15
# File 'motion-prime/sections/_cell_section_mixin.rb', line 13

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

Instance Method Details

#cell_nameObject



27
28
29
30
31
32
33
# File 'motion-prime/sections/_cell_section_mixin.rb', line 27

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

#cell_typeObject



21
22
23
24
25
# File 'motion-prime/sections/_cell_section_mixin.rb', line 21

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

#container_boundsObject



35
36
37
# File 'motion-prime/sections/_cell_section_mixin.rb', line 35

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

#deallocObject



78
79
80
81
82
# File 'motion-prime/sections/_cell_section_mixin.rb', line 78

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



73
74
75
76
# File 'motion-prime/sections/_cell_section_mixin.rb', line 73

def display
  @pending_display = false
  container_view.setNeedsDisplay
end

#init_container_element(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'motion-prime/sections/_cell_section_mixin.rb', line 44

def init_container_element(options = {})
  @container_element ||= begin
    options.merge!({
      screen: screen,
      section: self.weak_ref,
      has_drawn_content: true
    })
    options[:styles] ||= []
    options[:styles] = [:"#{table.name}_first_cell"] if table.data.first == self
    options[:styles] = [:"#{table.name}_last_cell"] if table.data.last == self
    MotionPrime::BaseElement.factory(:table_view_cell, options)
  end
end

#load_container_element(options = {}) ⇒ Object

FIXME: Why this duplicates functionality from other parts, e.g. draw_in?



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

def load_container_element(options = {})
  init_container_element(options)
  load_elements
  @container_element.compute_options! unless @container_element.computed_options
  if respond_to?(:prerender_elements_for_state) && prerender_enabled?
    prerender_elements_for_state(:normal)
  end
end

#pending_display!Object



68
69
70
71
# File 'motion-prime/sections/_cell_section_mixin.rb', line 68

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.



40
41
42
# File 'motion-prime/sections/_cell_section_mixin.rb', line 40

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

#section_stylesObject



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

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