Module: MotionPrime::TableSectionRefreshMixin

Included in:
TableSection
Defined in:
motion-prime/sections/table/refresh_mixin.rb

Instance Method Summary collapse

Instance Method Details

#add_pull_to_refresh(options = {}, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'motion-prime/sections/table/refresh_mixin.rb', line 3

def add_pull_to_refresh(options = {}, &block)
  screen.automaticallyAdjustsScrollViewInsets = false

  collection_view.addPullToRefreshWithActionHandler(block) # block must be a variable
  refresh_view = collection_view.pullToRefreshView

  options[:styles] ||= []
  options[:styles] += [:base_pull_to_refresh]
  # pass yOrigin to override view top
  base_options = {
    alpha: 0,
    custom_offset_threshold: - collection_view.contentInset.top - refresh_view.size.height,
    original_top_inset: collection_view.contentInset.top
  }
  screen.set_options_for refresh_view, base_options.deep_merge(options)
end

#finish_pull_to_refreshObject



20
21
22
23
# File 'motion-prime/sections/table/refresh_mixin.rb', line 20

def finish_pull_to_refresh
  reload_data
  collection_view.pullToRefreshView.stopAnimating
end