redpotion
redpotion copied to clipboard
Idea: Swipeable table cells
So I get requests from clients on almost EVERY project that they want to be able to have multiple buttons on either side of a tableview cell to do different things. I'm standardized on using MGSwipeTableCell as the tool of choice because it works well and is easy to understand.
Wondering if anyone else ever sees a need for this and if a DSL would be useful and maybe integrate into redpotion?
Here's a typical cell class:
class ChatCell < MGSwipeTableCell
def on_load
delete = MGSwipeButton.buttonWithTitle(
"Delete",
backgroundColor: color.grass,
padding: 20,
callback: -> sender { delete_action }
)
block = MGSwipeButton.buttonWithTitle(
"Block User",
backgroundColor: color.red,
padding: 20,
callback: -> sender { block_action }
)
self.rightButtons = [delete, block]
self.rightSwipeSettings.transition = MGSwipeTransitionDrag
self.rightExpansion.buttonIndex = 0
self.rightExpansion.fillOnTrigger = true
end
def will_display
end
def delete_action
mp "deleted!"
end
def block_action
mp "blocked!"
end
end
I'm thinking that this could be shortened to something like we do in ProMotion for the left and right titlebar buttons:
class ChatCell < PM::SwipeTableCell
def on_load
set_right_buttons([{
title: "Delete",
background_color: color.grass,
padding: 20,
action: :delete_action,
}, {
title: "Block User",
background_color: color.red,
padding: 20,
action: :block_action,
}], {
# Options
transition: MGSwipeTransitionDrag,
expansion_index: 0,
fill_on_trigger: true
})
end
# ...
end
:+1: Awesome! I didn't know about MGSwipeTableCell, but I've been needing to implement this feature in an app I'm working on, so I'll definitely be checking this out.
I like your idea of having a simple, concise, intuitive API that uses similar terminology that is being used throughout RedPotion/ProMotion. You could also alias MGSwipeTransitionDrag to :drag. I would also probably call the class PM::SwipeableTableCell
This is great, Mark. Definitely worth wrapping, I think. Could we make it a RedPotion add-on? Like redpotion-swipeable-cell or something? I don't think it should be in core.
What's the current status on this? I'm really looking forward to it.
CURRENT-STATUS-BOT ACTIVATED!
:zap: BEEP :zap: BOOP :zap: BEEP :zap:
-------------------------------
| |
| Inquiry: |
| Current status of |
| proposed implementation. |
| |
| Status Report: |
| Not started. |
| |
| Stated reason(s): |
| Currently too busy. |
| |
-------------------------------
:zap: BEEP :zap: BOOP :zap: BEEP :zap:
THANK YOU FOR USING CURRENT-STATUS-BOT
lol @markrickert
This does look great. @andersennl you could start writing the tests or a branch and it would build momentum :+1: