Class: MotionPrime::TableDelegate
- Inherits:
-
Object
- Object
- MotionPrime::TableDelegate
show all
- Includes:
- DelegateMixin
- Defined in:
- motion-prime/sections/table/table_delegate.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#clear_delegated, #delegated_by
Constructor Details
Returns a new instance of TableDelegate.
6
7
8
9
10
|
# File 'motion-prime/sections/table/table_delegate.rb', line 6
def initialize(options)
self.table_section = options[:section].try(:weak_ref)
@_section_info = table_section.to_s
@section_instance = table_section.to_s
end
|
Instance Attribute Details
#table_section ⇒ Object
Returns the value of attribute table_section.
4
5
6
|
# File 'motion-prime/sections/table/table_delegate.rb', line 4
def table_section
@table_section
end
|
Instance Method Details
#dealloc ⇒ Object
12
13
14
15
|
# File 'motion-prime/sections/table/table_delegate.rb', line 12
def dealloc
Prime.logger.dealloc_message :collection_delegate, @_section_info
super
end
|
#init_pull_to_refresh ⇒ Object
17
18
19
20
21
22
|
# File 'motion-prime/sections/table/table_delegate.rb', line 17
def init_pull_to_refresh
return unless block = table_section.class.pull_to_refresh_block
table_section.add_pull_to_refresh(table_section.class.pull_to_refresh_options || {}) do
table_section.instance_eval(&block)
end
end
|
#numberOfSectionsInTableView(table) ⇒ Object
24
25
26
|
# File 'motion-prime/sections/table/table_delegate.rb', line 24
def numberOfSectionsInTableView(table)
table_section.number_of_groups
end
|
79
80
81
|
# File 'motion-prime/sections/table/table_delegate.rb', line 79
def scrollViewDidEndDecelerating(scroll)
table_section.scroll_view_did_end_decelerating(scroll)
end
|
83
84
85
|
# File 'motion-prime/sections/table/table_delegate.rb', line 83
def scrollViewDidEndDragging(scroll, willDecelerate: will_decelerate)
table_section.scroll_view_did_end_dragging(scroll, willDecelerate: will_decelerate)
end
|
67
68
69
|
# File 'motion-prime/sections/table/table_delegate.rb', line 67
def scrollViewDidEndScrollingAnimation(scroll)
table_section.scroll_view_did_end_scrolling_animation(scroll)
end
|
62
63
64
65
|
# File 'motion-prime/sections/table/table_delegate.rb', line 62
def scrollViewDidScroll(scroll)
table_section.scroll_view_did_scroll(scroll)
table_section.update_pull_to_refresh_after_scroll(scroll)
end
|
75
76
77
|
# File 'motion-prime/sections/table/table_delegate.rb', line 75
def scrollViewWillBeginDecelerating(scroll)
table_section.scroll_view_will_begin_decelerating(scroll)
end
|
71
72
73
|
# File 'motion-prime/sections/table/table_delegate.rb', line 71
def scrollViewWillBeginDragging(scroll)
table_section.scroll_view_will_begin_dragging(scroll)
end
|
#tableView(table, heightForHeaderInSection: group) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'motion-prime/sections/table/table_delegate.rb', line 28
def tableView(table, cellForRowAtIndexPath: index)
cur_call_time = Time.now.to_f
cur_call_offset = table.contentOffset.y
if @prev_call_time
time_delta = cur_call_time - @prev_call_time
offset_delta = cur_call_offset - @prev_call_offset
@deceleration_speed = offset_delta/time_delta
end
@prev_call_time = cur_call_time
@prev_call_offset = cur_call_offset
table_section.cell_for_index(index)
end
|
#textFieldDidBeginEditing(text_field) ⇒ Object
93
94
95
|
# File 'motion-prime/sections/table/table_delegate.rb', line 93
def textFieldDidBeginEditing(text_field)
table_section.on_input_edit_begin(text_field)
end
|
#textFieldDidEndEditing(text_field) ⇒ Object
96
97
98
|
# File 'motion-prime/sections/table/table_delegate.rb', line 96
def textFieldDidEndEditing(text_field)
table_section.on_input_edit_end(text_field)
end
|
#textFieldShouldBeginEditing(text_field) ⇒ Object
90
91
92
|
# File 'motion-prime/sections/table/table_delegate.rb', line 90
def textFieldShouldBeginEditing(text_field)
text_field.respond_to?(:readonly) ? !text_field.readonly : true
end
|
#textFieldShouldReturn(text_field) ⇒ Object
87
88
89
|
# File 'motion-prime/sections/table/table_delegate.rb', line 87
def textFieldShouldReturn(text_field)
table_section.on_input_return(text_field)
end
|
#textViewDidBeginEditing(text_view) ⇒ Object
99
100
101
|
# File 'motion-prime/sections/table/table_delegate.rb', line 99
def textViewDidBeginEditing(text_view)
table_section.on_input_edit_begin(text_view)
end
|
#textViewDidChange(text_view) ⇒ Object
bug in iOS 7 - cursor is out of textView bounds
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'motion-prime/sections/table/table_delegate.rb', line 105
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 + text_view.textContainerInset.bottom
UIView.animate(duration: 0.2) do
text_view.setContentOffset(offset)
end
end
end
|
#textViewDidEndEditing(text_view) ⇒ Object
102
103
104
|
# File 'motion-prime/sections/table/table_delegate.rb', line 102
def textViewDidEndEditing(text_view)
table_section.on_input_edit_end(text_view)
end
|