Class: ButtonRow

Inherits:
TextInputRow show all
Defined in:
lib/project/rows/button_row.rb

Constant Summary

Constants inherited from TextInputRow

TextInputRow::EMAIL_REGEX, TextInputRow::URL_REGEX

Instance Attribute Summary collapse

Attributes inherited from TextInputRow

#value

Attributes inherited from BaseRow

#icon, #key, #label, #options

Instance Method Summary collapse

Methods inherited from TextInputRow

#did_end_editing, #setup_validation, #textFieldDidEndEditing, #valid?, #validation_rules

Methods inherited from BaseRow

#cell_identifier, #dealloc, #has_value?, #notification_center, #observe, #post

Constructor Details

#initialize(key, options) ⇒ ButtonRow

Returns a new instance of ButtonRow.



7
8
9
10
11
12
# File 'lib/project/rows/button_row.rb', line 7

def initialize(key, options)
  super

  @on_tap_callback = options.fetch(:action, lambda {})
  @accessory       = options.fetch(:accessory, nil)
end

Instance Attribute Details

#accessoryObject (readonly)

Returns the value of attribute accessory.



5
6
7
# File 'lib/project/rows/button_row.rb', line 5

def accessory
  @accessory
end

#on_tap_callbackObject (readonly)

Returns the value of attribute on_tap_callback.



5
6
7
# File 'lib/project/rows/button_row.rb', line 5

def on_tap_callback
  @on_tap_callback
end

Instance Method Details

#cell_typeObject



14
15
16
# File 'lib/project/rows/button_row.rb', line 14

def cell_type
  ButtonCell
end

#listenObject



22
23
24
# File 'lib/project/rows/button_row.rb', line 22

def listen
  observe('FormCellWasTapped', 'tapped:')
end

#tapped(notification) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/project/rows/button_row.rb', line 26

def tapped(notification)
  if notification.userInfo[:key] == key
    post('ButtonCallbackWillFire')

    on_tap_callback.call
  end
end

#update_cell(cell) ⇒ Object



34
35
36
37
38
# File 'lib/project/rows/button_row.rb', line 34

def update_cell(cell)
  super

  cell.accessory = accessory
end