# HG changeset patch # User Da Risk # Date 1745361892 14400 # Node ID b14d574cc2b1491842de410552bd88f48f795c54 # Parent 764faee147cc187c15bfbbe8511a1df1f0d927f9 ui:material2 extract OpenSourceDependenciesNavHost to common diff -r 764faee147cc -r b14d574cc2b1 gradle/libs.versions.toml --- a/gradle/libs.versions.toml Tue Apr 22 17:56:14 2025 -0400 +++ b/gradle/libs.versions.toml Tue Apr 22 18:44:52 2025 -0400 @@ -34,6 +34,7 @@ androidx-compose-bom = "2025.04.00" androidx-lifecycle = "2.8.7" org-jetbrains-androidx-lifecycle = "2.8.4" +org-jetbrains-androidx-navigation = "2.8.0-alpha11" geekdroid = "geekttrss-1.6.7" @@ -55,6 +56,7 @@ androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" } androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref="androidx-navigation" } +org-jetbrains-androidx-navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "org-jetbrains-androidx-navigation" } androidx-compose-material = { module = "androidx.compose.material:material" } androidx-compose-material-icons-core = { module = "androidx.compose.material:material-icons-core" } diff -r 764faee147cc -r b14d574cc2b1 ui/material2/build.gradle.kts --- a/ui/material2/build.gradle.kts Tue Apr 22 17:56:14 2025 -0400 +++ b/ui/material2/build.gradle.kts Tue Apr 22 18:44:52 2025 -0400 @@ -59,10 +59,13 @@ implementation(project(":core")) implementation(compose.material) implementation(compose.components.resources) + implementation(libs.org.jetbrains.androidx.navigation.compose) } androidMain.dependencies { api(libs.androidx.activity) + implementation(dependencies.platform(libs.androidx.compose.bom)) + implementation(libs.androidx.activity.compose) } } } @@ -110,10 +113,6 @@ } dependencies { - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.androidx.activity.compose) - implementation(libs.androidx.navigation.compose) - testImplementation(libs.junit) androidTestImplementation(libs.androidx.test.ext.junit) androidTestImplementation(libs.espresso.core) diff -r 764faee147cc -r b14d574cc2b1 ui/material2/src/androidMain/kotlin/OpenSourceLicensesActivity.kt --- a/ui/material2/src/androidMain/kotlin/OpenSourceLicensesActivity.kt Tue Apr 22 17:56:14 2025 -0400 +++ b/ui/material2/src/androidMain/kotlin/OpenSourceLicensesActivity.kt Tue Apr 22 18:44:52 2025 -0400 @@ -21,15 +21,11 @@ */ package com.geekorum.aboutoss.ui.material -import android.net.Uri import android.os.Bundle import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable -import androidx.navigation.compose.NavHost -import androidx.navigation.compose.composable -import androidx.navigation.compose.rememberNavController import com.geekorum.aboutoss.core.gms.GmsLicenseInfoRepository import com.geekorum.aboutoss.ui.common.BaseOpensourceLicenseActivity import com.geekorum.aboutoss.ui.common.Factory @@ -60,7 +56,7 @@ super.onCreate(savedInstanceState) setContent { themeProvider { - DependencyNavHost( + OpenSourceDependenciesNavHost( openSourceLicensesViewModel = viewModel, navigateUp = { if (!onNavigateUp()) { @@ -83,33 +79,3 @@ } } - -@Composable -fun DependencyNavHost( - openSourceLicensesViewModel: OpenSourceLicensesViewModel, - navigateUp: () -> Unit -) { - val navController = rememberNavController() - NavHost(navController, startDestination = "dependencies") { - composable("dependencies") { - OpenSourceDependenciesListScreen( - viewModel = openSourceLicensesViewModel, - onDependencyClick = { - navController.navigate("dependency_license/${Uri.encode(it)}") - }, - onUpClick = navigateUp - ) - } - composable("dependency_license/{dependency}") { - val dependency = requireNotNull(it.arguments?.getString("dependency")) - OpenSourceLicenseScreen( - viewModel = openSourceLicensesViewModel, - dependency = dependency, - onUpClick = { - navController.popBackStack() - }, - ) - } - } -} - diff -r 764faee147cc -r b14d574cc2b1 ui/material2/src/commonMain/kotlin/com/geekorum/aboutoss/ui/material/OpenSourceDependenciesNavHost.kt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/material2/src/commonMain/kotlin/com/geekorum/aboutoss/ui/material/OpenSourceDependenciesNavHost.kt Tue Apr 22 18:44:52 2025 -0400 @@ -0,0 +1,58 @@ +/* + * AboutOss is an utility library to retrieve and display + * opensource licenses in Android applications. + * + * Copyright (C) 2023-2025 by Frederic-Charles Barthelery. + * + * This file is part of AboutOss. + * + * AboutOss is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AboutOss is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AboutOss. If not, see . + */ +package com.geekorum.aboutoss.ui.material + +import androidx.compose.runtime.Composable +import androidx.core.uri.UriUtils +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import com.geekorum.aboutoss.ui.common.OpenSourceLicensesViewModel + +@Composable +fun OpenSourceDependenciesNavHost( + openSourceLicensesViewModel: OpenSourceLicensesViewModel, + navigateUp: () -> Unit +) { + val navController = rememberNavController() + NavHost(navController, startDestination = "dependencies") { + composable("dependencies") { + OpenSourceDependenciesListScreen( + viewModel = openSourceLicensesViewModel, + onDependencyClick = { + navController.navigate("dependency_license/${UriUtils.encode(it)}") + }, + onUpClick = navigateUp + ) + } + composable("dependency_license/{dependency}") { + val dependency = requireNotNull(it.arguments?.getString("dependency")) + OpenSourceLicenseScreen( + viewModel = openSourceLicensesViewModel, + dependency = dependency, + onUpClick = { + navController.popBackStack() + }, + ) + } + } +}