# HG changeset patch # User Da Risk # Date 1745363210 14400 # Node ID b144901856dc64da0cede63220323fcc8ca3b1ad # Parent d59fc19f19fa6aa7cc31e02c54d0fdf92142b527 ui:material3: extract OpenSourceDependenciesNavHost to common diff -r d59fc19f19fa -r b144901856dc ui/material3/src/androidMain/kotlin/OpenSourceLicensesActivity.kt --- a/ui/material3/src/androidMain/kotlin/OpenSourceLicensesActivity.kt Tue Apr 22 19:01:42 2025 -0400 +++ b/ui/material3/src/androidMain/kotlin/OpenSourceLicensesActivity.kt Tue Apr 22 19:06:50 2025 -0400 @@ -22,7 +22,6 @@ package com.geekorum.aboutoss.ui.material3 import android.app.Activity -import android.net.Uri import android.os.Bundle import androidx.activity.compose.setContent import androidx.activity.viewModels @@ -33,9 +32,6 @@ import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalView import androidx.core.view.WindowCompat -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 @@ -67,7 +63,7 @@ WindowCompat.setDecorFitsSystemWindows(window, false) setContent { themeProvider { - DependencyNavHost( + OpenSourceDependenciesNavHost( openSourceLicensesViewModel = viewModel, navigateUp = { if (!onNavigateUp()) { @@ -100,31 +96,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 d59fc19f19fa -r b144901856dc ui/material3/src/commonMain/kotlin/com/geekorum/aboutoss/ui/material3/OpenSourceDependenciesNavHost.kt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/material3/src/commonMain/kotlin/com/geekorum/aboutoss/ui/material3/OpenSourceDependenciesNavHost.kt Tue Apr 22 19:06:50 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.material3 + +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() + }, + ) + } + } +}