Giter Club home page Giter Club logo

Comments (2)

raamcosta avatar raamcosta commented on June 10, 2024 1

Hi @Velord 👋

Annotated Composables with @Destination create and correspond to a single route in your graph. If you find yourself wanting to include it in multiple graphs that all have the same "root" graph (the one you pass to DestinationsNavHost), you'll have multiple destinations with the same route.

This is described here also:
https://composedestinations.rafaelcosta.xyz/v2/multi-module-setup

IMPORTANT
Generated Destinations contain navigation stuff like the route. Routes should be unique. So you cannot import another module's Destination to more than one graph.
So, if you find yourself wanting to do this, you should instead expose the actual Composable, untied from any navigation stuff, then preparing multiple @destination Composables that just call that one.

What I would do:

  • The module that is exposing this SettingsDestination, instead exposes a simple Composable function. Not tied to navigation in any way.
  • Next to the graphs where you want to include this screen, create an annotated Composable with @destination that calls your Composable from the other module.
  • Include that in your graph by simply adding the correct graph @Destination<GRAPH>. If these are both in the same module, you can actually make use of multiple @Destination annotations in one single Composable, example:
@Destination<BottomNavigationGraph>
@Destination<XGraph>
@Composable
fun SettingsDestination() {
    SettingsScreen() // from that other module that's exposing it.
}

Because you're in the module that knows both XGraph and BottomNavigationGraph, this works. It will create two Destinations, one for each graph, with different routes for each in this case.

from compose-destinations.

Velord avatar Velord commented on June 10, 2024

Thank you for unambiguous answer !

from compose-destinations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.