Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit 0de400e

Browse files
authored
[Feature] Added color to accounts labels in transactions list Behind IvyFeatureToggle (#3628)
* Added color to accounts labels in transactions list Behind IvyFeatureToggle * Added color to accounts labels in transactions list Behind IvyFeatureToggle( Reviews Resolved)
1 parent f0ce9fd commit 0de400e

File tree

16 files changed

+103
-32
lines changed

16 files changed

+103
-32
lines changed

screen/home/src/main/java/com/ivy/home/HomeState.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ data class HomeState(
3333
val customerJourneyCards: ImmutableList<CustomerJourneyCardModel>,
3434
val hideBalance: Boolean,
3535
val hideIncome: Boolean,
36-
val expanded: Boolean
36+
val expanded: Boolean,
37+
val shouldShowAccountSpecificColorInTransactions: Boolean
3738
)

screen/home/src/main/java/com/ivy/home/HomeTab.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ fun BoxWithConstraintsScope.HomeUi(
189189
history = uiState.history,
190190

191191
customerJourneyCards = uiState.customerJourneyCards,
192+
shouldShowAccountSpecificColorInTransactions = uiState.shouldShowAccountSpecificColorInTransactions,
192193

193194
onPayOrGet = forward<Transaction>() then2 {
194195
HomeEvent.PayOrGetPlanned(it)
@@ -289,6 +290,7 @@ fun HomeLazyColumn(
289290
period: TimePeriod,
290291

291292
baseData: AppBaseData,
293+
shouldShowAccountSpecificColorInTransactions: Boolean,
292294

293295
upcoming: LegacyDueSection,
294296
overdue: LegacyDueSection,
@@ -386,6 +388,7 @@ fun HomeLazyColumn(
386388
timeFormatter = timeFormatter,
387389
)
388390
),
391+
shouldShowAccountSpecificColorInTransactions = shouldShowAccountSpecificColorInTransactions,
389392
onSkipTransaction = onSkipTransaction,
390393
onSkipAllTransactions = onSkipAllTransactions
391394
)
@@ -428,7 +431,8 @@ private fun BoxWithConstraintsScope.PreviewHomeTab(isDark: Boolean = false) {
428431
period = TimePeriod(month = Month.monthsList().first(), year = 2023),
429432
hideBalance = false,
430433
hideIncome = false,
431-
expanded = false
434+
expanded = false,
435+
shouldShowAccountSpecificColorInTransactions = false
432436
),
433437
onEvent = {}
434438
)

screen/home/src/main/java/com/ivy/home/HomeViewModel.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.ivy.base.time.TimeProvider
1515
import com.ivy.data.model.primitive.AssetCode
1616
import com.ivy.data.repository.CategoryRepository
1717
import com.ivy.data.repository.mapper.TransactionMapper
18+
import com.ivy.domain.features.Features
1819
import com.ivy.domain.usecase.exchange.SyncExchangeRatesUseCase
1920
import com.ivy.frp.fixUnit
2021
import com.ivy.frp.then
@@ -91,6 +92,7 @@ class HomeViewModel @Inject constructor(
9192
private val transactionMapper: TransactionMapper,
9293
private val timeProvider: TimeProvider,
9394
private val timeConverter: TimeConverter,
95+
private val features: Features
9496
) : ComposeViewModel<HomeState, HomeEvent>() {
9597
private var currentTheme by mutableStateOf(Theme.AUTO)
9698
private var name by mutableStateOf("")
@@ -126,7 +128,7 @@ class HomeViewModel @Inject constructor(
126128
)
127129
)
128130
private var customerJourneyCards by
129-
mutableStateOf<ImmutableList<CustomerJourneyCardModel>>(persistentListOf())
131+
mutableStateOf<ImmutableList<CustomerJourneyCardModel>>(persistentListOf())
130132
private var hideBalance by mutableStateOf(false)
131133
private var hideIncome by mutableStateOf(false)
132134
private var expanded by mutableStateOf(true)
@@ -151,10 +153,16 @@ class HomeViewModel @Inject constructor(
151153
customerJourneyCards = getCustomerJourneyCards(),
152154
hideBalance = getHideBalance(),
153155
expanded = getExpanded(),
154-
hideIncome = getHideIncome()
156+
hideIncome = getHideIncome(),
157+
shouldShowAccountSpecificColorInTransactions = getShouldShowAccountSpecificColorInTransactions()
155158
)
156159
}
157160

161+
@Composable
162+
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
163+
return features.showAccountColorsInTransactions.asEnabledState()
164+
}
165+
158166
@Composable
159167
private fun getTheme(): Theme {
160168
return currentTheme

screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ private fun BoxWithConstraintsScope.UI(
265265
},
266266
emptyStateTitle = stringRes(R.string.no_transactions),
267267
emptyStateText = stringRes(R.string.no_transactions_for_your_filter),
268+
shouldShowAccountSpecificColorInTransactions = state.showAccountColorsInTransactions,
268269
onSkipTransaction = {
269270
onEventHandler.invoke(ReportScreenEvent.SkipTransactionLegacy(transaction = it))
270271
},

screen/reports/src/main/java/com/ivy/reports/ReportScreenState.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ivy.reports
22

3-
import com.ivy.data.model.Transaction
43
import com.ivy.base.legacy.TransactionHistoryItem
54
import com.ivy.data.model.Category
65
import com.ivy.data.model.Tag
@@ -33,5 +32,6 @@ data class ReportScreenState(
3332
val filterOverlayVisible: Boolean = false,
3433
val showTransfersAsIncExpCheckbox: Boolean = false,
3534
val treatTransfersAsIncExp: Boolean = false,
36-
val allTags: ImmutableList<Tag> = persistentListOf()
35+
val allTags: ImmutableList<Tag> = persistentListOf(),
36+
val showAccountColorsInTransactions: Boolean = false
3737
)

screen/reports/src/main/java/com/ivy/reports/ReportViewModel.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.ivy.data.repository.mapper.TransactionMapper
3333
import com.ivy.data.temp.migration.getTransactionType
3434
import com.ivy.data.temp.migration.getValue
3535
import com.ivy.domain.RootScreen
36+
import com.ivy.domain.features.Features
3637
import com.ivy.domain.usecase.csv.ExportCsvUseCase
3738
import com.ivy.frp.filterSuspend
3839
import com.ivy.legacy.IvyWalletCtx
@@ -89,6 +90,7 @@ class ReportViewModel @Inject constructor(
8990
private val exportCsvUseCase: ExportCsvUseCase,
9091
private val timeProvider: TimeProvider,
9192
private val timeConverter: TimeConverter,
93+
private val features: Features
9294
) : ComposeViewModel<ReportScreenState, ReportScreenEvent>() {
9395
private val unSpecifiedCategory =
9496
Category(
@@ -128,6 +130,11 @@ class ReportViewModel @Inject constructor(
128130
private var tagSearchJob: Job? = null
129131
private val tagSearchDebounceTimeInMills: Long = 500
130132

133+
@Composable
134+
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
135+
return features.showAccountColorsInTransactions.asEnabledState()
136+
}
137+
131138
@Composable
132139
override fun uiState(): ReportScreenState {
133140
LaunchedEffect(Unit) {
@@ -157,7 +164,8 @@ class ReportViewModel @Inject constructor(
157164
upcomingExpenses = upcomingExpenses,
158165
upcomingIncome = upcomingIncome,
159166
upcomingTransactions = upcomingTransactions,
160-
allTags = allTags
167+
allTags = allTags,
168+
showAccountColorsInTransactions = getShouldShowAccountSpecificColorInTransactions()
161169
)
162170
}
163171

screen/search/src/main/java/com/ivy/search/SearchScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ private fun SearchUi(
105105
onPayOrGet = { },
106106
emptyStateTitle = emptyStateTitle,
107107
emptyStateText = emptyStateText,
108-
dateDividerMarginTop = 16.dp
108+
dateDividerMarginTop = 16.dp,
109+
shouldShowAccountSpecificColorInTransactions = uiState.shouldShowAccountSpecificColorInTransactions
109110
)
110111

111112
item {
@@ -134,7 +135,8 @@ private fun Preview(isDark: Boolean = false) {
134135
transactions = persistentListOf(),
135136
baseCurrency = "",
136137
accounts = persistentListOf(),
137-
categories = persistentListOf()
138+
categories = persistentListOf(),
139+
shouldShowAccountSpecificColorInTransactions = false
138140
),
139141
onEvent = {}
140142
)

screen/search/src/main/java/com/ivy/search/SearchState.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ data class SearchState(
1010
val transactions: ImmutableList<TransactionHistoryItem>,
1111
val baseCurrency: String,
1212
val accounts: ImmutableList<Account>,
13-
val categories: ImmutableList<Category>
13+
val categories: ImmutableList<Category>,
14+
val shouldShowAccountSpecificColorInTransactions: Boolean
1415
)

screen/search/src/main/java/com/ivy/search/SearchViewModel.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.ivy.data.model.primitive.NotBlankTrimmedString
1010
import com.ivy.ui.ComposeViewModel
1111
import com.ivy.data.model.Category
1212
import com.ivy.data.repository.CategoryRepository
13+
import com.ivy.domain.features.Features
1314
import com.ivy.legacy.datamodel.Account
1415
import com.ivy.legacy.utils.getDefaultFIATCurrency
1516
import com.ivy.legacy.utils.ioThread
@@ -31,7 +32,8 @@ class SearchViewModel @Inject constructor(
3132
private val accountsAct: AccountsAct,
3233
private val categoryRepository: CategoryRepository,
3334
private val baseCurrencyAct: BaseCurrencyAct,
34-
private val allTrnsAct: AllTrnsAct
35+
private val allTrnsAct: AllTrnsAct,
36+
private val features: Features
3537
) : ComposeViewModel<SearchState, SearchEvent>() {
3638

3739
private val transactions =
@@ -41,6 +43,11 @@ class SearchViewModel @Inject constructor(
4143
private val categories = mutableStateOf<ImmutableList<Category>>(persistentListOf())
4244
private val searchQuery = mutableStateOf("")
4345

46+
@Composable
47+
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
48+
return features.showAccountColorsInTransactions.asEnabledState()
49+
}
50+
4451
@Composable
4552
override fun uiState(): SearchState {
4653
LaunchedEffect(Unit) {
@@ -52,7 +59,8 @@ class SearchViewModel @Inject constructor(
5259
transactions = transactions.value,
5360
baseCurrency = baseCurrency.value,
5461
accounts = accounts.value,
55-
categories = categories.value
62+
categories = categories.value,
63+
shouldShowAccountSpecificColorInTransactions = getShouldShowAccountSpecificColorInTransactions()
5664
)
5765
}
5866

screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ fun BoxWithConstraintsScope.TransactionsScreen(screen: TransactionsScreen) {
137137
treatTransfersAsIncomeExpense = uiState.treatTransfersAsIncomeExpense,
138138

139139
history = uiState.history,
140+
shouldShowAccountSpecificColorInTransactions = uiState.showAccountColorsInTransactions,
140141

141142
upcoming = uiState.upcoming,
142143
upcomingExpanded = uiState.upcomingExpanded,
@@ -231,6 +232,7 @@ private fun BoxWithConstraintsScope.UI(
231232
choosePeriodModal: ChoosePeriodModalData?,
232233

233234
history: ImmutableList<TransactionHistoryItem>,
235+
shouldShowAccountSpecificColorInTransactions: Boolean,
234236

235237
onPreviousMonth: () -> Unit,
236238
onNextMonth: () -> Unit,
@@ -425,7 +427,8 @@ private fun BoxWithConstraintsScope.UI(
425427
timeConverter = timeConverter,
426428
timeFormatter = timeFormatter,
427429
)
428-
)
430+
),
431+
shouldShowAccountSpecificColorInTransactions = shouldShowAccountSpecificColorInTransactions
429432
)
430433
}
431434
}
@@ -857,6 +860,7 @@ private fun BoxWithConstraintsScope.Preview_empty() {
857860
onChoosePeriodModal = {},
858861
choosePeriodModal = null,
859862
screen = TransactionsScreen(),
863+
shouldShowAccountSpecificColorInTransactions = false
860864
)
861865
}
862866
}
@@ -903,6 +907,7 @@ private fun BoxWithConstraintsScope.Preview_crypto() {
903907
onChoosePeriodModal = {},
904908
choosePeriodModal = null,
905909
screen = TransactionsScreen(),
910+
shouldShowAccountSpecificColorInTransactions = false
906911
)
907912
}
908913
}
@@ -949,6 +954,7 @@ private fun BoxWithConstraintsScope.Preview_empty_upcoming() {
949954
onChoosePeriodModal = {},
950955
choosePeriodModal = null,
951956
screen = TransactionsScreen(),
957+
shouldShowAccountSpecificColorInTransactions = false
952958
)
953959
}
954960
}

0 commit comments

Comments
 (0)