|
1 /* |
|
2 * AboutOss is an utility library to retrieve and display |
|
3 * opensource licenses in Android applications. |
|
4 * |
|
5 * Copyright (C) 2023-2025 by Frederic-Charles Barthelery. |
|
6 * |
|
7 * This file is part of AboutOss. |
|
8 * |
|
9 * AboutOss is free software: you can redistribute it and/or modify |
|
10 * it under the terms of the GNU General Public License as published by |
|
11 * the Free Software Foundation, either version 3 of the License, or |
|
12 * (at your option) any later version. |
|
13 * |
|
14 * AboutOss is distributed in the hope that it will be useful, |
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 * GNU General Public License for more details. |
|
18 * |
|
19 * You should have received a copy of the GNU General Public License |
|
20 * along with AboutOss. If not, see <http://www.gnu.org/licenses/>. |
|
21 */ |
|
22 package com.geekorum.aboutoss.sampleapp |
|
23 |
|
24 import androidx.compose.runtime.Composable |
|
25 import androidx.lifecycle.viewmodel.compose.viewModel |
|
26 import androidx.navigation.compose.NavHost |
|
27 import androidx.navigation.compose.composable |
|
28 import androidx.navigation.compose.rememberNavController |
|
29 import com.geekorum.aboutoss.ui.common.OpenSourceLicensesViewModel |
|
30 import kotlinx.serialization.Serializable |
|
31 import com.geekorum.aboutoss.ui.material.OpenSourceDependenciesNavHost as Material2OpenSourceDependenciesNavHost |
|
32 import com.geekorum.aboutoss.ui.material3.OpenSourceDependenciesNavHost as Material3OpenSourceDependenciesNavHost |
|
33 |
|
34 |
|
35 @Serializable |
|
36 private object Home |
|
37 |
|
38 @Serializable |
|
39 private object Material2 |
|
40 |
|
41 @Serializable |
|
42 private object Material3 |
|
43 |
|
44 |
|
45 @Composable |
|
46 fun SampleAppIos() { |
|
47 val navController = rememberNavController() |
|
48 NavHost(navController = navController, startDestination = Home) { |
|
49 composable<Home> { |
|
50 SampleApp( |
|
51 onMaterial2Click = { |
|
52 navController.navigate(Material2) |
|
53 }, |
|
54 onMaterial3Click = { |
|
55 navController.navigate(Material3) |
|
56 } |
|
57 ) |
|
58 } |
|
59 composable<Material2> { |
|
60 Material2Screen(navigateUp = { |
|
61 navController.popBackStack() |
|
62 }) |
|
63 } |
|
64 composable<Material3> { |
|
65 Material3Screen(navigateUp = { |
|
66 navController.popBackStack() |
|
67 }) |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 @Composable |
|
73 fun Material2Screen(navigateUp: () -> Unit) { |
|
74 val viewModel: OpenSourceLicensesViewModel = viewModel(initializer = { |
|
75 createPrebuildOpenSourceLicensesViewModel() |
|
76 }) |
|
77 Material2OpenSourceDependenciesNavHost( |
|
78 openSourceLicensesViewModel = viewModel, |
|
79 navigateUp = navigateUp |
|
80 ) |
|
81 } |
|
82 |
|
83 @Composable |
|
84 fun Material3Screen(navigateUp: () -> Unit) { |
|
85 val viewModel: OpenSourceLicensesViewModel = viewModel(initializer = { |
|
86 createPrebuildOpenSourceLicensesViewModel() |
|
87 }) |
|
88 Material3OpenSourceDependenciesNavHost( |
|
89 openSourceLicensesViewModel = viewModel, |
|
90 navigateUp = navigateUp |
|
91 ) |
|
92 } |