class TextFieldCell

Constants

IDENTIFIER

Public Class Methods

has_value?() click to toggle source
# File lib/project/cells/text_field_cell.rb, line 17
def has_value?
  true
end

Public Instance Methods

capitalize=(bool) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 99
def capitalize=(bool)
  option = bool ? UITextAutocapitalizationTypeSentences : UITextAutocapitalizationTypeNone

  text_view.autocapitalizationType = option
end
initWithStyle(style, reuseIdentifier: reuse_identifier) click to toggle source
Calls superclass method BaseCell#initWithStyle
# File lib/project/cells/text_field_cell.rb, line 6
def initWithStyle(style, reuseIdentifier: reuse_identifier)
  super.tap do |cell|
    cell.observe('ButtonCallbackWillFire', 'resign_text_view:')
    cell.observe('FormWillValidate',       'resign_text_view:')
    cell.observe('FormWillRender',         'resign_text_view:')

    cell.setup_constraints
  end
end
label=(label) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 35
def label=(label)
end
notification_payload() click to toggle source
# File lib/project/cells/text_field_cell.rb, line 105
def notification_payload
  { key: key, value: value, text_field: text_view }
end
placeholder=(placeholder) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 38
def placeholder=(placeholder)
  text_view.placeholder = placeholder
end
resign_text_view(notification) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 31
def resign_text_view(notification)
  text_view.resignFirstResponder if text_view.isFirstResponder
end
secure=(secure) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 42
def secure=(secure)
end
setup_constraints() click to toggle source
# File lib/project/cells/text_field_cell.rb, line 22
def setup_constraints
  Motion::Layout.new do |layout|
    layout.view       contentView
    layout.subviews   'text_view' => text_view
    layout.horizontal '|[text_view]|'
    layout.vertical   '|[text_view]|'
  end
end
textFieldShouldReturn(text_view) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 69
def textFieldShouldReturn(text_view)
  text_view.resignFirstResponder

  true
end
textView(text_view, shouldChangeTextInRange: range, replacementText: text) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 75
def textView(text_view, shouldChangeTextInRange: range, replacementText: text)
  if text == "\n"
    text_view.resignFirstResponder

    false
  else
    true
  end
end
textViewDidBeginEditing(text_view) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 61
def textViewDidBeginEditing(text_view)
  post('FormCellDidBeginEditing', notification_payload)
end
textViewDidChange(text_view) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 85
def textViewDidChange(text_view)
  line     = text_view.caretRectForPosition(text_view.selectedTextRange.start)
  overflow = line.origin.y + line.size.height - (text_view.contentOffset.y + text_view.bounds.size.height - text_view.contentInset.bottom - text_view.contentInset.top )

  if overflow > 0
    offset = text_view.contentOffset
    offset.y += overflow + 7

    UIView.animateWithDuration(0.2, animations: -> {
      text_view.setContentOffset(offset)
    })
  end
end
textViewDidEndEditing(text_view) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 65
def textViewDidEndEditing(text_view)
  post('FormCellDidEndEditing', notification_payload)
end
text_field()
Alias for: text_view
text_view() click to toggle source
# File lib/project/cells/text_field_cell.rb, line 45
def text_view
  @text_view ||= SZTextView.alloc.init.tap do |text_view|
    text_view.font     = UIFont.fontWithName('HelveticaNeue-Light', size: 14.0)
    text_view.delegate = self
  end
end
Also aliased as: text_field
value() click to toggle source
# File lib/project/cells/text_field_cell.rb, line 53
def value
  text_view.text
end
value=(value) click to toggle source
# File lib/project/cells/text_field_cell.rb, line 57
def value=(value)
  text_view.text = value
end