Closed matthewsinclair closed 9 years ago
hey @matthewsinclair - I am still pretty new to the ProMotion side. But the native delete (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
should still be able to be handled, I think - right?
as far as I can tell thats not in ProMotion's base, but maybe it should be.
Yep, you're right. I ended up doing this:
# Added this to a base class for DataTables
def tableView(table_view, didSelectRowAtIndexPath: index_path)
super.tap do
on_cell_tapped(cell_at(index_path: index_path))
end
end
# Then use this in subclasses to catch a cell tapped event
def on_cell_tapped(data_cell)
...
end
Hey @matthewsinclair - it's easier than that :)
class Tag < CDQManagedObject
def cell
{
title: whatever,
action: :tapped_tag,
arguments: {
one: 1,
two: 2
}
}
end
end
class TagsPopularScreen < ::PM::DataTableScreen
title 'Popular'
stylesheet TagsPopularScreenStylesheet
model Tag, scope: :where_is_popular
searchable placeholder: "Search", fields: [:tag], hide_initially: true
def tapped_tag(args)
# args will be:
# {one: 1, two: 2}
end
end
Hope that clears it up for you!
Of course! I wasn't used to the cell definition in the model.
Regards, M@
On 7 Aug 2015, at 6:10 am, Mark Rickert notifications@github.com wrote:
Hey @matthewsinclair - it's easier than that :)
class Tag < CDQManagedObject def cell { title: whatever, action: :tapped_tag, arguments: { one: 1, two: 2 }
} end endclass TagsPopularScreen < ::PM::DataTableScreen title 'Popular' stylesheet TagsPopularScreenStylesheet model Tag, scope: :where_is_popular searchable placeholder: "Search", fields: [:tag], hide_initially: true
def tapped_tag(args)
args will be:
# {one: 1, two: 2}
end end Hope that clears it up for you!
— Reply to this email directly or view it on GitHub.
Yup. It's a little weird defining the action and arguments in the model and then having it execute in the controller, but it's the best system I could come up with.
I wonder if it would make sense to have something like a cell_for_entity(entity)
(bad name, but you know what I mean) method in DataTableScreen
that would be called to get the cell config hash for a particular entity? That way, the DataTableScreen
/ view controller stuff would be in the view controller, and not the model? Just a thought.
I've got a simple
::PM::DataTableScreen
that looks like this:What's the recommended approach for catching a touch event on one of the cells? This is trivial in a normal ProMotion table screen because you're providing the actions with the cell data. But I'm not sure what the right way to do that would be for a table where the data is coming from a CDQ data source.
Do I need to get in underneath and catch the raw iOS touch event for the table and work out manually what cell was tapped? Or is there a shorthand?
Thanks, M@