Prototype of a stepper composable helper for making backstacks.#1423
Prototype of a stepper composable helper for making backstacks.#1423zach-klippenstein wants to merge 2 commits intomainfrom
Conversation
e5c4530 to
f5c2987
Compare
640d581 to
79b24ba
Compare
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>> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
If this is a stack, why not call types and functions accordingly? push() and pop() feel more natural to me.
No description provided.