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

Commit

Permalink
[Feature] Added color to accounts labels in transactions list Behind …
Browse files Browse the repository at this point in the history
…IvyFeatureToggle (#3628)

* Added color to accounts labels in transactions list Behind IvyFeatureToggle

* Added color to accounts labels in transactions list Behind IvyFeatureToggle( Reviews Resolved)
  • Loading branch information
shamim-emon authored Oct 20, 2024
1 parent f0ce9fd commit 0de400e
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 32 deletions.
3 changes: 2 additions & 1 deletion screen/home/src/main/java/com/ivy/home/HomeState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ data class HomeState(
val customerJourneyCards: ImmutableList<CustomerJourneyCardModel>,
val hideBalance: Boolean,
val hideIncome: Boolean,
val expanded: Boolean
val expanded: Boolean,
val shouldShowAccountSpecificColorInTransactions: Boolean
)
6 changes: 5 additions & 1 deletion screen/home/src/main/java/com/ivy/home/HomeTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ fun BoxWithConstraintsScope.HomeUi(
history = uiState.history,

customerJourneyCards = uiState.customerJourneyCards,
shouldShowAccountSpecificColorInTransactions = uiState.shouldShowAccountSpecificColorInTransactions,

onPayOrGet = forward<Transaction>() then2 {
HomeEvent.PayOrGetPlanned(it)
Expand Down Expand Up @@ -289,6 +290,7 @@ fun HomeLazyColumn(
period: TimePeriod,

baseData: AppBaseData,
shouldShowAccountSpecificColorInTransactions: Boolean,

upcoming: LegacyDueSection,
overdue: LegacyDueSection,
Expand Down Expand Up @@ -386,6 +388,7 @@ fun HomeLazyColumn(
timeFormatter = timeFormatter,
)
),
shouldShowAccountSpecificColorInTransactions = shouldShowAccountSpecificColorInTransactions,
onSkipTransaction = onSkipTransaction,
onSkipAllTransactions = onSkipAllTransactions
)
Expand Down Expand Up @@ -428,7 +431,8 @@ private fun BoxWithConstraintsScope.PreviewHomeTab(isDark: Boolean = false) {
period = TimePeriod(month = Month.monthsList().first(), year = 2023),
hideBalance = false,
hideIncome = false,
expanded = false
expanded = false,
shouldShowAccountSpecificColorInTransactions = false
),
onEvent = {}
)
Expand Down
12 changes: 10 additions & 2 deletions screen/home/src/main/java/com/ivy/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.ivy.base.time.TimeProvider
import com.ivy.data.model.primitive.AssetCode
import com.ivy.data.repository.CategoryRepository
import com.ivy.data.repository.mapper.TransactionMapper
import com.ivy.domain.features.Features
import com.ivy.domain.usecase.exchange.SyncExchangeRatesUseCase
import com.ivy.frp.fixUnit
import com.ivy.frp.then
Expand Down Expand Up @@ -91,6 +92,7 @@ class HomeViewModel @Inject constructor(
private val transactionMapper: TransactionMapper,
private val timeProvider: TimeProvider,
private val timeConverter: TimeConverter,
private val features: Features
) : ComposeViewModel<HomeState, HomeEvent>() {
private var currentTheme by mutableStateOf(Theme.AUTO)
private var name by mutableStateOf("")
Expand Down Expand Up @@ -126,7 +128,7 @@ class HomeViewModel @Inject constructor(
)
)
private var customerJourneyCards by
mutableStateOf<ImmutableList<CustomerJourneyCardModel>>(persistentListOf())
mutableStateOf<ImmutableList<CustomerJourneyCardModel>>(persistentListOf())
private var hideBalance by mutableStateOf(false)
private var hideIncome by mutableStateOf(false)
private var expanded by mutableStateOf(true)
Expand All @@ -151,10 +153,16 @@ class HomeViewModel @Inject constructor(
customerJourneyCards = getCustomerJourneyCards(),
hideBalance = getHideBalance(),
expanded = getExpanded(),
hideIncome = getHideIncome()
hideIncome = getHideIncome(),
shouldShowAccountSpecificColorInTransactions = getShouldShowAccountSpecificColorInTransactions()
)
}

@Composable
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
return features.showAccountColorsInTransactions.asEnabledState()
}

@Composable
private fun getTheme(): Theme {
return currentTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ private fun BoxWithConstraintsScope.UI(
},
emptyStateTitle = stringRes(R.string.no_transactions),
emptyStateText = stringRes(R.string.no_transactions_for_your_filter),
shouldShowAccountSpecificColorInTransactions = state.showAccountColorsInTransactions,
onSkipTransaction = {
onEventHandler.invoke(ReportScreenEvent.SkipTransactionLegacy(transaction = it))
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ivy.reports

import com.ivy.data.model.Transaction
import com.ivy.base.legacy.TransactionHistoryItem
import com.ivy.data.model.Category
import com.ivy.data.model.Tag
Expand Down Expand Up @@ -33,5 +32,6 @@ data class ReportScreenState(
val filterOverlayVisible: Boolean = false,
val showTransfersAsIncExpCheckbox: Boolean = false,
val treatTransfersAsIncExp: Boolean = false,
val allTags: ImmutableList<Tag> = persistentListOf()
val allTags: ImmutableList<Tag> = persistentListOf(),
val showAccountColorsInTransactions: Boolean = false
)
10 changes: 9 additions & 1 deletion screen/reports/src/main/java/com/ivy/reports/ReportViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.ivy.data.repository.mapper.TransactionMapper
import com.ivy.data.temp.migration.getTransactionType
import com.ivy.data.temp.migration.getValue
import com.ivy.domain.RootScreen
import com.ivy.domain.features.Features
import com.ivy.domain.usecase.csv.ExportCsvUseCase
import com.ivy.frp.filterSuspend
import com.ivy.legacy.IvyWalletCtx
Expand Down Expand Up @@ -89,6 +90,7 @@ class ReportViewModel @Inject constructor(
private val exportCsvUseCase: ExportCsvUseCase,
private val timeProvider: TimeProvider,
private val timeConverter: TimeConverter,
private val features: Features
) : ComposeViewModel<ReportScreenState, ReportScreenEvent>() {
private val unSpecifiedCategory =
Category(
Expand Down Expand Up @@ -128,6 +130,11 @@ class ReportViewModel @Inject constructor(
private var tagSearchJob: Job? = null
private val tagSearchDebounceTimeInMills: Long = 500

@Composable
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
return features.showAccountColorsInTransactions.asEnabledState()
}

@Composable
override fun uiState(): ReportScreenState {
LaunchedEffect(Unit) {
Expand Down Expand Up @@ -157,7 +164,8 @@ class ReportViewModel @Inject constructor(
upcomingExpenses = upcomingExpenses,
upcomingIncome = upcomingIncome,
upcomingTransactions = upcomingTransactions,
allTags = allTags
allTags = allTags,
showAccountColorsInTransactions = getShouldShowAccountSpecificColorInTransactions()
)
}

Expand Down
6 changes: 4 additions & 2 deletions screen/search/src/main/java/com/ivy/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ private fun SearchUi(
onPayOrGet = { },
emptyStateTitle = emptyStateTitle,
emptyStateText = emptyStateText,
dateDividerMarginTop = 16.dp
dateDividerMarginTop = 16.dp,
shouldShowAccountSpecificColorInTransactions = uiState.shouldShowAccountSpecificColorInTransactions
)

item {
Expand Down Expand Up @@ -134,7 +135,8 @@ private fun Preview(isDark: Boolean = false) {
transactions = persistentListOf(),
baseCurrency = "",
accounts = persistentListOf(),
categories = persistentListOf()
categories = persistentListOf(),
shouldShowAccountSpecificColorInTransactions = false
),
onEvent = {}
)
Expand Down
3 changes: 2 additions & 1 deletion screen/search/src/main/java/com/ivy/search/SearchState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ data class SearchState(
val transactions: ImmutableList<TransactionHistoryItem>,
val baseCurrency: String,
val accounts: ImmutableList<Account>,
val categories: ImmutableList<Category>
val categories: ImmutableList<Category>,
val shouldShowAccountSpecificColorInTransactions: Boolean
)
12 changes: 10 additions & 2 deletions screen/search/src/main/java/com/ivy/search/SearchViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.ivy.data.model.primitive.NotBlankTrimmedString
import com.ivy.ui.ComposeViewModel
import com.ivy.data.model.Category
import com.ivy.data.repository.CategoryRepository
import com.ivy.domain.features.Features
import com.ivy.legacy.datamodel.Account
import com.ivy.legacy.utils.getDefaultFIATCurrency
import com.ivy.legacy.utils.ioThread
Expand All @@ -31,7 +32,8 @@ class SearchViewModel @Inject constructor(
private val accountsAct: AccountsAct,
private val categoryRepository: CategoryRepository,
private val baseCurrencyAct: BaseCurrencyAct,
private val allTrnsAct: AllTrnsAct
private val allTrnsAct: AllTrnsAct,
private val features: Features
) : ComposeViewModel<SearchState, SearchEvent>() {

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

@Composable
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
return features.showAccountColorsInTransactions.asEnabledState()
}

@Composable
override fun uiState(): SearchState {
LaunchedEffect(Unit) {
Expand All @@ -52,7 +59,8 @@ class SearchViewModel @Inject constructor(
transactions = transactions.value,
baseCurrency = baseCurrency.value,
accounts = accounts.value,
categories = categories.value
categories = categories.value,
shouldShowAccountSpecificColorInTransactions = getShouldShowAccountSpecificColorInTransactions()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ fun BoxWithConstraintsScope.TransactionsScreen(screen: TransactionsScreen) {
treatTransfersAsIncomeExpense = uiState.treatTransfersAsIncomeExpense,

history = uiState.history,
shouldShowAccountSpecificColorInTransactions = uiState.showAccountColorsInTransactions,

upcoming = uiState.upcoming,
upcomingExpanded = uiState.upcomingExpanded,
Expand Down Expand Up @@ -231,6 +232,7 @@ private fun BoxWithConstraintsScope.UI(
choosePeriodModal: ChoosePeriodModalData?,

history: ImmutableList<TransactionHistoryItem>,
shouldShowAccountSpecificColorInTransactions: Boolean,

onPreviousMonth: () -> Unit,
onNextMonth: () -> Unit,
Expand Down Expand Up @@ -425,7 +427,8 @@ private fun BoxWithConstraintsScope.UI(
timeConverter = timeConverter,
timeFormatter = timeFormatter,
)
)
),
shouldShowAccountSpecificColorInTransactions = shouldShowAccountSpecificColorInTransactions
)
}
}
Expand Down Expand Up @@ -857,6 +860,7 @@ private fun BoxWithConstraintsScope.Preview_empty() {
onChoosePeriodModal = {},
choosePeriodModal = null,
screen = TransactionsScreen(),
shouldShowAccountSpecificColorInTransactions = false
)
}
}
Expand Down Expand Up @@ -903,6 +907,7 @@ private fun BoxWithConstraintsScope.Preview_crypto() {
onChoosePeriodModal = {},
choosePeriodModal = null,
screen = TransactionsScreen(),
shouldShowAccountSpecificColorInTransactions = false
)
}
}
Expand Down Expand Up @@ -949,6 +954,7 @@ private fun BoxWithConstraintsScope.Preview_empty_upcoming() {
onChoosePeriodModal = {},
choosePeriodModal = null,
screen = TransactionsScreen(),
shouldShowAccountSpecificColorInTransactions = false
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ data class TransactionsState(
val skipAllModalVisible: Boolean,
val deleteModal1Visible: Boolean,
val choosePeriodModal: ChoosePeriodModalData?,
val showAccountColorsInTransactions: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.ivy.data.repository.TagRepository
import com.ivy.data.repository.TransactionRepository
import com.ivy.data.repository.mapper.TransactionMapper
import com.ivy.design.l0_system.RedLight
import com.ivy.domain.features.Features
import com.ivy.frp.then
import com.ivy.legacy.IvyWalletCtx
import com.ivy.legacy.data.model.TimePeriod
Expand Down Expand Up @@ -95,6 +96,7 @@ class TransactionsViewModel @Inject constructor(
private val tagRepository: TagRepository,
private val timeProvider: TimeProvider,
private val timeConverter: TimeConverter,
private val features: Features
) : ComposeViewModel<TransactionsState, TransactionsEvent>() {

private val period = mutableStateOf(ivyContext.selectedPeriod)
Expand Down Expand Up @@ -161,10 +163,16 @@ class TransactionsViewModel @Inject constructor(
enableDeletionButton = getEnableDeletionButton(),
skipAllModalVisible = getSkipAllModalVisible(),
deleteModal1Visible = getDeleteModal1Visible(),
choosePeriodModal = getChoosePeriodModal()
choosePeriodModal = getChoosePeriodModal(),
showAccountColorsInTransactions = getShouldShowAccountSpecificColorInTransactions()
)
}

@Composable
fun getShouldShowAccountSpecificColorInTransactions(): Boolean {
return features.showAccountColorsInTransactions.asEnabledState()
}

@Composable
private fun getPeriod(): TimePeriod {
return period.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Features {
val hideTotalBalance: BoolFeature
val showDecimalNumber: BoolFeature
val standardKeypadLayout: BoolFeature
val showAccountColorsInTransactions: BoolFeature

val allFeatures: List<BoolFeature>
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ class IvyFeatures @Inject constructor() : Features {
defaultValue = false
)

override val showAccountColorsInTransactions = BoolFeature(
key = "show_account_color",
group = FeatureGroup.Other,
name = "Show Account Color",
description = "Show account specific colors for accounts in transactions",
defaultValue = false
)

override val allFeatures: List<BoolFeature>
get() = listOf(
sortCategoriesAscending,
Expand All @@ -75,7 +83,8 @@ class IvyFeatures @Inject constructor() : Features {
showTitleSuggestions,
showCategorySearchBar,
hideTotalBalance,
standardKeypadLayout
standardKeypadLayout,
showAccountColorsInTransactions
/* will be uncommented when this functionality
* will be available across the application in up-coming PRs
showDecimalNumber
Expand Down
Loading

0 comments on commit 0de400e

Please sign in to comment.