Class: SwipeableCell

Inherits:
SWTableViewCell
  • Object
show all
Defined in:
lib/pm_swipe_cells/swipeable_cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#index_pathObject

Returns the value of attribute index_path.



3
4
5
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 3

def index_path
  @index_path
end

#left_buttonsObject

Returns the value of attribute left_buttons.



3
4
5
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 3

def left_buttons
  @left_buttons
end

#right_buttonsObject

Returns the value of attribute right_buttons.



3
4
5
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 3

def right_buttons
  @right_buttons
end

Instance Method Details

#add_left_buttons(cells_to_add = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 16

def add_left_buttons(cells_to_add = {})
  @left_buttons_array = Array.new
  cells_to_add.each do |opts|
    opts[:title] ||= opts[:action].to_s
    opts[:color] ||= UIColor.blueColor
    @left_buttons_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
  end
  @left_buttons_array
end

#add_right_buttons(cells_to_add = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 6

def add_right_buttons(cells_to_add = {})
  @right_buttons_array = Array.new
  cells_to_add.each do |opts|
    opts[:title] ||= opts[:action].to_s
    opts[:color] ||= UIColor.blueColor
    @right_buttons_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
  end
  @right_buttons_array
end

#closeObject



40
41
42
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 40

def close
  self.hideUtilityButtonsAnimated(true)
end

#config(opts = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 27

def config(opts = {})
  @right_buttons = opts[:right_buttons] if opts[:right_buttons]
  @left_buttons = opts[:left_buttons] if opts[:left_buttons]
  [@right_buttons, @left_buttons].each {|x| add_index_path_argument(x) unless x.nil?}
   if @right_buttons
    self.rightUtilityButtons = add_right_buttons(@right_buttons)
  end
  if @left_buttons
    self.leftUtilityButtons = add_left_buttons(@left_buttons)
  end
end

#show_buttons(side) ⇒ Object



45
46
47
# File 'lib/pm_swipe_cells/swipeable_cell.rb', line 45

def show_buttons(side)
  self.send("show#{side.to_s.capitalize}UtilityButtonsAnimated", true) if self.respond_to?("show#{side.to_s.capitalize}UtilityButtonsAnimated")
end