add main activity and some screens

This commit is contained in:
Mylloon 2023-11-27 04:46:50 +01:00
parent 704856b79a
commit e01ee18251
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
5 changed files with 85 additions and 8 deletions

View file

@ -0,0 +1,9 @@
package fr.uparis.diamantkennel.memorisationapplication
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
@Composable
fun HomeScreen(padding: PaddingValues) {
}

View file

@ -4,12 +4,27 @@ import android.os.Bundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
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.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import fr.uparis.diamantkennel.memorisationapplication.ui.theme.MemorisationApplicationTheme import fr.uparis.diamantkennel.memorisationapplication.ui.theme.MemorisationApplicationTheme
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
@ -22,7 +37,7 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background color = MaterialTheme.colorScheme.background
) { ) {
ScreenMainMainActivity() MainScreenMainActivity()
} }
} }
} }
@ -30,18 +45,50 @@ class MainActivity : ComponentActivity() {
} }
@Composable @Composable
fun ScreenMainMainActivity() { fun MainScreenMainActivity() {
MainMainActivity() MainScreen()
} }
@Preview(showBackground = true) @Preview(showBackground = true)
@Composable @Composable
fun ScreenMainActivityPreview() { fun MainScreenActivityPreview() {
MainMainActivity() MainScreen()
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScreen() {
val navController = rememberNavController()
Scaffold(topBar = { TopBar() },
bottomBar = { BottomBar(navController) }) { padding ->
NavHost(
navController = navController,
startDestination = HOME,
modifier = Modifier.padding(padding)
) {
composable(HOME) { HomeScreen(padding) }
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopBar() =
TopAppBar(title = {
Text(
"Projet",
style = MaterialTheme.typography.displayMedium
)
})
@Composable @Composable
fun MainMainActivity() { fun BottomBar(navController: NavHostController) =
Text("Hello world!") BottomNavigation(backgroundColor = MaterialTheme.colorScheme.primaryContainer) {
} val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route
BottomNavigationItem(selected = currentRoute == HOME, onClick = {
navController.navigate(HOME) { launchSingleTop = true }
}, icon = { Icon(Icons.Default.Home, "Page principale") })
}

View file

@ -0,0 +1,9 @@
package fr.uparis.diamantkennel.memorisationapplication
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
@Composable
fun ModifySetScreen(padding: PaddingValues) {
}

View file

@ -0,0 +1,9 @@
package fr.uparis.diamantkennel.memorisationapplication
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
@Composable
fun PlayScreen(padding: PaddingValues) {
}

View file

@ -0,0 +1,3 @@
package fr.uparis.diamantkennel.memorisationapplication
const val HOME = "home"