module ProMotion::Collection

Attributes

promotion_collection_data[R]

Protected Class Methods

included(base) click to toggle source
# File lib/ProMotion/collection/collection.rb, line 103
def self.included(base)
  base.extend(CollectionClassMethods)
end

Public Instance Methods

cell_at(args = {}) click to toggle source

Returns the data cell

# File lib/ProMotion/collection/collection.rb, line 42
def cell_at(args = {})
  self.promotion_collection_data.cell(args)
end
check_collection_data() click to toggle source
# File lib/ProMotion/collection/collection.rb, line 33
def check_collection_data
  mp("Missing #collection_data method in CollectionScreen #{self.class.to_s}.", force_color: :red) unless self.respond_to?(:collection_data)
end
collectionView(_, numberOfItemsInSection: section) click to toggle source

UICollectionViewDataSource ##

# File lib/ProMotion/collection/collection.rb, line 66
def collectionView(_, numberOfItemsInSection: section)
  self.promotion_collection_data.section_length(section)
end
collection_view() click to toggle source
# File lib/ProMotion/collection/collection.rb, line 9
def collection_view
  self.collectionView
end
numberOfSectionsInCollectionView(_) click to toggle source
# File lib/ProMotion/collection/collection.rb, line 70
def numberOfSectionsInCollectionView(_)
  self.promotion_collection_data.sections.length
end
reload_data() click to toggle source
# File lib/ProMotion/collection/collection.rb, line 57
def reload_data
  update_collection_view_data(collection_data)
end
Also aliased as: update_collection_data
screen_setup() click to toggle source
# File lib/ProMotion/collection/collection.rb, line 13
def screen_setup
  check_collection_data
end
set_up_register_class() click to toggle source
# File lib/ProMotion/collection/collection.rb, line 24
def set_up_register_class
  collection_view.registerClass(PM::CollectionViewCell, forCellWithReuseIdentifier: PM::CollectionViewCell::KIdentifier)
  if self.class.get_cell_classes
    self.class.get_cell_classes.each do |identifier, klass|
      collection_view.registerClass(klass, forCellWithReuseIdentifier: identifier.to_s)
    end
  end
end
update_collection_data()
Alias for: reload_data
update_collection_view_data(data, args = {}) click to toggle source
# File lib/ProMotion/collection/collection.rb, line 46
def update_collection_view_data(data, args = {})
  self.promotion_collection_data.data = data
  if args[:index_paths]
    collection_view.reloadItemsAtIndexPaths(Array(args[:index_paths]))
  elsif args[:sections]
    collection_view.reloadSections(args[:sections])
  else
    collection_view.reloadData
  end
end
viewDidLoad() click to toggle source

Override viewDidLoad here to register cell classes here. Calling it from `screen_setup` cause `on_load` to be called twice

Calls superclass method
# File lib/ProMotion/collection/collection.rb, line 19
def viewDidLoad
  super
  set_up_register_class
end