Class: ButtonRow

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

Constant Summary

Constants inherited from TextFieldRow

TextFieldRow::EMAIL_REGEX, TextFieldRow::URL_REGEX

Instance Attribute Summary collapse

Attributes inherited from TextFieldRow

#value

Attributes inherited from BaseRow

#icon, #key, #label, #options

Instance Method Summary collapse

Methods inherited from TextFieldRow

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

Methods inherited from BaseRow

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

Constructor Details

#initialize(key, options) ⇒ ButtonRow

Returns a new instance of ButtonRow.



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

def initialize(key, options)
  super

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

Instance Attribute Details

#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

#accessoryObject



17
18
19
# File 'lib/project/rows/button_row.rb', line 17

def accessory
  options.fetch(:accessory, nil)
end

#cell_typeObject



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

def cell_type
  ButtonCell
end

#listenObject



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

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

#tapped(notification) ⇒ Object



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

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

    on_tap_callback.call
  end
end