Class: ButtonCell
Constant Summary
collapse
- IDENTIFIER =
'ButtonCell'
Instance Attribute Summary
Attributes inherited from BaseCell
#key
Class Method Summary
collapse
Instance Method Summary
collapse
#icon=, #left_view, #resign_textfield, #secure=, #textFieldDidBeginEditing, #textFieldDidEndEditing, #textFieldShouldReturn, #text_field, #value, #value=
Methods inherited from BaseCell
#dealloc, #notification_center, #observe, #post, #selected_background_view
Class Method Details
.has_value? ⇒ Boolean
7
8
9
|
# File 'lib/project/cells/button_cell.rb', line 7
def has_value?
false
end
|
Instance Method Details
#accessory=(icon) ⇒ Object
49
50
51
|
# File 'lib/project/cells/button_cell.rb', line 49
def accessory=(icon)
right_view.name = icon
end
|
#add_right_view ⇒ Object
44
45
46
47
|
# File 'lib/project/cells/button_cell.rb', line 44
def add_right_view
text_field.rightView = right_view
text_field.rightViewMode = UITextFieldViewModeAlways
end
|
#add_tap_recognizer ⇒ Object
22
23
24
|
# File 'lib/project/cells/button_cell.rb', line 22
def add_tap_recognizer
addGestureRecognizer(tap_recognizer)
end
|
#build_highlighted_placeholder(label) ⇒ Object
30
31
32
33
34
|
# File 'lib/project/cells/button_cell.rb', line 30
def build_highlighted_placeholder(label)
NSAttributedString.alloc.initWithString(
label,
attributes: { NSForegroundColorAttributeName => MotionForm.button_text_color })
end
|
#initWithStyle(style, reuseIdentifier: reuse_identifier) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/project/cells/button_cell.rb', line 12
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do |cell|
cell.selectionStyle = UITableViewCellSelectionStyleGray
cell.text_field.enabled = false
cell.add_right_view
cell.add_tap_recognizer
end
end
|
#label=(label) ⇒ Object
26
27
28
|
# File 'lib/project/cells/button_cell.rb', line 26
def label=(label)
text_field.attributedPlaceholder = build_highlighted_placeholder(label)
end
|
#layoutSubviews ⇒ Object
57
58
59
60
61
|
# File 'lib/project/cells/button_cell.rb', line 57
def layoutSubviews
super
right_view.frame = [[size.width - 56, 0], [36, 43]]
end
|
#notification_payload ⇒ Object
63
64
65
|
# File 'lib/project/cells/button_cell.rb', line 63
def notification_payload
{ key: key }
end
|
#right_view ⇒ Object
53
54
55
|
# File 'lib/project/cells/button_cell.rb', line 53
def right_view
@right_view ||= IconView.alloc.init
end
|
#tap_recognizer ⇒ Object
36
37
38
|
# File 'lib/project/cells/button_cell.rb', line 36
def tap_recognizer
UITapGestureRecognizer.alloc.initWithTarget(self, action: 'tapped:')
end
|
#tapped(recognizer) ⇒ Object
40
41
42
|
# File 'lib/project/cells/button_cell.rb', line 40
def tapped(recognizer)
post('FormCellWasTapped', notification_payload)
end
|