All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.symphony.FixedActionsBuilder.kt Maven / Gradle / Ivy

Go to download

A kotlin multiplatform library for representing headless collection based ui such as lists, tables and grids

The newest version!
@file:Suppress("NOTHING_TO_INLINE")

package symphony

import kevlar.Action0
import kevlar.builders.Actions0Builder
import kollections.plus
import kollections.mutableMapOf
import kollections.associateBy
import kollections.filterKeys
import kollections.toList
import kollections.List
import kollections.size
import kollections.values

class FixedActionsBuilder @PublishedApi internal constructor(
    private val builder: Actions0Builder.() -> Unit,
    @PublishedApi
    internal val filters: MutableSet = mutableSetOf()
) {
    @PublishedApi
    internal val extraActions = mutableMapOf>()

    internal inline fun List>.applyFilters() = associateBy {
        it.key
    }.filterKeys {
        !filters.contains(it.lowercase())
    }.values.toList()

    fun buildActions() : List> {
        val actions = Actions0Builder().apply(builder).actions.toList()
        val extras = extraActions.values
        return (actions + extras).applyFilters()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy