From 24ada183e219d691308b842c1e8e6f2a141e6714 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 28 Jun 2026 15:17:57 +0200 Subject: [PATCH] components: add OptionalFormSection (revealable form section) The shared wrapper for optional edit-form fields behind a "More fields" toggle: AnimatedVisibility with the family's expand+fade motion over a full-width Column. Adds the first intra-kit dependency (components -> identity) for the shared transitions. Co-Authored-By: Claude Opus 4.8 (1M context) --- components/build.gradle.kts | 4 +++ .../floret/components/FormSection.kt | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 components/src/main/kotlin/de/jeanlucmakiola/floret/components/FormSection.kt diff --git a/components/build.gradle.kts b/components/build.gradle.kts index ef4d9af..cfcab7d 100644 --- a/components/build.gradle.kts +++ b/components/build.gradle.kts @@ -33,6 +33,10 @@ kotlin { } dependencies { + // identity supplies the shared motion (expandEnter/collapseExit) that the + // revealable components animate with. + implementation(project(":identity")) + implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.ui) implementation(libs.androidx.foundation) diff --git a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/FormSection.kt b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/FormSection.kt new file mode 100644 index 0000000..d190547 --- /dev/null +++ b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/FormSection.kt @@ -0,0 +1,26 @@ +package de.jeanlucmakiola.floret.components + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import de.jeanlucmakiola.floret.identity.collapseExit +import de.jeanlucmakiola.floret.identity.expandEnter + +/** + * A form section that reveals/hides with the family's expand+fade motion — the + * shared wrapper for the optional fields behind a "More fields" toggle in the + * edit forms. [content] is laid out in a full-width [Column]. + */ +@Composable +fun OptionalFormSection(visible: Boolean, content: @Composable ColumnScope.() -> Unit) { + AnimatedVisibility( + visible = visible, + enter = expandEnter(), + exit = collapseExit(), + ) { + Column(modifier = Modifier.fillMaxWidth(), content = content) + } +}