Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -20,11 +20,13 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalResources
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.unit.dp
import androidx.datastore.preferences.core.emptyPreferences
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.serranoie.app.minus.R
import com.serranoie.app.minus.domain.model.Transaction
import com.serranoie.app.minus.presentation.RECURRENT_PAYMENTS_VIEW_MODE_KEY
import com.serranoie.app.minus.presentation.settingsDataStore
Expand Down Expand Up @@ -59,6 +61,7 @@ fun History(
onShowInfoSnackbar: (message: String) -> Unit = {},
) {
val context = LocalContext.current
val resources = LocalResources.current
val view = LocalView.current
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val preferences by context.settingsDataStore.data.collectAsStateWithLifecycle(initialValue = emptyPreferences())
Expand All @@ -67,9 +70,10 @@ fun History(
}
val scrollState = rememberLazyListState()

val isAtEndOfList = remember(scrollState.canScrollForward, scrollState.layoutInfo.visibleItemsInfo) {
!scrollState.canScrollForward && scrollState.layoutInfo.visibleItemsInfo.lastOrNull() != null
}
val isAtEndOfList =
remember(scrollState.canScrollForward, scrollState.layoutInfo.visibleItemsInfo) {
!scrollState.canScrollForward && scrollState.layoutInfo.visibleItemsInfo.lastOrNull() != null
}

LaunchedEffect(isAtEndOfList) {
viewModel.processIntent(BudgetSystemIntent.SetLockSwipeable(!isAtEndOfList))
Expand Down Expand Up @@ -176,10 +180,16 @@ fun History(

fun queueDeleteWithUndo(transaction: Transaction) {
pendingRemovedTransactions = pendingRemovedTransactions + (transaction.id to transaction)
onQueueDeleteWithUndo(transaction, "${transaction.comment.ifEmpty { "Gasto" }} eliminado", {
onQueueDeleteWithUndo(
transaction,
resources.getString(
R.string.expense_deleted_format,
transaction.comment.ifEmpty { resources.getString(R.string.generic_expense) },
),
) {
pendingRemovedTransactions = pendingRemovedTransactions - transaction.id
onCancelPendingDelete()
})
}
}

fun toggleExpandedDate(date: LocalDate) {
Expand All @@ -194,7 +204,12 @@ fun History(
viewModel.processIntent(
BudgetTransactionIntent.EditTransactionTapped(updatedTransaction)
)
onShowInfoSnackbar("${updatedTransaction.comment.ifEmpty { "Gasto" }} ha sido modificado")
onShowInfoSnackbar(
resources.getString(
R.string.expense_modified_format,
updatedTransaction.comment.ifEmpty { resources.getString(R.string.generic_expense) },
),
)
onSaved()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.role
Expand Down Expand Up @@ -140,6 +141,10 @@ fun TransactionEditScreen(

var isCalculation by remember { mutableStateOf(false) }

// Calculate dynamic target height for numpad to take 48% of screen height
val configuration = LocalConfiguration.current
val screenHeight = configuration.screenHeightDp.dp
val targetNumpadHeight = screenHeight * 0.48f

val baseTextStyle = MaterialTheme.typography.displayLargeCondensed.copy(
fontWeight = FontWeight.W500
Expand Down Expand Up @@ -330,7 +335,7 @@ fun TransactionEditScreen(
Numpad(
modifier = Modifier
.fillMaxWidth()
.weight(2f),
.height(targetNumpadHeight),
editorState = editorState,
onNumberInput = { digit ->
editedAmount = if (editedAmount == "0") {
Expand Down Expand Up @@ -886,4 +891,4 @@ private fun evaluateCalculation(input: String): String? {
} catch (e: Exception) {
null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.foundation.gestures.detectVerticalDragGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -36,6 +35,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalHapticFeedback
Expand Down Expand Up @@ -94,7 +94,7 @@ fun Numpad(
onApplyPressedForTutorial: (() -> Unit)? = null,
onDragProgressChanged: (Float) -> Unit = {},
dragProgress: Float = 0f,
rowHeight: Dp = 55.dp,
rowHeight: Dp = 55.dp, // Still kept for backward compatibility but internal logic now uses weights
) {
val view = LocalView.current
val haptic = LocalHapticFeedback.current
Expand Down Expand Up @@ -186,14 +186,14 @@ fun Numpad(
Box(
Modifier
.fillMaxWidth()
.height(rowHeight * effectiveDragProgress)
.weight(effectiveDragProgress.coerceAtLeast(0.01f)) // Ensure weight > 0 to prevent crash
.clipToBounds(),
contentAlignment = androidx.compose.ui.Alignment.BottomCenter
) {
Row(
Modifier
.fillMaxWidth()
.height(rowHeight)
.fillMaxHeight()
.graphicsLayer(alpha = effectiveDragProgress)
) {
val operators = listOf('÷', '×', '+', '-')
Expand All @@ -216,7 +216,7 @@ fun Numpad(
Row(
Modifier
.fillMaxWidth()
.height(rowHeight * 4)
.weight(4f) // Use weight instead of fixed height
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -279,7 +279,6 @@ fun Numpad(
text = i.toString(),
onClick = {
onNumberInput(i)
onNumberPressedForTutorial?.invoke()
debugProgress = 0
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
})
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
<string name="new_budget_period">Nuevo período de ahorro</string>

<string name="expense_deleted_format">%1$s eliminado</string>
<string name="generic_expense">Gastos</string>
<string name="expense_modified_format">%1$s ha sido modificado</string>
<string name="generic_expense">Gasto</string>
<string name="expense_item_unnamed_expense">Gasto sin nombre</string>
<string name="expense_item_recurrent_subtitle_format">Gasto recurrente — %1$s</string>
<string name="hide_subscriptions_outside_period">Ocultar suscripciones fuera del período</string>
Expand All @@ -108,8 +109,8 @@
</plurals>

<plurals name="analytics_days_left">
<item quantity="one">%d día</item>
<item quantity="other">%d días</item>
<item quantity="one">%d día left</item>
<item quantity="other">%d días left</item>
</plurals>

<string name="total_budget">Presupuesto total</string>
Expand Down Expand Up @@ -325,7 +326,7 @@

<!-- Remaining Budget Strategy -->
<string name="strategy_dialog_title">Sobrante del presupuesto</string>
<string name="strategy_dialog_description">Puedes elegir como distribuir el balance del presupuesto al final de cada día.\n\nPor ejemplo, tienes un presupuesto de 500 al día, y ayer gastaste 400: puedes repartir 100 en los días que queda, o gastar 600 (presupuesto por día + sobrante del periodo anterior) hoy.</string>
<string name="strategy_dialog_description">Puedes elegir como distribuir el balance del presupuesto al final de cada día.\n\nFor ejemplo, tienes un presupuesto de 500 al día, y ayer gastaste 400: puedes repartir 100 en los días que queda, o gastar 600 (presupuesto por día + sobrante del periodo anterior) hoy.</string>
<string name="strategy_ask_always">Preguntarme siempre</string>
<string name="strategy_ask_always_desc">Al final del período te preguntaremos qué hacer con el sobrante</string>
<string name="strategy_split_equally">Repartir entre todos los días</string>
Expand All @@ -338,4 +339,4 @@
<string name="settings_recurrent_payments_view_mode_horizontal_title">Horizontal</string>
<string name="settings_recurrent_payments_view_mode_horizontal_subtitle">Mostrar los pagos recurrentes como tarjetas horizontales</string>
<string name="settings_recurrent_payments_view_mode_vertical_title">Vertical</string>
</resources>
</resources>
Loading
Loading