mirror of
https://github.com/danilkinkin/buckwheat.git
synced 2025-12-31 04:13:02 +00:00
feat: make change budget silents
This commit is contained in:
parent
2f0ae9d1a6
commit
9e434453ad
2 changed files with 6 additions and 142 deletions
|
|
@ -1,122 +0,0 @@
|
|||
package com.danilkinkin.buckwheat.wallet
|
||||
|
||||
import OverrideLocalize
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.danilkinkin.buckwheat.R
|
||||
import com.danilkinkin.buckwheat.base.RenderAdaptivePane
|
||||
import com.danilkinkin.buckwheat.ui.BuckwheatTheme
|
||||
|
||||
@Composable
|
||||
fun ConfirmChangeBudget(
|
||||
onConfirm: () -> Unit,
|
||||
onClose: () -> Unit,
|
||||
) {
|
||||
Card(
|
||||
shape = MaterialTheme.shapes.extraLarge,
|
||||
modifier = Modifier
|
||||
.widthIn(max = 440.dp)
|
||||
.padding(36.dp)
|
||||
) {
|
||||
Column {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 24.dp, bottom = 16.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_priority_high),
|
||||
tint = LocalContentColor.current.copy(alpha = 0.7f),
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = stringResource(R.string.confirm_change_budget_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 24.dp)
|
||||
.padding(bottom = 24.dp)
|
||||
.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(R.string.confirm_change_budget_description),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
modifier = Modifier.padding(horizontal = 24.dp),
|
||||
)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.End,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 12.dp, horizontal = 16.dp),
|
||||
) {
|
||||
Button(
|
||||
onClick = { onClose() },
|
||||
colors = ButtonDefaults.textButtonColors(),
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
) {
|
||||
Text(text = stringResource(R.string.cancel))
|
||||
}
|
||||
Button(
|
||||
onClick = {
|
||||
onConfirm()
|
||||
onClose()
|
||||
},
|
||||
colors = ButtonDefaults.textButtonColors(),
|
||||
contentPadding = ButtonDefaults.TextButtonContentPadding,
|
||||
) {
|
||||
Text(text = stringResource(R.string.confirm_change_budget))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ConfirmChangeBudgetDialog(
|
||||
onConfirm: () -> Unit,
|
||||
onClose: () -> Unit,
|
||||
) {
|
||||
Dialog(
|
||||
onDismissRequest = { onClose() },
|
||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
||||
) {
|
||||
OverrideLocalize {
|
||||
RenderAdaptivePane {
|
||||
ConfirmChangeBudget(
|
||||
onConfirm = onConfirm,
|
||||
onClose = onClose
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun PreviewDefault() {
|
||||
BuckwheatTheme {
|
||||
ConfirmChangeBudget({}, {})
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,6 @@ fun Wallet(
|
|||
val restBudget =
|
||||
(budgetCache - spent - spentFromDailyBudget)
|
||||
|
||||
val openConfirmChangeBudgetDialog = remember { mutableStateOf(false) }
|
||||
val openConfirmFinishBudgetDialog = remember { mutableStateOf(false) }
|
||||
|
||||
if (spends === null) return
|
||||
|
|
@ -305,17 +304,17 @@ fun Wallet(
|
|||
)
|
||||
Button(
|
||||
onClick = {
|
||||
spendsViewModel.changeDisplayCurrency(currency!!)
|
||||
|
||||
if (spends!!.isNotEmpty() && !forceChange) {
|
||||
openConfirmChangeBudgetDialog.value = true
|
||||
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
spendsViewModel.changeBudget(budgetCache, dateToValue.value!!)
|
||||
} else {
|
||||
spendsViewModel.changeDisplayCurrency(currency!!)
|
||||
spendsViewModel.setBudget(budgetCache, dateToValue.value!!)
|
||||
appViewModel.activateTutorial(TUTORS.OPEN_WALLET)
|
||||
|
||||
onClose()
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
}
|
||||
|
||||
onClose()
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
@ -345,19 +344,6 @@ fun Wallet(
|
|||
}
|
||||
}
|
||||
|
||||
if (openConfirmChangeBudgetDialog.value) {
|
||||
ConfirmChangeBudgetDialog(
|
||||
onConfirm = {
|
||||
spendsViewModel.changeDisplayCurrency(currency!!)
|
||||
spendsViewModel.changeBudget(budgetCache, dateToValue.value!!)
|
||||
|
||||
onClose()
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
},
|
||||
onClose = { openConfirmChangeBudgetDialog.value = false },
|
||||
)
|
||||
}
|
||||
|
||||
if (openConfirmFinishBudgetDialog.value) {
|
||||
ConfirmFinishEarlyDialog(
|
||||
onConfirm = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue