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

Reorderable table screen cells #570

Merged
merged 10 commits into from
Dec 5, 2014
Merged

Reorderable table screen cells #570

merged 10 commits into from
Dec 5, 2014

Conversation

markrickert
Copy link
Contributor

Pass :moveable in the cell hash as true and then put the table into editing mode by either calling toggle_edit_mode or edit_mode(enabled:true) and you'll see the draggable handles.

When you drop the cell, it will fire on_cell_moved: with arguments of a hash:

{
  :paths   => {
    :from     => #<NSIndexPath:0xb777380>,
    :to       => #<NSIndexPath:0xb777390>
  },
  :cell    => {
    :title        => "Whatever",
    :moveable     => true
    # Your other cell attributes
  }
}

this should be ready to go and has great test coverage.

@markrickert
Copy link
Contributor Author

Don't merge yet... going to make one more feature that allows the user to select if they want the cells to stay inside their own section or not.


def tableView(tableView, moveRowAtIndexPath:from_index_path, toIndexPath:to_index_path)
# TODO - Make this more readable
self.promotion_table_data.section(to_index_path.section)[:cells].insert(to_index_path.row, self.promotion_table_data.section(from_index_path.section)[:cells].delete_at(from_index_path.row))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this bit here that actually manipulates the data should be moved to the table_data.rb file. https://github.com/clearsightstudio/ProMotion/blob/master/lib/ProMotion/table/data/table_data.rb

We already have a delete_cell method in there, so maybe we could call the new method move_cell or something.

@markrickert
Copy link
Contributor Author

Added ability to pass moveable: :section to the cell and it will not allow the user to move the cell out of it's own section.

@silasjmatson
Copy link

👍 Looks good to me.

@jamonholmgren
Copy link
Owner

[FAILED - 0.==(3) failed] - should increment the tap counter on tap
BACKTRACE: Bacon::Error: 0.==(3) failed
    spec.rb:700:in `satisfy:': ProMotion::TableScreen functionality - should increment the tap counter on tap
    spec.rb:714:in `method_missing:'
    spec.rb:316:in `block in run_spec_block'
    spec.rb:440:in `execute_block'
    spec.rb:316:in `run_spec_block'
    spec.rb:331:in `run'

I HATE this test. Always fails randomly on Travis.

jamonholmgren added a commit that referenced this pull request Dec 5, 2014
@jamonholmgren jamonholmgren merged commit 387389d into master Dec 5, 2014
@jamonholmgren jamonholmgren deleted the reorderable branch December 5, 2014 18:45
@jamonholmgren
Copy link
Owner

Wiki?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants