Skip to content

Commit

Permalink
No error for non-positive rollover
Browse files Browse the repository at this point in the history
snackbar instead of toast
  • Loading branch information
mtotschnig committed Nov 9, 2024
1 parent 699bfc5 commit 2b4c0c0
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.totschnig.myexpenses.R
import org.totschnig.myexpenses.activity.BaseActivity
import org.totschnig.myexpenses.model.CurrencyUnit
import org.totschnig.myexpenses.model.Money
import org.totschnig.myexpenses.model.Sort
Expand Down Expand Up @@ -438,18 +439,16 @@ private fun RowScope.BudgetNumbers(
editRollOver?.getOrDefault(category.id, category.budget.rollOverNext)
?: category.budget.rollOverNext
val rollOverTotal = rollOver + rollOverFromChildren
val isError = rollOverTotal > remainder
val isError = rollOverTotal > remainder && rollOver > 0L
Row(
modifier = Modifier.numberColumn(this, narrowScreen, isLast = true),
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
if (isError) {
val context = LocalContext.current
val context = LocalContext.current as BaseActivity
val message = stringResource(R.string.rollover_edit_invalid)
Icon(
modifier = Modifier.clickable {
Toast.makeText(context, message, Toast.LENGTH_LONG).show()
},
modifier = Modifier.clickable { context.showSnackBar(message) },
imageVector = Icons.Default.ErrorOutline,
tint = colorResource(id = R.color.colorErrorDialog),
contentDescription = null
Expand Down

0 comments on commit 2b4c0c0

Please sign in to comment.