Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
817 B
2
Indexable
Never
private fun removeIconAndDescription(sections: List<DynamicMenuSection>): List<DynamicMenuSection> {
    return sections.map { section ->
        val modifiedContent = section.content?.map { content ->
            removeDescriptionFromContent(content)
        }
        DynamicMenuSection(
            section.title,
            modifiedContent ?: emptyList(),
            section.toggle,
            section.validate
        )
    }
}

private fun removeDescriptionFromContent(content: DynamicMenuContent?): DynamicMenuContent? {
    if (content == null) return null

    val modifiedChildren = content.children?.map { child ->
        removeDescriptionFromContent(child)
    }

    // Remove description at this level
    return content.copy(description = null, children = modifiedChildren)
}