diff --git a/screen/accounts/src/main/java/com/ivy/accounts/AccountsEvent.kt b/screen/accounts/src/main/java/com/ivy/accounts/AccountsEvent.kt index dea7eb56b7..94e0cfe082 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/AccountsEvent.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/AccountsEvent.kt @@ -1,10 +1,12 @@ package com.ivy.accounts +import com.ivy.data.model.Account + sealed interface AccountsEvent { data class OnReorder(val reorderedList: List) : AccountsEvent data class OnReorderModalVisible(val reorderVisible: Boolean) : AccountsEvent - data class OnVisibilityChange(val updatedList: List) : + data class OnVisibilityUpdate(val updatedList: List) : AccountsEvent data class OnHideModalVisible(val hideVisible: Boolean) : AccountsEvent } diff --git a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt index f3eb85f9c2..8f9636fca2 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt @@ -1,16 +1,12 @@ package com.ivy.accounts -import android.annotation.SuppressLint import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.BoxWithConstraintsScope import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -55,20 +51,16 @@ import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R import com.ivy.ui.rememberScrollPositionListState -import com.ivy.wallet.ui.theme.GradientGreen import com.ivy.wallet.ui.theme.Green import com.ivy.wallet.ui.theme.GreenLight -import com.ivy.wallet.ui.theme.White import com.ivy.wallet.ui.theme.components.BalanceRow import com.ivy.wallet.ui.theme.components.BalanceRowMini import com.ivy.wallet.ui.theme.components.CircleButtonFilled import com.ivy.wallet.ui.theme.components.ItemIconSDefaultIcon -import com.ivy.wallet.ui.theme.components.IvyCircleButton import com.ivy.wallet.ui.theme.components.ReorderButton import com.ivy.wallet.ui.theme.components.ReorderModalSingleType import com.ivy.wallet.ui.theme.dynamicContrast import com.ivy.wallet.ui.theme.findContrastTextColor -import com.ivy.wallet.ui.theme.modal.IvyModal import com.ivy.wallet.ui.theme.toComposeColor import kotlinx.collections.immutable.persistentListOf import java.util.UUID @@ -92,7 +84,7 @@ private fun BoxWithConstraintsScope.UI( val nav = navigation() val ivyContext = com.ivy.legacy.ivyWalletCtx() var listState = rememberLazyListState() - if (!state.accountsData.isEmpty()) { + if (state.accountsData.any { it.account.isVisible }) { listState = rememberScrollPositionListState( key = "accounts_lazy_column", initialFirstVisibleItemIndex = ivyContext.accountsListState?.firstVisibleItemIndex ?: 0, @@ -167,7 +159,7 @@ private fun BoxWithConstraintsScope.UI( Spacer(Modifier.height(16.dp)) } } - items(state.accountsData) { + items(state.accountsData.filter { it.account.isVisible }) { Spacer(Modifier.height(16.dp)) AccountCard( baseCurrency = state.baseCurrency, @@ -199,8 +191,8 @@ private fun BoxWithConstraintsScope.UI( HideAccountsModal( visible = state.hideVisible, initialItems = state.accountsData, - OnDismiss = { onEvent(AccountsEvent.OnHideModalVisible(hideVisible = false)) }, - onDone = { onEvent(AccountsEvent.OnVisibilityChange(updatedList = it)) } + onDismiss = { onEvent(AccountsEvent.OnHideModalVisible(hideVisible = false)) }, + onComplete = { onEvent(AccountsEvent.OnVisibilityUpdate(updatedList = it)) } ) ReorderModalSingleType( visible = state.reorderVisible, @@ -371,6 +363,7 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { icon = null, includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc2 = Account( @@ -381,6 +374,7 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { icon = null, includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc3 = Account( @@ -391,6 +385,7 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { icon = IconAsset.unsafe("revolut"), includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc4 = Account( @@ -401,6 +396,7 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { icon = IconAsset.unsafe("cash"), includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val state = AccountsState( baseCurrency = "BGN", @@ -459,6 +455,7 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { icon = null, includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc2 = Account( @@ -469,6 +466,7 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { icon = null, includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc3 = Account( @@ -479,6 +477,7 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { icon = IconAsset.unsafe("revolut"), includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val acc4 = Account( @@ -489,6 +488,7 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { icon = IconAsset.unsafe("cash"), includeInBalance = true, orderNum = 0.0, + isVisible = true, ) val state = AccountsState( baseCurrency = "BGN", diff --git a/screen/accounts/src/main/java/com/ivy/accounts/AccountsViewModel.kt b/screen/accounts/src/main/java/com/ivy/accounts/AccountsViewModel.kt index ac645367bc..bfad5b0e1a 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/AccountsViewModel.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/AccountsViewModel.kt @@ -14,6 +14,7 @@ import com.ivy.base.time.TimeConverter import com.ivy.base.time.TimeProvider import com.ivy.data.DataObserver import com.ivy.data.DataWriteEvent +import com.ivy.data.model.Account import com.ivy.data.repository.AccountRepository import com.ivy.domain.features.Features import com.ivy.legacy.IvyWalletCtx @@ -153,7 +154,10 @@ class AccountsViewModel @Inject constructor( is AccountsEvent.OnReorder -> reorder(event.reorderedList) is AccountsEvent.OnReorderModalVisible -> reorderModalVisible(event.reorderVisible) is AccountsEvent.OnHideModalVisible -> hideModalVisible(event.hideVisible) - is AccountsEvent.OnVisibilityChange -> TODO() + is AccountsEvent.OnVisibilityUpdate -> { + updateVisibility(event.updatedList) + hideVisible = false + } } } } @@ -168,6 +172,16 @@ class AccountsViewModel @Inject constructor( startInternally() } + private suspend fun updateVisibility(accounts: List) { + ioThread { + accounts.forEach { acc -> + accountRepository.save(acc) + } + } + + startInternally() + } + private fun onStart() { viewModelScope.launch(Dispatchers.Default) { startInternally() diff --git a/screen/accounts/src/main/java/com/ivy/accounts/HideAccountsModal.kt b/screen/accounts/src/main/java/com/ivy/accounts/HideAccountsModal.kt index 9905daefb9..818344f214 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/HideAccountsModal.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/HideAccountsModal.kt @@ -1,7 +1,6 @@ package com.ivy.accounts import android.annotation.SuppressLint -import android.util.Log import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -18,10 +17,7 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -43,24 +39,44 @@ import com.ivy.wallet.ui.theme.modal.IvyModal import java.util.UUID import androidx.compose.foundation.lazy.items import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.snapshots.SnapshotStateList import com.ivy.wallet.ui.theme.components.ItemIconSDefaultIcon import com.ivy.wallet.ui.theme.findContrastTextColor import com.ivy.wallet.ui.theme.toComposeColor +import kotlinx.collections.immutable.ImmutableList +@Suppress("ModifierMissing") @SuppressLint("ComposeModifierMissing") @Composable fun BoxScope.HideAccountsModal( visible: Boolean, - initialItems: List, - OnDismiss: () -> Unit, + initialItems: ImmutableList, + onDismiss: () -> Unit, id: UUID = UUID.randomUUID(), - onDone: (List) -> Unit + onComplete: (List) -> Unit ) { + val accounts: SnapshotStateList = remember(id) { + mutableStateListOf().apply { + addAll(initialItems.map { it.account }) + } + } + + val onUpdateItemVisibility: (AccountId, Boolean) -> Unit = + { id, isVisible -> + var selectedIndex = -1 + accounts.forEachIndexed { index, account -> + if (account.id == id) { + selectedIndex = index + } + } + accounts[selectedIndex] = accounts[selectedIndex].copy(isVisible = !isVisible) + } + IvyModal( id = id, visible = visible, scrollState = null, - dismiss = OnDismiss, + dismiss = onDismiss, PrimaryAction = { IvyCircleButton( modifier = Modifier @@ -69,8 +85,7 @@ fun BoxScope.HideAccountsModal( icon = R.drawable.ic_check, tint = White ) { - //onUpdateItemVisibility() - OnDismiss.invoke() + onComplete.invoke(accounts) } } ) { @@ -87,28 +102,12 @@ fun BoxScope.HideAccountsModal( Spacer(Modifier.height(24.dp)) - val accounts = remember { - mutableStateListOf().apply { - addAll(initialItems.map { it.account }) - } - } - val onUpdateItemVisibility: (AccountId, Boolean) -> Unit = - { id, isVisible -> - var selectedIndex = -1 - accounts.forEachIndexed { index, account -> - if (account.id == id) { - selectedIndex = index - } - } - accounts[selectedIndex] = accounts[selectedIndex].copy(isVisible = !isVisible) - } - LazyColumn( modifier = Modifier.fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(16.dp) ) { items(accounts) { account -> - HideAccountsColumn( + HideAccountsRow( account = account, onClick = onUpdateItemVisibility ) @@ -117,16 +116,16 @@ fun BoxScope.HideAccountsModal( Spacer(Modifier.height(150.dp)) } } - } } @Composable -private fun HideAccountsColumn( +private fun HideAccountsRow( account: Account, onClick: (AccountId, Boolean) -> Unit ) { val contrastColor = findContrastTextColor(account.color.value.toComposeColor()) + Row( modifier = Modifier .padding(horizontal = 16.dp) @@ -135,7 +134,6 @@ private fun HideAccountsColumn( .background(color = account.color.value.toComposeColor()), verticalAlignment = Alignment.CenterVertically ) { - Spacer(Modifier.width(12.dp)) ItemIconSDefaultIcon( @@ -162,7 +160,7 @@ private fun HideAccountsColumn( IvyIconScaled( modifier = Modifier - .size(size = 32.dp) + .size(size = 24.dp) .clickable { onClick.invoke(account.id, account.isVisible) }, @@ -173,6 +171,5 @@ private fun HideAccountsColumn( ) Spacer(Modifier.width(16.dp)) - } } \ No newline at end of file diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png index f5dc94fc90..b459a73e15 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png index 15855b09f6..621838a070 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png index 8c5c63d5cf..264b6d546e 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png index 07fffa6e55..ffc29b7e85 100644 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png and b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png differ diff --git a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt index dac4dabc1c..78fd566e6e 100644 --- a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt +++ b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt @@ -672,7 +672,7 @@ private fun BoxWithConstraintsScope.Preview(isDark: Boolean = false) { dateTime = testDateTime, description = null, category = null, - account = Account(name = "phyre", Orange.toArgb()), + account = Account(name = "phyre", isVisible = true, color = Orange.toArgb()), toAccount = null, amount = 0.0, dueDate = null, diff --git a/screen/import-data/src/main/java/com/ivy/importdata/csv/domain/CSVImporterV2.kt b/screen/import-data/src/main/java/com/ivy/importdata/csv/domain/CSVImporterV2.kt index a8fe327dcb..49ccc7d87e 100644 --- a/screen/import-data/src/main/java/com/ivy/importdata/csv/domain/CSVImporterV2.kt +++ b/screen/import-data/src/main/java/com/ivy/importdata/csv/domain/CSVImporterV2.kt @@ -282,7 +282,8 @@ class CSVImporterV2 @Inject constructor( ), color = colorArgb, icon = icon, - orderNum = orderNum ?: accountDao.findMaxOrderNum().nextOrderNum() + orderNum = orderNum ?: accountDao.findMaxOrderNum().nextOrderNum(), + isVisible = true, ) val domainAccount = newAccount.toDomainAccount(currencyRepository).getOrNull() ?: return null diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/components/Suggestions.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/components/Suggestions.kt index 990169b76e..eb066ffdd7 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/components/Suggestions.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/components/Suggestions.kt @@ -146,9 +146,9 @@ private fun Preview() { IvyWalletComponentPreview { Suggestions( suggestions = listOf( - Account("Cash", Green.toArgb()), - Account("Bank", Red.toArgb()), - Account("Revolut", Purple.toArgb()) + Account("Cash", isVisible = true, color = Green.toArgb()), + Account("Bank", isVisible = true, color = Red.toArgb()), + Account("Revolut", isVisible = true, color = Purple.toArgb()) ), onAddSuggestion = { } ) { diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt index ad6b497492..a42f60bb03 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt @@ -358,7 +358,8 @@ private fun Preview_Accounts() { account = Account( name = "Cash", color = Green.toArgb(), - icon = "cash" + icon = "cash", + isVisible = true, ), balance = 0.0 ) @@ -403,7 +404,8 @@ private fun Preview_Premium() { account = Account( name = "Cash", color = Green.toArgb(), - icon = "cash" + icon = "cash", + isVisible = true, ), balance = 0.0 ), @@ -411,7 +413,8 @@ private fun Preview_Premium() { account = Account( name = "Revolut", color = IvyDark.toArgb(), - icon = "cash" + icon = "cash", + isVisible = true, ), balance = 0.0 ), @@ -419,7 +422,8 @@ private fun Preview_Premium() { account = Account( name = "Revolut", color = Color(0xFF4DCAFF).toArgb(), - icon = "revolut" + icon = "revolut", + isVisible = true, ), balance = 0.0 ), diff --git a/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt b/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt index 8ffe95c7b0..1bb09b40fd 100644 --- a/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt +++ b/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt @@ -437,7 +437,7 @@ private fun Preview() { currency = "BGN", description = null, category = null, - account = Account(name = "phyre", Orange.toArgb()), + account = Account(name = "phyre", isVisible = true, color = Orange.toArgb()), amount = 0.0, transactionType = TransactionType.INCOME, categories = persistentListOf(), diff --git a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentCard.kt b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentCard.kt index 5019d60d50..192e7998bc 100644 --- a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentCard.kt +++ b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentCard.kt @@ -274,7 +274,7 @@ private fun RuleTextRow( private fun Preview_oneTime() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "Cash", Green.toArgb()) + val cash = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Food"), color = ColorInt(Blue.toArgb()), @@ -312,7 +312,7 @@ private fun Preview_oneTime() { private fun Preview_recurring() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val account = Account(name = "Revolut", Blue.toArgb()) + val account = Account(name = "Revolut", isVisible = true, color = Blue.toArgb()) val shisha = Category( name = NotBlankTrimmedString.unsafe("Shisha"), color = ColorInt(Orange.toArgb()), @@ -350,7 +350,7 @@ private fun Preview_recurring() { private fun Preview_recurringError() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val account = Account(name = "Revolut", Blue.toArgb()) + val account = Account(name = "Revolut", isVisible = true, color = Blue.toArgb()) val shisha = Category( name = NotBlankTrimmedString.unsafe("Shisha"), color = ColorInt(Orange.toArgb()), diff --git a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt index f5c24234a3..5a9c6d6d50 100644 --- a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt +++ b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt @@ -108,7 +108,7 @@ private fun BoxWithConstraintsScope.UI( @Composable private fun Preview() { IvyWalletPreview { - val account = Account(name = "Cash", Green.toArgb()) + val account = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Food"), color = ColorInt(Purple.toArgb()), diff --git a/screen/reports/src/main/java/com/ivy/reports/FilterOverlay.kt b/screen/reports/src/main/java/com/ivy/reports/FilterOverlay.kt index 63ac3391fe..13e4055e92 100644 --- a/screen/reports/src/main/java/com/ivy/reports/FilterOverlay.kt +++ b/screen/reports/src/main/java/com/ivy/reports/FilterOverlay.kt @@ -1062,8 +1062,8 @@ private fun FilterTitleText( @Composable private fun Preview() { IvyWalletPreview { - val acc1 = Account("Cash", color = Green.toArgb()) - val acc2 = Account("DSK", color = GreenDark.toArgb()) + val acc1 = Account("Cash", isVisible = true, color = Green.toArgb()) + val acc2 = Account("DSK", isVisible = true, color = GreenDark.toArgb()) val cat1 = Category( name = NotBlankTrimmedString.unsafe("Science"), color = ColorInt(Purple1Dark.toArgb()), @@ -1079,8 +1079,8 @@ private fun Preview() { accounts = listOf( acc1, acc2, - Account("phyre", color = GreenLight.toArgb(), icon = "cash"), - Account("Revolut", color = IvyDark.toArgb()), + Account("phyre", isVisible = true, color = GreenLight.toArgb(), icon = "cash"), + Account("Revolut", isVisible = true, color = IvyDark.toArgb()), ), categories = listOf( cat1, diff --git a/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt b/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt index 86571bf7d4..5a577af0c6 100644 --- a/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt +++ b/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt @@ -405,8 +405,8 @@ private fun Toolbar( @Composable private fun Preview(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { - val acc1 = Account("Cash", color = Green.toArgb()) - val acc2 = Account("DSK", color = GreenDark.toArgb()) + val acc1 = Account("Cash", isVisible = true, color = Green.toArgb()) + val acc2 = Account("DSK", isVisible = true, color = GreenDark.toArgb()) val cat1 = Category( name = NotBlankTrimmedString.unsafe("Science"), color = ColorInt(Purple1Dark.toArgb()), @@ -435,8 +435,8 @@ private fun Preview(theme: Theme = Theme.LIGHT) { accounts = persistentListOf( acc1, acc2, - Account("phyre", color = GreenLight.toArgb(), icon = "cash"), - Account("Revolut", color = IvyDark.toArgb()), + Account("phyre", isVisible = true, color = GreenLight.toArgb(), icon = "cash"), + Account("Revolut", isVisible = true, color = IvyDark.toArgb()), ), categories = persistentListOf( cat1, @@ -466,8 +466,8 @@ private fun Preview(theme: Theme = Theme.LIGHT) { @Composable private fun Preview_NO_FILTER(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { - val acc1 = Account("Cash", color = Green.toArgb()) - val acc2 = Account("DSK", color = GreenDark.toArgb()) + val acc1 = Account("Cash", isVisible = true, color = Green.toArgb()) + val acc2 = Account("DSK", isVisible = true, color = GreenDark.toArgb()) val cat1 = Category( name = NotBlankTrimmedString.unsafe("Science"), color = ColorInt(Purple1Dark.toArgb()), @@ -498,8 +498,8 @@ private fun Preview_NO_FILTER(theme: Theme = Theme.LIGHT) { accounts = persistentListOf( acc1, acc2, - Account("phyre", color = GreenLight.toArgb(), icon = "cash"), - Account("Revolut", color = IvyDark.toArgb()), + Account("phyre", isVisible = true, color = GreenLight.toArgb(), icon = "cash"), + Account("Revolut", isVisible = true, color = IvyDark.toArgb()), ), categories = persistentListOf( cat1, diff --git a/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt b/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt index 8e80535eab..11de870745 100644 --- a/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt +++ b/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt @@ -844,7 +844,7 @@ private fun BoxWithConstraintsScope.Preview_empty() { history = persistentListOf(), category = null, - account = Account("DSK", color = GreenDark.toArgb(), icon = "pet"), + account = Account("DSK", color = GreenDark.toArgb(), isVisible = true, icon = "pet"), onSetPeriod = { }, onPreviousMonth = {}, onNextMonth = {}, @@ -890,7 +890,8 @@ private fun BoxWithConstraintsScope.Preview_crypto() { name = "DSK", color = GreenDark.toArgb(), icon = "pet", - includeInBalance = false + includeInBalance = false, + isVisible = true, ), onSetPeriod = { }, onPreviousMonth = {}, @@ -931,7 +932,7 @@ private fun BoxWithConstraintsScope.Preview_empty_upcoming() { history = persistentListOf(), category = null, - account = Account("DSK", color = GreenDark.toArgb(), icon = "pet"), + account = Account("DSK", color = GreenDark.toArgb(), isVisible = true, icon = "pet"), onSetPeriod = { }, onPreviousMonth = {}, onNextMonth = {}, diff --git a/shared/data/core/schemas/com.ivy.data.db.IvyRoomDatabase/131.json b/shared/data/core/schemas/com.ivy.data.db.IvyRoomDatabase/131.json new file mode 100644 index 0000000000..8b3386b5e3 --- /dev/null +++ b/shared/data/core/schemas/com.ivy.data.db.IvyRoomDatabase/131.json @@ -0,0 +1,850 @@ +{ + "formatVersion": 1, + "database": { + "version": 131, + "identityHash": "f3cd75585a60842b5073098c628833dd", + "entities": [ + { + "tableName": "accounts", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `currency` TEXT, `color` INTEGER NOT NULL, `icon` TEXT, `orderNum` REAL NOT NULL, `includeInBalance` INTEGER NOT NULL, `isVisible` INTEGER NOT NULL, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "currency", + "columnName": "currency", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "orderNum", + "columnName": "orderNum", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "includeInBalance", + "columnName": "includeInBalance", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isVisible", + "columnName": "isVisible", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "transactions", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`accountId` TEXT NOT NULL, `type` TEXT NOT NULL, `amount` REAL NOT NULL, `toAccountId` TEXT, `toAmount` REAL, `title` TEXT, `description` TEXT, `dateTime` INTEGER, `categoryId` TEXT, `dueDate` INTEGER, `recurringRuleId` TEXT, `paidForDateTime` INTEGER, `attachmentUrl` TEXT, `loanId` TEXT, `loanRecordId` TEXT, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "toAccountId", + "columnName": "toAccountId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "toAmount", + "columnName": "toAmount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "dateTime", + "columnName": "dateTime", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "categoryId", + "columnName": "categoryId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "dueDate", + "columnName": "dueDate", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "recurringRuleId", + "columnName": "recurringRuleId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "paidForDateTime", + "columnName": "paidForDateTime", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "attachmentUrl", + "columnName": "attachmentUrl", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "loanId", + "columnName": "loanId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "loanRecordId", + "columnName": "loanRecordId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "categories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `color` INTEGER NOT NULL, `icon` TEXT, `orderNum` REAL NOT NULL, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "orderNum", + "columnName": "orderNum", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "settings", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`theme` TEXT NOT NULL, `currency` TEXT NOT NULL, `bufferAmount` REAL NOT NULL, `name` TEXT NOT NULL, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "theme", + "columnName": "theme", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "currency", + "columnName": "currency", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "bufferAmount", + "columnName": "bufferAmount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "planned_payment_rules", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`startDate` INTEGER, `intervalN` INTEGER, `intervalType` TEXT, `oneTime` INTEGER NOT NULL, `type` TEXT NOT NULL, `accountId` TEXT NOT NULL, `amount` REAL NOT NULL, `categoryId` TEXT, `title` TEXT, `description` TEXT, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "startDate", + "columnName": "startDate", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "intervalN", + "columnName": "intervalN", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "intervalType", + "columnName": "intervalType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "oneTime", + "columnName": "oneTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "categoryId", + "columnName": "categoryId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "users", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`email` TEXT NOT NULL, `authProviderType` TEXT NOT NULL, `firstName` TEXT NOT NULL, `lastName` TEXT, `profilePicture` TEXT, `color` INTEGER NOT NULL, `testUser` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "email", + "columnName": "email", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "authProviderType", + "columnName": "authProviderType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "firstName", + "columnName": "firstName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lastName", + "columnName": "lastName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "profilePicture", + "columnName": "profilePicture", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "testUser", + "columnName": "testUser", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "exchange_rates", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`baseCurrency` TEXT NOT NULL, `currency` TEXT NOT NULL, `rate` REAL NOT NULL, `manualOverride` INTEGER NOT NULL, PRIMARY KEY(`baseCurrency`, `currency`))", + "fields": [ + { + "fieldPath": "baseCurrency", + "columnName": "baseCurrency", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "currency", + "columnName": "currency", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "rate", + "columnName": "rate", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "manualOverride", + "columnName": "manualOverride", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "baseCurrency", + "currency" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "budgets", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `amount` REAL NOT NULL, `categoryIdsSerialized` TEXT, `accountIdsSerialized` TEXT, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `orderId` REAL NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "categoryIdsSerialized", + "columnName": "categoryIdsSerialized", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "accountIdsSerialized", + "columnName": "accountIdsSerialized", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "orderId", + "columnName": "orderId", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "loans", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`name` TEXT NOT NULL, `amount` REAL NOT NULL, `type` TEXT NOT NULL, `color` INTEGER NOT NULL, `icon` TEXT, `orderNum` REAL NOT NULL, `accountId` TEXT, `note` TEXT, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `dateTime` INTEGER, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "orderNum", + "columnName": "orderNum", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateTime", + "columnName": "dateTime", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "loan_records", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`loanId` TEXT NOT NULL, `amount` REAL NOT NULL, `note` TEXT, `dateTime` INTEGER NOT NULL, `interest` INTEGER NOT NULL, `accountId` TEXT, `convertedAmount` REAL, `loanRecordType` TEXT NOT NULL, `isSynced` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "loanId", + "columnName": "loanId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "dateTime", + "columnName": "dateTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interest", + "columnName": "interest", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountId", + "columnName": "accountId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "convertedAmount", + "columnName": "convertedAmount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "loanRecordType", + "columnName": "loanRecordType", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isSynced", + "columnName": "isSynced", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "tags", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `description` TEXT, `color` INTEGER NOT NULL, `icon` TEXT, `orderNum` REAL NOT NULL, `dateTime` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, `lastSyncedTime` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "color", + "columnName": "color", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "icon", + "columnName": "icon", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "orderNum", + "columnName": "orderNum", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "dateTime", + "columnName": "dateTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lastSyncedTime", + "columnName": "lastSyncedTime", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "tags_association", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tagId` TEXT NOT NULL, `associatedId` TEXT NOT NULL, `lastSyncedTime` INTEGER NOT NULL, `isDeleted` INTEGER NOT NULL, PRIMARY KEY(`tagId`, `associatedId`))", + "fields": [ + { + "fieldPath": "tagId", + "columnName": "tagId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "associatedId", + "columnName": "associatedId", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "lastSyncedTime", + "columnName": "lastSyncedTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isDeleted", + "columnName": "isDeleted", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "tagId", + "associatedId" + ] + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f3cd75585a60842b5073098c628833dd')" + ] + } +} \ No newline at end of file diff --git a/shared/data/core/src/main/java/com/ivy/data/db/IvyRoomDatabase.kt b/shared/data/core/src/main/java/com/ivy/data/db/IvyRoomDatabase.kt index 6ac47d304a..5c3332d6b1 100644 --- a/shared/data/core/src/main/java/com/ivy/data/db/IvyRoomDatabase.kt +++ b/shared/data/core/src/main/java/com/ivy/data/db/IvyRoomDatabase.kt @@ -44,6 +44,7 @@ import com.ivy.data.db.migration.Migration126to127_LoanRecordType import com.ivy.data.db.migration.Migration127to128_PaidForDateRecord import com.ivy.data.db.migration.Migration128to129_DeleteIsDeleted import com.ivy.data.db.migration.Migration129to130_LoanIncludeNote +import com.ivy.data.db.migration.Migration130to131_Account_Include_IsVisible import com.ivy.domain.db.RoomTypeConverters import com.ivy.domain.db.migration.Migration105to106_TrnRecurringRules import com.ivy.domain.db.migration.Migration106to107_Wishlist @@ -78,7 +79,7 @@ import com.ivy.domain.db.migration.Migration125to126_Tags spec = IvyRoomDatabase.DeleteSEMigration::class ) ], - version = 130, + version = 131, exportSchema = true ) @TypeConverters(RoomTypeConverters::class) @@ -135,7 +136,8 @@ abstract class IvyRoomDatabase : RoomDatabase() { Migration126to127_LoanRecordType(), Migration127to128_PaidForDateRecord(), Migration128to129_DeleteIsDeleted(), - Migration129to130_LoanIncludeNote() + Migration129to130_LoanIncludeNote(), + Migration130to131_Account_Include_IsVisible(), ) @Suppress("SpreadOperator") diff --git a/shared/data/core/src/main/java/com/ivy/data/db/entity/AccountEntity.kt b/shared/data/core/src/main/java/com/ivy/data/db/entity/AccountEntity.kt index b9e0277c1e..d7005f300a 100644 --- a/shared/data/core/src/main/java/com/ivy/data/db/entity/AccountEntity.kt +++ b/shared/data/core/src/main/java/com/ivy/data/db/entity/AccountEntity.kt @@ -25,7 +25,8 @@ data class AccountEntity( val orderNum: Double = 0.0, @SerialName("includeInBalance") val includeInBalance: Boolean = true, - + @SerialName("isVisible") + val isVisible: Boolean = true, @Deprecated("Obsolete field used for cloud sync. Can't be deleted because of backwards compatibility") @SerialName("isSynced") val isSynced: Boolean = false, diff --git a/shared/data/core/src/main/java/com/ivy/data/db/migration/Migration130to131_Account_Include_IsVisible.kt b/shared/data/core/src/main/java/com/ivy/data/db/migration/Migration130to131_Account_Include_IsVisible.kt new file mode 100644 index 0000000000..d5ef307219 --- /dev/null +++ b/shared/data/core/src/main/java/com/ivy/data/db/migration/Migration130to131_Account_Include_IsVisible.kt @@ -0,0 +1,11 @@ +package com.ivy.data.db.migration + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +@Suppress("MagicNumber", "ClassNaming") +class Migration130to131_Account_Include_IsVisible : Migration(130, 131) { + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE accounts ADD COLUMN isVisible INTEGER DEFAULT 1 NOT NULL") + } +} \ No newline at end of file diff --git a/shared/data/core/src/main/java/com/ivy/data/repository/mapper/AccountMapper.kt b/shared/data/core/src/main/java/com/ivy/data/repository/mapper/AccountMapper.kt index 1509f9759e..d360897fed 100644 --- a/shared/data/core/src/main/java/com/ivy/data/repository/mapper/AccountMapper.kt +++ b/shared/data/core/src/main/java/com/ivy/data/repository/mapper/AccountMapper.kt @@ -28,6 +28,7 @@ class AccountMapper @Inject constructor( icon = icon?.let(IconAsset::from)?.getOrNull(), includeInBalance = includeInBalance, orderNum = orderNum, + isVisible = isVisible ) } @@ -38,6 +39,7 @@ class AccountMapper @Inject constructor( color = color.value, icon = icon?.id, orderNum = orderNum, + isVisible = isVisible, includeInBalance = includeInBalance, id = id.value, isSynced = true, // TODO: Delete this diff --git a/shared/data/model/src/main/kotlin/com/ivy/data/model/Account.kt b/shared/data/model/src/main/kotlin/com/ivy/data/model/Account.kt index 5ddf11050e..120bcfab08 100644 --- a/shared/data/model/src/main/kotlin/com/ivy/data/model/Account.kt +++ b/shared/data/model/src/main/kotlin/com/ivy/data/model/Account.kt @@ -18,6 +18,6 @@ data class Account( val color: ColorInt, val icon: IconAsset?, val includeInBalance: Boolean, - var isVisible: Boolean = true, + var isVisible: Boolean, override val orderNum: Double, ) : Identifiable, Reorderable diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/Account.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/Account.kt index 98519f2f1b..626f5100da 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/Account.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/Account.kt @@ -23,7 +23,7 @@ data class Account( val icon: String? = null, val orderNum: Double = 0.0, val includeInBalance: Boolean = true, - + val isVisible: Boolean, val isSynced: Boolean = false, val isDeleted: Boolean = false, @@ -38,6 +38,7 @@ data class Account( includeInBalance = includeInBalance, isSynced = isSynced, isDeleted = isDeleted, + isVisible = isVisible, id = id ) @@ -55,6 +56,7 @@ data class Account( icon = icon?.let(IconAsset::from)?.getOrNull(), includeInBalance = includeInBalance, orderNum = orderNum, + isVisible = isVisible ) } } diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/AccountExt.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/AccountExt.kt index 2332086294..e5ed19c793 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/AccountExt.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/datamodel/temp/AccountExt.kt @@ -12,5 +12,6 @@ fun AccountEntity.toLegacyDomain(): Account = Account( includeInBalance = includeInBalance, isSynced = isSynced, isDeleted = isDeleted, + isVisible = isVisible, id = id ) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/wallet/CalcWalletBalanceAct.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/wallet/CalcWalletBalanceAct.kt index 5b26cbb6a3..5aa5a061de 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/wallet/CalcWalletBalanceAct.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/action/wallet/CalcWalletBalanceAct.kt @@ -44,6 +44,7 @@ class CalcWalletBalanceAct @Inject constructor( icon = account.icon?.let { IconAsset.from(it).getOrNull() }, includeInBalance = account.includeInBalance, orderNum = account.orderNum, + isVisible = account.isVisible ), range = range ) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/AccountCreator.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/AccountCreator.kt index 51794e1d46..932927224f 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/AccountCreator.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/AccountCreator.kt @@ -40,6 +40,7 @@ class AccountCreator @Inject constructor( icon = data.icon?.let(IconAsset::from)?.getOrNull(), includeInBalance = data.includeBalance, orderNum = accountDao.findMaxOrderNum().nextOrderNum(), + isVisible = data.isVisible ) }.getOrNull() ?: return@ioThread accountRepository.save(account) @@ -52,7 +53,8 @@ class AccountCreator @Inject constructor( includeInBalance = data.includeBalance, orderNum = accountDao.findMaxOrderNum().nextOrderNum(), isSynced = false, - id = account.id.value + id = account.id.value, + isVisible = account.isVisible ) accountLogic.adjustBalance( account = legacyAccount, diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PreloadDataLogic.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PreloadDataLogic.kt index 16874a9ca2..30f608ae34 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PreloadDataLogic.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/PreloadDataLogic.kt @@ -61,7 +61,8 @@ class PreloadDataLogic @Inject constructor( color = Green.toArgb(), icon = "cash", orderNum = 0.0, - isSynced = false + isSynced = false, + isVisible = true ) val bank = Account( @@ -70,7 +71,8 @@ class PreloadDataLogic @Inject constructor( color = IvyDark.toArgb(), icon = "bank", orderNum = 1.0, - isSynced = false + isSynced = false, + isVisible = true ) cash.toDomainAccount(currencyRepository).getOrNull() diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/csv/CSVImporter.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/csv/CSVImporter.kt index 3e35794988..4a17bf81c6 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/csv/CSVImporter.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/csv/CSVImporter.kt @@ -474,7 +474,8 @@ class CSVImporter @Inject constructor( ), color = colorArgb, icon = icon, - orderNum = orderNum ?: accountDao.findMaxOrderNum().nextOrderNum() + orderNum = orderNum ?: accountDao.findMaxOrderNum().nextOrderNum(), + isVisible = true ) val domainAccount = newAccount.toDomainAccount(currencyRepository).getOrNull() ?: return null diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/model/CreateAccountData.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/model/CreateAccountData.kt index db372738bb..03809757cd 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/model/CreateAccountData.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/domain/deprecated/logic/model/CreateAccountData.kt @@ -9,4 +9,5 @@ data class CreateAccountData( val icon: String?, val balance: Double, val includeBalance: Boolean = true, + val isVisible: Boolean = true ) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/edit/core/EditBottomSheet.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/edit/core/EditBottomSheet.kt index a7f1aa26be..29aa3f9b01 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/edit/core/EditBottomSheet.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/edit/core/EditBottomSheet.kt @@ -795,7 +795,7 @@ private fun LabelAccountMini( @Composable private fun Preview() { IvyWalletPreview { - val acc1 = Account("Cash", color = Green.toArgb()) + val acc1 = Account("Cash", isVisible = true, color = Green.toArgb()) BoxWithConstraints( modifier = Modifier @@ -812,9 +812,9 @@ private fun Preview() { }, accounts = listOf( acc1, - Account("DSK", color = GreenDark.toArgb()), - Account("phyre", color = GreenLight.toArgb()), - Account("Revolut", color = IvyDark.toArgb()), + Account("DSK", isVisible = true, color = GreenDark.toArgb()), + Account("phyre", isVisible = true, color = GreenLight.toArgb()), + Account("Revolut" ,isVisible = true, color = IvyDark.toArgb()), ), selectedAccount = acc1, toAccount = null, @@ -833,8 +833,8 @@ private fun Preview() { @Composable private fun Preview_Transfer() { IvyWalletPreview { - val acc1 = Account("Cash", color = Green.toArgb()) - val acc2 = Account("DSK", color = GreenDark.toArgb()) + val acc1 = Account("Cash", isVisible = true, color = Green.toArgb()) + val acc2 = Account("DSK", isVisible = true, color = GreenDark.toArgb()) BoxWithConstraints( modifier = Modifier @@ -852,8 +852,8 @@ private fun Preview_Transfer() { accounts = listOf( acc1, acc2, - Account("phyre", color = GreenLight.toArgb(), icon = "cash"), - Account("Revolut", color = IvyDark.toArgb()), + Account("phyre", isVisible = true, color = GreenLight.toArgb(), icon = "cash"), + Account("Revolut", isVisible = true, color = IvyDark.toArgb()), ), selectedAccount = acc1, toAccount = acc2, diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt index 46c2981b07..53f56b7fdb 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/ui/component/transaction/TransactionCard.kt @@ -656,7 +656,7 @@ private data class AmountTypeStyle( private fun PreviewUpcomingExpense() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "Cash", Green.toArgb()) + val cash = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Food"), color = ColorInt(Blue.toArgb()), @@ -695,7 +695,7 @@ private fun PreviewUpcomingExpense() { private fun PreviewUpcomingExpenseBadgeSecondRow() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "Cash", Green.toArgb()) + val cash = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Food-Travel-Entertaiment-Food"), color = ColorInt(Blue.toArgb()), @@ -734,7 +734,7 @@ private fun PreviewUpcomingExpenseBadgeSecondRow() { private fun PreviewOverdueExpense() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "Cash", color = Green.toArgb()) + val cash = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Rent"), color = ColorInt(Green.toArgb()), @@ -773,7 +773,7 @@ private fun PreviewOverdueExpense() { private fun PreviewNormalExpense() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "Cash", color = Green.toArgb()) + val cash = Account(name = "Cash", isVisible = true, color = Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Bitovi"), color = ColorInt(Orange.toArgb()), @@ -811,7 +811,7 @@ private fun PreviewNormalExpense() { private fun PreviewIncome() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val cash = Account(name = "DSK Bank", color = Green.toArgb()) + val cash = Account(name = "DSK Bank", isVisible = true, color = Green.toArgb()) val category = Category( name = NotBlankTrimmedString.unsafe("Salary"), color = ColorInt(GreenDark.toArgb()), @@ -849,8 +849,8 @@ private fun PreviewIncome() { private fun PreviewTransfer() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val acc1 = Account(name = "DSK Bank", color = Green.toArgb(), icon = "bank") - val acc2 = Account(name = "Revolut", color = IvyDark.toArgb(), icon = "revolut") + val acc1 = Account(name = "DSK Bank", color = Green.toArgb(), isVisible = true, icon = "bank") + val acc2 = Account(name = "Revolut", color = IvyDark.toArgb(), isVisible = true, icon = "revolut") item { TransactionCard( @@ -881,12 +881,13 @@ private fun PreviewTransfer() { private fun PreviewTransfer_differentCurrency() { IvyWalletPreview { LazyColumn(Modifier.fillMaxSize()) { - val acc1 = Account(name = "DSK Bank", color = Green.toArgb(), icon = "bank") + val acc1 = Account(name = "DSK Bank", color = Green.toArgb(), isVisible = true, icon = "bank") val acc2 = Account( name = "Revolut", currency = "EUR", color = IvyDark.toArgb(), - icon = "revolut" + icon = "revolut", + isVisible = true, ) item {