infinitered / bluepotion

Like RedPotion, but for Android
MIT License
74 stars 18 forks source link

[WIP] Initial work on PMListScreen #25

Closed jamonholmgren closed 9 years ago

jamonholmgren commented 9 years ago

This is a bare-bones implementation of PMListScreen. The API works something like this:

class NormalScreen < PMListScreen
  title "Normal with an array"

  def table_data
    [
      { title: "item 1", action: :something, arguments: { some: "args" }, cell_class: Potion::TextView },
      { title: "item 2", action: :something, arguments: { some: "args" }, cell_class: Potion::TextView },
      { title: "item 3", action: :something, arguments: { some: "args" }, cell_class: Potion::TextView },
      { title: "item 4", action: :something, arguments: { some: "args" }, cell_class: Potion::TextView },
      { title: "item 5", action: :something, arguments: { some: "args" }, cell_class: Potion::TextView },
    ]
  end

  def something(arguments, position)
    cell = adapter.item(position)
  end
end

class CursorScreen < PMListScreen
  title "Cursor screen"

  def table_data
    {
      cursor: @data_cursor, # some Cursor object
      cell: {
        title_column: 1, # column to populate the cell.text
        cell_class: :xml_to_inflate, # or takes a real class, defaults to Potion::TextView
        action: :something,
      }
    }
  end

  def something(data, position)
    cell = adapter.item(position)
  end
end
GantMan commented 9 years ago

@darinwilson and I have some stuff to help with this.

jamonholmgren commented 9 years ago

Great. We should chat about the API too. I'm not at all satisfied with how this looks. Now that I've done this exploratory programming part, I think I know enough about how it works to rethink the API and make it align more closely with what ProMotion users expect.

jamonholmgren commented 9 years ago

I think we could merge this into master, @twerth . It works (I think) and the API isn't completely nonsense anymore.