Skip to content

Simple-Stack Compose Integration 0.12.0

Choose a tag to compare

@Zhuinden Zhuinden released this 08 Apr 17:21
· 12 commits to master since this release

Simple Stack Compose Integration 0.12.0 (2023-04-08)

  • ADDED NEW MAJOR FEATURE (added by @matejdro): Support for Backstack managed by Compose.

This allows Backstack to be created at any arbitrary nesting level within composables, including nested stacks.

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            ComposeNavigator {
                createBackstack(
                    History.of(InitialKey()),
                    scopedServices = DefaultServiceProvider()
                )
            }
        }
    }
}

Nesting it like so

        Box(
            Modifier
                .weight(1f)
                .fillMaxWidth()
                .padding(bottom = 8.dp),
            propagateMinConstraints = true
        ) {
            ComposeNavigator(id = "TOP", interceptBackButton = false) {
                createBackstack(
                    History.of(FirstNestedKey()),
                    scopedServices = DefaultServiceProvider()
                )
            }
        }

and

        Box(
            Modifier
                .weight(1f)
                .fillMaxWidth()
                .padding(bottom = 8.dp),
            propagateMinConstraints = true
        ) {
            ComposeNavigator(id = "BOTTOM", interceptBackButton = false) {
                createBackstack(
                    History.of(FirstNestedKey()),
                    scopedServices = DefaultServiceProvider()
                )
            }
        }