class SwipeableCell

Attributes

index_path[RW]
left_buttons[RW]
right_buttons[RW]

Public Instance Methods

add_left_buttons(cells_to_add = {}) click to toggle source
# File lib/pm_swipe_cells/swipeable_cell.rb, line 20
def add_left_buttons(cells_to_add = {})
  @left_buttons_array = Array.new
  cells_to_add.each do |opts|
    opts[:color] ||= UIColor.blueColor
    if opts[:icon] # Must be a UIImage
      @left_buttons_array.sw_addUtilityButtonWithColor(opts[:color], icon: opts[:icon])
    else
      opts[:title] ||= opts[:action].to_s
      @left_buttons_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
    end
  end
  @left_buttons_array
end
add_right_buttons(cells_to_add = {}) click to toggle source
# 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[:color] ||= UIColor.blueColor
    if opts[:icon] # Must be a UIImage
      @right_buttons_array.sw_addUtilityButtonWithColor(opts[:color], icon: opts[:icon])
    else
      opts[:title] ||= opts[:action].to_s
      @right_buttons_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
    end
  end
  @right_buttons_array
end
close() click to toggle source
# File lib/pm_swipe_cells/swipeable_cell.rb, line 48
def close
  self.hideUtilityButtonsAnimated(true)
end
config(opts = {}) click to toggle source
# File lib/pm_swipe_cells/swipeable_cell.rb, line 35
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) click to toggle source
# File lib/pm_swipe_cells/swipeable_cell.rb, line 53
def show_buttons(side)
  self.send("show#{side.to_s.capitalize}UtilityButtonsAnimated", true) if self.respond_to?("show#{side.to_s.capitalize}UtilityButtonsAnimated")
end

Private Instance Methods

add_index_path_argument(buttons) click to toggle source
# File lib/pm_swipe_cells/swipeable_cell.rb, line 60
def add_index_path_argument(buttons)
  buttons.each do |x|
    arity = self.delegate.method(x[:action]).arity
    if arity == 1 and x[:arguments].nil?
      x[:arguments] = self
    end
  end
end