infinitered / infinitered/redpotion

Idea: Swipeable table cells

Open
#129 5 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.