Imported from flaringapp/ComposeCollapsingTopBar (
AGENTS.md). Install upstream withnpx skills add flaringapp/ComposeCollapsingTopBar. Copyright stays with the author.
Repository Guidelines
Project Focus
This repo contains a published Compose Multiplatform library for collapsing top bar / toolbar UI. Most work here is incremental library evolution rather than greenfield setup: adding modifiers, extending existing behavior, tightening interactions, and keeping the sample app aligned with library changes.
Treat changes as library work first:
- Preserve existing behavior unless the task explicitly changes it.
- For any behavior change, read the affected implementation end-to-end and review nearby code paths that may now be inconsistent.
- If you touch public API, verify whether docs, samples, and the checked-in ABI snapshot also need updates.
Project Structure
ComposeCollapsingTopBar/ is the published library module.
- Public APIs live in
ComposeCollapsingTopBar/src/commonMain/kotlin/com/flaringapp/compose/topbar. - Related behavior is grouped under
scaffold,nestedscroll,nestedcollapse,snap, anddependent. - The ABI snapshot is
ComposeCollapsingTopBar/api/ComposeCollapsingTopBar.klib.api.
sample/shared/ is the Compose Multiplatform sample app used to exercise and demonstrate library behavior.
- Entry point:
sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/App.kt - Sample registry:
sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/CollapsingTopBarSampleGroups.kt - Gallery UI:
sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/gallery - Shared sample helpers:
sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/common
sample/android/ packages the Android launcher app for manual verification. Documentation assets used by the README live in docs/assets/.
Change Expectations
Before editing:
- Read all directly related files, not just the first obvious entry point.
- Trace how state, modifiers, nested scroll, snap, and scaffold interactions connect if your change touches any of them.
- Check whether sample code already demonstrates the behavior you are changing.
When editing:
- Update existing code paths when needed so old and new behavior remain coherent.
- Keep new APIs and modifiers aligned with existing naming and package structure under
com.flaringapp.compose.topbar. - Be explicit about public visibility and return types.
After editing:
- Revisit impacted samples and previews.
- If behavior changed, make sure the sample app still demonstrates the intended interaction clearly.
Build, Test, and Verification
Use the Gradle wrapper from the repo root:
./gradlew ktlintCheck./gradlew ktlintFormat./gradlew checkLegacyAbi./gradlew :sample:android:assembleDebug
Minimum expectation for most code changes:
- Run
./gradlew :sample:android:assembleDebug ktlintCheck checkLegacyAbiwhen feasible. - For Compose API or implementation changes, also run the relevant Compose lint task for each changed module, for example
./gradlew :ComposeCollapsingTopBar:compileLintor the corresponding sample-module lint task when changes are made there. - For public API changes, pay special attention to
checkLegacyAbiand the.klib.apisnapshot. - For behavior changes, validate through the sample app, especially
sample/shared/and the Android sample shell.
Coding Style
- Follow Kotlin defaults with 4-space indentation and trailing commas where formatting expects them.
- Use
UpperCamelCasefor composables and state holders. - Use
lowerCamelCasefor functions and properties. - Keep package names under
com.flaringapp.compose.topbar. - Run
./gradlew ktlintFormatbefore wrapping up when formatting changed.
Samples And Preview Structure
The preview strategy is sample-driven. Most previews live in sample/shared/src/commonMain/... beside the composable they exercise.
High-level structure:
- Each navigable sample is typically an
objectimplementingCollapsingTopBarSample. - That object exposes
namefor the gallery card andContent(onBack)for in-app navigation. - The actual reusable UI usually lives in a
*SampleContent(...)composable in the same file. - Local
@Previewfunctions render that content insideComposeCollapsingTopBarTheme.
Current sample wiring:
App.ktbuilds the gallery fromCollapsingTopBarSampleGroups.CollapsingTopBarSampleGroupsis the source of truth for which samples appear in each gallery section.- Gallery rows render sample names only; the preview itself is not the gallery card.
- Reusable sample pieces and control widgets are split into
common/,scaffold/,gallery/, and feature-specific packages.
How to add a new sample preview for a feature:
- Add or update the feature sample file under the relevant package in
sample/shared/ui/samples. - If it should be navigable from the sample app, expose it as a
CollapsingTopBarSampleobject. - Put the main demo UI in a reusable
*SampleContent(...)composable. - Add a local
@Previewthat wraps*SampleContent(...)inComposeCollapsingTopBarTheme. - Register the sample in
CollapsingTopBarSampleGroupsif it belongs in the gallery. - If the feature depends on shared demo building blocks, prefer extending existing helpers in
ui/samples/commonor scaffold controls instead of duplicating UI setup.
Tests
There is no large committed unit-test suite yet. All testing is done manually at this point.
