Skip to content

Conversation

zach-klippenstein
Copy link
Collaborator

No description provided.

@zach-klippenstein zach-klippenstein force-pushed the zachklipp/backstack-helper branch 8 times, most recently from e5c4530 to f5c2987 Compare September 11, 2025 19:37
@zach-klippenstein zach-klippenstein force-pushed the zachklipp/backstack-helper branch from 640d581 to 79b24ba Compare September 11, 2025 19:58
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
public interface Stepper<T, R> {

/** The (possibly empty) stack of steps that came before the current one. */
val previousSteps: List<Step<R>>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you added this one later and it wasn't part of the initial revision and I meant to call out that something like this is needed. Likely, I would even go a step further and argue that stepper() should not return a List<R>, but rather a type that expresses how the backstack was changed.

Here is my prototype that Amazon uses in production now: https://github.com/amzn/app-platform/blob/main/recipes/common/impl/src/commonMain/kotlin/software/amazon/app/platform/recipes/backstack/PresenterBackstackScope.kt#L19-L32 (it's not part of the official API, because I wanted get an idea first how it works out in production). Here it runs in the browser: https://amzn.github.io/app-platform/#web-recipe-app

The problem I wanted to solve is to make it easy for the UI layer to play animations for changes in the backstack, like the cross-slide animation in the demo above. Exposing only a stack makes this more challenging for the UI layer. That's why I introduced the BackstackChange type.

*
* @return False if the stack was empty (i.e. this is a noop).
*/
fun goBack(): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a stack, why not call types and functions accordingly? push() and pop() feel more natural to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants