infinitered / infinitered/redpotion
Idea: Swipeable table cells
- Dominant language
- Ruby
- Stars
- 233
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
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`](https://github.com/MortimerGoro/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:
``` ruby
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:
``` ruby
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
```
Contributor guide
Research direction
Start by reviewing the proposed MGSwipeTableCell usage and the shortened PM::SwipeTableCell DSL example in the issue. Determine whether RedPotion should support this abstraction, which button and option APIs it would need, and what examples or tests would demonstrate a complete design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100