- Notifications
You must be signed in to change notification settings - Fork112
Prototype of a stepper composable helper for making backstacks.#1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
e5c4530 tof5c2987Compare640d581 to79b24baCompareSigned-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.
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 thatstepper() should not return aList<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 theBackstackChange type.
| * | ||
| * @return False if the stack was empty (i.e. this is a noop). | ||
| */ | ||
| fun goBack(): Boolean |
There was a problem hiding this comment.
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() andpop() feel more natural to me.
No description provided.