Icon List added for Category

This commit is contained in:
Florian 2025-01-15 17:11:33 +01:00
parent 63083c6cab
commit 359a67e560
2 changed files with 42 additions and 10 deletions

View File

@ -90,7 +90,7 @@ fun LedgerApp(modifier: Modifier = Modifier){
navController.navigate("home") navController.navigate("home")
}, },
onCardClick = { onCardClick = {
navController.navigate("catEdit/$it") navController.navigate("categoryEdit/$it")
} }
) )
} }

View File

@ -1,5 +1,6 @@
package at.xaxa.ledger.ui.category.add package at.xaxa.ledger.ui.category.add
import android.util.Log
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
@ -7,6 +8,22 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.Call
import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.LocationOn
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.ShoppingCart
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -34,6 +51,21 @@ fun addCategory(
onCardClick: (Int) -> Unit, onCardClick: (Int) -> Unit,
categoryViewModel: CategoryViewModel = viewModel(factory = AppViewModelProvider.Factory) categoryViewModel: CategoryViewModel = viewModel(factory = AppViewModelProvider.Factory)
) { ) {
val icons = listOf(
Icons.Filled.Call,
Icons.Filled.Home,
Icons.Filled.Build,
Icons.Filled.ShoppingCart,
Icons.Filled.Notifications,
Icons.Filled.LocationOn,
Icons.Filled.Delete,
Icons.Filled.Lock,
Icons.Filled.Info,
Icons.Filled.Warning,
Icons.Filled.Check,
Icons.Filled.Close,
Icons.Filled.AccountBox
)
var name by remember { mutableStateOf("") } var name by remember { mutableStateOf("") }
var icon by remember { mutableStateOf(0) } var icon by remember { mutableStateOf(0) }
@ -48,8 +80,9 @@ fun addCategory(
.padding(16.dp, 0.dp), .padding(16.dp, 0.dp),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
OutlinedTextField( OutlinedTextField(
value = category.categoryName, value = name,
onValueChange = { name = it }, onValueChange = { name = it },
label = { Text("Name") }, label = { Text("Name") },
modifier = Modifier modifier = Modifier
@ -83,25 +116,24 @@ fun addCategory(
} }
) )
} }
LazyColumn( LazyColumn(
Modifier.weight(1f) Modifier.weight(1f)
) { ) {
items(categories) { item -> items(categories) { item ->
Column( Column(
modifier = Modifier.padding(vertical = 4.dp) modifier = Modifier.padding(vertical = 4.dp)
) { ) {
Log.w("KRAUSI", item.categoryName )
CategoryCard( CategoryCard(
modifier = modifier, modifier = modifier,
name = category.categoryName, name = item.categoryName,
icon = category.icon, icon = item.icon,
onClick = { onCardClick(category._id) } onClick = { onCardClick(item._id) }
) )
} }
} }
} }
} }
} }