Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Delete account 2nd and 3rd confirmation #2641

Merged
9 changes: 6 additions & 3 deletions config/detekt/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
<ID>ComposableParamOrder:CircleButtons.kt$CircleButtonFilledGradient</ID>
<ID>ComposableParamOrder:CurrencyPicker.kt$CurrencyPicker</ID>
<ID>ComposableParamOrder:CustomExchangeRateCard.kt$CustomExchangeRateCard</ID>
<ID>ComposableParamOrder:DeleteModal.kt$DeleteConfirmationModal</ID>
<ID>ComposableParamOrder:DeleteModal.kt$DeleteModal</ID>
<ID>ComposableParamOrder:DescriptionModal.kt$DescriptionModal</ID>
<ID>ComposableParamOrder:EditBottomSheet.kt$AccountsRow</ID>
Expand Down Expand Up @@ -2312,7 +2313,7 @@
<ID>LongMethod:FilterOverlay.kt$@Composable fun BoxWithConstraintsScope.FilterOverlay( visible: Boolean, baseCurrency: String, accounts: List&lt;Account&gt;, categories: List&lt;Category&gt;, filter: ReportFilter?, onClose: () -&gt; Unit, onSetFilter: (ReportFilter?) -&gt; Unit )</ID>
<ID>LongMethod:HomeTab.kt$@ExperimentalAnimationApi @ExperimentalFoundationApi @Composable private fun BoxWithConstraintsScope.UI( state: HomeState, onEvent: (HomeEvent) -&gt; Unit )</ID>
<ID>LongMethod:ImportResultUI.kt$@Composable fun ImportResultUI( result: ImportResult, launchedFromOnboarding: Boolean, isManualCsvImport: Boolean = false, onTryAgain: (() -&gt; Unit)? = null, onFinish: () -&gt; Unit )</ID>
<ID>LongMethod:ItemStatisticScreen.kt$@Composable private fun BoxWithConstraintsScope.UI( period: TimePeriod, baseCurrency: String, currency: String, account: Account?, category: Category?, categories: ImmutableList&lt;Category&gt;, accounts: ImmutableList&lt;Account&gt;, balance: Double, balanceBaseCurrency: Double?, income: Double, expenses: Double, initWithTransactions: Boolean = false, treatTransfersAsIncomeExpense: Boolean = false, history: ImmutableList&lt;TransactionHistoryItem&gt;, upcomingExpanded: Boolean = true, setUpcomingExpanded: (Boolean) -&gt; Unit = {}, upcomingIncome: Double = 0.0, upcomingExpenses: Double = 0.0, upcoming: ImmutableList&lt;Transaction&gt; = persistentListOf(), overdueExpanded: Boolean = true, setOverdueExpanded: (Boolean) -&gt; Unit = {}, overdueIncome: Double = 0.0, overdueExpenses: Double = 0.0, overdue: ImmutableList&lt;Transaction&gt; = persistentListOf(), onPreviousMonth: () -&gt; Unit, onNextMonth: () -&gt; Unit, onSetPeriod: (TimePeriod) -&gt; Unit, onEditAccount: (Account, Double) -&gt; Unit, onEditCategory: (Category) -&gt; Unit, onDelete: () -&gt; Unit, onPayOrGet: (Transaction) -&gt; Unit = {}, onSkipTransaction: (Transaction) -&gt; Unit = {}, onSkipAllTransactions: (List&lt;Transaction&gt;) -&gt; Unit = {} )</ID>
<ID>LongMethod:ItemStatisticScreen.kt$@Composable private fun BoxWithConstraintsScope.UI( period: TimePeriod, baseCurrency: String, currency: String, account: Account?, category: Category?, accountNameConfirmation: TextFieldValue, updateAccountNameConfirmation: (String) -&gt; Unit, enableDeletionButton: Boolean, categories: ImmutableList&lt;Category&gt;, accounts: ImmutableList&lt;Account&gt;, balance: Double, balanceBaseCurrency: Double?, income: Double, expenses: Double, initWithTransactions: Boolean = false, treatTransfersAsIncomeExpense: Boolean = false, history: ImmutableList&lt;TransactionHistoryItem&gt;, upcomingExpanded: Boolean = true, setUpcomingExpanded: (Boolean) -&gt; Unit = {}, upcomingIncome: Double = 0.0, upcomingExpenses: Double = 0.0, upcoming: ImmutableList&lt;Transaction&gt; = persistentListOf(), overdueExpanded: Boolean = true, setOverdueExpanded: (Boolean) -&gt; Unit = {}, overdueIncome: Double = 0.0, overdueExpenses: Double = 0.0, overdue: ImmutableList&lt;Transaction&gt; = persistentListOf(), onPreviousMonth: () -&gt; Unit, onNextMonth: () -&gt; Unit, onSetPeriod: (TimePeriod) -&gt; Unit, onEditAccount: (Account, Double) -&gt; Unit, onEditCategory: (Category) -&gt; Unit, onDelete: () -&gt; Unit, onPayOrGet: (Transaction) -&gt; Unit = {}, onSkipTransaction: (Transaction) -&gt; Unit = {}, onSkipAllTransactions: (List&lt;Transaction&gt;) -&gt; Unit = {} )</ID>
<ID>LongMethod:LoanDetailsScreen.kt$@Composable private fun BoxWithConstraintsScope.UI( baseCurrency: String, loan: Loan?, displayLoanRecords: List&lt;DisplayLoanRecord&gt; = emptyList(), amountPaid: Double, loanAmountPaid: Double = 0.0, accounts: List&lt;Account&gt; = emptyList(), selectedLoanAccount: Account? = null, createLoanTransaction: Boolean = false, onCreateAccount: (CreateAccountData) -&gt; Unit = {}, onEditLoan: (Loan, Boolean) -&gt; Unit = { _, _ -&gt; }, onCreateLoanRecord: (CreateLoanRecordData) -&gt; Unit = {}, onEditLoanRecord: (EditLoanRecordData) -&gt; Unit = {}, onDeleteLoanRecord: (LoanRecord) -&gt; Unit = {}, onDeleteLoan: () -&gt; Unit = {}, )</ID>
<ID>LongMethod:LoanDetailsScreen.kt$@Composable private fun LoanInfoCard( loan: Loan, baseCurrency: String, amountPaid: Double, loanAmountPaid: Double = 0.0, selectedLoanAccount: Account? = null, onAddRecord: () -&gt; Unit )</ID>
<ID>LongMethod:LoanModal.kt$@Deprecated("Old design system. Use `:ivy-design` and Material3") @Composable fun BoxWithConstraintsScope.LoanModal( accounts: List&lt;Account&gt; = emptyList(), onCreateAccount: (CreateAccountData) -&gt; Unit = {}, modal: LoanModalData?, onCreateLoan: (CreateLoanData) -&gt; Unit, onEditLoan: (Loan, Boolean) -&gt; Unit, onPerformCalculations: () -&gt; Unit = {}, dismiss: () -&gt; Unit, )</ID>
Expand All @@ -2328,7 +2329,7 @@
<ID>LongParameterList:EditTransactionScreen.kt$( screen: EditTransactionScreen, transactionType: TransactionType, baseCurrency: String, initialTitle: String?, titleSuggestions: Set&lt;String&gt;, description: String?, category: Category?, dateTime: LocalDateTime?, account: Account?, toAccount: Account?, dueDate: LocalDateTime?, amount: Double, loanData: EditTransactionDisplayLoan = EditTransactionDisplayLoan(), backgroundProcessing: Boolean = false, customExchangeRateState: CustomExchangeRateState, categories: List&lt;Category&gt;, accounts: List&lt;Account&gt;, hasChanges: Boolean = false, onTitleChanged: (String?) -&gt; Unit, onDescriptionChanged: (String?) -&gt; Unit, onAmountChanged: (Double) -&gt; Unit, onCategoryChanged: (Category?) -&gt; Unit, onAccountChanged: (Account) -&gt; Unit, onToAccountChanged: (Account) -&gt; Unit, onDueDateChanged: (LocalDateTime?) -&gt; Unit, onSetDateTime: (LocalDateTime) -&gt; Unit, onSetTransactionType: (TransactionType) -&gt; Unit, onCreateCategory: (CreateCategoryData) -&gt; Unit, onEditCategory: (Category) -&gt; Unit, onPayPlannedPayment: () -&gt; Unit, onSave: (closeScreen: Boolean) -&gt; Unit, onSetHasChanges: (hasChanges: Boolean) -&gt; Unit, onDelete: () -&gt; Unit, onCreateAccount: (CreateAccountData) -&gt; Unit, onExchangeRateChanged: (Double?) -&gt; Unit = { } )</ID>
<ID>LongParameterList:HomeTab.kt$( hideBalanceRowState: MutableState&lt;Boolean&gt;, listState: LazyListState, buffer: BufferInfo, hideCurrentBalance: Boolean, period: TimePeriod, baseData: AppBaseData, upcoming: DueSection, overdue: DueSection, balance: BigDecimal, stats: IncomeExpensePair, history: List&lt;TransactionHistoryItem&gt;, customerJourneyCards: List&lt;CustomerJourneyCardModel&gt;, setUpcomingExpanded: (Boolean) -&gt; Unit, setOverdueExpanded: (Boolean) -&gt; Unit, onOpenMoreMenu: () -&gt; Unit, onBalanceClick: () -&gt; Unit, onHiddenBalanceClick: () -&gt; Unit = {}, onPayOrGet: (Transaction) -&gt; Unit, onDismiss: (CustomerJourneyCardModel) -&gt; Unit, onSkipTransaction: (Transaction) -&gt; Unit = {}, onSkipAllTransactions: (List&lt;Transaction&gt;) -&gt; Unit = {} )</ID>
<ID>LongParameterList:ItemStatisticScreen.kt$( history: List&lt;TransactionHistoryItem&gt;, currency: String, baseCurrency: String, itemColor: Color, account: Account?, category: Category?, balance: Double, balanceBaseCurrency: Double?, income: Double, expenses: Double, treatTransfersAsIncomeExpense: Boolean = false, onEdit: () -&gt; Unit, onDelete: () -&gt; Unit, onBalanceClick: () -&gt; Unit, showCategoryModal: () -&gt; Unit, showAccountModal: () -&gt; Unit, )</ID>
<ID>LongParameterList:ItemStatisticScreen.kt$( period: TimePeriod, baseCurrency: String, currency: String, account: Account?, category: Category?, categories: ImmutableList&lt;Category&gt;, accounts: ImmutableList&lt;Account&gt;, balance: Double, balanceBaseCurrency: Double?, income: Double, expenses: Double, initWithTransactions: Boolean = false, treatTransfersAsIncomeExpense: Boolean = false, history: ImmutableList&lt;TransactionHistoryItem&gt;, upcomingExpanded: Boolean = true, setUpcomingExpanded: (Boolean) -&gt; Unit = {}, upcomingIncome: Double = 0.0, upcomingExpenses: Double = 0.0, upcoming: ImmutableList&lt;Transaction&gt; = persistentListOf(), overdueExpanded: Boolean = true, setOverdueExpanded: (Boolean) -&gt; Unit = {}, overdueIncome: Double = 0.0, overdueExpenses: Double = 0.0, overdue: ImmutableList&lt;Transaction&gt; = persistentListOf(), onPreviousMonth: () -&gt; Unit, onNextMonth: () -&gt; Unit, onSetPeriod: (TimePeriod) -&gt; Unit, onEditAccount: (Account, Double) -&gt; Unit, onEditCategory: (Category) -&gt; Unit, onDelete: () -&gt; Unit, onPayOrGet: (Transaction) -&gt; Unit = {}, onSkipTransaction: (Transaction) -&gt; Unit = {}, onSkipAllTransactions: (List&lt;Transaction&gt;) -&gt; Unit = {} )</ID>
<ID>LongParameterList:ItemStatisticScreen.kt$( period: TimePeriod, baseCurrency: String, currency: String, account: Account?, category: Category?, accountNameConfirmation: TextFieldValue, updateAccountNameConfirmation: (String) -&gt; Unit, enableDeletionButton: Boolean, categories: ImmutableList&lt;Category&gt;, accounts: ImmutableList&lt;Account&gt;, balance: Double, balanceBaseCurrency: Double?, income: Double, expenses: Double, initWithTransactions: Boolean = false, treatTransfersAsIncomeExpense: Boolean = false, history: ImmutableList&lt;TransactionHistoryItem&gt;, upcomingExpanded: Boolean = true, setUpcomingExpanded: (Boolean) -&gt; Unit = {}, upcomingIncome: Double = 0.0, upcomingExpenses: Double = 0.0, upcoming: ImmutableList&lt;Transaction&gt; = persistentListOf(), overdueExpanded: Boolean = true, setOverdueExpanded: (Boolean) -&gt; Unit = {}, overdueIncome: Double = 0.0, overdueExpenses: Double = 0.0, overdue: ImmutableList&lt;Transaction&gt; = persistentListOf(), onPreviousMonth: () -&gt; Unit, onNextMonth: () -&gt; Unit, onSetPeriod: (TimePeriod) -&gt; Unit, onEditAccount: (Account, Double) -&gt; Unit, onEditCategory: (Category) -&gt; Unit, onDelete: () -&gt; Unit, onPayOrGet: (Transaction) -&gt; Unit = {}, onSkipTransaction: (Transaction) -&gt; Unit = {}, onSkipAllTransactions: (List&lt;Transaction&gt;) -&gt; Unit = {} )</ID>
<ID>LongParameterList:PlannedPaymentsLazyColumn.kt$( nav: Navigation, currency: String, categories: List&lt;Category&gt;, accounts: List&lt;Account&gt;, listState: LazyListState, oneTime: List&lt;PlannedPaymentRule&gt;, oneTimeIncome: Double, oneTimeExpenses: Double, oneTimeExpanded: Boolean, setOneTimeExpanded: (Boolean) -&gt; Unit, recurring: List&lt;PlannedPaymentRule&gt;, recurringIncome: Double, recurringExpenses: Double, recurringExpanded: Boolean, setRecurringExpanded: (Boolean) -&gt; Unit )</ID>
<ID>LoopWithTooManyJumpStatements:PieChart.kt$PieChartView$for</ID>
<ID>MagicNumber:AmountFormatting.kt$0.009</ID>
Expand Down Expand Up @@ -2375,6 +2376,7 @@
<ID>MagicNumber:DateExt.kt$23</ID>
<ID>MagicNumber:DateExt.kt$30</ID>
<ID>MagicNumber:DateExt.kt$59</ID>
<ID>MagicNumber:DeleteModal.kt$50</ID>
<ID>MagicNumber:DueDate.kt$5</ID>
<ID>MagicNumber:EditBottomSheet.kt$0.01f</ID>
<ID>MagicNumber:EditBottomSheet.kt$16</ID>
Expand Down Expand Up @@ -4062,6 +4064,7 @@
<ID>ModifierMissing:CustomerJourney.kt$CustomerJourney</ID>
<ID>ModifierMissing:CustomerJourney.kt$CustomerJourneyCard</ID>
<ID>ModifierMissing:DefaultImportSteps.kt$DefaultImportSteps</ID>
<ID>ModifierMissing:DeleteModal.kt$DeleteConfirmationModal</ID>
<ID>ModifierMissing:DeleteModal.kt$DeleteModal</ID>
<ID>ModifierMissing:DescriptionModal.kt$DescriptionModal</ID>
<ID>ModifierMissing:Dividers.kt$DividerH</ID>
Expand Down Expand Up @@ -4216,7 +4219,6 @@
<ID>MultipleEmitters:TransactionSectionDivider.kt$SectionDivider</ID>
<ID>MutableParams:HomeTab.kt$hideBalanceRowState</ID>
<ID>NestedBlockDepth:AccValueFunctions.kt$AccountValueFunctions$fun balance( transaction: Transaction, accountId: UUID ): BigDecimal</ID>
<ID>NoBlankLineBeforeRbrace:CoroutineTestExample.kt$CoroutineTestExample$ </ID>
<ID>NoConsecutiveBlankLines:Accessors11xxvwy0y6zsdmgi5tg7sgrcq.kt$ </ID>
<ID>NoConsecutiveBlankLines:Accessors12l04gyw3iri7cbpx1tj9yrz6.kt$ </ID>
<ID>NoConsecutiveBlankLines:Accessors15c80wxji7qdhvcsteytc58m6.kt$ </ID>
Expand Down Expand Up @@ -7152,6 +7154,7 @@
<ID>ReturnCount:PlannedPaymentsLogic.kt$PlannedPaymentsLogic$private suspend fun amountForMonthInBaseCurrency( plannedPayment: PlannedPaymentRule, baseCurrency: String, accounts: List&lt;Account&gt; ): Double</ID>
<ID>ReturnCount:ReportFilter.kt$ReportFilter$fun validate(): Boolean</ID>
<ID>ReturnCount:SyncExchangeRatesAct.kt$SyncExchangeRatesAct$private suspend fun sync(baseCurrency: String)</ID>
<ID>SpacingAroundCurly:DeleteModal.kt${</ID>
<ID>SpacingAroundParens:TestScreen.kt$(</ID>
<ID>SpacingBetweenDeclarationsWithAnnotations:Colors.kt$@Deprecated("Old design system. Use `:ivy-design` and Material3") val Black = Color(0xFF111114)</ID>
<ID>SpacingBetweenDeclarationsWithAnnotations:Colors.kt$@Deprecated("Old design system. Use `:ivy-design` and Material3") val Blue2 = Color(0xFF45E6E6)</ID>
Expand Down
2 changes: 2 additions & 0 deletions ivy-resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
<string name="no_transactions_for_period">You don\'t have any transactions for %1$s.\nYou can add one by scrolling down and tapping "Add income" or "Add expense" button at the top.</string>
<string name="account_confirm_deletion_description">Note: Deleting this account will remove it permanently and delete all associated transactions with it.</string>
<string name="category_confirm_deletion_description">Note: Deleting this category will remove it permanently.</string>
<string name="account_confirm_deletion_description2" translatable="false">Once you delete this account you cannot get it back and all the transactions associated with the account will be removed.</string>
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
<string name="account_confirm_deletion_type_account_name" translatable="false">Please type \"%s\" in order to delete your account.</string>
<string name="edit">Edit</string>
<string name="transactions">transactions</string>
<string name="home">Home</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
Expand Down Expand Up @@ -74,6 +75,7 @@ import com.ivy.wallet.ui.theme.findContrastTextColor
import com.ivy.wallet.ui.theme.isDarkColor
import com.ivy.wallet.ui.theme.modal.ChoosePeriodModal
import com.ivy.wallet.ui.theme.modal.ChoosePeriodModalData
import com.ivy.wallet.ui.theme.modal.DeleteConfirmationModal
import com.ivy.wallet.ui.theme.modal.DeleteModal
import com.ivy.wallet.ui.theme.modal.edit.AccountModal
import com.ivy.wallet.ui.theme.modal.edit.AccountModalData
Expand Down Expand Up @@ -196,7 +198,10 @@ fun BoxWithConstraintsScope.ItemStatisticScreen(screen: ItemStatisticScreen) {
},
onSkipAllTransactions = { transactions ->
viewModel.skipTransactions(screen, transactions)
}
},
accountNameConfirmation = viewModel.accountNameConfirmation,
updateAccountNameConfirmation = viewModel::updateAccountDeletionState,
enableDeletionButton = viewModel.enableDeletionButton
)
}

Expand All @@ -209,6 +214,10 @@ private fun BoxWithConstraintsScope.UI(
account: Account?,
category: Category?,

accountNameConfirmation: TextFieldValue,
updateAccountNameConfirmation: (String) -> Unit,
enableDeletionButton: Boolean,

categories: ImmutableList<Category>,
accounts: ImmutableList<Account>,

Expand Down Expand Up @@ -247,7 +256,9 @@ private fun BoxWithConstraintsScope.UI(
val ivyContext = ivyWalletCtx()
val itemColor = (account?.color ?: category?.color)?.toComposeColor() ?: Gray

var deleteModalVisible by remember { mutableStateOf(false) }
var deleteModal1Visible by remember { mutableStateOf(false) }
var deleteModal2Visible by remember { mutableStateOf(false) }
var deleteModal3Visible by remember { mutableStateOf(false) }
var skipAllModalVisible by remember { mutableStateOf(false) }
var categoryModalData: CategoryModalData? by remember { mutableStateOf(null) }
var accountModalData: AccountModalData? by remember { mutableStateOf(null) }
Expand Down Expand Up @@ -298,7 +309,7 @@ private fun BoxWithConstraintsScope.UI(
treatTransfersAsIncomeExpense = treatTransfersAsIncomeExpense,

onDelete = {
deleteModalVisible = true
deleteModal1Visible = true
},
onEdit = {
when {
Expand Down Expand Up @@ -422,16 +433,53 @@ private fun BoxWithConstraintsScope.UI(
}

DeleteModal(
visible = deleteModalVisible,
visible = deleteModal1Visible,
title = stringResource(R.string.confirm_deletion),
description = if (account != null) {
stringResource(R.string.account_confirm_deletion_description)
} else {
stringResource(R.string.category_confirm_deletion_description)
},
dismiss = { deleteModalVisible = false }
dismiss = { deleteModal1Visible = false }
) {
deleteModal2Visible = true
}

DeleteModal(
visible = deleteModal2Visible,
title = stringResource(R.string.confirm_deletion),
description = if (account != null) {
stringResource(R.string.account_confirm_deletion_description2)
} else {
stringResource(R.string.category_confirm_deletion_description)
},
dismiss = {
deleteModal2Visible = false
deleteModal1Visible = false
}
) {
deleteModal3Visible = true
}

DeleteConfirmationModal(
visible = deleteModal3Visible,
title = stringResource(id = R.string.confirm_deletion),
description = stringResource(
id = R.string.account_confirm_deletion_type_account_name,
account?.name ?: ""
),
accountName = accountNameConfirmation,
onAccountNameChange = updateAccountNameConfirmation,
enableDeletionButton = enableDeletionButton,
dismiss = {
updateAccountNameConfirmation("")
deleteModal3Visible = false
deleteModal2Visible = false
deleteModal1Visible = false
}
) {
onDelete()
updateAccountNameConfirmation("")
}

DeleteModal(
Expand Down Expand Up @@ -739,7 +787,10 @@ private fun Preview_empty() {
onNextMonth = {},
onDelete = {},
onEditAccount = { _, _ -> },
onEditCategory = {}
onEditCategory = {},
accountNameConfirmation = TextFieldValue(),
updateAccountNameConfirmation = {},
enableDeletionButton = true
)
}
}
Expand Down Expand Up @@ -776,7 +827,10 @@ private fun Preview_crypto() {
onNextMonth = {},
onDelete = {},
onEditAccount = { _, _ -> },
onEditCategory = {}
onEditCategory = {},
accountNameConfirmation = TextFieldValue(),
updateAccountNameConfirmation = {},
enableDeletionButton = true
)
}
}
Expand Down Expand Up @@ -811,7 +865,10 @@ private fun Preview_empty_upcoming() {
onEditCategory = {},
upcoming = persistentListOf(
Transaction(UUID(1L, 2L), TransactionType.EXPENSE, BigDecimal.valueOf(10L))
)
),
accountNameConfirmation = TextFieldValue(),
updateAccountNameConfirmation = {},
enableDeletionButton = true
)
}
}
Loading