Class: TextFieldCell
- Inherits:
-
BaseCell
- Object
- UITableViewCell
- BaseCell
- TextFieldCell
show all
- Defined in:
- lib/project/cells/text_field_cell.rb
Constant Summary
collapse
- IDENTIFIER =
'TextFieldCell'
Instance Attribute Summary
Attributes inherited from BaseCell
#key
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCell
#dealloc, #notification_center, #observe, #post, #selected_background_view
Class Method Details
.has_value? ⇒ Boolean
18
19
20
|
# File 'lib/project/cells/text_field_cell.rb', line 18
def has_value?
true
end
|
Instance Method Details
#icon=(icon) ⇒ Object
42
43
44
|
# File 'lib/project/cells/text_field_cell.rb', line 42
def icon=(icon)
left_view.name = icon
end
|
#initWithStyle(style, reuseIdentifier: reuse_identifier) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/project/cells/text_field_cell.rb', line 7
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) ⇒ Object
36
37
|
# File 'lib/project/cells/text_field_cell.rb', line 36
def label=(label)
end
|
#left_view ⇒ Object
55
56
57
|
# File 'lib/project/cells/text_field_cell.rb', line 55
def left_view
@left_view ||= IconView.alloc.init
end
|
#notification_payload ⇒ Object
105
106
107
|
# File 'lib/project/cells/text_field_cell.rb', line 105
def notification_payload
{ key: key, value: value, text_field: text_view }
end
|
#resign_text_view(notification) ⇒ Object
32
33
34
|
# File 'lib/project/cells/text_field_cell.rb', line 32
def resign_text_view(notification)
text_view.resignFirstResponder if text_view.isFirstResponder
end
|
#secure=(secure) ⇒ Object
39
40
|
# File 'lib/project/cells/text_field_cell.rb', line 39
def secure=(secure)
end
|
#setup_constraints ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/project/cells/text_field_cell.rb', line 23
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
|
#text_view ⇒ Object
Also known as:
text_field
46
47
48
49
50
51
52
|
# File 'lib/project/cells/text_field_cell.rb', line 46
def text_view
@text_view ||= SZTextView.alloc.init.tap do |text_view|
text_view.font = UIFont.fontWithName('HelveticaNeue-Light', size: 14.0)
text_view.placeholder = 'Write a short bio'
text_view.delegate = self
end
end
|
#textFieldShouldReturn(text_view) ⇒ Object
75
76
77
78
79
|
# File 'lib/project/cells/text_field_cell.rb', line 75
def textFieldShouldReturn(text_view)
text_view.resignFirstResponder
true
end
|
#textView(text_view, shouldChangeTextInRange: range, replacementText: text) ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/project/cells/text_field_cell.rb', line 81
def textView(text_view, shouldChangeTextInRange: range, replacementText: text)
if text == "\n"
text_view.resignFirstResponder
false
else
true
end
end
|
#textViewDidBeginEditing(text_view) ⇒ Object
67
68
69
|
# File 'lib/project/cells/text_field_cell.rb', line 67
def textViewDidBeginEditing(text_view)
post('FormCellDidBeginEditing', notification_payload)
end
|
#textViewDidChange(text_view) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/project/cells/text_field_cell.rb', line 91
def textViewDidChange(text_view)
line = text_view.caretRectForPosition(text_view..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) ⇒ Object
71
72
73
|
# File 'lib/project/cells/text_field_cell.rb', line 71
def textViewDidEndEditing(text_view)
post('FormCellDidEndEditing', notification_payload)
end
|
#value ⇒ Object
59
60
61
|
# File 'lib/project/cells/text_field_cell.rb', line 59
def value
text_view.text
end
|
#value=(value) ⇒ Object
63
64
65
|
# File 'lib/project/cells/text_field_cell.rb', line 63
def value=(value)
text_view.text = value
end
|