Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Swipeable table cells #129

Open
markrickert opened this issue Jul 9, 2015 · 5 comments
Open

Idea: Swipeable table cells #129

markrickert opened this issue Jul 9, 2015 · 5 comments

Comments

@markrickert
Copy link
Member

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
@andrewhavens
Copy link
Collaborator

👍 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

@jamonholmgren
Copy link
Member

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.

@andersennl
Copy link

What's the current status on this? I'm really looking forward to it.

@markrickert
Copy link
Member Author

CURRENT-STATUS-BOT ACTIVATED!

⚡ BEEP ⚡ BOOP ⚡ BEEP ⚡

-------------------------------
|                             |
| Inquiry:                    |
| Current status of           |
| proposed implementation.    |
|                             |
| Status Report:              |
| Not started.                |
|                             |
| Stated reason(s):           |
| Currently too busy.         |
|                             |
-------------------------------

⚡ BEEP ⚡ BOOP ⚡ BEEP ⚡

THANK YOU FOR USING CURRENT-STATUS-BOT

@GantMan
Copy link
Member

GantMan commented Aug 8, 2015

lol @markrickert

This does look great. @andersennl you could start writing the tests or a branch and it would build momentum 👍

@andrewhavens andrewhavens changed the title Discussion: Swipeable table cells Idea: Swipeable table cells Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants