Class: UnderOs::UI::Collection
- Defined in:
- lib/under_os/ui/collection.rb
Defined Under Namespace
Classes: Cell, Delegate, Item, Styles
Constant Summary
Constants included from Wrap
Wrap::INSTANCES_CACHE, Wrap::RAW_WRAPS_MAP, Wrap::WRAPS_TAGS_MAP
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Collection
constructor
A new instance of Collection.
- #item_class ⇒ Object
- #item_class=(klass) ⇒ Object
- #layout ⇒ Object
- #layout=(layout) ⇒ Object
- #number_of_items(section = 0) ⇒ Object
- #number_of_items=(value) ⇒ Object
- #number_of_sections ⇒ Object
- #on(*args, &block) ⇒ Object
- #reload ⇒ Object
- #repaint(stylesheet = nil) ⇒ Object
Methods inherited from View
Methods included from Manipulation
#append, #clear, #insert, #insertTo, #prepend, #remove
Methods included from Traversing
#children, #empty?, #find, #first, #matches, #parent, #siblings
Methods included from Dimensions
#position, #position=, #size, #size=
Methods included from Animation
#animate, #fade_in, #fade_out, #highlight
Methods included from Commons
#data, #data=, #hidden, #hide, #id, #id=, #page, #show, #tagName, #toggle, #visible
Methods included from Styles
#addClass, #className, #className=, #classNames, #classNames=, #hasClass, #radioClass, #removeClass, #style, #style=, #toggleClass
Methods included from Events
Methods included from Wrap
Constructor Details
#initialize(options = {}) ⇒ Collection
Returns a new instance of Collection.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/under_os/ui/collection.rb', line 4 def initialize(={}) super self.layout = Layout.new if ! [:layout] self.layout = .delete(:layout) if [:layout].is_a?(Class) self.layout = .delete(:layout).constantize if [:layout].is_a?(String) @_.delegate = @_.dataSource = Delegate.new(self) @_.registerClass(Cell, forCellWithReuseIdentifier:'UOSCollectionCell') end |
Instance Method Details
#item_class ⇒ Object
33 34 35 |
# File 'lib/under_os/ui/collection.rb', line 33 def item_class Cell.classes[self] end |
#item_class=(klass) ⇒ Object
37 38 39 |
# File 'lib/under_os/ui/collection.rb', line 37 def item_class=(klass) Cell.classes[self] = klass end |
#layout ⇒ Object
24 25 26 |
# File 'lib/under_os/ui/collection.rb', line 24 def layout @layout end |
#layout=(layout) ⇒ Object
28 29 30 31 |
# File 'lib/under_os/ui/collection.rb', line 28 def layout=(layout) layout = Layout.new(layout) if layout.is_a?(UICollectionViewLayout) @_.collectionViewLayout = (@layout = layout)._ end |
#number_of_items(section = 0) ⇒ Object
46 47 48 |
# File 'lib/under_os/ui/collection.rb', line 46 def number_of_items(section=0) (@number_of_items || [0])[section] end |
#number_of_items=(value) ⇒ Object
50 51 52 53 |
# File 'lib/under_os/ui/collection.rb', line 50 def number_of_items=(value) @number_of_items = value.is_a?(Numeric) ? [value] : value reload end |
#number_of_sections ⇒ Object
55 56 57 |
# File 'lib/under_os/ui/collection.rb', line 55 def number_of_sections (@number_of_items || [0]).size end |
#on(*args, &block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/under_os/ui/collection.rb', line 15 def on(*args, &block) super *args do |event| params = [event.item, event.index, event.section] params = params.slice(0, block.arity) if block.arity > -1 block.call *params end end |
#reload ⇒ Object
41 42 43 44 |
# File 'lib/under_os/ui/collection.rb', line 41 def reload @_.reloadData self end |