Class: UnderOs::UI::Collection
- Inherits:
-
View
show all
- 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
Methods inherited from View
#inspect
#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
#emit, #off, #on=
Methods included from Wrap
included
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(options={})
super
self.layout = Layout.new if ! options[:layout]
self.layout = options.delete(:layout) if options[:layout].is_a?(Class)
self.layout = options.delete(:layout).constantize if options[: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
|
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
|
41
42
43
44
|
# File 'lib/under_os/ui/collection.rb', line 41
def reload
@_.reloadData
self
end
|
#repaint(stylesheet = nil) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/under_os/ui/collection.rb', line 59
def repaint(stylesheet=nil)
stylesheet ||= page && page.stylesheet
self.style = stylesheet.styles_for(self) if stylesheet
Styles.build(self, stylesheet) if stylesheet
end
|