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

[Question + Discussion] Adding sibling views to table_view in TableScreen and GroupedTableScreen #765

Open
hboon opened this issue Nov 20, 2015 · 3 comments

Comments

@hboon
Copy link

hboon commented Nov 20, 2015

Is there a straightforward way to add sibling views to table_view in TableScreen and GroupedTableView?

I'm looking specifically at 2 use cases:

  • (A) when the table_view and a sibling view don't overlap, say table_view at the top half of the screen and the sibling view at the bottom half
  • (B) when the sibling view overlays/overlaps the table_view.

I created a variation of the classes — TableViewController2, TableScreen2 and GroupedTableScreen2 to inherit from a UIViewController and adding the table_view as a subview so sibling views can be added to the resulting TableScreen2 (to work with use cases A and B). It looks like this modification can be made directly to the original 3 classes and still remain compatible.

If there's no way to do this currently with ProMotion, and there isn't a fundamental issue with this, I can create a PR for this.

I haven't thought of specific ways to test this other than the existing spec. If anyone has any idea, feel free to pitch in :)

@jamonholmgren
Copy link
Owner

Interesting approach. So instead of self.view being a UITableView, it would be a UIView that contains the UITableView as a subview?

I'm in favor of this, but it would need to be thoroughly tested for issues with existing code bases.

@bmichotte
Copy link
Contributor

This is something I had to do. I wanted a PM::TableScreen inside a PM::Screen.
It's quite easy to do

class MyTableScreen < PM::Screen

  include PM::Table
  include PM::GroupedTable

  def on_load
    init_table_view
  end

  def init_table_view
    table_view = UITableView.alloc.initWithFrame(CGRectZero, style: UITableViewStyleGrouped)
    @table_view = append!(table_view, :table_view)
    @table_view.delegate = self
    @table_view.dataSource = self
  end

  def table_view
    @table_view
  end

  alias :tableView :table_view

  def table_data
    []
  end
end

Except in this case, I don't think it's a good idea to change the way UITableViewController works.
my 2¢

@hboon
Copy link
Author

hboon commented Nov 22, 2015

Ah, that's nice. The proposed change doesn't retrofit UITableViewController. It subclasses UIViewController instead. But no worries, I'll just keep them as a custom class outside ProMotion then.

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

3 participants