Feature Request: Making rows more scalable
Joebayld opened this issue · comments
I was thinking about how I can introduce more custom types of rows without modifying too much of the source code. I came up with something different..
What if the Row
protocol had a method to generate it's own UITableViewCell
. That way the logic for the row generation is in the object and not the QuickTableViewController
.
example:
extension Row {
/// Return a customized cell for the table
public func tableCell() -> UITableViewCell {
return UITableViewCell()
}
}
I want to make a row that allows selection. Essentially a NavigationRow
with the option to change the accessoryType.
My first idea might just be nonsense... It might just be easier to add a accessoryType
variable to navigation row, and have the view controller check if the accessory type is set. Ideally I want to just view a checkmark... See attached image.. Thoughts?
Update:
Take a look at this commit I made. It has a few major changes. I don't have pods installed so I removed those files. I also don't think the master framework would want to use any pods, but I could be wrong..
The original idea of this table view controller is to map a cellReuseIdentifier
from the model to a customized table view cell class. If there are needs for a new type of cell, I would probably create a new type of cell and still let the view controller be responsible for:
- configuring the cell with the
isSelected
value intableView(_:cellForRowAt:)
- performing the action when
tableView(_:didSelectRowAt:)
.
struct SelectableRow: Row {
let cellReuseIdentifier = NSStringFromClass(SelectableCell.self)
var isSelected: Bool = false
// ...
}
class SelectableCell: UITableViewCell {}
If the view creation has to be attached to the model, I think each Row
can be the carrier of the corresponding setups. A closure (Row) -> UITableViewCell
assigned to each row might be better than moving the view configuration to the models like dc550a7.
I'll experiment this more. Thanks for the feedback.
@Joebayld can you check if this branch works for you?
pod "QuickTableViewController",
git: "https://github.com/bcylin/QuickTableViewController.git",
branch: "feature/cell-configuration"
I've added an additional customization block to each row, along with other style related properties.
Just now looking at this. This will work. I assume you will add the delegate methods to the base class.
Thanks for this one!