Compare commits

..

2 Commits

Author SHA1 Message Date
Rafal Wisniewski
38f3760cef fix: math on add expense screen 2026-05-04 21:57:23 +02:00
Rafal Wisniewski
9225f2275f fix: adjust style of delete confirmation dialog 2026-05-04 21:42:55 +02:00
3 changed files with 33 additions and 25 deletions

View File

@@ -115,10 +115,6 @@ fun AddExpenseBottomSheet(
) { ) {
val currentTripId = currentTrip.id val currentTripId = currentTrip.id
// if (categories.isEmpty()) {
// return
// }
var amount by remember { var amount by remember {
mutableStateOf( mutableStateOf(
"%.2f".format(expenseDtoToEdit?.expense?.amount ?: 0.00) "%.2f".format(expenseDtoToEdit?.expense?.amount ?: 0.00)
@@ -139,7 +135,7 @@ fun AddExpenseBottomSheet(
) )
} }
var category by remember { var category by remember {
mutableStateOf<Category?>( mutableStateOf(
expenseDtoToEdit?.category ?: if (categories.isEmpty()) null else categories[0] expenseDtoToEdit?.category ?: if (categories.isEmpty()) null else categories[0]
) )
} }
@@ -484,12 +480,20 @@ fun NumberKeyboard(
modifier = Modifier modifier = Modifier
.weight(1f), .weight(1f),
containerColor = Color.Transparent, containerColor = Color.Transparent,
onLongClick = onLongBackspaceClick onLongClick = onLongBackspaceClick,
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
) )
"+", "÷", "", "×" -> KeyboardButton( "+", "÷", "", "×" -> KeyboardButton(
text = key, text = key,
onClick = { onOperatorClick(key) }, onClick = {
when (key) {
"+" -> onOperatorClick("+")
"÷" -> onOperatorClick("/")
"" -> onOperatorClick("-")
"×" -> onOperatorClick("*")
}
},
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
containerColor = MaterialTheme.colorScheme.tertiaryContainer, containerColor = MaterialTheme.colorScheme.tertiaryContainer,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer contentColor = MaterialTheme.colorScheme.onTertiaryContainer
@@ -500,7 +504,7 @@ fun NumberKeyboard(
onClick = { onNumberClick(key) }, onClick = { onNumberClick(key) },
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
containerColor = Color.Transparent, containerColor = Color.Transparent,
contentColor = MaterialTheme.colorScheme.onSecondary contentColor = MaterialTheme.colorScheme.onPrimaryContainer
) )
} }
} }
@@ -532,7 +536,8 @@ fun KeyboardButton(
when { when {
text != null -> Text( text != null -> Text(
text = text, text = text,
style = MaterialTheme.typography.headlineMedium style = MaterialTheme.typography.headlineMedium,
color = contentColor
) )
icon != null -> Icon(painter = icon, contentDescription = null) icon != null -> Icon(painter = icon, contentDescription = null)

View File

@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.os.Build import android.os.Build
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@@ -22,6 +21,8 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
@@ -400,20 +401,22 @@ fun DeleteConfirmationDialog(
.fillMaxWidth() .fillMaxWidth()
.padding(top = 24.dp) .padding(top = 24.dp)
) { ) {
Text( Button(
text = stringResource(string.cancel), modifier = Modifier.padding(end = 20.dp),
style = MaterialTheme.typography.titleMedium, onClick = onCancel
color = MaterialTheme.colorScheme.onSecondaryContainer, ) {
modifier = Modifier Text(stringResource(string.cancel))
.padding(end = 24.dp) }
.clickable { onCancel() }
) Button(
Text( onClick = onConfirm,
text = stringResource(string.delete), colors = ButtonDefaults.buttonColors(
color = MaterialTheme.colorScheme.error, containerColor = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.titleMedium, contentColor = MaterialTheme.colorScheme.onError
modifier = Modifier.clickable { onConfirm() }
) )
) {
Text(stringResource(string.delete))
}
} }
} }
} }

View File

@@ -230,7 +230,7 @@ fun SwipeToDeleteExpenseCard(
Modifier Modifier
.clip(CardDefaults.elevatedShape) .clip(CardDefaults.elevatedShape)
.fillMaxSize() .fillMaxSize()
.background(MaterialTheme.colorScheme.onError) .background(MaterialTheme.colorScheme.errorContainer)
.padding(horizontal = 20.dp), .padding(horizontal = 20.dp),
contentAlignment = Alignment.CenterEnd contentAlignment = Alignment.CenterEnd
) { ) {