# simple-stack

Published articles for simple-stack.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Simplified navigation between Composables of Jetpack Compose using Simple-Stack

DevFeed: [Simplified navigation between Composables of Jetpack Compose using Simple-Stack](<https://devfeed.tech/articles/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-25936.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/simplified-navigation-between-composables-of-jetpack-compose-using-simple-stack-9a796a909128?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-03-09T15:10:09Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Compose](<https://devfeed.tech/topics/compose.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [android-jetpack-compose](<https://devfeed.tech/tags/android-jetpack-compose.md>), [compose](<https://devfeed.tech/tags/compose.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>), [state](<https://devfeed.tech/tags/state.md>), [state-management](<https://devfeed.tech/tags/state-management.md>)

### AI overview

This tutorial explains how to use Simple-Stack's Compose integration for navigation between Jetpack Compose screens. It covers dependency and Activity setup, key classes, backstack navigation, configuration-change data storage, scoped services, lifecycle callbacks, and state persistence. The integration is described as beta.

### Source excerpt

Have you ever wanted to navigate between two Composables? Do you wish it were as easy as backstack.goTo(SomeScreen(arg1, arg2)) and you would go there? Good news, because now that seems to be possible with Simple-Stack's Compose integration -- which I consider BETA for now, but nonetheless, it's possible. What it looks likeInitial setup and dependencies: First, you would add the dependencies: implementation 'com.github.Zhuinden:simple-stack:2.6.0' implementation 'com.github.Zhuinden:simple-stack-extensions:2.2.0' implementation 'com.github.Zhuinden:simple-stack-compose-integration:0.2.0' And of course, you'd add Jitpack (not JCenter): // build.gradle allprojects { repositories { // ... maven { url "https://jitpack.io" } } // ... } And most importantly, you'd enable Compose: compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' useIR = true } buildFeatures { compose true }Setup To use Simple-Stack within an Activity, we use the Navigator, as always. The Compose integration is merely a different implementation of StateChanger, along with a helper that allows exposing the Backstack as a CompositionLocal for children within the composable tree. class MainActivity : AppCompatActivity() { private val composeStateChanger = AnimatingComposeStateChanger() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val backstack = Navigator.configure() .setScopedServices(DefaultServiceProvider()) .setStateChanger(AsyncStateChanger(composeStateChanger)) .install(this, androidContentFrame, History.of(FirstKey())) setContent { BackstackProvider(backstack) { MaterialTheme { Box(Modifier.fillMaxSize()) { composeStateChanger.RenderScreen() } } } } } override fun onBackPressed() { if (!Navigator.onBackPressed(this)) { super.onBackPressed() } } } This implementation of StateChanger is able to switch between keys that extend from DefaultComposeKey. In the samples, I genera

## Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack

DevFeed: [Creating a BottomNavigation Multi-Stack using child Fragments with Simple-Stack](<https://devfeed.tech/articles/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-25935.md>)

Original publisher: [Read original article](<https://zhuinden.medium.com/creating-a-bottomnavigation-multi-stack-using-child-fragments-with-simple-stack-c73c1ca3bbd4?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2021-01-25T17:03:22Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [navigation](<https://devfeed.tech/topics/navigation.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [configuration](<https://devfeed.tech/topics/configuration.md>)

Tags: [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [bottom-navigation](<https://devfeed.tech/tags/bottom-navigation.md>), [bottomnavigationview](<https://devfeed.tech/tags/bottomnavigationview.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-navigation](<https://devfeed.tech/tags/jetpack-navigation.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>)

### AI overview

A tutorial on implementing bottom navigation with a separate navigation history stack for each tab using child fragments and Simple-Stack. It explains fragment attachment and detachment, lifecycle management, and keeping back stacks alive across configuration changes.

### Source excerpt

It's been a recurring question, regardless of navigation framework of choice: how is it possible to create a screen with a bottom navigation view, that would host a navigation history stack per each tab? Each framework has its own unique ways. For example, Jetpack Navigation provides NavigationExtensions as a sample, there's FragNav, but how would you do it with Simple-Stack? How bottom navigation with child fragments normally works If you intend to create a BottomNavigationView that is hosted by a Fragment (and that Fragment hosts each tab as a child fragment), there's a bit of work needed to be done. To keep the fragments alive while switching between them, they must all be added. However, to make sure that the fragments are in the correct lifecycle (stopped while not showing), it makes sense to detach them (and attach the one that is meant to be showing). https://medium.com/media/1667d9733c198c3ae611fd45504f6bd0/href This example is also available here. Please note that there is nothing specific to Simple-Stack in this snippet, this is how a fragment can manage its child fragments and keep only one of them attached, while the rest are detached. In fact, the NavigationAdvancedSample works the same way. We will use this knowledge later in the article. What Simple-Stack normally does When you use Simple-Stack, you typically install a Navigator using Navigator.install(). This allows a single global Backstack instance to be accessible through the Activity's context (and thus making it available to all views within the Activity), and provides automatic lifecycle management to ensure that navigation is handled correctly. https://medium.com/media/03bde713eca4e7ef47d7dae31f6e095d/href This is important to know, because if we want to create a Backstack for each Fragment within our BottomNavigationView, we must manage the lifecycle (and keep the Backstack instance alive across configuration changes) ourselves. Thankfully, this is actually quite simple to do! After all, frag

## Simplified Android Development Using Simple-Stack

DevFeed: [Simplified Android Development Using Simple-Stack](<https://devfeed.tech/articles/simplified-android-development-using-simple-stack-25930.md>)

Original publisher: [Read original article](<https://medium.com/swlh/simplified-android-development-using-simple-stack-6e44ce808c35?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-11-14T03:32:51Z

Content type: tutorial

Language: en

Sources: [Stories by Gabor Varadi on Medium](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [navigation](<https://devfeed.tech/topics/navigation.md>), [android-development](<https://devfeed.tech/topics/android-development.md>), [Android](<https://devfeed.tech/topics/android.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [android-apps](<https://devfeed.tech/topics/android-apps.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [dagger-hilt](<https://devfeed.tech/tags/dagger-hilt.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>)

### AI overview

An Android development article explains Simple-Stack, a navigation framework for tracking navigation state with immutable Parcelable screen identifiers. It describes the framework's origins in Flow and Mortar and its use for type-safe Fragment navigation.

### Source excerpt

It's been a long time since I've wanted to write this article. Time to go at it, shall we? :) People always seem to be surprised and say, "wait, you DON'T use Jetpack ViewModel, Jetpack Navigation, and Dagger-Hilt? Then what DO you use?" This article intends to answer that. We use Simple-Stack. (If you prefer watching talks, then a talk on the same subject is available at https://www.youtube.com/watch?v=5ACcin1Z2HQ) What is Simple-Stack? Simple-Stack is a navigation framework that I've been working on since the beginning of 2017, although its roots go back to 2015 -- when we were still experimenting with multiple versions of Mortar & Flow. (The 90s kids might still remember). Following up on the original proposition by Square, "Advocating Against Android Fragments" and "Simpler Android Apps with Flow and Mortar", we've been using Single-Activity approach in our apps since 2015. Now, the history of Flow and Mortar isn't all roses. I've heard people say "we tried it and it didn't work for us". I can attest to that: we had to manage our own fork, but even with that, we hit some of its limitations over time. We needed something reliable and versioned, so we rewrote Flow's original behavior, and intended to improve upon its limitations. This rewrite is what resulted in the creation of Simple-Stack. Why Simple-Stack? Simple-Stack is based on the idea that you intend to track your navigation state as a list of immutable and Parcelable classes -- screen identifiers (which the library calls "keys"). As long as the underlying navigation implementation allows for "navigation from any state to any state", it is possible to wrap that implementation using Simple-Stack. For example, something I hear often is that "navigation with Fragments is hard". I always point out that in our code, it's been like this since 2016: backstack.goTo(new SecondScreen(detailId)); // java No explicit fragment transaction, no Bundle, no newInstance(), just calling a method. How is this possible? Isn't Fr