commonMain.com.github.insanusmokrassar.TelegramBotAPI.utils.Matrix.kt Maven / Gradle / Ivy
package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.Matrix
fun row(block: RowBuilder.() -> Unit): List {
return RowBuilder().also(block).row
}
fun MatrixBuilder.row(block: RowBuilder.() -> Unit) {
add(RowBuilder().also(block).row)
}
fun matrix(block: MatrixBuilder.() -> Unit): Matrix {
return MatrixBuilder().also(block).matrix
}
class RowBuilder {
private val mutRow: MutableList = ArrayList()
val row: List
get() = mutRow
fun add(t: T) = mutRow.add(t)
}
class MatrixBuilder {
private val mutMatrix: MutableList> = ArrayList()
val matrix: Matrix
get() = mutMatrix
fun add(t: List) = mutMatrix.add(t)
operator fun plus(t: List) = add(t)
}