navigate to add
This commit is contained in:
parent
5d72d47c8b
commit
ec6a6e341b
@ -9,6 +9,7 @@ import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import at.xaxa.ledger.ui.add.Add
|
||||
import at.xaxa.ledger.ui.home.Home
|
||||
|
||||
enum class AppRoutes(val route: String) {
|
||||
@ -30,16 +31,22 @@ fun LedgerApp(modifier: Modifier = Modifier){
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
composable(AppRoutes.Home.route){
|
||||
Home(onCardClick = {
|
||||
navController.navigate("home")
|
||||
Home(
|
||||
onCardClick = {
|
||||
navController.navigate("edit/$id")
|
||||
},
|
||||
onButtonClick = {
|
||||
navController.navigate("add")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
composable(AppRoutes.Add.route) {
|
||||
Add(onCardClick = {
|
||||
navController.navigate("add")
|
||||
})
|
||||
}
|
||||
/*
|
||||
composable(AppRoutes.Add.route) {
|
||||
SearchList(onCardClick = {
|
||||
navController.navigate("add/$it")
|
||||
})
|
||||
}
|
||||
composable(
|
||||
route = AppRoutes.Edit.route,
|
||||
arguments = listOf(navArgument("gameId") {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package at.xaxa.ledger.ui
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -13,7 +11,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.requiredHeight
|
||||
import androidx.compose.foundation.layout.requiredWidth
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
|
@ -1,2 +1,34 @@
|
||||
package at.xaxa.ledger.ui.add
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import at.xaxa.ledger.ui.AppViewModelProvider
|
||||
import at.xaxa.ledger.ui.home.HomeViewModel
|
||||
|
||||
@Composable
|
||||
fun Add(modifier: Modifier = Modifier, onCardClick: (Int) -> Unit, HomeViewModel : HomeViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
||||
var spending by remember { mutableStateOf("") }
|
||||
|
||||
Column(
|
||||
modifier = modifier.fillMaxSize()
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = spending,
|
||||
onValueChange = { spending = it },
|
||||
label = { Text("Spending") },
|
||||
modifier = Modifier.fillMaxWidth().padding(16.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import at.xaxa.ledger.ui.HorizontalCard
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun Home(modifier: Modifier = Modifier, onCardClick: (Int) -> Unit, HomeViewModel : HomeViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
||||
fun Home(modifier: Modifier = Modifier, onCardClick: (Int) -> Unit, onButtonClick: () -> Unit, HomeViewModel : HomeViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
||||
val state by HomeViewModel.entryUIState.entry.collectAsState(initial = emptyList())
|
||||
|
||||
Column(
|
||||
@ -58,7 +58,7 @@ fun Home(modifier: Modifier = Modifier, onCardClick: (Int) -> Unit, HomeViewMode
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
ButtonSuccess(modifier = Modifier, "Add Transaction", onClick = { println("success") })
|
||||
ButtonSuccess(modifier = Modifier, "Add Transaction", onClick = { onButtonClick() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user