|
|
@ -4,13 +4,26 @@ import android.os.Bundle |
|
|
|
import androidx.activity.ComponentActivity |
|
|
|
import androidx.activity.ComponentActivity |
|
|
|
import androidx.activity.compose.setContent |
|
|
|
import androidx.activity.compose.setContent |
|
|
|
import androidx.activity.enableEdgeToEdge |
|
|
|
import androidx.activity.enableEdgeToEdge |
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Box |
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.Column |
|
|
|
import androidx.compose.foundation.layout.fillMaxSize |
|
|
|
import androidx.compose.foundation.layout.fillMaxSize |
|
|
|
import androidx.compose.foundation.layout.padding |
|
|
|
import androidx.compose.foundation.layout.padding |
|
|
|
|
|
|
|
import androidx.compose.material.icons.Icons |
|
|
|
|
|
|
|
import androidx.compose.material.icons.filled.Favorite |
|
|
|
|
|
|
|
import androidx.compose.material.icons.filled.Home |
|
|
|
|
|
|
|
import androidx.compose.material3.Icon |
|
|
|
|
|
|
|
import androidx.compose.material3.NavigationBar |
|
|
|
|
|
|
|
import androidx.compose.material3.NavigationBarItem |
|
|
|
import androidx.compose.material3.Scaffold |
|
|
|
import androidx.compose.material3.Scaffold |
|
|
|
import androidx.compose.material3.Text |
|
|
|
import androidx.compose.material3.Text |
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
|
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
|
|
|
|
import androidx.navigation.compose.NavHost |
|
|
|
|
|
|
|
import androidx.navigation.compose.composable |
|
|
|
|
|
|
|
import androidx.navigation.compose.currentBackStackEntryAsState |
|
|
|
|
|
|
|
import androidx.navigation.compose.rememberNavController |
|
|
|
import at.xaxa.demonstrator2.ui.theme.Demonstrator2Theme |
|
|
|
import at.xaxa.demonstrator2.ui.theme.Demonstrator2Theme |
|
|
|
|
|
|
|
|
|
|
|
class MainActivity : ComponentActivity() { |
|
|
|
class MainActivity : ComponentActivity() { |
|
|
@ -19,12 +32,7 @@ class MainActivity : ComponentActivity() { |
|
|
|
enableEdgeToEdge() |
|
|
|
enableEdgeToEdge() |
|
|
|
setContent { |
|
|
|
setContent { |
|
|
|
Demonstrator2Theme { |
|
|
|
Demonstrator2Theme { |
|
|
|
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> |
|
|
|
NavigationBar() |
|
|
|
Greeting( |
|
|
|
|
|
|
|
name = "Android", |
|
|
|
|
|
|
|
modifier = Modifier.padding(innerPadding) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -44,4 +52,51 @@ fun GreetingPreview() { |
|
|
|
Demonstrator2Theme { |
|
|
|
Demonstrator2Theme { |
|
|
|
Greeting("Android") |
|
|
|
Greeting("Android") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
fun NavigationBar() { |
|
|
|
|
|
|
|
val navController = rememberNavController() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scaffold( |
|
|
|
|
|
|
|
bottomBar = { |
|
|
|
|
|
|
|
NavigationBar { |
|
|
|
|
|
|
|
NavigationBarItem( |
|
|
|
|
|
|
|
icon = { Icon(Icons.Default.Home, contentDescription = "Home") }, |
|
|
|
|
|
|
|
label = { Text("Home") }, |
|
|
|
|
|
|
|
selected = navController.currentBackStackEntryAsState().value?.destination?.route == "home", |
|
|
|
|
|
|
|
onClick = { navController.navigate("home") } |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
NavigationBarItem( |
|
|
|
|
|
|
|
icon = { Icon(Icons.Default.Favorite, contentDescription = "Favorites") }, |
|
|
|
|
|
|
|
label = { Text("Favorites") }, |
|
|
|
|
|
|
|
selected = navController.currentBackStackEntryAsState().value?.destination?.route == "favorites", |
|
|
|
|
|
|
|
onClick = { navController.navigate("favorites") } |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) { innerPadding -> |
|
|
|
|
|
|
|
NavHost( |
|
|
|
|
|
|
|
navController = navController, |
|
|
|
|
|
|
|
startDestination = "home", |
|
|
|
|
|
|
|
modifier = Modifier.padding(innerPadding) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
composable("home") { HomeScreen() } |
|
|
|
|
|
|
|
composable("favorites") { FavoritesScreen() } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
fun HomeScreen() { |
|
|
|
|
|
|
|
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { |
|
|
|
|
|
|
|
Text("Home Screen") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
|
|
|
|
fun FavoritesScreen() { |
|
|
|
|
|
|
|
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { |
|
|
|
|
|
|
|
Text("Favorites Screen") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |