class TextInputCell
Constants
- IDENTIFIER
Public Class Methods
has_value?()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 48 def has_value? true end
Public Instance Methods
capitalize=(bool)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 111 def capitalize=(bool) option = bool ? UITextAutocapitalizationTypeSentences : UITextAutocapitalizationTypeNone text_field.autocapitalizationType = option end
initWithStyle(style, reuseIdentifier: reuse_identifier)
click to toggle source
Calls superclass method
BaseCell#initWithStyle
# File lib/project/cells/text_input_cell.rb, line 6 def initWithStyle(style, reuseIdentifier: reuse_identifier) super.tap do |cell| cell.setup_constraints cell.observe('ButtonCallbackWillFire', 'resign_textfield:') cell.observe('FormWillValidate', 'resign_textfield:') cell.observe('FormWillRender', 'resign_textfield:') end end
label=(label)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 57 def label=(label) text_label.text = label end
notification_payload()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 117 def notification_payload { key: key, value: value, text_field: text_field } end
placeholder=(placeholder)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 65 def placeholder=(placeholder) text_field.placeholder = placeholder end
resign_textfield(notification)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 53 def resign_textfield(notification) text_field.resignFirstResponder if text_field.isFirstResponder end
secure=(secure)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 61 def secure=(secure) text_field.secureTextEntry = secure end
setup_constraints()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 16 def setup_constraints [text_label, text_field].each do |subview| subview.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(subview) end contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat( 'H:|-margin-[label(100@1000)][input]-margin-|', options: NSLayoutFormatAlignAllCenterY, metrics: { 'margin' => 10 }, views: subviews_dict)) contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat( 'V:|[label]|', options: 0, metrics: {}, views: subviews_dict)) contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat( 'V:|[input]|', options: 0, metrics: {}, views: subviews_dict)) end
subviews_dict()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 42 def subviews_dict { 'label' => text_label, 'input' => text_field } end
textFieldDidBeginEditing(text_field)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 97 def textFieldDidBeginEditing(text_field) post('FormCellDidBeginEditing', notification_payload) end
textFieldDidEndEditing(text_field)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 101 def textFieldDidEndEditing(text_field) post('FormCellDidEndEditing', notification_payload) end
textFieldShouldReturn(text_field)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 105 def textFieldShouldReturn(text_field) text_field.resignFirstResponder true end
text_field()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 69 def text_field @text_field ||= UITextField.alloc.init.tap do |field| field.autocorrectionType = UITextAutocorrectionTypeNo field.backgroundColor = UIColor.clearColor field.clearButtonMode = UITextFieldViewModeWhileEditing field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter field.textColor = UIColor.darkGrayColor field.font = UIFont.fontWithName('HelveticaNeue-Light', size: 16.0) field.delegate = self end end
text_label()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 82 def text_label @text_label ||= UILabel.alloc.init.tap do |label| label.textColor = UIColor.darkGrayColor label.font = UIFont.fontWithName('HelveticaNeue-Light', size: 18.0) end end
value()
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 89 def value text_field.text end
value=(value)
click to toggle source
# File lib/project/cells/text_input_cell.rb, line 93 def value=(value) text_field.text = value end