Sha256: 2f79c99b83d42fff6cd53f506dc8ff137bbecfacb3a2776ba5cb8d63b1fdc1d0
Contents?: true
Size: 1.1 KB
Versions: 23
Compression:
Stored size: 1.1 KB
Contents
# ** What is a TableSection? ** # # "TableSection" is a "Section" which have some sugar to work with UITableViews. # ** Create a Cell Section. ** # # Inherit it from `Prime::Section`. # # Each element inside this section will be part of one cell. class FooCellSection < Prime::Section element :title, text: proc { model[:title] } end # ** Create a Table Section. ** # # Just inherit it from `Prime::TableSection`. # # The key method which should be created is `table_data`. It should return array of any sections. class FooTableSection < Prime::TableSection def table_data my_foo_items.map do |fruit_name| model = {title: fruit_name} FooCellSection.new(model: model) end end def my_foo_items %w[Orange Apricot Banana] end end # ** Render table to a Screen. ** # class FooScreen < Prime::Screen def render @main_section = FooTableSection.new(screen: self) @main_section.render end end # ** Style it. ** # # Of course, don't forget to add styles for table cells. Prime::Styles.define :foo_cell do style :title, left: 20, top: 5, width: 200, height: 20 end
Version data entries
23 entries across 23 versions & 1 rubygems