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: "headless" tables #65

Open
jamonholmgren opened this issue Mar 29, 2015 · 1 comment
Open

Idea: "headless" tables #65

jamonholmgren opened this issue Mar 29, 2015 · 1 comment

Comments

@jamonholmgren
Copy link
Member

@twerth and I discussed several scenarios related to #63 and infinitered/rmq#232. One of the sticking points is collections or sets of data and how to represent those on a screen. Todd and I agree that tables are underutilized as child views, and I'd like to make that easier.

I have this concept of a "headless" table view. ProMotion makes it easy to make a PM::TableScreen subclass, but what if we could do this in a normal screen:

class ContactScreen < PM::Screen
  def on_load
    append email_view, :emails
  end

  def email_view
    @email_view ||= build_table_view([{
      title: "Email addresses",
      cells: @emails.map do |email|
        {
          cell_class: SomeCustomClass,
          title: email,
          action: :tapped_email,
          arguments: { email: email } 
        }
      end
    }])
  end

  def tapped_email(args={})
    args[:email] # => some email
  end
end

No explicit PM::TableScreen subclass would be necessary. All events would be passed through to the parent screen, and the UITableViewController instance would be automatically built, added as a childViewController, and managed from your current screen instance. These things are usually pretty boilerplate anyway, so it makes sense to have a helper for this.

Thoughts?

@jamonholmgren
Copy link
Member Author

It's possible that this should be considered as a ProMotion-proper feature, so I've added an issue there too to track this. jamonholmgren/ProMotion#652

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

2 participants