Sha256: cdff8a5d63b548090ac60108ef23c365d6b062f886d4a91f75e6bab0a69a61ba

Contents?: true

Size: 760 Bytes

Versions: 6

Compression:

Stored size: 760 Bytes

Contents

#
# This is the collection item class that you supposed
# to inherit (well, if you need to)
#
class UnderOs::UI::Collection::Item < UnderOs::UI::View

  tag :item

  def self.build(collection, &builder)
    @builders           ||= {}
    @builders[collection] = builder
    collection.item_class = self
  end

  def self.for(collection, stylesheet=nil)
    new.tap do |view|
      def view.parent; @_parent; end
      view.instance_variable_set('@_parent', collection)

      @builders[collection] && @builders[collection].call.each do |child|
        view.insert child
      end

      view.repaint(stylesheet || UnderOs::App.history.current_page.stylesheet)
    end
  end

  def cleanup
    # implement me if you need to clean cells between reuse
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/ui/collection/item.rb
under-os-1.3.0 lib/under_os/ui/collection/item.rb
under-os-1.2.1 lib/under_os/ui/collection/item.rb
under-os-1.2.0 lib/under_os/ui/collection/item.rb
under-os-1.1.0 lib/under_os/ui/collection/item.rb
under-os-1.0.0 lib/under_os/ui/collection/item.rb