Class: MotionWizard::IndexItem

Inherits:
UIView
  • Object
show all
Defined in:
lib/motion-wizard/views/index_item_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/motion-wizard/views/index_item_view.rb', line 3

def label
  @label
end

#label_wrapperObject (readonly)

Returns the value of attribute label_wrapper.



3
4
5
# File 'lib/motion-wizard/views/index_item_view.rb', line 3

def label_wrapper
  @label_wrapper
end

Instance Method Details

#create_labelObject



16
17
18
19
20
# File 'lib/motion-wizard/views/index_item_view.rb', line 16

def create_label
  @label               = UILabel.alloc.init
  @label.textAlignment = NSTextAlignmentCenter
  @label.origin        = [0, 0]
end

#create_label_wrapperObject



22
23
24
25
26
# File 'lib/motion-wizard/views/index_item_view.rb', line 22

def create_label_wrapper
  @label_wrapper                 = UIView.alloc.init
  @label_wrapper.origin          = [0, 0]
  @label_wrapper.backgroundColor = UIColor.clearColor
end

#initObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/motion-wizard/views/index_item_view.rb', line 5

def init
  super
  create_label
  create_label_wrapper
  @label_wrapper.addSubview(@label)
  addSubview(@label_wrapper)

  initialize_callbacks
  self
end

#initialize_callbacksObject



28
29
30
31
32
33
34
35
# File 'lib/motion-wizard/views/index_item_view.rb', line 28

def initialize_callbacks
  when_selected do
    @original_text = @label.text
    @label.text = "[#{@label.text}]"
  end

  when_unselected { @label.text = @original_text}
end

#selectObject



45
46
47
# File 'lib/motion-wizard/views/index_item_view.rb', line 45

def select
  @when_selected.call
end

#unselectObject



49
50
51
# File 'lib/motion-wizard/views/index_item_view.rb', line 49

def unselect
  @when_unselected.call
end

#when_selected(&block) ⇒ Object



37
38
39
# File 'lib/motion-wizard/views/index_item_view.rb', line 37

def when_selected(&block)
  @when_selected = block
end

#when_unselected(&block) ⇒ Object



41
42
43
# File 'lib/motion-wizard/views/index_item_view.rb', line 41

def when_unselected(&block)
  @when_unselected = block
end