Tiamat Destinations ------------------- > [!IMPORTANT] > This is experimental api Tiamat destinations library allow to generate destination list for navController automatically by applying `InstallIn` annotation on `navDestiantions` ## Setup ```kotlin // Apply compiler plugin in the plugins section plugins { id("io.github.composegears.tiamat.destinations.compiler") version "$version" } ``` ```kotlin // Add dependency sourceSets { commonMain.dependencies { implementation("io.github.composegears:tiamat-destinations:$version") } } ``` ## Usage Create graph `object` extends from `TiamatGraph` ```kotlin object Graph : TiamatGraph ``` Annotate `navDestination` with `InstallIn` annotation (multiple installations allowed), here is some valid options: ```kotlin // Using delegate @InstallIn(Graph::class) val Screen1 by navDestination { } // Using constructor @InstallIn(Graph::class) val Screen2 = NavDestination(name = "Screen2", extensions = emptyList()) {} // using object @InstallIn(Graph::class) object Screen3 : NavDestination { override val name: String = "Screen3" override val extensions: List> = emptyList() @Composable override fun NavDestinationScope.Content() { } } // NOT ALLOWED HERE class Screen4Class : NavDestination { override val name: String = "Screen4" override val extensions: List> = emptyList() @Composable override fun NavDestinationScope.Content() { } } // Using global instance property @InstallIn(Graph::class) @InstallIn(SomneOtherGraph::class) val Screen4 = Screen4Class() ``` Use graph instead of `destinations` ```kotlin val nc = rememberNavController(...) Navigation( navController = nc, graph = Graph ) ``` Multiple graphs usage also allowed ```kotlin ///... object Graph1 : TiamatGraph object Graph2 : TiamatGraph //... Navigation( navController = nc, graph = Graph1 + Graph2 ) ``` ## Emergency case In case the plugin problems, there is backport solution: override graph `destinations` function manually and disable compiler plugin ```kotlin object Graph : TiamatGraph { override fun destinations(): Array> = arrayOf( Screen1, Screen2, Screen3 ) } ``` ## Plugin & Kotlin versions compatibility | Plugin Version | Kotlin Version | |----------------|:--------------:| | 1.5.2 | 2.2.0 | | 2.0.0-alpha01 | 2.2.0 |