icons in list and reformatting

This commit is contained in:
Xaver 2025-01-15 18:12:56 +01:00
parent c65b271f9c
commit 4dbeeda782
3 changed files with 22 additions and 15 deletions

View File

@ -158,7 +158,7 @@ fun HorizontalCard(modifier: Modifier = Modifier, name: String, date: String, am
fun CategoryCard( fun CategoryCard(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
name: String, name: String,
iconid: Int, iconId: Int,
onClick: () -> Unit onClick: () -> Unit
) { ) {
Surface( Surface(
@ -176,12 +176,7 @@ fun CategoryCard(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
) { ) {
LayoutMediaText(modifier, name) LayoutMediaText(modifier, name, iconId)
Icon(
icons[iconid],
contentDescription = "$name Icon"
)
} }
} }
} }
@ -235,17 +230,20 @@ fun LayoutMediaText(modifier: Modifier = Modifier, name: String, date: String, a
} }
} }
@Composable @Composable
fun LayoutMediaText(modifier: Modifier = Modifier, name: String) { fun LayoutMediaText(modifier: Modifier = Modifier, name: String, iconId: Int) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
modifier = modifier modifier = modifier
.fillMaxWidth() .fillMaxWidth()
) { ) {
Column( Row(
verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.Top), verticalAlignment = Alignment.CenterVertically, // Aligns items vertically in the center
modifier = Modifier horizontalArrangement = Arrangement.spacedBy(4.dp) // Adds space between the icon and text
.weight(1f)
) { ) {
Icon(
icons[iconId],
contentDescription = "$name Icon"
)
Text( Text(
text = name, text = name,
color = Color(0xff1b1b1b), color = Color(0xff1b1b1b),
@ -256,7 +254,6 @@ fun LayoutMediaText(modifier: Modifier = Modifier, name: String) {
letterSpacing = 0.15.sp letterSpacing = 0.15.sp
) )
) )
} }
} }
} }

View File

@ -44,7 +44,7 @@ fun CategoryOverview(
CategoryCard( CategoryCard(
modifier = modifier, modifier = modifier,
name = item.categoryName, name = item.categoryName,
icon = item.icon, iconId = item.icon,
onClick = { onCardClick(item._id) } onClick = { onCardClick(item._id) }
) )
} }

View File

@ -3,6 +3,7 @@ package at.xaxa.ledger.ui.category.add
import android.util.Log 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.defaultMinSize
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
@ -16,6 +17,7 @@ import androidx.compose.material.icons.filled.Call
import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Home import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.LocationOn import androidx.compose.material.icons.filled.LocationOn
@ -28,6 +30,7 @@ import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuBox import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -60,9 +63,10 @@ fun AddCategory(
var selectedIconIndex by remember { mutableStateOf(0) } // Store index of selected icon var selectedIconIndex by remember { mutableStateOf(0) } // Store index of selected icon
var expanded by remember { mutableStateOf(false) } // Controls dropdown visibility var expanded by remember { mutableStateOf(false) } // Controls dropdown visibility
/*
val categories by categoryViewModel.categoryUiState.categories.collectAsState(initial = emptyList()) val categories by categoryViewModel.categoryUiState.categories.collectAsState(initial = emptyList())
val category = categoryViewModel.categoryUi.category val category = categoryViewModel.categoryUi.category
var expanded by remember { mutableStateOf(false) } var expanded by remember { mutableStateOf(false) }*/
Column( Column(
modifier = modifier modifier = modifier
@ -87,6 +91,12 @@ fun AddCategory(
onValueChange = {}, onValueChange = {},
label = { Text("Icon") }, label = { Text("Icon") },
readOnly = true, readOnly = true,
leadingIcon = {
Icon(
imageVector = icons[selectedIconIndex], // Replace with your desired icon
contentDescription = "Leading Icon"
)
},
trailingIcon = { trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)
}, },