Module: MotionPrime::CellSectionMixin

Extended by:
MotionSupport::Concern
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

Instance Attribute Details

#collection_sectionObject



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

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

#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

Instance Method Details

#cellObject



69
70
71
72
73
74
75
# File 'motion-prime/sections/_cell_section_mixin.rb', line 69

def cell
  container_view || begin
    first_element = elements.values.first
    return unless first_element.is_a?(BaseElement) && first_element.view
    first_element.view.superview.superview
  end
end

#cell_section_nameObject



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

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

#cell_typeObject



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

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

#container_boundsObject



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

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

#deallocObject



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

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



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

def display
  @pending_display = false
  container_view.setNeedsDisplay
end

#init_container_element(options = {}) ⇒ Object



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

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

#pending_display!Object



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

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

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

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



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

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

#section_stylesObject



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

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

#tableObject



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

def table
  Prime.logger.info "Section#table is deprecated: #{caller[0]}"
  collection_section
end