EurekaCommunity / SplitRow

A row for Eureka to put two rows side by side into the same UITableViewCell
MIT License
56 stars 27 forks source link

Generic split row funtion #28

Closed scottmesser closed 5 years ago

scottmesser commented 5 years ago

Anyway to make adding a split row more generic?

For example...

form +++ SplitRow<TextFloatLabelRow, TextFloatLabelRow>() {...}

this requires that TextFloatLabelRow be explicitly stated. I would like to do something like...

form +++ SplitRow<rowA, rowB>() {...}

this would allow rowA to be TextRow,EmailRow, Phone row, etc. Any ideas? Thanks!

scottmesser commented 5 years ago

not exactly a dupe, I would like to pass in a row type not modify it post creation.

scottmesser commented 5 years ago

this seems to work for now,

func addSplitRow<row: RowType>(rowType: row,) where row: BaseRow {
     form +++ SplitRow<row, row>() {
            switch rowType {
            case is TextFloatLabelRow:
                $0.rowLeft = //add row 
            default:
                //default case
            }
     }
}
marbetschar commented 5 years ago

@SMesser55 glad you found a solution!

I'm aware that typing the type twice (once in the row definition and once for child-row-initialization) is a bit tedious, but both serve a different purpose. I can't think of a clever solution to make this easier and still support each builtin and possible future custom row.

However, If you find such a clever solution I'm happy to merge a pull request!