Skip to content

Instantly share code, notes, and snippets.

@landarskiy
Last active December 16, 2022 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landarskiy/7612eb5f0f85ab8b71a956878cdaf614 to your computer and use it in GitHub Desktop.
Save landarskiy/7612eb5f0f85ab8b71a956878cdaf614 to your computer and use it in GitHub Desktop.
public data class GridPadCells(
val rowSizes: ImmutableList<GridPadCellSize>,
val columnSizes: ImmutableList<GridPadCellSize>
) {
public constructor(
rowSizes: Iterable<GridPadCellSize>, columnSizes: Iterable<GridPadCellSize>
) : this(rowSizes = rowSizes.toImmutableList(), columnSizes = columnSizes.toImmutableList())
//...
public class Builder(rowCount: Int, columnCount: Int) {
private val rowSizes: MutableList<GridPadCellSize> = GridPadCellSize.weight(rowCount)
private val columnSizes: MutableList<GridPadCellSize> = GridPadCellSize.weight(columnCount)
public fun rowSize(index: Int, size: GridPadCellSize): Builder = apply {
rowSizes[index] = size
}
public fun columnSize(index: Int, size: GridPadCellSize): Builder = apply {
columnSizes[index] = size
}
public fun build(): GridPadCells {
return GridPadCells(
rowSizes = rowSizes, columnSizes = columnSizes
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment