diff --git a/app/src/main/java/com/tangem/tap/di/domain/MarketsDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/MarketsDomainModule.kt index 6e154f3fc1..e56953ffdc 100644 --- a/app/src/main/java/com/tangem/tap/di/domain/MarketsDomainModule.kt +++ b/app/src/main/java/com/tangem/tap/di/domain/MarketsDomainModule.kt @@ -115,7 +115,7 @@ object MarketsDomainModule { return FilterAvailableNetworksForWalletUseCase( userWalletsListManager = userWalletsListManager, userWalletsListRepository = userWalletsListRepository, - useNewRepository = hotWalletFeatureToggles.isHotWalletEnabled, + shouldUseNewRepository = hotWalletFeatureToggles.isHotWalletEnabled, excludedBlockchains = excludedBlockchains, ) } diff --git a/common/ui/detekt-baseline-debug.xml b/common/ui/detekt-baseline-debug.xml index 13ac4c3486..312ce47852 100644 --- a/common/ui/detekt-baseline-debug.xml +++ b/common/ui/detekt-baseline-debug.xml @@ -9,20 +9,11 @@ BooleanPropertyNaming:NotificationUM.kt$NotificationUM.Error.ExceedsBalance$val mergeFeeNetworkName: Boolean = false BooleanPropertyNaming:NotificationsFactory.kt$NotificationsFactory$val showNotification = sendingAmount + feeAmount > balance - minimumRequirement.orZero() BooleanPropertyNaming:TokenReceiveBottomSheetConfig.kt$TokenReceiveBottomSheetConfig$val showMemoDisclaimer: Boolean - CanBeNonNullable:AmountBlockV2.kt$onClick: (() -> Unit)? = null - CanBeNonNullable:NavigationButtonsBlock.kt$footerText: TextReference? - CanBeNonNullable:NavigationButtonsBlock.kt$pairButtons: Pair<NavigationButton, NavigationButton>? - CanBeNonNullable:NavigationButtonsBlock.kt$prevButton: NavigationButton? - CanBeNonNullable:NotificationsFactory.kt$NotificationsFactory$dustValue: BigDecimal? - CanBeNonNullable:NotificationsFactory.kt$NotificationsFactory$minAdaValue: BigDecimal? - CanBeNonNullable:NotificationsFactory.kt$NotificationsFactory$minimumSendAmount: BigDecimal? - CanBeNonNullable:NotificationsFactory.kt$NotificationsFactory$rentWarning: CryptoCurrencyWarning.Rent? MultilineLambdaItParameter:ExpressStatusItems.kt${ val itemInfo = expressTxs[it].info val (iconRes, tint) = when (itemInfo.iconState) { ExpressTransactionStateIconUM.Warning -> { R.drawable.ic_alert_triangle_20 to TangemTheme.colors.icon.attention } ExpressTransactionStateIconUM.Error -> { R.drawable.ic_alert_circle_24 to TangemTheme.colors.icon.warning } ExpressTransactionStateIconUM.None -> null to null } ExpressStatusItem( title = itemInfo.title, fromTokenIconState = itemInfo.fromCurrencyIcon, toTokenIconState = itemInfo.toCurrencyIcon, fromAmount = itemInfo.fromAmount, fromSymbol = itemInfo.fromAmountSymbol, toAmount = itemInfo.toAmount, toSymbol = itemInfo.toAmountSymbol, onClick = itemInfo.onClick, infoIconRes = iconRes, infoIconTint = tint, modifier = modifier.animateItem(), ) } MultilineLambdaItParameter:TokenItemStateConverter.kt$TokenItemStateConverter.Companion${ it.key.equals( other = token.yieldSupplyKey(), ignoreCase = BlockchainUtils.isCaseInsensitiveContractAddress(token.network.rawId), ) } NoNameShadowing:NavigationButtonsBlock.kt$navigationUM NoNameShadowing:UserWalletItem.kt$balance NullableBooleanCheck:TokenItemStateConverter.kt$TokenItemStateConverter.Companion$cryptoCurrencyStatus.value.yieldSupplyStatus?.isActive ?: false - NullableToStringCall:TokenItemStateConverter.kt$TokenItemStateConverter.Companion$${id.rawCurrencyId} ReusedModifierInstance:AddTokenContent.kt$AddButton( modifier = modifier.fillMaxWidth(), state = state.button, ) UnnecessaryEventHandlerParameter:SendDoneButtons.kt$onShareClick: (String) -> Unit UnnecessaryLet:TokenItemStateConverter.kt$TokenItemStateConverter.Companion$let(::add) diff --git a/core/datasource/detekt-baseline-debug.xml b/core/datasource/detekt-baseline-debug.xml index 7d14c576a1..08b13f32ec 100644 --- a/core/datasource/detekt-baseline-debug.xml +++ b/core/datasource/detekt-baseline-debug.xml @@ -12,6 +12,5 @@ NestedScopeFunctions:RetrofitApiBuilder.kt$RetrofitApiBuilder$let { withWriteTimeout(timeout = it.duration, unit = it.unit) } UnreachableCode:MockApiConfigsManager.kt$MockApiConfigsManager$apiConfigs + (apiConfig to environment) UnreachableCode:MockApiConfigsManager.kt$MockApiConfigsManager$val apiConfig = apiConfigs.keys.firstOrNull { it.id.name == id } ?: error("Api config with id [$id] not found. Check that ApiConfig with id [$id] was provided into DI") - UnusedImports:NetworkModule.kt$import com.tangem.datasource.api.common.config.MoonPay diff --git a/core/ui/detekt-baseline-debug.xml b/core/ui/detekt-baseline-debug.xml index 662bc3318f..9cd3507ca1 100644 --- a/core/ui/detekt-baseline-debug.xml +++ b/core/ui/detekt-baseline-debug.xml @@ -5,12 +5,6 @@ BooleanPropertyNaming:BigDecimalPercentFormat.kt$BigDecimalPercentFormat$val withPercentSign: Boolean = true BooleanPropertyNaming:FullScreen.kt$FullScreenLayout$private val focusable: Boolean BooleanPropertyNaming:TokenItemState.kt$TokenItemState.TitleState.Content$val earnApyIsActive: Boolean = false - CanBeNonNullable:FooterContainer.kt$footer: TextReference? = null - CanBeNonNullable:InputRowImageBase.kt$iconRes: Int? - CanBeNonNullable:InputRowImageInfo.kt$subtitleEndIconRes: Int? - CanBeNonNullable:SearchBar.kt$keyboardController: SoftwareKeyboardController? - CanBeNonNullable:TextFields.kt$caption: String? = null - CanBeNonNullable:TransactionList.kt$txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>? CastNullableToNonNullableType:DialogFullScreen.kt$as CastNullableToNonNullableType:FullScreen.kt$FullScreenLayout$as MultilineLambdaItParameter:Actions.kt${ ActionButtonContent( config = config, text = { textColor -> Text(text = config.text, textColor = textColor) }, modifier = it.padding( start = TangemTheme.dimens.spacing16, end = TangemTheme.dimens.spacing24, ), ) } @@ -27,6 +21,5 @@ ReusedModifierInstance:TangemRadioButton.kt$AnimatedVisibility( visible = isSelected, label = "Radio button animation", modifier = modifier .size(TangemTheme.dimens.size24), ) { Icon( painter = painterResource(id = R.drawable.ic_check_circle_24), contentDescription = null, tint = TangemTheme.colors.control.checked, ) } ReusedModifierInstance:TokenPrice.kt$Icon( modifier = modifier, painter = painterResource( id = when (animatedType) { PriceChangeType.UP -> R.drawable.ic_arrow_up_8 PriceChangeType.DOWN -> R.drawable.ic_arrow_down_8 PriceChangeType.NEUTRAL -> R.drawable.ic_elipse_8 }, ), tint = when (animatedType) { PriceChangeType.UP -> TangemTheme.colors.icon.accent PriceChangeType.DOWN -> TangemTheme.colors.icon.warning PriceChangeType.NEUTRAL -> TangemTheme.colors.icon.inactive }, contentDescription = null, ) UnnecessaryEventHandlerParameter:PinTextField.kt$onValueChange: (String) -> Unit - UnnecessaryEventHandlerParameter:ResizableText.kt$onFontSizeChange: (Float) -> Unit diff --git a/data/markets/detekt-baseline-debug.xml b/data/markets/detekt-baseline-debug.xml deleted file mode 100644 index fd96850854..0000000000 --- a/data/markets/detekt-baseline-debug.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - BooleanPropertyNaming:DefaultMarketsTokenRepository.kt$DefaultMarketsTokenRepository.<no name provided>$val last = res.tokens.size < request.limit - MultilineLambdaItParameter:DefaultMarketsTokenRepository.kt$DefaultMarketsTokenRepository${ val error = it as QuotesFetcher.Error.ApiOperationError val errorEvent = createDetailsErrorEvent( error = error.apiError, request = MarketsDataAnalyticsEvent.Details.Error.Request.Info, tokenSymbol = tokenSymbol, ) analyticsEventHandler.send(errorEvent.toEvent()) throw error.apiError } - MultilineLambdaItParameter:MarketsBatchUpdateFetcher.kt$MarketsBatchUpdateFetcher${ it.copy( tokenCharts = TokenMarketChartsConverter.convert( chartsToCopy = it.tokenCharts, tokenId = it.id, interval = updateRequest.interval, value = update, ), ) } - MultilineLambdaItParameter:MarketsBatchUpdateFetcher.kt$MarketsBatchUpdateFetcher${ val exception = if (it is QuotesFetcher.Error.ApiOperationError) { onApiResponseError(it.apiError) it.apiError } else { error("Cause: $it") } throw exception } - MultilineLambdaItParameter:TokenMarketInfoConverter.kt$TokenMarketInfoConverter${ TokenMarketInfo.Link( title = it.title, id = it.id, link = it.link, ) } - NullableBooleanCheck:TokenMarketListConverter.kt$TokenMarketListConverter$token.isUnderMarketCapLimit ?: false - SuspendFunWithFlowReturnType:DefaultMarketsTokenRepository.kt$DefaultMarketsTokenRepository$suspend - UnsafeCallOnNullableType:DefaultMarketsTokenRepository.kt$DefaultMarketsTokenRepository$network.contractAddress!! - UseEmptyCounterpart:MarketsDataAnalyticsEvent.kt$MarketsDataAnalyticsEvent.Details$mapOf() - UseEmptyCounterpart:MarketsDataAnalyticsEvent.kt$MarketsDataAnalyticsEvent.List$mapOf() - - diff --git a/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt b/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt index 2f974d4f31..d6df4d9333 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt @@ -90,13 +90,13 @@ internal class DefaultMarketsTokenRepository( requestTimeStamp.set(res.timestamp ?: 0) } - val last = res.tokens.size < request.limit + val isLast = res.tokens.size < request.limit val tokenMarketListWithMaxApy = TokenMarketListConverter.convert(res) return BatchFetchResult.Success( data = tokenMarketListWithMaxApy.tokens, - last = last, + last = isLast, empty = res.tokens.isEmpty(), ) } @@ -227,8 +227,8 @@ internal class DefaultMarketsTokenRepository( currencyId = tokenId.value, field = QuotesFetcher.Field.ALL_PRICES, ) - .getOrElse { - val error = it as QuotesFetcher.Error.ApiOperationError + .getOrElse { fetchError -> + val error = fetchError as QuotesFetcher.Error.ApiOperationError val errorEvent = createDetailsErrorEvent( error = error.apiError, @@ -274,7 +274,7 @@ internal class DefaultMarketsTokenRepository( name = token.name, symbol = token.symbol, decimals = network.decimalCount ?: error("Unknown decimal"), - contractAddress = network.contractAddress!!, + contractAddress = requireNotNull(network.contractAddress) { "Contract address is required for token" }, ) } } diff --git a/data/markets/src/main/java/com/tangem/data/markets/MarketsBatchUpdateFetcher.kt b/data/markets/src/main/java/com/tangem/data/markets/MarketsBatchUpdateFetcher.kt index 82ab261728..11a6852e47 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/MarketsBatchUpdateFetcher.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/MarketsBatchUpdateFetcher.kt @@ -79,13 +79,13 @@ internal class MarketsBatchUpdateFetcher( currenciesIds = currenciesIds, fields = setOf(QuotesFetcher.Field.ALL_PRICES), ) - .getOrElse { - val exception = if (it is QuotesFetcher.Error.ApiOperationError) { - onApiResponseError(it.apiError) + .getOrElse { error -> + val exception = if (error is QuotesFetcher.Error.ApiOperationError) { + onApiResponseError(error.apiError) - it.apiError + error.apiError } else { - error("Cause: $it") + error("Cause: $error") } throw exception @@ -116,11 +116,11 @@ internal class MarketsBatchUpdateFetcher( Batch( key = batchToUpdate.key, - data = batchToUpdate.data.map { - it.copy( + data = batchToUpdate.data.map { tokenMarket -> + tokenMarket.copy( tokenCharts = TokenMarketChartsConverter.convert( - chartsToCopy = it.tokenCharts, - tokenId = it.id, + chartsToCopy = tokenMarket.tokenCharts, + tokenId = tokenMarket.id, interval = updateRequest.interval, value = update, ), diff --git a/data/markets/src/main/java/com/tangem/data/markets/analytics/MarketsDataAnalyticsEvent.kt b/data/markets/src/main/java/com/tangem/data/markets/analytics/MarketsDataAnalyticsEvent.kt index 5d04e7511f..dc94cd9ceb 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/analytics/MarketsDataAnalyticsEvent.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/analytics/MarketsDataAnalyticsEvent.kt @@ -7,7 +7,7 @@ sealed interface MarketsDataAnalyticsEvent { sealed class List( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = "Markets", event = event, params = params), MarketsDataAnalyticsEvent { data class Error( @@ -26,7 +26,7 @@ sealed interface MarketsDataAnalyticsEvent { sealed class Details( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = "Markets / Chart", event = event, params = params), MarketsDataAnalyticsEvent { data class Error( diff --git a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt index a00841547c..a1044051b9 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt @@ -62,7 +62,7 @@ internal class TokenMarketInfoConverter( network.contractAddress.isNullOrEmpty() -> { TokenMarketInfo.Network( networkId = network.networkId, - exchangeable = network.exchangeable, + isExchangeable = network.exchangeable, contractAddress = network.contractAddress, decimalCount = network.decimalCount, ) @@ -71,7 +71,7 @@ internal class TokenMarketInfoConverter( blockchain.canHandleTokens() -> { TokenMarketInfo.Network( networkId = network.networkId, - exchangeable = network.exchangeable, + isExchangeable = network.exchangeable, contractAddress = blockchain.reformatContractAddress(network.contractAddress), decimalCount = network.decimalCount, ) @@ -147,11 +147,11 @@ internal class TokenMarketInfoConverter( @JvmName("convertLink") private fun List.convert(): List { - return map { + return map { link -> TokenMarketInfo.Link( - title = it.title, - id = it.id, - link = it.link, + title = link.title, + id = link.id, + link = link.link, ) } } diff --git a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketListConverter.kt b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketListConverter.kt index ed6cb59dc4..f43e7ddae1 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketListConverter.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketListConverter.kt @@ -31,7 +31,7 @@ internal object TokenMarketListConverter : ConverterMultilineLambdaItParameter:WcEthMessageSignUseCase.kt$LegacySdkHelper${ val char = it.toInt().toChar() if (char.isAscii()) char else return null } MultilineLambdaItParameter:WcEthNetwork.kt$WcEthNetwork${ if (this == WcEthMethodName.AddEthereumChain) { WcEthMethod.AddEthereumChain(rawChain = it).right() } else { WcEthMethod.SwitchEthereumChain(rawChain = it).right() } } MultilineLambdaItParameter:WcEthNetwork.kt$WcEthNetwork${ if (this == WcEthMethodName.SignTransaction) { WcEthMethod.SignTransaction(transaction = it).right() } else { WcEthMethod.SendTransaction(transaction = it).right() } } - MultilineLambdaItParameter:WcNetworksConverter.kt$WcNetworksConverter${ val walletAddress = walletManagersFacade.getDefaultAddress(wallet.walletId, it) walletAddress?.lowercase() == caip10.accountAddress.lowercase() } MultilineLambdaItParameter:WcPairSdkDelegate.kt$WcPairSdkDelegate${ proposalCallback.cancel() return@coroutineScope it.left() } MultilineLambdaItParameter:WcPairSdkDelegate.kt$WcPairSdkDelegate${ store.removePendingApproval(forSave) it.left() } MultilineLambdaItParameter:WcSdkSessionConverter.kt$WcSdkSessionConverter${ WcAppMetaDataConverter.convert( value = WcAppMetaDataConverter.Input( originUrl = value.originUrl, peerMetaData = it, ), ) } diff --git a/detekt_baseline_report.txt b/detekt_baseline_report.txt index d36313f946..6637a2e509 100644 --- a/detekt_baseline_report.txt +++ b/detekt_baseline_report.txt @@ -1,7 +1,7 @@ ========================================== Detekt Baseline Updater & Issue Counter ========================================== -Date: 2025-12-13 00:34:09 +Date: 2026-01-04 19:04:51 Step 1: Running detekt to check for new issues... @@ -17,13 +17,13 @@ Counting issues in baseline files... ========================================== Summary: - Total Issues: 1271 - Modules with Issues: 69 - Average Issues per Module: 18 + Total Issues: 1065 + Modules with Issues: 65 + Average Issues per Module: 16 Progress: - Fixed: 662 out of 1933 (34%) - Remaining: 1271 + Fixed: 868 out of 1933 (44%) + Remaining: 1065 ========================================== All Modules with Issues (sorted by count) @@ -31,54 +31,51 @@ All Modules with Issues (sorted by count) Module Issues ──────────────────────────────────────────────────────────────── -features/markets/impl 147 -features/wallet/impl 144 +features/wallet/impl 138 features/onboarding-v2/impl 128 -data/wallet-connect 54 -features/hot-wallet/impl 51 +data/wallet-connect 53 +features/hot-wallet/impl 50 features/walletconnect/impl 47 -features/staking/impl 46 features/tokendetails/impl 45 features/manage-tokens/impl 44 -domain/wallets 37 -features/nft/impl 34 -features/tester/impl 28 -core/ui 26 -domain/tokens 25 -common/ui 24 +domain/wallets 36 +features/staking/impl 35 +features/nft/impl 33 +features/tester/impl 27 +domain/tokens 23 features/yield-supply/impl 21 features/tangempay/details/impl 21 domain/models 21 data/visa 21 data/nft 19 +core/ui 19 core/pagination 16 +common/ui 15 domain/staking/models 13 data/wallets 13 features/token-recieve/impl 11 features/qr-scanning/impl 11 data/onramp 11 -core/datasource 11 core/analytics/models 11 -data/markets 10 +core/datasource 10 features/details/impl 9 domain/account/status 9 data/yield-supply 9 data/networks 9 domain/visa/models 8 domain/transaction 8 -domain/staking 8 core/utils 8 libs/tangem-sdk-api 7 features/referral/impl 7 domain/tokens/models 7 +domain/staking 7 data/txhistory 7 -features/welcome/impl 6 domain/wallet-connect/models 6 domain/onramp 6 domain/account 6 libs/visa 5 +features/welcome/impl 5 features/home/impl 5 -domain/markets 5 domain/core 5 data/account 5 domain/onramp/models 4 @@ -97,7 +94,6 @@ domain/transaction/models 1 domain/quotes 1 domain/promo 1 domain/onboarding 1 -domain/markets/models 1 domain/feedback/models 1 domain/express/models 1 ──────────────────────────────────────────────────────────────── \ No newline at end of file diff --git a/domain/markets/detekt-baseline-debug.xml b/domain/markets/detekt-baseline-debug.xml deleted file mode 100644 index 64d62630c1..0000000000 --- a/domain/markets/detekt-baseline-debug.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - BooleanPropertyNaming:FilterAvailableNetworksForWalletUseCase.kt$FilterAvailableNetworksForWalletUseCase$private val useNewRepository: Boolean - BooleanPropertyNaming:GetStakingNotificationMaxApyUseCase.kt$GetStakingNotificationMaxApyUseCase$val showStakingNotification = if (!hideClicked && walletFirstUsageDate != 0L) { currentDate - walletFirstUsageDate > TWO_WEEKS_IN_MILLIS } else { false } - MultilineLambdaItParameter:FilterAvailableNetworksForWalletUseCase.kt$FilterAvailableNetworksForWalletUseCase${ val blockchain = Blockchain.fromNetworkId(it.networkId) supportedBlockchains.contains(blockchain) } - SuspendFunWithFlowReturnType:GetStakingNotificationMaxApyUseCase.kt$GetStakingNotificationMaxApyUseCase$suspend - SuspendFunWithFlowReturnType:MarketsTokenRepository.kt$MarketsTokenRepository$suspend - - diff --git a/domain/markets/models/detekt-baseline-main.xml b/domain/markets/models/detekt-baseline-main.xml deleted file mode 100644 index 17228539ba..0000000000 --- a/domain/markets/models/detekt-baseline-main.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - BooleanPropertyNaming:TokenMarketInfo.kt$TokenMarketInfo.Network$val exchangeable: Boolean - - diff --git a/domain/markets/models/src/main/kotlin/com/tangem/domain/markets/TokenMarketInfo.kt b/domain/markets/models/src/main/kotlin/com/tangem/domain/markets/TokenMarketInfo.kt index 5354432e4c..bbd7a840ce 100644 --- a/domain/markets/models/src/main/kotlin/com/tangem/domain/markets/TokenMarketInfo.kt +++ b/domain/markets/models/src/main/kotlin/com/tangem/domain/markets/TokenMarketInfo.kt @@ -23,7 +23,7 @@ data class TokenMarketInfo( @Serializable data class Network( val networkId: String, - val exchangeable: Boolean, + val isExchangeable: Boolean, val contractAddress: String?, val decimalCount: Int?, ) diff --git a/domain/markets/src/main/java/com/tangem/domain/markets/FilterAvailableNetworksForWalletUseCase.kt b/domain/markets/src/main/java/com/tangem/domain/markets/FilterAvailableNetworksForWalletUseCase.kt index 467ab832d1..aaf389d312 100644 --- a/domain/markets/src/main/java/com/tangem/domain/markets/FilterAvailableNetworksForWalletUseCase.kt +++ b/domain/markets/src/main/java/com/tangem/domain/markets/FilterAvailableNetworksForWalletUseCase.kt @@ -12,7 +12,7 @@ import com.tangem.domain.wallets.legacy.UserWalletsListManager class FilterAvailableNetworksForWalletUseCase( private val userWalletsListManager: UserWalletsListManager, private val userWalletsListRepository: UserWalletsListRepository, - private val useNewRepository: Boolean, + private val shouldUseNewRepository: Boolean, private val excludedBlockchains: ExcludedBlockchains, ) { @@ -32,13 +32,13 @@ class FilterAvailableNetworksForWalletUseCase( excludedBlockchains = excludedBlockchains, ) - return networks.filter { - val blockchain = Blockchain.fromNetworkId(it.networkId) + return networks.filter { network -> + val blockchain = Blockchain.fromNetworkId(network.networkId) supportedBlockchains.contains(blockchain) }.toSet() } - private fun getWallets() = if (useNewRepository) { + private fun getWallets() = if (shouldUseNewRepository) { userWalletsListRepository.requireUserWalletsSync() } else { userWalletsListManager.userWalletsSync diff --git a/domain/staking/detekt-baseline-debug.xml b/domain/staking/detekt-baseline-debug.xml index ced29d17bf..f52428665c 100644 --- a/domain/staking/detekt-baseline-debug.xml +++ b/domain/staking/detekt-baseline-debug.xml @@ -5,7 +5,6 @@ MultilineLambdaItParameter:FetchStakingYieldBalanceUseCase.kt$FetchStakingYieldBalanceUseCase${ when (it) { is StakingIdFactory.Error.UnableToGetAddress -> raise(StakingError.DomainError("$it")) StakingIdFactory.Error.UnsupportedCurrency -> Unit.right() } return@either } MultilineLambdaItParameter:InvalidatePendingTransactionsUseCase.kt$InvalidatePendingTransactionsUseCase${ !it.isPending && action.amount < it.amount && it.type == BalanceType.STAKED && it.validatorAddress == action.validatorAddress } NamedArguments:GetConstructedStakingTransactionUseCase.kt$GetConstructedStakingTransactionUseCase$constructTransaction(networkId, fee, amount, transactionId) - NullableToStringCall:StakingApyFlowUseCase.kt$StakingApyFlowUseCase$${yield.token.coinGeckoId} UnnecessaryAbstractClass:MultiStakingBalanceSupplier.kt$MultiStakingBalanceSupplier$MultiStakingBalanceSupplier UnnecessaryAbstractClass:SingleStakingBalanceSupplier.kt$SingleStakingBalanceSupplier$SingleStakingBalanceSupplier UseEmptyCounterpart:StakingAnalyticsEvent.kt$StakingAnalyticsEvent$mapOf() diff --git a/domain/tokens/detekt-baseline-debug.xml b/domain/tokens/detekt-baseline-debug.xml index 34d0f3eeb3..352d25c614 100644 --- a/domain/tokens/detekt-baseline-debug.xml +++ b/domain/tokens/detekt-baseline-debug.xml @@ -11,14 +11,12 @@ MultilineLambdaItParameter:FetchCurrencyStatusUseCase.kt$FetchCurrencyStatusUseCase${ when (it) { is StakingIdFactory.Error.UnableToGetAddress -> raise(IllegalStateException("$it")) StakingIdFactory.Error.UnsupportedCurrency -> Unit.right() } return@either } MultilineLambdaItParameter:GetBalanceNotEnoughForFeeWarningUseCase.kt$GetBalanceNotEnoughForFeeWarningUseCase${ it is CryptoCurrency.Token && it.contractAddress.equals(feePaidToken.contractAddress, ignoreCase = true) && it.network.derivationPath == tokenStatus.currency.network.derivationPath } MultilineLambdaItParameter:GetCryptoCurrencyActionsUseCase.kt$GetCryptoCurrencyActionsUseCase${ TokenActionsState( walletId = userWallet.walletId, cryptoCurrencyStatus = cryptoCurrencyStatus, states = it.toList(), ) } - MultilineLambdaItParameter:GetCryptoCurrencyActionsUseCase.kt$GetCryptoCurrencyActionsUseCase${ outdatedDataActionsFactory.create( userWallet = userWallet, cryptoCurrencyStatus = cryptoCurrencyStatus, stakingAvailability = it, ) } MultilineLambdaItParameter:GetCurrencyWarningsUseCase.kt$GetCurrencyWarningsUseCase${ if (isNeedToCreateAccountWithoutReserve(networkId = currencyStatus.currency.network.rawId)) { CryptoCurrencyWarning.TopUpWithoutReserve } else { CryptoCurrencyWarning.SomeNetworksNoAccount( amountToCreateAccount = it.amountToCreateAccount, amountCurrency = currencyStatus.currency, ) } } MultilineLambdaItParameter:GetCurrencyWarningsUseCase.kt$GetCurrencyWarningsUseCase${ it is CryptoCurrency.Token && it.contractAddress.equals(feePaidToken.contractAddress, ignoreCase = true) && it.network.derivationPath == tokenStatus.currency.network.derivationPath } MultilineLambdaItParameter:GetWalletTotalBalanceUseCase.kt$GetWalletTotalBalanceUseCase${ Timber.e("failed to load balances with error: $it") TotalFiatBalance.Failed } MultilineLambdaItParameter:PriceChangeCalculator.kt$PriceChangeCalculator${ val weight = it.value.fiatAmount.orZero().divide(balance, 2, RoundingMode.HALF_UP) val priceChange = it.value.priceChange.orZero() weight * priceChange } MultilineLambdaItParameter:WalletBalanceFetcher.kt$WalletBalanceFetcher${ val stakingId = stakingIdFactory.create(userWalletId = userWalletId, cryptoCurrency = it) if (stakingId.isLeft { it is StakingIdFactory.Error.UnableToGetAddress }) { Timber.e("Unable to get staking ID for user wallet $userWalletId and currency ${it.id}") } stakingId } NamedArguments:ApplyTokenListSortingUseCase.kt$ApplyTokenListSortingUseCase$saveTokens(userWalletId, currencies, isGrouped, isSortedByBalance) - NamedArguments:GetCurrencyWarningsUseCase.kt$GetCurrencyWarningsUseCase$combine( getCoinRelatedWarnings( userWalletId = userWalletId, networkId = currency.network.id, currencyId = currency.id, derivationPath = derivationPath, isSingleWalletWithTokens = isSingleWalletWithTokens, ), flowOf(currencyChecksRepository.getRentInfoWarning(userWalletId, currencyStatus)), flowOf(currencyChecksRepository.getExistentialDeposit(userWalletId, currency.network)), flowOf(currencyChecksRepository.getFeeResourceAmount(userWalletId, currency.network)), ) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource -> setOfNotNull( maybeRentWarning, maybeEdWarning?.let { getExistentialDepositWarning(currency, it) }, maybeFeeResource?.let { getFeeResourceWarning(it) }, * coinRelatedWarnings.toTypedArray(), getNetworkUnavailableWarning(currencyStatus), getNetworkNoAccountWarning(currencyStatus), getBeaconChainShutdownWarning(rawId = currency.network.id.rawId), getAssetRequirementsWarning(userWalletId = userWalletId, currency = currency), getMigrationFromMaticToPolWarning(currency), ) } NoNameShadowing:WalletBalanceFetcher.kt$WalletBalanceFetcher${ it is StakingIdFactory.Error.UnableToGetAddress } NullableBooleanCheck:GetCurrencyCheckUseCase.kt$GetCurrencyCheckUseCase$recipientAddress?.let { currencyChecksRepository.checkIfAccountFunded( userWalletId, network, recipientAddress, ) } ?: false SuspendFunWithFlowReturnType:BaseCurrencyStatusOperations.kt$BaseCurrencyStatusOperations$suspend diff --git a/domain/wallets/detekt-baseline-debug.xml b/domain/wallets/detekt-baseline-debug.xml index b55688a97f..cbda6c3779 100644 --- a/domain/wallets/detekt-baseline-debug.xml +++ b/domain/wallets/detekt-baseline-debug.xml @@ -28,7 +28,6 @@ MultilineLambdaItParameter:UpdateWalletUseCase.kt$UpdateWalletUseCase${ when (it) { is SaveWalletError.DataError -> DataError( IllegalStateException("Failed to update wallet: ${it.messageId}"), ) is SaveWalletError.WalletAlreadySaved -> UpdateWalletError.NameAlreadyExists } } NestedScopeFunctions:ColdUserWalletBuilder.kt$ColdUserWalletBuilder$let { UserWallet.Cold( walletId = it, name = generateWalletNameUseCase( card = card, productType = productType, isStartToCoin = cardTypesResolver.isStart2Coin(), ), cardsInWallet = backupCardsIds.plus(card.cardId), scanResponse = this, isMultiCurrency = cardTypesResolver.isMultiwalletAllowed(), hasBackupError = hasBackupError, ) } NoNameShadowing:SaveWalletUseCase.kt$SaveWalletUseCase$userWallet - NullableToStringCall:GenerateBuyTangemCardLinkUseCase.kt$GenerateBuyTangemCardLinkUseCase$$id NullableToStringCall:UpdateWalletUseCase.kt$UpdateWalletUseCase$${it.messageId} ObjectExtendsThrowable:UserWalletsListError.kt$UserWalletsListError$AllKeysInvalidated : UserWalletsListError ObjectExtendsThrowable:UserWalletsListError.kt$UserWalletsListError$BiometricsAuthenticationDisabled : UserWalletsListError diff --git a/features/hot-wallet/impl/detekt-baseline-debug.xml b/features/hot-wallet/impl/detekt-baseline-debug.xml index 2e3bf90a57..0695c0d515 100644 --- a/features/hot-wallet/impl/detekt-baseline-debug.xml +++ b/features/hot-wallet/impl/detekt-baseline-debug.xml @@ -20,7 +20,6 @@ BooleanPropertyNaming:WalletHardwareBackupUM.kt$WalletHardwareBackupUM$val showPurchaseBlock: Boolean = false MultilineLambdaItParameter:AddExistingWalletImportModel.kt$AddExistingWalletImportModel${ Timber.e(it) setImportProgress(false) } MultilineLambdaItParameter:AddExistingWalletImportModel.kt$AddExistingWalletImportModel${ setImportProgress(false) when (it) { is SaveWalletError.DataError -> Timber.e(it.toString(), "Unable to save user wallet") is SaveWalletError.WalletAlreadySaved -> { uiMessageSender.send( SnackbarMessage(resourceReference(R.string.hw_import_seed_phrase_already_imported)), ) } } } - MultilineLambdaItParameter:CreateHardwareWalletModel.kt$CreateHardwareWalletModel${ delay(HIDE_PROGRESS_DELAY) setLoading(false) when (it) { is SaveWalletError.DataError -> Timber.e(it.toString(), "Unable to save user wallet") is SaveWalletError.WalletAlreadySaved -> { userWalletsListRepository.unlock( userWalletId = userWallet.walletId, unlockMethod = UserWalletsListRepository.UnlockMethod.Scan(scanResponse), ).onRight { router.replaceAll(AppRoute.Wallet) } } } } MultilineLambdaItParameter:ForgetWalletModel.kt$ForgetWalletModel${ Timber.e("Unable to delete wallet: $it") uiMessageSender.send( message = SnackbarMessage(resourceReference(R.string.common_unknown_error)), ) return@launch } MultilineLambdaItParameter:ForgetWalletModel.kt$ForgetWalletModel${ val newValue = !it.firstCheckboxChecked it.copy( firstCheckboxChecked = newValue, isForgetButtonEnabled = newValue && it.secondCheckboxChecked, ) } MultilineLambdaItParameter:ForgetWalletModel.kt$ForgetWalletModel${ val newValue = !it.secondCheckboxChecked it.copy( secondCheckboxChecked = newValue, isForgetButtonEnabled = it.firstCheckboxChecked && newValue, ) } diff --git a/features/markets/impl/detekt-baseline-debug.xml b/features/markets/impl/detekt-baseline-debug.xml deleted file mode 100644 index d9fe99460d..0000000000 --- a/features/markets/impl/detekt-baseline-debug.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - - BooleanPropertyNaming:AddToPortfolioBSContentUM.kt$AddToPortfolioBSContentUM$val continueButtonEnabled: Boolean - BooleanPropertyNaming:AvailableToAddData.kt$AvailableToAddData$val availableToAdd: Boolean get() = availableToAddWallets.isNotEmpty() - BooleanPropertyNaming:AvailableToAddData.kt$SelectedNetwork$val availableMoreNetwork: Boolean - BooleanPropertyNaming:AvailableToAddData.kt$SelectedPortfolio$val availableMorePortfolio: Boolean - BooleanPropertyNaming:DefaultAddToPortfolioComponent.kt$DefaultAddToPortfolioComponent$val scrollableContent = when (stack.active.configuration) { AddToPortfolioRoutes.PortfolioSelector -> false AddToPortfolioRoutes.AddToken, AddToPortfolioRoutes.Empty, is AddToPortfolioRoutes.NetworkSelector, AddToPortfolioRoutes.TokenActions, -> true } - BooleanPropertyNaming:MarketsList.kt$val mainScrolled by remember { derivedStateOf { mainLazyListState.firstVisibleItemScrollOffset > 0 } } - BooleanPropertyNaming:MarketsList.kt$val searchScrolledState by remember { derivedStateOf { searchLazyListState.firstVisibleItemScrollOffset > 0 } } - BooleanPropertyNaming:MarketsListAnalyticsEvent.kt$MarketsListAnalyticsEvent.TokenSearched$val tokenFound: Boolean - BooleanPropertyNaming:MarketsListUM.kt$ListUM.Content$val showUnder100kTokensNotification: Boolean - BooleanPropertyNaming:MarketsListUM.kt$ListUM.Content$val showUnder100kTokensNotificationWasHidden: Boolean - BooleanPropertyNaming:MarketsListUMStateManager.kt$MarketsListUMStateManager$private var sortByBottomSheetIsShown get() = state.value.sortByBottomSheet.isShown set(value) = state.update { it.copy(sortByBottomSheet = it.sortByBottomSheet.copy(isShown = value)) } - BooleanPropertyNaming:MarketsTokenDetailsContent.kt$val showPriceSubtitle by remember { derivedStateOf { lazyListState.firstVisibleItemIndex > 1 } } - BooleanPropertyNaming:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel$val allWalletsIsHot = getUserWalletsUseCase.invokeSync().all { it is UserWallet.Hot } - BooleanPropertyNaming:MarketsTokenDetailsUM.kt$MarketsTokenDetailsUM$val markerSet: Boolean - BooleanPropertyNaming:MetricsBlock.kt$var expanded by remember { mutableStateOf(false) } - BooleanPropertyNaming:PortfolioBSVisibilityModel.kt$PortfolioBSVisibilityModel$val addToPortfolioBSVisibility: Boolean = false - BooleanPropertyNaming:PortfolioBSVisibilityModel.kt$PortfolioBSVisibilityModel$val walletSelectorBSVisibility: Boolean = false - BooleanPropertyNaming:PortfolioItem.kt$var quickActionsShown by remember { mutableStateOf(value = false) } - BooleanPropertyNaming:PortfolioUIData.kt$PortfolioUIData$val needColdWalletInteraction: Boolean - BooleanPropertyNaming:QuickActionUM.kt$QuickActionUM$val longClickAvailable: Boolean = false - BooleanPropertyNaming:QuickActionUM.kt$QuickActionUM.Exchange$val showBadge: Boolean - BooleanPropertyNaming:TokenActionsHandler.kt$TokenActionsHandler$val demoCard = isDemoCardUseCase.invoke(userWallet.cardId) - BooleanPropertyNaming:TokenActionsHandler.kt$TokenActionsHandler$val needShowDemoWarning = demoCard && disabledActionsInDemoMode.contains(action) - CanBeNonNullable:TokenMarketDetailsBody.kt$portfolioBlock: @Composable ((Modifier) -> Unit)? - CastNullableToNonNullableType:PortfolioItem.kt$PortfolioTokenUMProvider$as - CastNullableToNonNullableType:PortfolioItem.kt$PortfolioTokenUMProvider.Companion$as - MaxChainedCallsOnSameLine:AddToPortfolioModel.kt$AddToPortfolioModel$selectedPortfolio.first().account.account.account.accountId - MaxChainedCallsOnSameLine:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager$batchFlow.state.value.data.map { it.data }.flatten().find { it.id == id } - MaxChainedCallsOnSameLine:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager$batchFlow.state.value.data.map { it.key }.toSet() - MaxChainedCallsOnSameLine:MarketsListModel.kt$MarketsListModel$marketsListUMStateManager.state.map { it.selectedSortBy }.distinctUntilChanged().drop(1).collectLatest { mainMarketsListManager.reload() } - MaxChainedCallsOnSameLine:MarketsPortfolioModel.kt$MarketsPortfolioModel$handledAction.cryptoCurrencyData.status.currency.network.name - MaxChainedCallsOnSameLine:TokenActionsModel.kt$TokenActionsModel$handledAction.cryptoCurrencyData.status.currency.network.name - MultilineLambdaItParameter:AddToPortfolioBSContentUMFactory.kt$AddToPortfolioBSContentUMFactory${ if (it != selectedWalletId) { onAnotherWalletSelect(it) onWalletSelectorVisibilityChange(false) } } - MultilineLambdaItParameter:AddToPortfolioBottomSheet.kt${ Content( modifier = Modifier.fillMaxWidth(), state = it, ) WalletSelectorBottomSheet(it.walletSelectorConfig) } - MultilineLambdaItParameter:AddToPortfolioManager.kt$AddToPortfolioManager${ it.toMutableMap().apply { this[userWalletId] = if (isAddAction) { this[userWalletId].orEmpty() + network } else { this[userWalletId].orEmpty() - network } } } - MultilineLambdaItParameter:AddToPortfolioModel.kt$AddToPortfolioModel${ Timber.e(it) params.callback.onDismiss() } - MultilineLambdaItParameter:AddToPortfolioModel.kt$AddToPortfolioModel${ tokenActionsData.emit(it) navigation.replaceAll(AddToPortfolioRoutes.TokenActions) } - MultilineLambdaItParameter:AddTokenModel.kt$AddTokenModel${ processError(error = it) uiState.value = um.toggleProgress(false) return@launch } - MultilineLambdaItParameter:AvailableToAddDataConverter.kt$AvailableToAddDataConverter${ val (walletId, _) = it val availableToAddWallet = getAvailableToAddWallet(it) walletId to availableToAddWallet } - MultilineLambdaItParameter:ChooseNetworkModel.kt$ChooseNetworkModel${ Timber.e( it, """ Failed to check currency unsupported state |- User wallet ID: $userWalletId |- Network ID: $rawNetworkId |- Is main network: $isMainNetwork """.trimIndent(), ) val message = SnackbarMessage( message = it.localizedMessage?.let(::stringReference) ?: resourceReference(R.string.common_error), ) messageSender.send(message) null } - MultilineLambdaItParameter:DefaultMarketsTokenDetailsComponent.kt$DefaultMarketsTokenDetailsComponent${ when (it) { is TokenNetworksState.NetworksAvailable -> portfolioComponent?.setTokenNetworks(it.networks) TokenNetworksState.NoNetworksAvailable -> portfolioComponent?.setNoNetworksAvailable() else -> {} } } - MultilineLambdaItParameter:DefaultMarketsTokenListComponent.kt$DefaultMarketsTokenListComponent${ MarketsListWithBack( modifier = Modifier .statusBarsPadding() .imePadding() .padding(it), state = state, bottomSheetState = BottomSheetState.EXPANDED, onBackClick = router::pop, ) } - MultilineLambdaItParameter:EntryBottomSheetContent.kt${ when (it.configuration) { is MarketsEntryChildFactory.Child.TokenDetails -> { (it.instance as MarketsTokenDetailsComponent).BottomSheetContent( bottomSheetState = bottomSheetState, onHeaderSizeChange = onHeaderSizeChange, modifier = modifier, ) } is MarketsEntryChildFactory.Child.TokenList -> { (it.instance as MarketsTokenListComponent).BottomSheetContent( bottomSheetState = bottomSheetState, onHeaderSizeChange = onHeaderSizeChange, modifier = modifier, ) } } } - MultilineLambdaItParameter:InsightsBlock.kt${ InfoPoint( modifier = Modifier.align(Alignment.CenterStart), infoPointUM = it, ) } - MultilineLambdaItParameter:InsightsBlock.kt${ currentInterval = it state.onIntervalChanged(it) } - MultilineLambdaItParameter:LinksBlock.kt${ Chip( text = stringReference(it.title), iconResId = it.iconRes, onClick = { onLinkClick(it) }, ) } - MultilineLambdaItParameter:MarketTokenDetailsChart.kt${ when (it) { MarketChartLook.Type.Growing -> growingColor MarketChartLook.Type.Falling -> fallingColor MarketChartLook.Type.Neutral -> neutralColor } } - MultilineLambdaItParameter:MarketsList.kt${ if (it.size.height > 0) { with(density) { onHeaderSizeChange(it.size.height.toDp()) } } } - MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ Batch( key = it.key, data = converter.convertList(it.data), ) } - MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ currentSearchText().isNullOrEmpty().not() && it.status is PaginationStatus.EndOfPagination && it.data.isEmpty() } - MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ val first = it.data.firstOrNull() ?: return@filter false val chartByInterval = when (interval) { TrendInterval.H24 -> first.tokenCharts.h24 TrendInterval.D7 -> first.tokenCharts.week TrendInterval.M1 -> first.tokenCharts.month } chartByInterval != null } - MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ when (val status = it.status) { is PaginationStatus.Paginating -> { if (status.lastResult is BatchFetchResult.Success) { it.data.lastOrNull()?.key } else { null } } is PaginationStatus.EndOfPagination -> { it.data.lastOrNull()?.key } else -> null } } - MultilineLambdaItParameter:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager${ when (val status = it.status) { is PaginationStatus.Paginating -> { if (status.lastResult is BatchFetchResult.Success) { it.data.size == 1 } else { null } } is PaginationStatus.EndOfPagination -> { it.data.size == 1 } else -> null } } - MultilineLambdaItParameter:MarketsListItem.kt${ if (Random.nextBoolean()) { it.first.inc() to PriceChangeType.UP } else { it.first.dec() to PriceChangeType.DOWN } } - MultilineLambdaItParameter:MarketsListLazyColumn.kt${ (it.key as? String)?.split(TOKEN_LAZY_LIST_ID_SEPARATOR)?.first() ?.let { rawId -> CryptoCurrency.RawID(rawId) } } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it) { analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(tokenFound = false)) } } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it.isNotEmpty()) { activeListManager.getBatchKeysByItemIds(visibleItemIds.value) } else { null } } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ if (it.list !is ListUM.Content) { visibleItemIds.value = emptyList() } } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ mainMarketsListManager.loadCharts(setOf(it), marketsListUMStateManager.selectedInterval) modelScope.loadQuotesWithTimer(timeMillis = UPDATE_QUOTES_TIMER_MILLIS) } - MultilineLambdaItParameter:MarketsListModel.kt$MarketsListModel${ searchMarketsListManager.loadCharts(setOf(it), marketsListUMStateManager.selectedInterval) modelScope.loadQuotesWithTimer(timeMillis = UPDATE_QUOTES_TIMER_MILLIS) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( list = if (it.list is ListUM.Content) { it.list.copy( triggerScrollReset = consumedEvent(), ) } else { it.list }, ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( price = it.price.copy( changeType = if (visibleItemIds.contains(it.id)) { it.price.changeType } else { null }, ), ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( searchBar = it.searchBar.copy( query = value, isActive = value.isNotEmpty(), ), ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( selectedInterval = value, list = if (it.list is ListUM.Content && it.selectedSortBy != SortByTypeUM.Rating && it.selectedInterval != value ) { it.list.copy(triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }) } else { it.list }, ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( selectedSortBy = sortByTypeUM, sortByBottomSheet = it.sortByBottomSheet.copy( isShown = false, content = (it.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( selectedOption = sortByTypeUM, ), ), ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ it.copy( selectedSortBy = value, sortByBottomSheet = it.sortByBottomSheet.copy( content = (it.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( selectedOption = value, ), ), list = if (it.list is ListUM.Content && it.selectedSortBy != value) { it.list.copy(triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }) } else { it.list }, ) } - MultilineLambdaItParameter:MarketsListUMStateManager.kt$MarketsListUMStateManager${ when { isInErrorState -> { it.copy( list = ListUM.LoadingError(onRetryClicked = onRetryButtonClicked), ) } isSearchNotFound -> { it.copy(list = ListUM.SearchNothingFound) } uiItems.isEmpty() -> { it.copy(list = ListUM.Loading) } else -> { it.updateItems( newItems = uiItems, stakingNotificationMaxApy = stakingNotificationMaxApy, ) } } } - MultilineLambdaItParameter:MarketsPortfolioModel.kt$MarketsPortfolioModel${ Timber.e( it, """ Failed to check currency unsupported state |- User wallet ID: $userWalletId |- Network ID: $rawNetworkId |- Is main network: $isMainNetwork """.trimIndent(), ) val message = SnackbarMessage( message = it.localizedMessage ?.let(::stringReference) ?: resourceReference(R.string.common_error), ) messageSender.send(message) null } - MultilineLambdaItParameter:MarketsPortfolioModel.kt$MarketsPortfolioModel${ onWalletSelect(it) // === Analytics === analyticsEventHandler.send( analyticsEventBuilder.addToPortfolioWalletChanged(), ) } - MultilineLambdaItParameter:MarketsPortfolioModel.kt$MarketsPortfolioModel${ when (it) { is NewAddToPortfolioManager.State.AvailableToAdd -> AddButtonState.Available NewAddToPortfolioManager.State.Init -> AddButtonState.Loading NewAddToPortfolioManager.State.NothingToAdd -> AddButtonState.Unavailable } } - MultilineLambdaItParameter:MarketsTokenDetailsContent.kt${ if (it.size.height > 0) { with(density) { onHeaderSizeChange(it.size.height.toDp()) } } } - MultilineLambdaItParameter:MarketsTokenDetailsContent.kt${ val nextColor = when (it) { PriceChangeType.UP, -> growColor PriceChangeType.DOWN -> fallColor PriceChangeType.NEUTRAL -> return@EventEffect } color.animateTo(nextColor, snap()) color.animateTo(generalColor, tween(durationMillis = 500)) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ BlockchainUtils.isSupportedNetworkId( blockchainId = it.networkId, excludedBlockchains = excludedBlockchains, hotExcludedBlockchains = hotWalletExcludedBlockchains, hasOnlyHotWallets = allWalletsIsHot, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ ExchangesBottomSheetContent.Content( exchangeItems = ExchangeItemStateConverter.convertList(it).toImmutableList(), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ MarketsDateTimeFormatters.formatDateByIntervalWithMarker( interval = currentState.selectedInterval, markerTimestamp = it, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ analyticsEventHandler.send( analyticsEventBuilder.intervalChanged( intervalType = MarketDetailsAnalyticsEvent.IntervalType.Insights, interval = it, ), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ analyticsEventHandler.send( analyticsEventBuilder.intervalChanged( intervalType = MarketDetailsAnalyticsEvent.IntervalType.PricePerformance, interval = it, ), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ getChangePercentBetween( previousPrice = it, currentPrice = currentQuotes.value.currentPrice, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ if (it.chartState.status == MarketsTokenDetailsUM.ChartState.Status.DATA) { it.copy( body = MarketsTokenDetailsUM.Body.Error( onLoadRetryClick = ::onLoadRetryClicked, ), ) } else { it.copy( body = MarketsTokenDetailsUM.Body.Nothing, ) } } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( body = MarketsTokenDetailsUM.Body.Loading, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( chartState = it.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.DATA, ), body = if (it.body is MarketsTokenDetailsUM.Body.Nothing) { MarketsTokenDetailsUM.Body.Error(onLoadRetryClick = ::onLoadRetryClicked) } else { it.body }, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( chartState = it.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.ERROR, ), body = if (it.body is MarketsTokenDetailsUM.Body.Error) { MarketsTokenDetailsUM.Body.Nothing } else { it.body }, ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( chartState = it.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.LOADING, ), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( priceChangePercentText = priceChangePercent, selectedInterval = interval, priceChangeType = quotes.getPercentByInterval(interval)?.percentChangeType() ?: PriceChangeType.NEUTRAL, dateTimeText = getDefaultDateTimeString(interval), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( priceText = newInfo.quotes.currentPrice.format { fiat( fiatCurrencySymbol = currentAppCurrency.value.symbol, fiatCurrencyCode = currentAppCurrency.value.code, ).price() }, priceChangePercentText = newInfo.quotes.getFormattedPercentByInterval( interval = it.selectedInterval, ), priceChangeType = percent.percentChangeType(), body = MarketsTokenDetailsUM.Body.Content( description = descriptionConverter.convert(newInfo), infoBlocks = infoConverter.convert(newInfo), ), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( selectedInterval = interval, chartState = it.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.LOADING, ), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( type = percent.percentChangeType().toChartType(), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( xAxisFormatter = xAxisFormatter, type = state.value.priceChangeType.toChartType(), ) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.urlData?.fullUrl?.let { url -> urlOpener.openUrl(url) } // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.securityScoreProviderClicked(it.name)) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ showBottomSheet(it) // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.readMoreClicked()) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ showBottomSheet(it) // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.securityScoreOpened()) } - MultilineLambdaItParameter:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ val percentChangeType = params.token.tokenQuotes.h24Percent.percentChangeType() it.copy( type = percentChangeType.toChartType(), xAxisFormatter = MarketsDateTimeFormatters.getChartXFormatterByInterval(PriceChangeInterval.H24), yAxisFormatter = { value -> value.format { fiat( fiatCurrencyCode = currentAppCurrency.value.code, fiatCurrencySymbol = currentAppCurrency.value.symbol, ).price() } }, ) } - MultilineLambdaItParameter:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate${ PortfoliosWithThisCurrency( currencyRawId = currencyRawId, portfolios = it.toList(), ) } - MultilineLambdaItParameter:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate${ when (it) { AddButtonState.Loading -> MyPortfolioUM.Loading AddButtonState.Available -> MyPortfolioUM.AddFirstToken( onAddClick = onAddClick, addToPortfolioBSConfig = TangemBottomSheetConfig.Empty, ) AddButtonState.Unavailable -> MyPortfolioUM.Unavailable } } - MultilineLambdaItParameter:PortfolioDataLoader.kt$PortfolioDataLoader${ PortfolioData.CryptoCurrencyData( userWallet = wallet, status = it, actions = emptyList(), ) } - MultilineLambdaItParameter:PortfolioDataLoader.kt$PortfolioDataLoader${ PortfolioData.CryptoCurrencyData( userWallet = wallet, status = status, actions = it.states, ) } - MultilineLambdaItParameter:PortfolioItem.kt${ val onClick = state.tokenItemState.onItemClick if (onClick != null) { hapticManager.perform(TangemHapticEffect.View.ContextClick) onClick.invoke(it) } } - MultilineLambdaItParameter:PortfolioTokenUMConverter.kt$PortfolioTokenUMConverter.Companion${ if (it == QuickActionUM.Receive) { tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.CopyAddress, cryptoCurrencyData = cryptoData, ) } } - MultilineLambdaItParameter:PortfolioTokenUMConverter.kt$PortfolioTokenUMConverter.Companion${ when (it) { QuickActionUM.Buy -> tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.Buy, cryptoCurrencyData = cryptoData, ) is QuickActionUM.Exchange -> tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.Exchange, cryptoCurrencyData = cryptoData, ) QuickActionUM.Receive -> tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.Receive, cryptoCurrencyData = cryptoData, ) QuickActionUM.Stake -> tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.Stake, cryptoCurrencyData = cryptoData, ) } } - MultilineLambdaItParameter:PricePerformanceBlock.kt${ currentInterval = it state.onIntervalChanged(it) } - MultilineLambdaItParameter:SecurityScoreConverter.kt$SecurityScoreConverter${ SecurityScoreBottomSheetContent.SecurityScoreProviderUM( name = it.providerName, lastAuditDate = it.lastAuditDate?.let { date -> MarketsDateTimeFormatters.formatAsDate(date.millis) }, score = it.securityScore, urlData = it.urlData?.let { urlData -> SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = urlData.fullUrl, rootHost = urlData.rootHost, ) }, iconUrl = it.iconUrl, ) } - MultilineLambdaItParameter:TokenActionsContent.kt${ key(it.title) { ActionRow( state = it, onClick = { state.quickActions.onQuickActionClick(it) }, onLongClick = { state.quickActions.onQuickActionLongClick(it) }, ) } } - MultilineLambdaItParameter:TokenMarketBlockModel.kt$TokenMarketBlockModel${ it.onSome { res -> quotesState = QuotesState( currentPrice = res.fiatRate, h24Percent = res.priceChange, ) state.value = state.value.copy( currentPrice = res.fiatRate.format { fiat( // TODO get currency from quotes use case AND-8022 fiatCurrencyCode = currentAppCurrency.value.code, // TODO get currency from quotes use case AND-8022 fiatCurrencySymbol = currentAppCurrency.value.symbol, ).price() }, h24Percent = res.priceChange.format { percent() }, priceChangeType = PriceChangeType.fromBigDecimal(res.priceChange), ) } } - MultilineLambdaItParameter:TokenMarketInfoConverter.kt$TokenMarketInfoConverter${ pricePerformanceConverter.convert( value = it, currentPrice = value.quotes.currentPrice, ) } - MultilineLambdaItParameter:TokensPortfolioUMConverter.kt$TokensPortfolioUMConverter${ it.copy( isQuickActionsShown = if (it.matchWith(cryptoData)) { !it.isQuickActionsShown } else { false }, ) } - NamedArguments:AvailableToAddDataConverter.kt$AvailableToAddDataConverter$createCryptoCurrency(wallet, it, marketParams, this.account) - NamedArguments:MarketsListModel.kt$MarketsListModel$combine( mainMarketsListManager.uiItems, mainMarketsListManager.isInInitialLoadingErrorState, getStakingNotificationMaxApyUseCase(), getUserCountryUseCase.invoke(), ) { uiItems, isInInitialLoadingErrorState, stakingNotificationMaxApy, userCountry -> MarketsItemsData( items = uiItems, isInErrorState = isInInitialLoadingErrorState, isSearchNotFound = false, stakingNotificationMaxApy = stakingNotificationMaxApy, userCountry = userCountry, ) } - NamedArguments:MarketsListModel.kt$MarketsListModel$combine( searchMarketsListManager.uiItems, searchMarketsListManager.isInInitialLoadingErrorState, searchMarketsListManager.isSearchNotFoundState, getStakingNotificationMaxApyUseCase(), getUserCountryUseCase.invoke(), ) { uiItems, isInInitialLoadingErrorState, isSearchNotFoundState, stakingMaxApy, userCountry -> MarketsItemsData( items = uiItems, isInErrorState = isInInitialLoadingErrorState, isSearchNotFound = isSearchNotFoundState, stakingNotificationMaxApy = stakingMaxApy, userCountry = userCountry, ) } - NestedScopeFunctions:DescriptionConverter.kt$DescriptionConverter$let { fullDescription -> stringReference(fullDescription) } - NoNameShadowing:MarketsPortfolioModel.kt$MarketsPortfolioModel${ it.isMultiCurrency } - NoNameShadowing:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ if (it.chartState.status == MarketsTokenDetailsUM.ChartState.Status.DATA) { it.copy( body = MarketsTokenDetailsUM.Body.Error( onLoadRetryClick = ::onLoadRetryClicked, ), ) } else { it.copy( body = MarketsTokenDetailsUM.Body.Nothing, ) } } - NoNameShadowing:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel${ it.copy( chartState = it.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.ERROR, ), body = if (it.body is MarketsTokenDetailsUM.Body.Error) { MarketsTokenDetailsUM.Body.Nothing } else { it.body }, ) } - NoNameShadowing:MyPortfolioUMFactory.kt$MyPortfolioUMFactory${ networkIds.contains(it.status.currency.network.backendId) } - NoNameShadowing:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate$portfolio - NullableToStringCall:MarketsListItemUM.kt$MarketsListItemUM$marketCap.toString() - PropertyUsedBeforeDeclaration:MarketsListModel.kt$MarketsListModel$activeListManager - PropertyUsedBeforeDeclaration:MarketsListUMStateManager.kt$MarketsListUMStateManager$state - PropertyUsedBeforeDeclaration:MarketsPortfolioModel.kt$MarketsPortfolioModel$_state - PropertyUsedBeforeDeclaration:MarketsPortfolioModel.kt$MarketsPortfolioModel$currentAppCurrency - PropertyUsedBeforeDeclaration:PreviewMyPortfolioUMProvider.kt$PreviewMyPortfolioUMProvider$accountHeader - PropertyUsedBeforeDeclaration:PreviewMyPortfolioUMProvider.kt$PreviewMyPortfolioUMProvider$accountToken - PropertyUsedBeforeDeclaration:PreviewMyPortfolioUMProvider.kt$PreviewMyPortfolioUMProvider$sampleToken - PropertyUsedBeforeDeclaration:PreviewMyPortfolioUMProvider.kt$PreviewMyPortfolioUMProvider$walletHeader - PropertyUsedBeforeDeclaration:PreviewMyPortfolioUMProvider.kt$PreviewMyPortfolioUMProvider$walletPortfolioHeader - ReusedModifierInstance:EntryBottomSheetContent.kt$BottomSheetContent( bottomSheetState = bottomSheetState, onHeaderSizeChange = onHeaderSizeChange, modifier = modifier, ) - ReusedModifierInstance:PortfolioQuickActions.kt$Column(modifier = modifier) { actions.fastForEach { action -> LineSeparator() QuickActionItem( state = action, onClick = { onActionClick(action) }, onLongClick = { onActionLongClick(action) }.takeIf { action.longClickAvailable }, ) } } - ReusedModifierInstance:TokenActionsContent.kt$SecondaryButton( modifier = modifier.fillMaxWidth(), text = stringResourceSafe(R.string.common_later), onClick = state.onLaterClick, ) - SuspendFunWithFlowReturnType:AddToPortfolioModel.kt$AddToPortfolioModel$suspend - UnnecessaryEventHandlerParameter:SecurityScoreBottomSheet.kt$onLinkClick: (SecurityScoreBottomSheetContent.SecurityScoreProviderUM) -> Unit - UnnecessaryLet:PortfolioAnalyticsEvent.kt$PortfolioAnalyticsEvent.EventBuilder$let { put("Source", source) } - UnnecessaryLet:SecurityScoreBottomSheet.kt$let { Text( text = providerUM.lastAuditDate, style = TangemTheme.typography.caption2, color = TangemTheme.colors.text.tertiary, ) } - UnsafeCallOnNullableType:DefaultMarketsPortfolioComponent.kt$DefaultMarketsPortfolioComponent$model.newAddToPortfolioManager!! - UnsafeCallOnNullableType:MarketsListBatchFlowManager.kt$MarketsListBatchFlowManager$previousList!! - UnsafeCallOnNullableType:PricePerformanceConverter.kt$PricePerformanceConverter$high!! - UnsafeCallOnNullableType:PricePerformanceConverter.kt$PricePerformanceConverter$low!! - UseAnyOrNoneInsteadOfFind:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate$find { account -> account.addedCurrency.isNotEmpty() } - UseEmptyCounterpart:MarketDetailsAnalyticsEvent.kt$MarketDetailsAnalyticsEvent$mapOf() - UseEmptyCounterpart:MarketsListAnalyticsEvent.kt$MarketsListAnalyticsEvent$mapOf() - UseEmptyCounterpart:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate$setOf() - UseEmptyCounterpart:PortfolioAnalyticsEvent.kt$PortfolioAnalyticsEvent$mapOf() - UseOrEmpty:DescriptionConverter.kt$DescriptionConverter$value.fullDescription ?: "" - UseOrEmpty:Formatters.kt$percent?.format { percent() } ?: "" - UseOrEmpty:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel$percent?.format { percent() } ?: "" - UseOrEmpty:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate$allActions[currencyStatus.currency]?.states ?: emptyList() - UseOrEmpty:NewMarketsPortfolioDelegate.kt$NewMarketsPortfolioDelegate$portfolio.portfolios .find { it.accountsWithAdded.find { account -> account.addedCurrency.isNotEmpty() } != null } ?.userWallet ?.let { setOf(it.walletId to currency.currency.id) } ?: setOf() - VarCouldBeVal:MarketsListModel.kt$MarketsListModel$private var updateQuotesJob = JobHolder() - VarCouldBeVal:MarketsTokenDetailsModel.kt$MarketsTokenDetailsModel$private var quotesJob = JobHolder() - - diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/DefaultMarketsTokenDetailsComponent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/DefaultMarketsTokenDetailsComponent.kt index 54aa223690..e6f564100f 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/DefaultMarketsTokenDetailsComponent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/DefaultMarketsTokenDetailsComponent.kt @@ -62,9 +62,11 @@ internal class DefaultMarketsTokenDetailsComponent @AssistedInject constructor( init { componentScope.launch { - model.networksState.collectLatest { - when (it) { - is TokenNetworksState.NetworksAvailable -> portfolioComponent?.setTokenNetworks(it.networks) + model.networksState.collectLatest { networksState -> + when (networksState) { + is TokenNetworksState.NetworksAvailable -> portfolioComponent?.setTokenNetworks( + networksState.networks, + ) TokenNetworksState.NoNetworksAvailable -> portfolioComponent?.setNoNetworksAvailable() else -> {} } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt index 85d934fd13..c3674eb4cc 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt @@ -6,7 +6,7 @@ import com.tangem.domain.markets.TokenMarketParams internal class MarketDetailsAnalyticsEvent( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = "Markets / Chart", event = event, params = params) { data class EventBuilder( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt index 6107b6d7a2..f2a44120b9 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt @@ -78,7 +78,7 @@ internal class MarketsTokenDetailsModel @Inject constructor( private val getUserWalletsUseCase: GetWalletsUseCase, ) : Model() { - private var quotesJob = JobHolder() + private val quotesJob = JobHolder() private var userCountry: UserCountry? = null private val params = paramsContainer.require() private val analyticsEventBuilder = MarketDetailsAnalyticsEvent.EventBuilder(token = params.token) @@ -101,34 +101,34 @@ internal class MarketsTokenDetailsModel @Inject constructor( // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.linkClicked(linkTitle = link.title)) }, - onSecurityScoreInfoClick = { - showBottomSheet(it) + onSecurityScoreInfoClick = { content -> + showBottomSheet(content) // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.securityScoreOpened()) }, - onSecurityScoreProviderLinkClick = { - it.urlData?.fullUrl?.let { url -> + onSecurityScoreProviderLinkClick = { provider -> + provider.urlData?.fullUrl?.let { url -> urlOpener.openUrl(url) } // === Analytics === - analyticsEventHandler.send(analyticsEventBuilder.securityScoreProviderClicked(it.name)) + analyticsEventHandler.send(analyticsEventBuilder.securityScoreProviderClicked(provider.name)) }, // === Analytics === - onPricePerformanceIntervalChanged = { + onPricePerformanceIntervalChanged = { interval -> analyticsEventHandler.send( analyticsEventBuilder.intervalChanged( intervalType = MarketDetailsAnalyticsEvent.IntervalType.PricePerformance, - interval = it, + interval = interval, ), ) }, - onInsightsIntervalChanged = { + onInsightsIntervalChanged = { interval -> analyticsEventHandler.send( analyticsEventBuilder.intervalChanged( intervalType = MarketDetailsAnalyticsEvent.IntervalType.Insights, - interval = it, + interval = interval, ), ) }, @@ -139,8 +139,8 @@ internal class MarketsTokenDetailsModel @Inject constructor( ) private val descriptionConverter = DescriptionConverter( - onReadModeClicked = { - showBottomSheet(it) + onReadModeClicked = { content -> + showBottomSheet(content) // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.readMoreClicked()) }, @@ -162,10 +162,10 @@ internal class MarketsTokenDetailsModel @Inject constructor( private val chartDataProducer = MarketChartDataProducer.build(dispatcher = dispatchers.default) { chartData = MarketChartData.NoData.Loading - updateLook { + updateLook { currentLook -> val percentChangeType = params.token.tokenQuotes.h24Percent.percentChangeType() - it.copy( + currentLook.copy( type = percentChangeType.toChartType(), xAxisFormatter = MarketsDateTimeFormatters.getChartXFormatterByInterval(PriceChangeInterval.H24), yAxisFormatter = { value -> @@ -220,7 +220,7 @@ internal class MarketsTokenDetailsModel @Inject constructor( ), selectedInterval = PriceChangeInterval.H24, onSelectedIntervalChange = ::onSelectedIntervalChange, - markerSet = false, + isMarkerSet = false, body = MarketsTokenDetailsUM.Body.Loading, triggerPriceChange = consumedEvent(), bottomSheetConfig = TangemBottomSheetConfig( @@ -237,11 +237,11 @@ internal class MarketsTokenDetailsModel @Inject constructor( currentQuotes = currentQuotes, lastUpdatedTimestamp = lastUpdatedTimestamp, currentTokenInfo = currentTokenInfo, - onPricePerformanceIntervalChanged = { + onPricePerformanceIntervalChanged = { interval -> analyticsEventHandler.send( analyticsEventBuilder.intervalChanged( intervalType = MarketDetailsAnalyticsEvent.IntervalType.PricePerformance, - interval = it, + interval = interval, ), ) }, @@ -256,7 +256,7 @@ internal class MarketsTokenDetailsModel @Inject constructor( modelScope.launch { currentAppCurrency .filter { it != params.appCurrency } - .collectLatest { + .collectLatest { _ -> initialLoad() } } @@ -286,9 +286,9 @@ internal class MarketsTokenDetailsModel @Inject constructor( private fun loadChart(interval: PriceChangeInterval) { modelScope.launch { - state.update { - it.copy( - chartState = it.chartState.copy( + state.update { currentState -> + currentState.copy( + chartState = currentState.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.LOADING, ), ) @@ -306,10 +306,10 @@ internal class MarketsTokenDetailsModel @Inject constructor( preview = false, ) - state.update { - it.copy( + state.update { currentState -> + currentState.copy( selectedInterval = interval, - chartState = it.chartState.copy( + chartState = currentState.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.LOADING, ), ) @@ -318,15 +318,15 @@ internal class MarketsTokenDetailsModel @Inject constructor( chart .onRight { updateTokenChart(it) } .onLeft { - state.update { - it.copy( - chartState = it.chartState.copy( + state.update { currentState -> + currentState.copy( + chartState = currentState.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.ERROR, ), - body = if (it.body is MarketsTokenDetailsUM.Body.Error) { + body = if (currentState.body is MarketsTokenDetailsUM.Body.Error) { MarketsTokenDetailsUM.Body.Nothing } else { - it.body + currentState.body }, ) } @@ -343,31 +343,31 @@ internal class MarketsTokenDetailsModel @Inject constructor( x = tokenChart.timeStamps.map { it.toBigDecimal() }.toImmutableList(), ).sorted() - updateLook { - it.copy( + updateLook { currentLook -> + currentLook.copy( xAxisFormatter = xAxisFormatter, type = state.value.priceChangeType.toChartType(), ) } } - state.update { - it.copy( - chartState = it.chartState.copy( + state.update { currentState -> + currentState.copy( + chartState = currentState.chartState.copy( status = MarketsTokenDetailsUM.ChartState.Status.DATA, ), - body = if (it.body is MarketsTokenDetailsUM.Body.Nothing) { + body = if (currentState.body is MarketsTokenDetailsUM.Body.Nothing) { MarketsTokenDetailsUM.Body.Error(onLoadRetryClick = ::onLoadRetryClicked) } else { - it.body + currentState.body }, ) } } private fun loadInfo() { - state.update { - it.copy( + state.update { currentState -> + currentState.copy( body = MarketsTokenDetailsUM.Body.Loading, ) } @@ -382,15 +382,15 @@ internal class MarketsTokenDetailsModel @Inject constructor( tokenMarketInfo.fold( ifRight = { result -> updateInfo(result) }, ifLeft = { - state.update { - if (it.chartState.status == MarketsTokenDetailsUM.ChartState.Status.DATA) { - it.copy( + state.update { currentState -> + if (currentState.chartState.status == MarketsTokenDetailsUM.ChartState.Status.DATA) { + currentState.copy( body = MarketsTokenDetailsUM.Body.Error( onLoadRetryClick = ::onLoadRetryClicked, ), ) } else { - it.copy( + currentState.copy( body = MarketsTokenDetailsUM.Body.Nothing, ) } @@ -408,8 +408,8 @@ internal class MarketsTokenDetailsModel @Inject constructor( val percent = newInfo.quotes.getPercentByInterval(interval = state.value.selectedInterval) - state.update { - it.copy( + state.update { currentState -> + currentState.copy( priceText = newInfo.quotes.currentPrice.format { fiat( fiatCurrencySymbol = currentAppCurrency.value.symbol, @@ -417,7 +417,7 @@ internal class MarketsTokenDetailsModel @Inject constructor( ).price() }, priceChangePercentText = newInfo.quotes.getFormattedPercentByInterval( - interval = it.selectedInterval, + interval = currentState.selectedInterval, ), priceChangeType = percent.percentChangeType(), body = MarketsTokenDetailsUM.Body.Content( @@ -427,14 +427,14 @@ internal class MarketsTokenDetailsModel @Inject constructor( ) } - val allWalletsIsHot = getUserWalletsUseCase.invokeSync().all { it is UserWallet.Hot } + val areAllWalletsHot = getUserWalletsUseCase.invokeSync().all { it is UserWallet.Hot } - val networks = newInfo.networks?.filter { + val networks = newInfo.networks?.filter { network -> BlockchainUtils.isSupportedNetworkId( - blockchainId = it.networkId, + blockchainId = network.networkId, excludedBlockchains = excludedBlockchains, hotExcludedBlockchains = hotWalletExcludedBlockchains, - hasOnlyHotWallets = allWalletsIsHot, + hasOnlyHotWallets = areAllWalletsHot, ) } @@ -445,8 +445,8 @@ internal class MarketsTokenDetailsModel @Inject constructor( } chartDataProducer.runTransaction { - updateLook { - it.copy(type = percent.percentChangeType().toChartType()) + updateLook { currentLook -> + currentLook.copy(type = percent.percentChangeType().toChartType()) } } } @@ -481,8 +481,8 @@ internal class MarketsTokenDetailsModel @Inject constructor( val quotes = currentQuotes.value val priceChangePercent = quotes.getFormattedPercentByInterval(interval) - state.update { - it.copy( + state.update { currentState -> + currentState.copy( priceChangePercentText = priceChangePercent, selectedInterval = interval, priceChangeType = quotes.getPercentByInterval(interval)?.percentChangeType() @@ -502,10 +502,10 @@ internal class MarketsTokenDetailsModel @Inject constructor( private fun onMarkerPointSelected(markerTimestamp: BigDecimal?, price: BigDecimal?) { val currentState = state.value - val dateTimeText = markerTimestamp?.let { + val dateTimeText = markerTimestamp?.let { timestamp -> MarketsDateTimeFormatters.formatDateByIntervalWithMarker( interval = currentState.selectedInterval, - markerTimestamp = it, + markerTimestamp = timestamp, ) } ?: getDefaultDateTimeString(currentState.selectedInterval) @@ -516,18 +516,18 @@ internal class MarketsTokenDetailsModel @Inject constructor( ).price() } - val percent = price?.let { + val percent = price?.let { selectedPrice -> getChangePercentBetween( - previousPrice = it, + previousPrice = selectedPrice, currentPrice = currentQuotes.value.currentPrice, ) } ?: currentQuotes.value.getPercentByInterval(currentState.selectedInterval) - val percentText = percent?.format { percent() } ?: "" + val percentText = percent?.format { percent() }.orEmpty() state.update { stateToUpdate -> stateToUpdate.copy( - markerSet = markerTimestamp != null, + isMarkerSet = markerTimestamp != null, dateTimeText = dateTimeText, priceText = priceText, priceChangePercentText = percentText, @@ -536,8 +536,8 @@ internal class MarketsTokenDetailsModel @Inject constructor( } chartDataProducer.runTransaction { - updateLook { - it.copy( + updateLook { currentLook -> + currentLook.copy( type = percent.percentChangeType().toChartType(), ) } @@ -603,9 +603,9 @@ internal class MarketsTokenDetailsModel @Inject constructor( ifLeft = { ExchangesBottomSheetContent.Error(onRetryClick = { onListedOnClick(exchangesCount) }) }, - ifRight = { + ifRight = { exchanges -> ExchangesBottomSheetContent.Content( - exchangeItems = ExchangeItemStateConverter.convertList(it).toImmutableList(), + exchangeItems = ExchangeItemStateConverter.convertList(exchanges).toImmutableList(), ) }, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/DescriptionConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/DescriptionConverter.kt index f1e55176d1..ae495c8db0 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/DescriptionConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/DescriptionConverter.kt @@ -20,29 +20,26 @@ internal class DescriptionConverter( override fun convert(value: TokenMarketInfo): MarketsTokenDetailsUM.Description? { if (needApplyFCARestrictions()) return null - return value.shortDescription?.let { desc -> - MarketsTokenDetailsUM.Description( - shortDescription = stringReference(desc), - fullDescription = value.fullDescription?.let { fullDescription -> - stringReference(fullDescription) - }, - onReadMoreClick = { - onReadModeClicked( - InfoBottomSheetContent( - title = resourceReference( - R.string.markets_token_details_about_token_title, - wrappedList( - value.name, - ), - ), - body = stringReference(value.fullDescription ?: ""), - generatedAINotificationUM = InfoBottomSheetContent.GeneratedAINotificationUM( - onClick = onGeneratedAINotificationClick, + val shortDesc = value.shortDescription ?: return null + return MarketsTokenDetailsUM.Description( + shortDescription = stringReference(shortDesc), + fullDescription = value.fullDescription?.let(::stringReference), + onReadMoreClick = { + onReadModeClicked( + InfoBottomSheetContent( + title = resourceReference( + R.string.markets_token_details_about_token_title, + wrappedList( + value.name, ), ), - ) - }, - ) - } + body = stringReference(value.fullDescription.orEmpty()), + generatedAINotificationUM = InfoBottomSheetContent.GeneratedAINotificationUM( + onClick = onGeneratedAINotificationClick, + ), + ), + ) + }, + ) } } \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/PricePerformanceConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/PricePerformanceConverter.kt index 738710939a..c3aa321cb1 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/PricePerformanceConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/PricePerformanceConverter.kt @@ -56,11 +56,13 @@ internal class PricePerformanceConverter( } private fun TokenMarketInfo.Range.calculateFraction(currentPrice: BigDecimal): Float { + val lowValue = low + val highValue = high return when { - low == null || high == null || high == BigDecimal.ZERO || currentPrice < low -> 0f - currentPrice > high || low == high -> 1f + lowValue == null || highValue == null || highValue == BigDecimal.ZERO || currentPrice < lowValue -> 0f + currentPrice > highValue || lowValue == highValue -> 1f else -> { - (currentPrice - low!!).divide(high!! - low!!, RoundingMode.HALF_UP) + (currentPrice - lowValue).divide(highValue - lowValue, RoundingMode.HALF_UP) .setScale(2, RoundingMode.HALF_UP) .toFloat().coerceAtMost(1f) } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt index aee019594a..d3bec1f927 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt @@ -31,21 +31,20 @@ internal class SecurityScoreConverter( SecurityScoreBottomSheetContent( title = resourceReference(R.string.markets_token_details_security_score), description = resourceReference(R.string.markets_token_details_security_score_description), - providers = value.securityScoreProviderData.map { + providers = value.securityScoreProviderData.map { provider -> SecurityScoreBottomSheetContent.SecurityScoreProviderUM( - name = it.providerName, - lastAuditDate = it.lastAuditDate?.let { date -> + name = provider.providerName, + lastAuditDate = provider.lastAuditDate?.let { date -> MarketsDateTimeFormatters.formatAsDate(date.millis) }, - score = it.securityScore, - urlData = it.urlData?.let { - urlData -> + score = provider.securityScore, + urlData = provider.urlData?.let { urlData -> SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = urlData.fullUrl, rootHost = urlData.rootHost, ) }, - iconUrl = it.iconUrl, + iconUrl = provider.iconUrl, ) }, onProviderLinkClick = onSecurityScoreProviderLinkClick, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt index 8f67567773..e7aa05eeb5 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt @@ -64,9 +64,9 @@ internal class TokenMarketInfoConverter( insights = insights, securityScore = securityScore, metrics = value.metrics?.let { metricsConverter.convert(it) }, - pricePerformance = value.pricePerformance?.let { + pricePerformance = value.pricePerformance?.let { performance -> pricePerformanceConverter.convert( - value = it, + value = performance, currentPrice = value.quotes.currentPrice, ) }, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt index 78f0a49fb3..bc1aeb77e3 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt @@ -21,7 +21,7 @@ internal fun TokenQuotes.getFormattedPercentByInterval(interval: PriceChangeInte PriceChangeInterval.ALL_TIME -> allTimeChangePercent } - return percent?.format { percent() } ?: "" + return percent?.format { percent() }.orEmpty() } internal fun TokenQuotes.getPercentByInterval(interval: PriceChangeInterval): BigDecimal? { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/state/QuotesStateUpdater.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/state/QuotesStateUpdater.kt index 74d10c5742..116fb390b4 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/state/QuotesStateUpdater.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/state/QuotesStateUpdater.kt @@ -53,7 +53,7 @@ internal class QuotesStateUpdater( val priceChangeType = percent.percentChangeType() // wait until marker is removed - state.first { it.markerSet.not() } + state.first { it.isMarkerSet.not() } currentQuotes.value = newQuotes lastUpdatedTimestamp.value = DateTime.now().millis diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/MarketsTokenDetailsContent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/MarketsTokenDetailsContent.kt index cd2f2b68b1..a732ce35a6 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/MarketsTokenDetailsContent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/MarketsTokenDetailsContent.kt @@ -107,10 +107,10 @@ private fun Content( .fillMaxSize(), ) { TopBar( - modifier = Modifier.onGloballyPositioned { - if (it.size.height > 0) { + modifier = Modifier.onGloballyPositioned { coordinates -> + if (coordinates.size.height > 0) { with(density) { - onHeaderSizeChange(it.size.height.toDp()) + onHeaderSizeChange(coordinates.size.height.toDp()) } } }, @@ -174,7 +174,7 @@ private fun TopBar( onBackClick: () -> Unit, modifier: Modifier = Modifier, ) { - val showPriceSubtitle by remember { + val shouldShowPriceSubtitle by remember { derivedStateOf { lazyListState.firstVisibleItemIndex > 1 } @@ -183,7 +183,7 @@ private fun TopBar( TangemTopAppBar( modifier = modifier, title = tokenName, - subtitle = if (showPriceSubtitle) tokenPrice else null, + subtitle = if (shouldShowPriceSubtitle) tokenPrice else null, startButton = TopAppBarButtonUM.Back( onBackClicked = onBackClick, enabled = isBackButtonEnabled, @@ -240,8 +240,8 @@ private fun TokenPriceText( val color = remember(generalColor) { Animatable(generalColor) } - EventEffect(triggerPriceChange) { - val nextColor = when (it) { + EventEffect(triggerPriceChange) { changeType -> + val nextColor = when (changeType) { PriceChangeType.UP, -> growColor PriceChangeType.DOWN -> fallColor diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/InsightsBlock.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/InsightsBlock.kt index 8b5e829a64..d40e37b970 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/InsightsBlock.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/InsightsBlock.kt @@ -48,12 +48,12 @@ internal fun InsightsBlock(state: InsightsUM, modifier: Modifier = Modifier) { PriceChangeInterval.MONTH, ), initialSelectedItem = PriceChangeInterval.H24, - onClick = { - currentInterval = it - state.onIntervalChanged(it) + onClick = { interval -> + currentInterval = interval + state.onIntervalChanged(interval) }, modifier = Modifier.width(IntrinsicSize.Min), - ) { + ) { interval -> Box( Modifier .fillMaxSize() @@ -65,7 +65,7 @@ internal fun InsightsBlock(state: InsightsUM, modifier: Modifier = Modifier) { ) { Text( modifier = Modifier.align(Alignment.Center), - text = it.getText().resolveReference(), + text = interval.getText().resolveReference(), style = TangemTheme.typography.caption1, color = TangemTheme.colors.text.primary1, ) @@ -82,10 +82,10 @@ internal fun InsightsBlock(state: InsightsUM, modifier: Modifier = Modifier) { GridItems( items = infoPoints, - itemContent = { + itemContent = { infoPoint -> InfoPoint( modifier = Modifier.align(Alignment.CenterStart), - infoPointUM = it, + infoPointUM = infoPoint, ) }, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/LinksBlock.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/LinksBlock.kt index 5825ba908b..6d10ec8957 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/LinksBlock.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/LinksBlock.kt @@ -96,11 +96,11 @@ private fun SubBlock( horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing12), verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing12), ) { - links.fastForEach { + links.fastForEach { link -> Chip( - text = stringReference(it.title), - iconResId = it.iconRes, - onClick = { onLinkClick(it) }, + text = stringReference(link.title), + iconResId = link.iconRes, + onClick = { onLinkClick(link) }, ) } } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MarketTokenDetailsChart.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MarketTokenDetailsChart.kt index 076b704bb8..0ad6b22ee0 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MarketTokenDetailsChart.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MarketTokenDetailsChart.kt @@ -30,8 +30,8 @@ internal fun MarketTokenDetailsChart( val chartState = rememberMarketChartState( dataProducer = state.dataProducer, - colorMapper = { - when (it) { + colorMapper = { chartType -> + when (chartType) { MarketChartLook.Type.Growing -> growingColor MarketChartLook.Type.Falling -> fallingColor MarketChartLook.Type.Neutral -> neutralColor diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MetricsBlock.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MetricsBlock.kt index 9d33b61034..98e74fd06f 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MetricsBlock.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/MetricsBlock.kt @@ -29,7 +29,7 @@ const val MAX_METRICS_COUNT = 6 @Composable internal fun MetricsBlock(state: MetricsUM, modifier: Modifier = Modifier) { - var expanded by remember { mutableStateOf(false) } + var isExpanded by remember { mutableStateOf(false) } InformationBlock( modifier = modifier, @@ -44,11 +44,11 @@ internal fun MetricsBlock(state: MetricsUM, modifier: Modifier = Modifier) { }, action = { if (state.metrics.size > MAX_METRICS_COUNT) { - ShowLessMoreButton(expanded = expanded, onClick = { expanded = !expanded }) + ShowLessMoreButton(expanded = isExpanded, onClick = { isExpanded = !isExpanded }) } }, content = { - val metrics = if (expanded) { + val metrics = if (isExpanded) { state.metrics } else { state.metrics.take(MAX_METRICS_COUNT).toImmutableList() diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/PricePerformanceBlock.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/PricePerformanceBlock.kt index efede75d0e..17e8d19e3f 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/PricePerformanceBlock.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/PricePerformanceBlock.kt @@ -53,12 +53,12 @@ internal fun PricePerformanceBlock(state: PricePerformanceUM, modifier: Modifier PriceChangeInterval.ALL_TIME, ), initialSelectedItem = PriceChangeInterval.H24, - onClick = { - currentInterval = it - state.onIntervalChanged(it) + onClick = { interval -> + currentInterval = interval + state.onIntervalChanged(interval) }, modifier = Modifier.width(IntrinsicSize.Min), - ) { + ) { interval -> Box( Modifier .fillMaxSize() @@ -70,7 +70,7 @@ internal fun PricePerformanceBlock(state: PricePerformanceUM, modifier: Modifier ) { Text( modifier = Modifier.align(Alignment.Center), - text = it.getText().resolveReference(), + text = interval.getText().resolveReference(), style = TangemTheme.typography.caption1, color = TangemTheme.colors.text.primary1, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt index e6ef8e94b6..b8c4242c9a 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt @@ -70,7 +70,7 @@ internal fun SecurityScoreBottomSheet(config: TangemBottomSheetConfig) { ) { SecurityScoreProviderRow( providerUM = provider, - onLinkClick = content.onProviderLinkClick, + onLinkClick = { content.onProviderLinkClick(provider) }, ) } } @@ -85,7 +85,7 @@ internal fun SecurityScoreBottomSheet(config: TangemBottomSheetConfig) { @Composable private fun SecurityScoreProviderRow( providerUM: SecurityScoreBottomSheetContent.SecurityScoreProviderUM, - onLinkClick: (SecurityScoreBottomSheetContent.SecurityScoreProviderUM) -> Unit, + onLinkClick: () -> Unit, ) { Row( modifier = Modifier @@ -118,7 +118,7 @@ private fun SecurityScoreProviderRow( style = TangemTheme.typography.subtitle2, color = TangemTheme.colors.text.primary1, ) - providerUM.lastAuditDate?.let { + if (providerUM.lastAuditDate != null) { Text( text = providerUM.lastAuditDate, style = TangemTheme.typography.caption2, @@ -136,7 +136,7 @@ private fun SecurityScoreProviderRow( enabled = providerUM.urlData != null, indication = ripple(bounded = false), interactionSource = remember { MutableInteractionSource() }, - onClick = { onLinkClick(providerUM) }, + onClick = onLinkClick, ), ) { ScoreStarsBlock( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/MarketsTokenDetailsPreview.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/MarketsTokenDetailsPreview.kt index 46ad847bf6..83be0ff031 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/MarketsTokenDetailsPreview.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/MarketsTokenDetailsPreview.kt @@ -39,7 +39,7 @@ internal object MarketsTokenDetailsPreview { onDismissRequest = {}, content = TangemBottomSheetConfigContent.Empty, ), - markerSet = false, + isMarkerSet = false, triggerPriceChange = consumedEvent(), ) @@ -123,7 +123,7 @@ internal object MarketsTokenDetailsPreview { onDismissRequest = {}, content = TangemBottomSheetConfigContent.Empty, ), - markerSet = true, + isMarkerSet = true, triggerPriceChange = consumedEvent(), ) } \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/MarketsTokenDetailsUM.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/MarketsTokenDetailsUM.kt index a4b669739a..94f581efd7 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/MarketsTokenDetailsUM.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/MarketsTokenDetailsUM.kt @@ -17,7 +17,7 @@ internal data class MarketsTokenDetailsUM( val priceChangePercentText: String?, val priceChangeType: PriceChangeType, val selectedInterval: PriceChangeInterval, - val markerSet: Boolean, + val isMarkerSet: Boolean, val chartState: ChartState, val onSelectedIntervalChange: (PriceChangeInterval) -> Unit, val bottomSheetConfig: TangemBottomSheetConfig, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/entry/impl/ui/EntryBottomSheetContent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/entry/impl/ui/EntryBottomSheetContent.kt index a19e160096..7814672735 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/entry/impl/ui/EntryBottomSheetContent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/entry/impl/ui/EntryBottomSheetContent.kt @@ -37,20 +37,21 @@ internal fun EntryBottomSheetContent( Children( stack = stackState.value, animation = stackAnimation(slide()), - ) { - when (it.configuration) { + modifier = modifier, + ) { child -> + when (child.configuration) { is MarketsEntryChildFactory.Child.TokenDetails -> { - (it.instance as MarketsTokenDetailsComponent).BottomSheetContent( + (child.instance as MarketsTokenDetailsComponent).BottomSheetContent( bottomSheetState = bottomSheetState, onHeaderSizeChange = onHeaderSizeChange, - modifier = modifier, + modifier = Modifier, ) } is MarketsEntryChildFactory.Child.TokenList -> { - (it.instance as MarketsTokenListComponent).BottomSheetContent( + (child.instance as MarketsTokenListComponent).BottomSheetContent( bottomSheetState = bottomSheetState, onHeaderSizeChange = onHeaderSizeChange, - modifier = modifier, + modifier = Modifier, ) } } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/api/AvailableToAddData.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/api/AvailableToAddData.kt index 557fd53518..3ca633edf5 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/api/AvailableToAddData.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/api/AvailableToAddData.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable internal data class AvailableToAddData( val availableToAddWallets: Map, ) { - val availableToAdd: Boolean + val isAvailableToAdd: Boolean get() = availableToAddWallets.isNotEmpty() val isSinglePortfolio: Boolean get() = availableToAddWallets.size == 1 && availableToAddWallets.values.first().accounts.size == 1 @@ -48,11 +48,11 @@ internal data class SelectedPortfolio( val userWallet: UserWallet, val account: AvailableToAddAccount, val isAccountMode: Boolean, - val availableMorePortfolio: Boolean, + val hasMorePortfoliosAvailable: Boolean, ) internal data class SelectedNetwork( val selectedNetwork: TokenMarketInfo.Network, val cryptoCurrency: CryptoCurrency, - val availableMoreNetwork: Boolean, + val hasMoreNetworksAvailable: Boolean, ) \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/DefaultAddToPortfolioComponent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/DefaultAddToPortfolioComponent.kt index 69b9573e71..81c2f24a63 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/DefaultAddToPortfolioComponent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/DefaultAddToPortfolioComponent.kt @@ -131,7 +131,7 @@ internal class DefaultAddToPortfolioComponent @AssistedInject constructor( end = 16.dp, bottom = 16.dp, ) - val scrollableContent = when (stack.active.configuration) { + val isScrollableContent = when (stack.active.configuration) { AddToPortfolioRoutes.PortfolioSelector -> false AddToPortfolioRoutes.AddToken, AddToPortfolioRoutes.Empty, @@ -139,7 +139,7 @@ internal class DefaultAddToPortfolioComponent @AssistedInject constructor( AddToPortfolioRoutes.TokenActions, -> true } - if (scrollableContent) { + if (isScrollableContent) { Column( modifier = paddingModifier.verticalScroll(rememberScrollState()), ) { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/converter/AvailableToAddDataConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/converter/AvailableToAddDataConverter.kt index 4bbeec4cee..7004e37dfc 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/converter/AvailableToAddDataConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/converter/AvailableToAddDataConverter.kt @@ -30,7 +30,14 @@ internal class AvailableToAddDataConverter @Inject constructor( ): AvailableToAddData { suspend fun AccountStatus.getAvailableToAddAccount(wallet: UserWallet): AvailableToAddAccount? { val currencies = availableNetworks - .mapNotNull { createCryptoCurrency(wallet, it, marketParams, this.account) } + .mapNotNull { network -> + createCryptoCurrency( + userWallet = wallet, + network = network, + marketParams = marketParams, + account = this.account, + ) + } if (currencies.isEmpty()) return null @@ -74,9 +81,9 @@ internal class AvailableToAddDataConverter @Inject constructor( } val availableToAddWallets: Map = balances - .map { - val (walletId, _) = it - val availableToAddWallet = getAvailableToAddWallet(it) + .map { entry -> + val (walletId, _) = entry + val availableToAddWallet = getAvailableToAddWallet(entry) walletId to availableToAddWallet } .filter { (_, wallet) -> wallet.availableToAddAccounts.isNotEmpty() } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt index 40c339c730..2ae6b5b028 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt @@ -101,7 +101,7 @@ internal class AddToPortfolioModel @Inject constructor( val data = featureDataFlow.value // you must control it via [AddToPortfolioManager.state] - if (!data.availableToAdd) { + if (!data.isAvailableToAdd) { finishFlow() return@channelFlow } @@ -182,8 +182,8 @@ internal class AddToPortfolioModel @Inject constructor( messageSender.send(ToastMessage(message = resourceReference(R.string.markets_token_added))) setupTokenActionsFlow(selectedPortfolio, addedToken) - .onEach { - tokenActionsData.emit(it) + .onEach { cryptoCurrencyData -> + tokenActionsData.emit(cryptoCurrencyData) navigation.replaceAll(AddToPortfolioRoutes.TokenActions) } .onEmpty { finishFlow() } @@ -192,8 +192,8 @@ internal class AddToPortfolioModel @Inject constructor( callbackDelegate.onLaterClick.receiveAsFlow().first() finishFlow() } - .catch { - Timber.e(it) + .catch { error -> + Timber.e(error) params.callback.onDismiss() } .launchIn(modelScope) @@ -213,14 +213,15 @@ internal class AddToPortfolioModel @Inject constructor( } } - private suspend fun changePortfolioNavigationFlow(data: AvailableToAddData): Flow { - val selectedAccount = selectedPortfolio.first().account.account.account.accountId + private fun changePortfolioNavigationFlow(data: AvailableToAddData): Flow = flow { + val selectedPortfolioValue = selectedPortfolio.first() + val selectedAccount = selectedPortfolioValue.account.account.account.accountId portfolioSelectorController.selectAccount(selectedAccount) val changedPortfolio = setupPortfolioFlow(data) .drop(1) .onEach { portfolio -> navigation.pushNew(routeToNetworkSelector(portfolio)) } val changedNetwork = setupNetworkFlow(changedPortfolio) - return combine( + combine( flow = changedPortfolio, flow2 = changedNetwork, transform = { newPortfolio, newNetwork -> @@ -228,7 +229,7 @@ internal class AddToPortfolioModel @Inject constructor( selectedNetwork.tryEmit(newNetwork) navigation.popToFirst() }, - ) + ).collect { emit(it) } } private fun setupTokenActionsFlow( @@ -276,7 +277,7 @@ internal class AddToPortfolioModel @Inject constructor( isAccountMode = isAccountMode, userWallet = availableToAddWallets.userWallet, account = availableToAddAccount, - availableMorePortfolio = !data.isSinglePortfolio, + hasMorePortfoliosAvailable = !data.isSinglePortfolio, ) }, ) @@ -293,7 +294,7 @@ internal class AddToPortfolioModel @Inject constructor( account = selectedPortfolio.account, ) ?: return@transform null, selectedNetwork = selectedNetwork, - availableMoreNetwork = !selectedPortfolio.account.isSingleNetwork, + hasMoreNetworksAvailable = !selectedPortfolio.account.isSingleNetwork, ) }, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenModel.kt index b0f322b6f5..7c5ba2defd 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenModel.kt @@ -78,8 +78,8 @@ internal class AddTokenModel @Inject constructor( val account = selectedPortfolio.account.account.account val accountId = account.accountId manageCryptoCurrenciesUseCase(accountId = accountId, add = cryptoCurrency) - .onLeft { - processError(error = it) + .onLeft { error -> + processError(error = error) uiState.value = um.toggleProgress(false) return@launch } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt index adcb476815..1d95ddde68 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt @@ -29,7 +29,7 @@ internal class AddTokenUiBuilder @Inject constructor( return AddTokenUM.Network( icon = selectedNetwork.cryptoCurrency.network.iconResId, name = stringReference(selectedNetwork.cryptoCurrency.network.name), - editable = selectedNetwork.availableMoreNetwork, + editable = selectedNetwork.hasMoreNetworksAvailable, onClick = { params.callbacks.onChangeNetworkClick() }, ) } @@ -54,7 +54,7 @@ internal class AddTokenUiBuilder @Inject constructor( icon = accountIcon, name = portfolioName, isAccountMode = selectedPortfolio.isAccountMode, - isMultiChoice = selectedPortfolio.availableMorePortfolio, + isMultiChoice = selectedPortfolio.hasMorePortfoliosAvailable, onClick = { params.callbacks.onChangePortfolioClick() }, ) } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/ChooseNetworkModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/ChooseNetworkModel.kt index fa3e0c3ab8..1d1ecc80d0 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/ChooseNetworkModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/ChooseNetworkModel.kt @@ -82,9 +82,9 @@ internal class ChooseNetworkModel @Inject constructor( userWalletId = userWalletId, networkId = rawNetworkId, isMainNetwork = isMainNetwork, - ).getOrElse { + ).getOrElse { error -> Timber.e( - it, + error, """ Failed to check currency unsupported state |- User wallet ID: $userWalletId @@ -94,7 +94,7 @@ internal class ChooseNetworkModel @Inject constructor( ) val message = SnackbarMessage( - message = it.localizedMessage?.let(::stringReference) ?: resourceReference(R.string.common_error), + message = error.localizedMessage?.let(::stringReference) ?: resourceReference(R.string.common_error), ) messageSender.send(message) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/DefaultAddToPortfolioManager.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/DefaultAddToPortfolioManager.kt index 9c82131fe6..e396ef008e 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/DefaultAddToPortfolioManager.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/DefaultAddToPortfolioManager.kt @@ -45,7 +45,7 @@ internal class DefaultAddToPortfolioManager @AssistedInject constructor( availableNetworks = availableNetworks, marketParams = token, ) - if (data.availableToAdd) { + if (data.isAvailableToAdd) { State.AvailableToAdd(data) } else { State.NothingToAdd diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/TokenActionsContent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/TokenActionsContent.kt index 97e8645655..e0b24bf672 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/TokenActionsContent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/ui/TokenActionsContent.kt @@ -63,12 +63,12 @@ internal fun TokenActionsContent(state: TokenActionsUM, modifier: Modifier = Mod .clip(RoundedCornerShape(TangemTheme.dimens.radius14)) .background(TangemTheme.colors.background.action), ) { - state.quickActions.actions.fastForEach { - key(it.title) { + state.quickActions.actions.fastForEach { action -> + key(action.title) { ActionRow( - state = it, - onClick = { state.quickActions.onQuickActionClick(it) }, - onLongClick = { state.quickActions.onQuickActionLongClick(it) }, + state = action, + onClick = { state.quickActions.onQuickActionClick(action) }, + onLongClick = { state.quickActions.onQuickActionLongClick(action) }, ) } } @@ -77,7 +77,7 @@ internal fun TokenActionsContent(state: TokenActionsUM, modifier: Modifier = Mod SpacerH16() SecondaryButton( - modifier = modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth(), text = stringResourceSafe(R.string.common_later), onClick = state.onLaterClick, ) @@ -102,7 +102,7 @@ private fun ActionRow( modifier = modifier .fillMaxWidth() .combinedClickable( - onLongClick = onLongClickInternal.takeIf { state.longClickAvailable }, + onLongClick = onLongClickInternal.takeIf { state.isLongClickAvailable }, onClick = { hapticManager.perform(TangemHapticEffect.View.SegmentTick) onClick() @@ -123,7 +123,7 @@ private fun ActionRow( .size(36.dp) .drawWithContent { drawContent() - if (state is QuickActionUM.Exchange && state.showBadge) { + if (state is QuickActionUM.Exchange && state.shouldShowBadge) { drawBadge(containerColor = containerColor, offset = 4.dp) } }, @@ -191,7 +191,7 @@ private class TokenActionsContentPreviewProvider : PreviewParameterProvider addToPortfolioComponentFactory.create( context = childByContext(componentContext), params = AddToPortfolioComponent.Params( - addToPortfolioManager = model.newAddToPortfolioManager!!, + addToPortfolioManager = requireNotNull(model.newAddToPortfolioManager) { + "newAddToPortfolioManager must be initialized" + }, callback = model.addToPortfolioCallback, ), ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/analytics/PortfolioAnalyticsEvent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/analytics/PortfolioAnalyticsEvent.kt index a547351b4c..50b5428039 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/analytics/PortfolioAnalyticsEvent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/analytics/PortfolioAnalyticsEvent.kt @@ -6,7 +6,7 @@ import com.tangem.features.markets.portfolio.impl.ui.state.TokenActionsBSContent internal class PortfolioAnalyticsEvent( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = "Markets / Chart", event = event, params = params) { data class EventBuilder( @@ -52,7 +52,7 @@ internal class PortfolioAnalyticsEvent( }, params = buildMap { put("Token", token.symbol) - source?.let { put("Source", source) } + if (source != null) put("Source", source) put("blockchain", blockchainName) }, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt index d5522e7218..0dadd3bcf4 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt @@ -80,11 +80,11 @@ internal class PortfolioDataLoader @Inject constructor( YieldSupplyAvailability.Unavailable } getCryptoCurrencyActionsUseCase(wallet, status, yieldSupplyAvailability) - .map { + .map { actionStates -> PortfolioData.CryptoCurrencyData( userWallet = wallet, status = status, - actions = it.states, + actions = actionStates.states, ) } } @@ -93,18 +93,18 @@ internal class PortfolioDataLoader @Inject constructor( combine(actionsFlows) { actions -> walletsWithStatuses.mapValues { entry -> entry.value.mapNotNull { status -> - actions.firstOrNull { - it.userWallet == entry.key && it.status == status + actions.firstOrNull { data -> + data.userWallet == entry.key && data.status == status } } } }.onEmpty { emit( walletsWithStatuses.mapValues { (wallet, statuses) -> - statuses.map { + statuses.map { status -> PortfolioData.CryptoCurrencyData( userWallet = wallet, - status = it, + status = status, actions = emptyList(), ) } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioBSContentUMFactory.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioBSContentUMFactory.kt index 0b6b839c45..bf294a2895 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioBSContentUMFactory.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioBSContentUMFactory.kt @@ -58,7 +58,7 @@ internal class AddToPortfolioBSContentUMFactory( artworks: Map, ): TangemBottomSheetConfig { return (currentState ?: TangemBottomSheetConfig.Empty).copy( - isShown = portfolioUIData.portfolioBSVisibilityModel.addToPortfolioBSVisibility, + isShown = portfolioUIData.portfolioBSVisibilityModel.isAddToPortfolioBSVisible, onDismissRequest = { onAddToPortfolioVisibilityChange(false) }, content = if (selectedWallet != null && alreadyAddedNetworks != null) { AddToPortfolioBSContentUM( @@ -76,8 +76,8 @@ internal class AddToPortfolioBSContentUMFactory( alreadyAddedNetworks = alreadyAddedNetworks, onNetworkSwitchClick = onNetworkSwitchClick, ).convert(value = token), - isScanCardNotificationVisible = portfolioUIData.needColdWalletInteraction, - continueButtonEnabled = portfolioUIData.addToPortfolioData.isUserAddedNetworks( + isScanCardNotificationVisible = portfolioUIData.shouldRequireColdWalletInteraction, + isContinueButtonEnabled = portfolioUIData.addToPortfolioData.isUserAddedNetworks( userWalletId = selectedWallet.walletId, ), onContinueButtonClick = { @@ -90,7 +90,7 @@ internal class AddToPortfolioBSContentUMFactory( ) }, walletSelectorConfig = createWalletSelectorBSConfig( - isShow = portfolioUIData.portfolioBSVisibilityModel.walletSelectorBSVisibility, + isShow = portfolioUIData.portfolioBSVisibilityModel.isWalletSelectorBSVisible, portfolioData = portfolioData, selectedWalletId = selectedWallet.walletId, artworks = artworks, @@ -136,9 +136,9 @@ internal class AddToPortfolioBSContentUMFactory( val balance = portfolioData.walletsWithBalance[userWallet.walletId] UserWalletItemUMConverter( - onClick = { - if (it != selectedWalletId) { - onAnotherWalletSelect(it) + onClick = { walletId -> + if (walletId != selectedWalletId) { + onAnotherWalletSelect(walletId) onWalletSelectorVisibilityChange(false) } }, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioManager.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioManager.kt index c617f718cd..15718128de 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioManager.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/AddToPortfolioManager.kt @@ -124,8 +124,8 @@ internal class AddToPortfolioManager @Inject constructor( return } - update { - it.toMutableMap().apply { + update { currentMap -> + currentMap.toMutableMap().apply { this[userWalletId] = if (isAddAction) { this[userWalletId].orEmpty() + network } else { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MarketsPortfolioModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MarketsPortfolioModel.kt index a314e9a0e1..529f20adbc 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MarketsPortfolioModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MarketsPortfolioModel.kt @@ -77,8 +77,8 @@ internal class MarketsPortfolioModel @Inject constructor( private val newMarketsPortfolioDelegateFactory: NewMarketsPortfolioDelegate.Factory, ) : Model() { - val state: StateFlow get() = _state private val _state: MutableStateFlow = MutableStateFlow(value = MyPortfolioUM.Loading) + val state: StateFlow get() = _state private val params = paramsContainer.require() private val analyticsEventBuilder = PortfolioAnalyticsEvent.EventBuilder( @@ -99,6 +99,16 @@ internal class MarketsPortfolioModel @Inject constructor( override fun onDismiss() = bottomSheetNavigation.dismiss() } + private val currentAppCurrency = getSelectedAppCurrencyUseCase() + .map { maybeAppCurrency -> + maybeAppCurrency.getOrElse { AppCurrency.Default } + } + .stateIn( + scope = modelScope, + started = SharingStarted.Eagerly, + initialValue = AppCurrency.Default, + ) + private val tokenActionsHandler = tokenActionsIntentsFactory.create( currentAppCurrency = Provider { currentAppCurrency.value }, updateTokenReceiveBSConfig = { updateBlock -> @@ -109,10 +119,11 @@ internal class MarketsPortfolioModel @Inject constructor( } }, onHandleQuickAction = { handledAction -> + val currencyNetwork = handledAction.cryptoCurrencyData.status.currency.network analyticsEventHandler.send( analyticsEventBuilder.quickActionClick( actionUM = handledAction.action, - blockchainName = handledAction.cryptoCurrencyData.status.currency.network.name, + blockchainName = currencyNetwork.name, ), ) if (tokenReceiveFeatureToggle.isNewTokenReceiveEnabled) { @@ -121,16 +132,6 @@ internal class MarketsPortfolioModel @Inject constructor( }, ) - private val currentAppCurrency = getSelectedAppCurrencyUseCase() - .map { maybeAppCurrency -> - maybeAppCurrency.getOrElse { AppCurrency.Default } - } - .stateIn( - scope = modelScope, - started = SharingStarted.Eagerly, - initialValue = AppCurrency.Default, - ) - private val factory = MyPortfolioUMFactory( onAddClick = { onAddToPortfolioBSVisibilityChange(isShow = true) @@ -145,8 +146,8 @@ internal class MarketsPortfolioModel @Inject constructor( onAddToPortfolioVisibilityChange = ::onAddToPortfolioBSVisibilityChange, onWalletSelectorVisibilityChange = ::onWalletSelectorVisibilityChange, onNetworkSwitchClick = ::onNetworkSwitchClick, - onAnotherWalletSelect = { - onWalletSelect(it) + onAnotherWalletSelect = { walletId -> + onWalletSelect(walletId) // === Analytics === analyticsEventHandler.send( analyticsEventBuilder.addToPortfolioWalletChanged(), @@ -186,8 +187,8 @@ internal class MarketsPortfolioModel @Inject constructor( scope = modelScope, token = params.token, tokenActionsHandler = tokenActionsHandler, - buttonState = newAddToPortfolioManager.state.map { - when (it) { + buttonState = newAddToPortfolioManager.state.map { managerState -> + when (managerState) { is NewAddToPortfolioManager.State.AvailableToAdd -> AddButtonState.Available NewAddToPortfolioManager.State.Init -> AddButtonState.Loading NewAddToPortfolioManager.State.NothingToAdd -> AddButtonState.Unavailable @@ -230,8 +231,8 @@ internal class MarketsPortfolioModel @Inject constructor( Timber.e("Failed to load selected wallet: $e") error("Failed to load selected wallet") } - .onEach { - selectedMultiWalletIdFlow.value = it.takeIf { it.isMultiCurrency }?.walletId + .onEach { wallet -> + selectedMultiWalletIdFlow.value = wallet.takeIf { it.isMultiCurrency }?.walletId } .launchIn(modelScope) } @@ -277,7 +278,10 @@ internal class MarketsPortfolioModel @Inject constructor( portfolioBSVisibilityModel = portfolioBSVisibilityModel, selectedWalletId = selectedWalletId, addToPortfolioData = addToPortfolioData, - needColdWalletInteraction = needColdWalletInteraction(selectedWalletId, addToPortfolioData), + shouldRequireColdWalletInteraction = needColdWalletInteraction( + selectedWalletId, + addToPortfolioData, + ), ) }, ) @@ -333,9 +337,9 @@ internal class MarketsPortfolioModel @Inject constructor( userWalletId = userWalletId, networkId = rawNetworkId, isMainNetwork = isMainNetwork, - ).getOrElse { + ).getOrElse { error -> Timber.e( - it, + error, """ Failed to check currency unsupported state |- User wallet ID: $userWalletId @@ -345,7 +349,7 @@ internal class MarketsPortfolioModel @Inject constructor( ) val message = SnackbarMessage( - message = it.localizedMessage + message = error.localizedMessage ?.let(::stringReference) ?: resourceReference(R.string.common_error), ) @@ -401,13 +405,13 @@ internal class MarketsPortfolioModel @Inject constructor( private fun onAddToPortfolioBSVisibilityChange(isShow: Boolean) { portfolioBSVisibilityModelFlow.update { - it.copy(addToPortfolioBSVisibility = isShow, walletSelectorBSVisibility = false) + it.copy(isAddToPortfolioBSVisible = isShow, isWalletSelectorBSVisible = false) } } private fun onWalletSelectorVisibilityChange(isShow: Boolean) { portfolioBSVisibilityModelFlow.update { - it.copy(addToPortfolioBSVisibility = true, walletSelectorBSVisibility = isShow) + it.copy(isAddToPortfolioBSVisible = true, isWalletSelectorBSVisible = isShow) } } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MyPortfolioUMFactory.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MyPortfolioUMFactory.kt index 9fe46dc75b..d5c027adb8 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MyPortfolioUMFactory.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/MyPortfolioUMFactory.kt @@ -143,8 +143,8 @@ internal class MyPortfolioUMFactory( ): List { val networkIds = networks.map(TokenMarketInfo.Network::networkId) - return mapNotNull { - it.takeIf { networkIds.contains(it.status.currency.network.backendId) } + return mapNotNull { currencyData -> + currencyData.takeIf { networkIds.contains(it.status.currency.network.backendId) } } } } \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt index fd1f0fecea..9a6de7c950 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt @@ -98,8 +98,8 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( } } - private fun addFirstTokenFlow(): Flow = buttonState.map { - when (it) { + private fun addFirstTokenFlow(): Flow = buttonState.map { state -> + when (state) { AddButtonState.Loading -> MyPortfolioUM.Loading AddButtonState.Available -> MyPortfolioUM.AddFirstToken( onAddClick = onAddClick, @@ -120,7 +120,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( }.flatten() val allAddedTokenActions = - portfolio.portfolios.map { portfolio -> portfolio.actionsFoAccountCurrencies() }.flatten() + portfolio.portfolios.map { portfolioItem -> portfolioItem.actionsFoAccountCurrencies() }.flatten() return combine( flow = combine(allAddedTokenActions) { it.toMap() }.distinctUntilChanged(), @@ -153,12 +153,12 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( val currency = allAddedCurrency.first() // find userWallet than have this single added token portfolio.portfolios - .find { it.accountsWithAdded.find { account -> account.addedCurrency.isNotEmpty() } != null } + .find { it.accountsWithAdded.any { account -> account.addedCurrency.isNotEmpty() } } ?.userWallet ?.let { setOf(it.walletId to currency.currency.id) } - ?: setOf() + .orEmpty() } - else -> setOf() + else -> emptySet() } return MutableStateFlow(initValue) .also { this.expandedHolder = it } @@ -166,10 +166,10 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( private fun portfolioWithThisCurrencyFLow(): Flow = allAccountSupplier().map { list -> list.map { it.addedAccountsFlow() } }.flatMapLatest { flows -> - combine(flows) { + combine(flows) { portfolios -> PortfoliosWithThisCurrency( currencyRawId = currencyRawId, - portfolios = it.toList(), + portfolios = portfolios.toList(), ) } }.distinctUntilChanged() @@ -237,8 +237,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( } accountWithAdded.addedCurrency.forEach { currencyStatus -> - val actions = allActions[currencyStatus.currency]?.states - ?: emptyList() + val actions = allActions[currencyStatus.currency]?.states.orEmpty() val value = PortfolioData.CryptoCurrencyData( userWallet = userWallet, status = currencyStatus, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioBSVisibilityModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioBSVisibilityModel.kt index b2d43ea69a..acf1b7934c 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioBSVisibilityModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioBSVisibilityModel.kt @@ -3,12 +3,12 @@ package com.tangem.features.markets.portfolio.impl.model /** * Model for portfolio bottom sheet visibility * - * @property addToPortfolioBSVisibility visibility of add to portfolio bottom sheet - * @property walletSelectorBSVisibility visibility of wallet selector bottom sheet + * @property isAddToPortfolioBSVisible visibility of add to portfolio bottom sheet + * @property isWalletSelectorBSVisible visibility of wallet selector bottom sheet * [REDACTED_AUTHOR] */ internal data class PortfolioBSVisibilityModel( - val addToPortfolioBSVisibility: Boolean = false, - val walletSelectorBSVisibility: Boolean = false, + val isAddToPortfolioBSVisible: Boolean = false, + val isWalletSelectorBSVisible: Boolean = false, ) \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioTokenUMConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioTokenUMConverter.kt index b64ee6bf1f..17b0a6cdf5 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioTokenUMConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioTokenUMConverter.kt @@ -95,8 +95,8 @@ internal class PortfolioTokenUMConverter( ) } }, - onQuickActionLongClick = { - if (it == QuickActionUM.Receive) { + onQuickActionLongClick = { quickAction -> + if (quickAction == QuickActionUM.Receive) { tokenActionsHandler.handle( action = TokenActionsBSContentUM.Action.CopyAddress, cryptoCurrencyData = cryptoData, @@ -111,7 +111,9 @@ internal class PortfolioTokenUMConverter( if (action.unavailabilityReason == ScenarioUnavailabilityReason.None) { when (action) { is TokenActionsState.ActionState.Buy -> QuickActionUM.Buy - is TokenActionsState.ActionState.Swap -> QuickActionUM.Exchange(showBadge = action.showBadge) + is TokenActionsState.ActionState.Swap -> QuickActionUM.Exchange( + shouldShowBadge = action.showBadge, + ) is TokenActionsState.ActionState.Receive -> QuickActionUM.Receive is TokenActionsState.ActionState.Stake -> QuickActionUM.Stake is TokenActionsState.ActionState.YieldMode -> QuickActionUM.YieldMode(apy = action.apy) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioUIData.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioUIData.kt index f0dfad20dd..855e596731 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioUIData.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/PortfolioUIData.kt @@ -8,7 +8,7 @@ import com.tangem.domain.models.wallet.UserWalletId * @property portfolioBSVisibilityModel portfolio bottom sheet visibility model * @property selectedWalletId selected wallet id * @property addToPortfolioData add to portfolio data - * @property needColdWalletInteraction flag that indicates if user has missed derivations and has a cold wallet + * @property shouldRequireColdWalletInteraction flag that indicates if user has missed derivations and has a cold wallet * [REDACTED_AUTHOR] */ @@ -16,5 +16,5 @@ internal data class PortfolioUIData( val portfolioBSVisibilityModel: PortfolioBSVisibilityModel, val selectedWalletId: UserWalletId?, val addToPortfolioData: AddToPortfolioManager.AddToPortfolioData, - val needColdWalletInteraction: Boolean, + val shouldRequireColdWalletInteraction: Boolean, ) \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt index e62d311737..7e6523b992 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt @@ -73,14 +73,14 @@ internal class TokenActionsHandler @AssistedInject constructor( } private fun handleDemoMode(action: TokenActionsBSContentUM.Action, userWallet: UserWallet.Cold): Boolean { - val demoCard = isDemoCardUseCase.invoke(userWallet.cardId) - val needShowDemoWarning = demoCard && disabledActionsInDemoMode.contains(action) + val isDemoCard = isDemoCardUseCase.invoke(userWallet.cardId) + val shouldShowDemoWarning = isDemoCard && disabledActionsInDemoMode.contains(action) - if (needShowDemoWarning) { + if (shouldShowDemoWarning) { showDemoModeWarning() } - return needShowDemoWarning + return shouldShowDemoWarning } private fun showDemoModeWarning() { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokensPortfolioUMConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokensPortfolioUMConverter.kt index 9e5aba6a0a..47fe6e3cf3 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokensPortfolioUMConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokensPortfolioUMConverter.kt @@ -93,10 +93,10 @@ internal class TokensPortfolioUMConverter( private fun toggleQuickActions(cryptoData: PortfolioData.CryptoCurrencyData) { updateTokens { tokenList -> - tokenList.map { - it.copy( - isQuickActionsShown = if (it.matchWith(cryptoData)) { - !it.isQuickActionsShown + tokenList.map { token -> + token.copy( + isQuickActionsShown = if (token.matchWith(cryptoData)) { + !token.isQuickActionsShown } else { false }, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/AddToPortfolioBottomSheet.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/AddToPortfolioBottomSheet.kt index c12a36531c..f2d2d22dd2 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/AddToPortfolioBottomSheet.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/AddToPortfolioBottomSheet.kt @@ -54,13 +54,13 @@ internal fun AddToPortfolioBottomSheet(config: TangemBottomSheetConfig) { containerColor = TangemTheme.colors.background.tertiary, addBottomInsets = false, titleText = resourceReference(R.string.common_add_to_portfolio), - ) { + ) { contentState -> Content( modifier = Modifier.fillMaxWidth(), - state = it, + state = contentState, ) - WalletSelectorBottomSheet(it.walletSelectorConfig) + WalletSelectorBottomSheet(contentState.walletSelectorConfig) } } @@ -130,7 +130,7 @@ private fun Content(state: AddToPortfolioBSContentUM, modifier: Modifier = Modif .onGloballyPositioned { continueButtonAreaHeight = it.size.height }, - enabled = state.continueButtonEnabled, + enabled = state.isContinueButtonEnabled, isTangemIconVisible = state.isScanCardNotificationVisible, onClick = state.onContinueButtonClick, ) @@ -355,11 +355,11 @@ private fun PreviewContentTestOnDevice( isScanCardNotificationVisible = !contentState.isScanCardNotificationVisible, ) }, - continueButtonEnabled = true, + isContinueButtonEnabled = true, selectedWallet = content.selectedWallet.copy( onClick = { contentState = contentState.copy( - continueButtonEnabled = !contentState.continueButtonEnabled, + isContinueButtonEnabled = !contentState.isContinueButtonEnabled, ) }, ), diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/PortfolioItem.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/PortfolioItem.kt index 4f47bfddab..d7800514fc 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/PortfolioItem.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/PortfolioItem.kt @@ -31,11 +31,11 @@ internal fun PortfolioItem(state: PortfolioTokenUM, lastInList: Boolean, modifie val tokenItemState = remember(state.tokenItemState) { when (state.tokenItemState) { is TokenItemState.Content -> state.tokenItemState.copy( - onItemClick = { + onItemClick = { cryptoCurrency -> val onClick = state.tokenItemState.onItemClick if (onClick != null) { hapticManager.perform(TangemHapticEffect.View.ContextClick) - onClick.invoke(it) + onClick.invoke(cryptoCurrency) } }, ) @@ -73,10 +73,10 @@ internal fun PortfolioItem(state: PortfolioTokenUM, lastInList: Boolean, modifie @Composable private fun Preview(@PreviewParameter(PortfolioTokenUMProvider::class) tokenUM: PortfolioTokenUM) { TangemThemePreview { - var quickActionsShown by remember { mutableStateOf(value = false) } + var areQuickActionsShown by remember { mutableStateOf(value = false) } val onItemClick = { - quickActionsShown = quickActionsShown.not() + areQuickActionsShown = areQuickActionsShown.not() } PortfolioItem( @@ -87,7 +87,7 @@ private fun Preview(@PreviewParameter(PortfolioTokenUMProvider::class) tokenUM: is TokenItemState.Unreachable -> tokenUM.tokenItemState.copy(onItemClick = { onItemClick() }) else -> tokenUM.tokenItemState }, - isQuickActionsShown = quickActionsShown, + isQuickActionsShown = areQuickActionsShown, ), lastInList = true, ) @@ -111,7 +111,8 @@ private class PortfolioTokenUMProvider : CollectionPreviewParameterProvider LineSeparator() QuickActionItem( state = action, onClick = { onActionClick(action) }, - onLongClick = { onActionLongClick(action) }.takeIf { action.longClickAvailable }, + onLongClick = { onActionLongClick(action) }.takeIf { action.isLongClickAvailable }, ) } } @@ -174,7 +175,7 @@ private fun AnimatedVisibilityScope.QuickActionIcon(state: QuickActionUM) { .size(TangemTheme.dimens.size32) .drawWithContent { drawContent() - if (state is QuickActionUM.Exchange && state.showBadge) { + if (state is QuickActionUM.Exchange && state.shouldShowBadge) { drawBadge(containerColor = containerColor, offset = 4.dp) } }, @@ -215,7 +216,7 @@ private fun Preview() { PortfolioQuickActions( actions = persistentListOf( QuickActionUM.Buy, - QuickActionUM.Exchange(showBadge = true), + QuickActionUM.Exchange(shouldShowBadge = true), QuickActionUM.Receive, ), isVisible = isVisible, @@ -236,7 +237,7 @@ private fun PreviewRtl() { PortfolioQuickActions( actions = persistentListOf( QuickActionUM.Buy, - QuickActionUM.Exchange(showBadge = true), + QuickActionUM.Exchange(shouldShowBadge = true), QuickActionUM.Receive, ), isVisible = true, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewAddToPortfolioBSContentProvider.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewAddToPortfolioBSContentProvider.kt index 16b7cf769f..bdc1b092e3 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewAddToPortfolioBSContentProvider.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewAddToPortfolioBSContentProvider.kt @@ -54,7 +54,7 @@ internal class PreviewAddToPortfolioBSContentProvider : PreviewParameterProvider ), isScanCardNotificationVisible = true, isWalletBlockVisible = true, - continueButtonEnabled = true, + isContinueButtonEnabled = true, onContinueButtonClick = {}, walletSelectorConfig = TangemBottomSheetConfig.Empty, ), @@ -78,7 +78,7 @@ internal class PreviewAddToPortfolioBSContentProvider : PreviewParameterProvider ), isScanCardNotificationVisible = true, isWalletBlockVisible = false, - continueButtonEnabled = false, + isContinueButtonEnabled = false, onContinueButtonClick = {}, walletSelectorConfig = TangemBottomSheetConfig.Empty, ), diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewMyPortfolioUMProvider.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewMyPortfolioUMProvider.kt index 6f8a95f4fc..4e1b5c5bd9 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewMyPortfolioUMProvider.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/preview/PreviewMyPortfolioUMProvider.kt @@ -17,6 +17,76 @@ import java.util.UUID internal class PreviewMyPortfolioUMProvider : PreviewParameterProvider { + val sampleToken + get() = PortfolioTokenUM( + tokenItemState = TokenItemState.Content( + id = UUID.randomUUID().toString(), + iconState = CurrencyIconState.Locked, + titleState = TokenItemState.TitleState.Content(text = stringReference(value = "My wallet")), + fiatAmountState = TokenItemState.FiatAmountState.Content(text = "486,65 \$"), + subtitle2State = TokenItemState.Subtitle2State.TextContent(text = "733,71097 MATIC"), + subtitleState = TokenItemState.SubtitleState.TextContent( + value = stringReference(value = "XRP Ledger token"), + ), + onItemClick = {}, + onItemLongClick = {}, + ), + isQuickActionsShown = false, + quickActions = PortfolioTokenUM.QuickActions( + actions = persistentListOf( + QuickActionUM.Buy, + QuickActionUM.Exchange(shouldShowBadge = true), + QuickActionUM.Receive, + ), + onQuickActionClick = {}, + onQuickActionLongClick = {}, + ), + isBalanceHidden = false, + walletId = UserWalletId(""), + ) + + val walletHeader + get() = WalletHeader( + id = UUID.randomUUID().toString(), + name = stringReference("Wallet 1"), + ) + + val walletPortfolioHeader + get() = PortfolioHeader( + state = AccountTitleUM.Text(title = stringReference("Wallet 1")), + id = UUID.randomUUID().toString(), + ) + + val accountHeader + get() = PortfolioHeader( + state = AccountTitleUM.Account( + icon = AccountIconPreviewData.randomAccountIcon(), + name = stringReference("Main Account"), + prefixText = TextReference.EMPTY, + ), + id = UUID.randomUUID().toString(), + ) + val coinIconState + get() = CurrencyIconState.CoinIcon( + url = null, + fallbackResId = com.tangem.core.ui.R.drawable.img_polygon_22, + isGrayscale = false, + shouldShowCustomBadge = false, + ) + val accountToken + get() = sampleToken.copy( + tokenItemState = TokenItemState.Content( + id = UUID.randomUUID().toString(), + iconState = coinIconState, + titleState = TokenItemState.TitleState.Content(text = stringReference(value = "Polygon")), + fiatAmountState = FiatAmountState.Content(text = "321 $"), + subtitle2State = TokenItemState.Subtitle2State.TextContent(text = "5,412 MATIC"), + subtitleState = TokenItemState.SubtitleState.TextContent(stringReference(value = "Token")), + onItemClick = {}, + onItemLongClick = {}, + ), + ) + override val values: Sequence get() = sequenceOf( MyPortfolioUM.Tokens( @@ -77,74 +147,4 @@ internal class PreviewMyPortfolioUMProvider : PreviewParameterProvider Unit, val walletSelectorConfig: TangemBottomSheetConfig, ) : TangemBottomSheetConfigContent \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/state/QuickActionUM.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/state/QuickActionUM.kt index 777dd019c1..040f3d243e 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/state/QuickActionUM.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/ui/state/QuickActionUM.kt @@ -12,7 +12,7 @@ internal sealed class QuickActionUM( val title: TextReference, val description: TextReference, @DrawableRes val icon: Int, - val longClickAvailable: Boolean = false, + val isLongClickAvailable: Boolean = false, ) { data object Buy : QuickActionUM( title = resourceReference(R.string.common_buy), @@ -21,7 +21,7 @@ internal sealed class QuickActionUM( ) data class Exchange( - val showBadge: Boolean, + val shouldShowBadge: Boolean, ) : QuickActionUM( title = resourceReference(R.string.common_exchange), description = resourceReference(R.string.exсhange_token_description), @@ -32,7 +32,7 @@ internal sealed class QuickActionUM( title = resourceReference(R.string.common_receive), description = resourceReference(R.string.receive_token_description), icon = R.drawable.ic_arrow_down_24, - longClickAvailable = true, + isLongClickAvailable = true, ) data object Stake : QuickActionUM( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/token/block/impl/model/TokenMarketBlockModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/token/block/impl/model/TokenMarketBlockModel.kt index db7d46227c..1cdaebeff0 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/token/block/impl/model/TokenMarketBlockModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/token/block/impl/model/TokenMarketBlockModel.kt @@ -79,8 +79,8 @@ internal class TokenMarketBlockModel @Inject constructor( currencyID = params.cryptoCurrency.id, interval = PriceChangeInterval.H24, refresh = true, - ).collect { - it.onSome { res -> + ).collect { quotesOption -> + quotesOption.onSome { res -> quotesState = QuotesState( currentPrice = res.fiatRate, h24Percent = res.priceChange, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/DefaultMarketsTokenListComponent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/DefaultMarketsTokenListComponent.kt index 14e1c4dc72..16c594bee1 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/DefaultMarketsTokenListComponent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/DefaultMarketsTokenListComponent.kt @@ -107,12 +107,12 @@ internal class DefaultMarketsTokenListComponent @AssistedInject constructor( Scaffold( contentWindowInsets = WindowInsetsZero, containerColor = TangemTheme.colors.background.primary, - ) { + ) { paddingValues -> MarketsListWithBack( modifier = Modifier .statusBarsPadding() .imePadding() - .padding(it), + .padding(paddingValues), state = state, bottomSheetState = BottomSheetState.EXPANDED, onBackClick = router::pop, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/analytics/MarketsListAnalyticsEvent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/analytics/MarketsListAnalyticsEvent.kt index 996e95d31b..ee943d293b 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/analytics/MarketsListAnalyticsEvent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/analytics/MarketsListAnalyticsEvent.kt @@ -6,7 +6,7 @@ import com.tangem.features.markets.tokenlist.impl.ui.state.SortByTypeUM internal sealed class MarketsListAnalyticsEvent( event: String, - params: Map = mapOf(), + params: Map = emptyMap(), ) : AnalyticsEvent(category = "Markets", event = event, params = params) { class BottomSheetOpened : MarketsListAnalyticsEvent(event = "Markets Screen Opened") @@ -39,10 +39,10 @@ internal sealed class MarketsListAnalyticsEvent( class YieldModeMoreInfoClicked : MarketsListAnalyticsEvent(event = "Yield Mode More Info") - data class TokenSearched(val tokenFound: Boolean) : MarketsListAnalyticsEvent( + data class TokenSearched(val wasTokenFound: Boolean) : MarketsListAnalyticsEvent( event = "Token Searched", params = mapOf( - "Result" to if (tokenFound) "Yes" else "No", + "Result" to if (wasTokenFound) "Yes" else "No", ), ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/MarketsListModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/MarketsListModel.kt index d33935747e..c898c68a73 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/MarketsListModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/MarketsListModel.kt @@ -52,7 +52,7 @@ internal class MarketsListModel @Inject constructor( private val analyticsEventHandler: AnalyticsEventHandler, ) : Model() { - private var updateQuotesJob = JobHolder() + private val updateQuotesJob = JobHolder() private val currentAppCurrency = getSelectedAppCurrencyUseCase().map { maybeAppCurrency -> maybeAppCurrency.getOrElse { AppCurrency.Default } @@ -64,6 +64,8 @@ internal class MarketsListModel @Inject constructor( private val visibleItemIds = MutableStateFlow>(emptyList()) + private lateinit var activeListManager: MarketsListBatchFlowManager + private val marketsListUMStateManager = MarketsListUMStateManager( currentVisibleIds = Provider { visibleItemIds.value }, onLoadMoreUiItems = { activeListManager.loadMore() }, @@ -95,7 +97,9 @@ internal class MarketsListModel @Inject constructor( dispatchers = dispatchers, ) - private var activeListManager: MarketsListBatchFlowManager = mainMarketsListManager + init { + activeListManager = mainMarketsListManager + } private val _tokenSelected = MutableSharedFlow>() @@ -173,8 +177,8 @@ internal class MarketsListModel @Inject constructor( } } - state.onEach { - if (it.list !is ListUM.Content) { + state.onEach { currentState -> + if (currentState.list !is ListUM.Content) { visibleItemIds.value = emptyList() } }.launchIn(modelScope) @@ -188,8 +192,8 @@ internal class MarketsListModel @Inject constructor( }.launchIn(modelScope) // load charts when new batch is being loaded - mainMarketsListManager.onLastBatchLoadedSuccess.onEach { - mainMarketsListManager.loadCharts(setOf(it), marketsListUMStateManager.selectedInterval) + mainMarketsListManager.onLastBatchLoadedSuccess.onEach { batchKey -> + mainMarketsListManager.loadCharts(setOf(batchKey), marketsListUMStateManager.selectedInterval) modelScope.loadQuotesWithTimer(timeMillis = UPDATE_QUOTES_TIMER_MILLIS) }.launchIn(modelScope) @@ -210,15 +214,19 @@ internal class MarketsListModel @Inject constructor( // reload list when sorting type has changed modelScope.launch { - marketsListUMStateManager.state.map { it.selectedSortBy }.distinctUntilChanged().drop(1).collectLatest { - mainMarketsListManager.reload() - } + marketsListUMStateManager.state + .map { state -> state.selectedSortBy } + .distinctUntilChanged() + .drop(1) + .collectLatest { + mainMarketsListManager.reload() + } } // listen current visible batch and update charts modelScope.launch { - visibleItemIds.mapNotNull { - if (it.isNotEmpty()) { + visibleItemIds.mapNotNull { itemIds -> + if (itemIds.isNotEmpty()) { activeListManager.getBatchKeysByItemIds(visibleItemIds.value) } else { null @@ -252,20 +260,20 @@ internal class MarketsListModel @Inject constructor( } modelScope.launch { - searchMarketsListManager.onLastBatchLoadedSuccess.collectLatest { - searchMarketsListManager.loadCharts(setOf(it), marketsListUMStateManager.selectedInterval) + searchMarketsListManager.onLastBatchLoadedSuccess.collectLatest { batchKey -> + searchMarketsListManager.loadCharts(setOf(batchKey), marketsListUMStateManager.selectedInterval) modelScope.loadQuotesWithTimer(timeMillis = UPDATE_QUOTES_TIMER_MILLIS) } } - searchMarketsListManager.isSearchNotFoundState.onEach { - if (it) { - analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(tokenFound = false)) + searchMarketsListManager.isSearchNotFoundState.onEach { isNotFound -> + if (isNotFound) { + analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(wasTokenFound = false)) } }.launchIn(modelScope) searchMarketsListManager.onFirstBatchLoadedSuccess.onEach { - analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(tokenFound = true)) + analyticsEventHandler.send(MarketsListAnalyticsEvent.TokenSearched(wasTokenFound = true)) }.launchIn(modelScope) // analytics diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListBatchFlowManager.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListBatchFlowManager.kt index 4847ff333a..e96284ced9 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListBatchFlowManager.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListBatchFlowManager.kt @@ -68,17 +68,17 @@ internal class MarketsListBatchFlowManager( val onLastBatchLoadedSuccess = batchFlow.state .distinctUntilChanged { old, new -> old.status == new.status && old.data.size == new.data.size } - .mapNotNull { - when (val status = it.status) { + .mapNotNull { state -> + when (val status = state.status) { is PaginationStatus.Paginating -> { if (status.lastResult is BatchFetchResult.Success) { - it.data.lastOrNull()?.key + state.data.lastOrNull()?.key } else { null } } is PaginationStatus.EndOfPagination -> { - it.data.lastOrNull()?.key + state.data.lastOrNull()?.key } else -> null } @@ -86,22 +86,22 @@ internal class MarketsListBatchFlowManager( val onFirstBatchLoadedSuccess = batchFlow.state .distinctUntilChanged { old, new -> old.status == new.status && old.data.size == new.data.size } - .mapNotNull { - when (val status = it.status) { + .mapNotNull { state -> + when (val status = state.status) { is PaginationStatus.Paginating -> { if (status.lastResult is BatchFetchResult.Success) { - it.data.size == 1 + state.data.size == 1 } else { null } } is PaginationStatus.EndOfPagination -> { - it.data.size == 1 + state.data.size == 1 } else -> null } } - .filter { it } + .filter { isFirstBatch -> isFirstBatch } val isInInitialLoadingErrorState = batchFlow.state .map { it.status is PaginationStatus.InitialLoadingError } @@ -113,10 +113,10 @@ internal class MarketsListBatchFlowManager( ) val isSearchNotFoundState = batchFlow.state - .map { + .map { state -> currentSearchText().isNullOrEmpty().not() && - it.status is PaginationStatus.EndOfPagination && - it.data.isEmpty() + state.status is PaginationStatus.EndOfPagination && + state.data.isEmpty() } .distinctUntilChanged() .stateIn( @@ -175,22 +175,21 @@ internal class MarketsListBatchFlowManager( forceUpdate || previousList.isNullOrEmpty() || newList.first().key != previousList.first().key val outItems = if (isInitialLoading) { - newList.map { + newList.map { batch -> Batch( - key = it.key, - data = converter.convertList(it.data), + key = batch.key, + data = converter.convertList(batch.data), ) } } else { - previousList!! if (previousList.size != newList.size) { val keysToAdd = newList.map { it.key }.subtract(previousList.map { it.key }.toSet()) val newBatches = newList.filter { keysToAdd.contains(it.key) } - items + newBatches.map { + items + newBatches.map { batch -> Batch( - key = it.key, - data = converter.convertList(it.data), + key = batch.key, + data = converter.convertList(batch.data), ) } } else { @@ -264,8 +263,8 @@ internal class MarketsListBatchFlowManager( modelScope.launch { val currentData = batchFlow.state.value.data val alreadyLoadedChartsBatchKeys = currentData - .filter { - val first = it.data.firstOrNull() ?: return@filter false + .filter { batch -> + val first = batch.data.firstOrNull() ?: return@filter false val chartByInterval = when (interval) { TrendInterval.H24 -> first.tokenCharts.h24 TrendInterval.D7 -> first.tokenCharts.week @@ -273,7 +272,7 @@ internal class MarketsListBatchFlowManager( } chartByInterval != null } - .map { it.key } + .map { batch -> batch.key } .toSet() val batchesKeysToLoad = batchKeys.minus(alreadyLoadedChartsBatchKeys) @@ -302,9 +301,12 @@ internal class MarketsListBatchFlowManager( }, ) + val batchKeys = batchFlow.state.value.data + .map { it.key } + .toSet() actionsFlow.emit( BatchAction.UpdateBatches( - keys = batchFlow.state.value.data.map { it.key }.toSet(), + keys = batchKeys, updateRequest = TokenMarketUpdateRequest.UpdateQuotes( currencyId = currentAppCurrency().code, ), @@ -332,7 +334,10 @@ internal class MarketsListBatchFlowManager( } fun getTokenById(id: CryptoCurrency.RawID): TokenMarket? { - return batchFlow.state.value.data.map { it.data }.flatten().find { it.id == id } + val allTokens = batchFlow.state.value.data + .map { it.data } + .flatten() + return allTokens.find { it.id == id } } private fun SortByTypeUM.toRequestOrder(): TokenMarketListConfig.Order { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListUMStateManager.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListUMStateManager.kt index 33f89173a9..8c33b39d79 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListUMStateManager.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/model/statemanager/MarketsListUMStateManager.kt @@ -29,15 +29,19 @@ internal class MarketsListUMStateManager( private val onShowTokensUnder100kClicked: () -> Unit, ) { - private var sortByBottomSheetIsShown + val state = MutableStateFlow(createInitialState()) + val isInSearchStateFlow = state.map { it.searchBar.isActive }.distinctUntilChanged() + val searchQueryFlow = state.map { it.searchBar.query }.distinctUntilChanged() + + private var isSortByBottomSheetShown get() = state.value.sortByBottomSheet.isShown set(value) = state.update { it.copy(sortByBottomSheet = it.sortByBottomSheet.copy(isShown = value)) } var searchQuery get() = state.value.searchBar.query - private set(value) = state.update { - it.copy( - searchBar = it.searchBar.copy( + private set(value) = state.update { currentState -> + currentState.copy( + searchBar = currentState.searchBar.copy( query = value, isActive = value.isNotEmpty(), ), @@ -50,42 +54,42 @@ internal class MarketsListUMStateManager( var selectedSortByType get() = state.value.selectedSortBy - set(value) = state.update { - it.copy( + set(value) = state.update { currentState -> + currentState.copy( selectedSortBy = value, - sortByBottomSheet = it.sortByBottomSheet.copy( - content = (it.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( + sortByBottomSheet = currentState.sortByBottomSheet.copy( + content = (currentState.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( selectedOption = value, ), ), - list = if (it.list is ListUM.Content && it.selectedSortBy != value) { - it.list.copy(triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }) + list = if (currentState.list is ListUM.Content && currentState.selectedSortBy != value) { + currentState.list.copy( + triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }, + ) } else { - it.list + currentState.list }, ) } var selectedInterval get() = state.value.selectedInterval - set(value) = state.update { - it.copy( + set(value) = state.update { currentState -> + currentState.copy( selectedInterval = value, - list = if (it.list is ListUM.Content && - it.selectedSortBy != SortByTypeUM.Rating && - it.selectedInterval != value + list = if (currentState.list is ListUM.Content && + currentState.selectedSortBy != SortByTypeUM.Rating && + currentState.selectedInterval != value ) { - it.list.copy(triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }) + currentState.list.copy( + triggerScrollReset = triggeredEvent(Unit) { consumeTriggerResetScrollEvent() }, + ) } else { - it.list + currentState.list }, ) } - val state = MutableStateFlow(state()) - val isInSearchStateFlow = state.map { it.searchBar.isActive }.distinctUntilChanged() - val searchQueryFlow = state.map { it.searchBar.query }.distinctUntilChanged() - fun onUiItemsChanged( isInErrorState: Boolean, isSearchNotFound: Boolean, @@ -127,7 +131,7 @@ internal class MarketsListUMStateManager( return currentState.copy( list = generalContentState(itemsWithFilteredPriceChange) .copy( - showUnder100kTokensNotificationWasHidden = currentState.showUnder100kButtonAlreadyPressed(), + wasUnder100kTokensNotificationHidden = currentState.showUnder100kButtonAlreadyPressed(), ), marketsNotificationUM = marketsNotificationUM, ) @@ -144,8 +148,8 @@ internal class MarketsListUMStateManager( return currentState.copy( list = generalContentState(filtered).copy( - showUnder100kTokensNotificationWasHidden = false, - showUnder100kTokensNotification = true, + wasUnder100kTokensNotificationHidden = false, + shouldShowUnder100kTokensNotification = true, onShowTokensUnder100kClicked = { onShowTokensUnder100kClicked() state.update { s -> @@ -153,8 +157,8 @@ internal class MarketsListUMStateManager( s.copy( list = s.list.copy( items = searchUiItemsCached, - showUnder100kTokensNotification = false, - showUnder100kTokensNotificationWasHidden = true, + shouldShowUnder100kTokensNotification = false, + wasUnder100kTokensNotificationHidden = true, ), ) } ?: s @@ -170,17 +174,17 @@ internal class MarketsListUMStateManager( } private fun MarketsListUM.showUnder100kButtonAlreadyPressed(): Boolean { - return this.list is ListUM.Content && this.isInSearchMode && this.list.showUnder100kTokensNotificationWasHidden + return this.list is ListUM.Content && this.isInSearchMode && this.list.wasUnder100kTokensNotificationHidden } // Show price change animation for visible items only private fun ImmutableList.filterPriceChangeByVisibility(): ImmutableList { val visibleItemIds = currentVisibleIds() - return map { - it.copy( - price = it.price.copy( - changeType = if (visibleItemIds.contains(it.id)) { - it.price.changeType + return map { item -> + item.copy( + price = item.price.copy( + changeType = if (visibleItemIds.contains(item.id)) { + item.price.changeType } else { null }, @@ -194,15 +198,43 @@ internal class MarketsListUMStateManager( items = newItems, loadMore = onLoadMoreUiItems, visibleIdsChanged = visibleItemsChanged, - showUnder100kTokensNotification = false, + shouldShowUnder100kTokensNotification = false, onShowTokensUnder100kClicked = {}, triggerScrollReset = consumedEvent(), onItemClick = onTokenClick, - showUnder100kTokensNotificationWasHidden = false, + wasUnder100kTokensNotificationHidden = false, ) } - private fun state(): MarketsListUM = MarketsListUM( + private fun onBottomSheetOptionClicked(sortByTypeUM: SortByTypeUM) { + state.update { currentState -> + currentState.copy( + selectedSortBy = sortByTypeUM, + sortByBottomSheet = currentState.sortByBottomSheet.copy( + isShown = false, + content = (currentState.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( + selectedOption = sortByTypeUM, + ), + ), + ) + } + } + + private fun consumeTriggerResetScrollEvent() { + state.update { currentState -> + currentState.copy( + list = if (currentState.list is ListUM.Content) { + currentState.list.copy( + triggerScrollReset = consumedEvent(), + ) + } else { + currentState.list + }, + ) + } + } + + private fun createInitialState(): MarketsListUM = MarketsListUM( list = ListUM.Loading, searchBar = SearchBarUM( placeholderText = resourceReference(R.string.markets_search_header_title), @@ -214,10 +246,10 @@ internal class MarketsListUMStateManager( selectedSortBy = SortByTypeUM.Rating, selectedInterval = MarketsListUM.TrendInterval.H24, onIntervalClick = { selectedInterval = it }, - onSortByButtonClick = { sortByBottomSheetIsShown = true }, + onSortByButtonClick = { isSortByBottomSheetShown = true }, sortByBottomSheet = TangemBottomSheetConfig( isShown = false, - onDismissRequest = { sortByBottomSheetIsShown = false }, + onDismissRequest = { isSortByBottomSheetShown = false }, content = SortByBottomSheetContentUM( selectedOption = SortByTypeUM.Rating, onOptionClicked = ::onBottomSheetOptionClicked, @@ -225,32 +257,4 @@ internal class MarketsListUMStateManager( ), marketsNotificationUM = null, ) - - private fun onBottomSheetOptionClicked(sortByTypeUM: SortByTypeUM) { - state.update { - it.copy( - selectedSortBy = sortByTypeUM, - sortByBottomSheet = it.sortByBottomSheet.copy( - isShown = false, - content = (it.sortByBottomSheet.content as SortByBottomSheetContentUM).copy( - selectedOption = sortByTypeUM, - ), - ), - ) - } - } - - private fun consumeTriggerResetScrollEvent() { - state.update { - it.copy( - list = if (it.list is ListUM.Content) { - it.list.copy( - triggerScrollReset = consumedEvent(), - ) - } else { - it.list - }, - ) - } - } } \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/MarketsList.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/MarketsList.kt index 0a7e31ebfc..79b42c8c55 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/MarketsList.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/MarketsList.kt @@ -81,10 +81,10 @@ internal fun MarketsList( end = TangemTheme.dimens.spacing16, bottom = 8.dp, ) - .onGloballyPositioned { - if (it.size.height > 0) { + .onGloballyPositioned { layoutCoordinates -> + if (layoutCoordinates.size.height > 0) { with(density) { - onHeaderSizeChange(it.size.height.toDp()) + onHeaderSizeChange(layoutCoordinates.size.height.toDp()) } } } @@ -312,23 +312,23 @@ private fun ItemsList( val searchLazyListState = rememberLazyListState() val mainLazyListState = rememberLazyListState() - val mainScrolled by remember { + val isMainScrolled by remember { derivedStateOf { mainLazyListState.firstVisibleItemScrollOffset > 0 } } - val searchScrolledState by remember { + val isSearchScrolled by remember { derivedStateOf { searchLazyListState.firstVisibleItemScrollOffset > 0 } } - LaunchedEffect(mainScrolled, isInSearchMode, searchScrolledState) { + LaunchedEffect(isMainScrolled, isInSearchMode, isSearchScrolled) { scrolledState.value = if (isInSearchMode) { - searchScrolledState + isSearchScrolled } else { - mainScrolled + isMainScrolled } } @@ -392,8 +392,8 @@ private fun Preview() { item.copy(id = CryptoCurrency.RawID(index.toString())) } .toImmutableList(), - showUnder100kTokensNotification = false, - showUnder100kTokensNotificationWasHidden = false, + shouldShowUnder100kTokensNotification = false, + wasUnder100kTokensNotificationHidden = false, loadMore = {}, visibleIdsChanged = {}, onShowTokensUnder100kClicked = {}, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListItem.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListItem.kt index e0daa6f742..1854695357 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListItem.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListItem.kt @@ -295,11 +295,11 @@ private fun Preview(@PreviewParameter(MarketChartListItemPreviewDataProvider::cl Button( onClick = { - prices = prices.map { + prices = prices.map { priceInfo -> if (Random.nextBoolean()) { - it.first.inc() to PriceChangeType.UP + priceInfo.first.inc() to PriceChangeType.UP } else { - it.first.dec() to PriceChangeType.DOWN + priceInfo.first.dec() to PriceChangeType.DOWN } } state1 = state1.copy( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListLazyColumn.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListLazyColumn.kt index bbdcbf2697..b38a9cd3d9 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListLazyColumn.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/components/MarketsListLazyColumn.kt @@ -101,7 +101,7 @@ internal fun MarketsListLazyColumn( ) } - if (isInSearchMode && state.showUnder100kTokensNotification) { + if (isInSearchMode && state.shouldShowUnder100kTokensNotification) { item(key = "show tokens under 100k".hashCode()) { ShowTokensUnder100kItem( onShowTokensClick = state.onShowTokensUnder100kClicked, @@ -126,7 +126,7 @@ internal fun MarketsListLazyColumn( triggerLoadMoreCheckOnItemsCountChange = true, onLoadMore = remember(state) { { - if (state is ListUM.Content && state.showUnder100kTokensNotification.not()) { + if (state is ListUM.Content && state.shouldShowUnder100kTokensNotification.not()) { state.loadMore() true } else { @@ -197,8 +197,8 @@ private fun SearchNothingFoundText(modifier: Modifier = Modifier) { private fun VisibleItemsTracker(listState: LazyListState, state: ListUM) { val visibleItems by remember { derivedStateOf { - listState.layoutInfo.visibleItemsInfo.mapNotNull { - (it.key as? String)?.split(TOKEN_LAZY_LIST_ID_SEPARATOR)?.first() + listState.layoutInfo.visibleItemsInfo.mapNotNull { item -> + (item.key as? String)?.split(TOKEN_LAZY_LIST_ID_SEPARATOR)?.first() ?.let { rawId -> CryptoCurrency.RawID(rawId) } } } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListItemUM.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListItemUM.kt index a83ea2e7d6..58b80368b4 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListItemUM.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListItemUM.kt @@ -36,7 +36,7 @@ data class MarketsListItemUM( ) fun getComposeKey(): String { - return id.value + TOKEN_LAZY_LIST_ID_SEPARATOR + marketCap.toString() + updateTimestamp + return id.value + TOKEN_LAZY_LIST_ID_SEPARATOR + marketCap.orEmpty() + updateTimestamp } companion object { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListUM.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListUM.kt index 8404856a87..d0ade846a6 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListUM.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/tokenlist/impl/ui/state/MarketsListUM.kt @@ -46,8 +46,8 @@ sealed class ListUM { data class Content( val items: ImmutableList, - val showUnder100kTokensNotification: Boolean, - val showUnder100kTokensNotificationWasHidden: Boolean, + val shouldShowUnder100kTokensNotification: Boolean, + val wasUnder100kTokensNotificationHidden: Boolean, val loadMore: () -> Unit, val visibleIdsChanged: (List) -> Unit, val onShowTokensUnder100kClicked: () -> Unit, diff --git a/features/nft/impl/detekt-baseline-debug.xml b/features/nft/impl/detekt-baseline-debug.xml index e079f03d2a..97fee15b2b 100644 --- a/features/nft/impl/detekt-baseline-debug.xml +++ b/features/nft/impl/detekt-baseline-debug.xml @@ -8,7 +8,6 @@ BooleanPropertyNaming:NFTCollectionsModel.kt$NFTCollectionsModel$val assetsFulfillQuery = if (query.isEmpty()) { true } else { when (val assets = it.assets) { is NFTCollection.Assets.Empty, is NFTCollection.Assets.Failed, is NFTCollection.Assets.Loading, -> false is NFTCollection.Assets.Value -> { assets.items.any { asset -> asset.name?.lowercase()?.contains(query.lowercase()) == true } } } } BooleanPropertyNaming:NFTCollectionsModel.kt$NFTCollectionsModel$val collectionFulfillQuery = query.isEmpty() || it.name?.lowercase()?.contains(query.lowercase()) == true BooleanPropertyNaming:UpdateDataStateTransformer.kt$UpdateDataStateTransformer$val custom = derivationPath is Network.DerivationPath.Custom - CanBeNonNullable:NFTReceive.kt$bottomSheetConfig: TangemBottomSheetConfig? MultilineLambdaItParameter:ChangeCollectionExpandedStateTransformer.kt$ChangeCollectionExpandedStateTransformer${ val collectionId = collection.collectionIdProvider() if (it.id == collectionId && it is NFTCollectionUM) { if (!it.isExpanded) { onFirstExpanded() } it.copy(isExpanded = !it.isExpanded) } else { it } } MultilineLambdaItParameter:NFTCollectionsContent.kt${ key(it.id) { NFTCollectionWarning( modifier = Modifier .padding(top = TangemTheme.dimens.spacing16), state = it, ) } } MultilineLambdaItParameter:NFTCollectionsModel.kt$NFTCollectionsModel${ ChangeCollectionExpandedStateTransformer( collection = collection, collectionIdProvider = collectionIdProvider, onFirstExpanded = { onFirstExpanded(collection) }, ).transform(it) } diff --git a/features/staking/impl/detekt-baseline-debug.xml b/features/staking/impl/detekt-baseline-debug.xml index 79c9fb9f11..113f53de5d 100644 --- a/features/staking/impl/detekt-baseline-debug.xml +++ b/features/staking/impl/detekt-baseline-debug.xml @@ -7,41 +7,30 @@ BooleanPropertyNaming:StakingModel.kt$StakingModel$val noBalanceState = balanceState == null BooleanPropertyNaming:StakingUiState.kt$StakingStates.InitialInfoState.Data$val showBanner: Boolean BooleanPropertyNaming:StakingUiState.kt$StakingUiState$val showColdWalletInteractionIcon: Boolean - CanBeNonNullable:StakingScreen.kt$bottomSheetConfig: TangemBottomSheetConfig? CastNullableToNonNullableType:SetApprovalBottomSheetInProgressTransformer.kt$SetApprovalBottomSheetInProgressTransformer$as CastNullableToNonNullableType:SetApprovalBottomSheetTypeChangeTransformer.kt$SetApprovalBottomSheetTypeChangeTransformer$as MultilineLambdaItParameter:AddStakingNotificationsTransformer.kt$AddStakingNotificationsTransformer${ it is StakingNotification.Error || it is NotificationUM.Error || it is NotificationUM.Warning.NetworkFeeUnreachable || it is StakingNotification.Warning.TransactionInProgress || it is StakingNotification.Warning.InitializeTonAccount } MultilineLambdaItParameter:DefaultStakingDeepLinkHandler.kt$DefaultStakingDeepLinkHandler${ val isNetwork = it.network.backendId.equals(networkId, ignoreCase = true) val isCurrency = it.id.rawCurrencyId?.value?.equals(tokenId, ignoreCase = true) == true isNetwork && isCurrency } MultilineLambdaItParameter:StakingFeeBlock.kt${ if (it == FeeState.Error) { Text( text = DASH_SIGN, color = TangemTheme.colors.text.primary1, style = TangemTheme.typography.body1, ) } } MultilineLambdaItParameter:StakingFeeBlock.kt${ if (it == FeeState.Loading) { RectangleShimmer( radius = TangemTheme.dimens.radius3, modifier = Modifier.size( height = TangemTheme.dimens.size24, width = TangemTheme.dimens.size90, ), ) } } - MultilineLambdaItParameter:StakingFeeTransactionLoader.kt$StakingFeeTransactionLoader${ onStakingFeeError(it) null } - MultilineLambdaItParameter:StakingFeeTransactionLoader.kt$StakingFeeTransactionLoader${ onStakingFeeError(it) return } MultilineLambdaItParameter:StakingInfoNotificationsFactory.kt$StakingInfoNotificationsFactory${ it.type == BalanceType.PREPARING || it.type == BalanceType.STAKED || it.type == BalanceType.LOCKED } - MultilineLambdaItParameter:StakingInfoNotificationsFactory.kt$StakingInfoNotificationsFactory${ it.type == BalanceType.STAKED || it.type == BalanceType.PREPARING || it.type == BalanceType.UNSTAKED } MultilineLambdaItParameter:StakingModel.kt$StakingModel${ EnterAmountBoundary( amount = it, fiatRate = status.value.fiatRate.orZero(), ) } MultilineLambdaItParameter:StakingModel.kt$StakingModel${ Timber.e(it) false } MultilineLambdaItParameter:StakingModel.kt$StakingModel${ isBalanceHiddenFlow.value = it.isBalanceHidden stateController.update( transformer = HideBalanceStateTransformer( isBalanceHidden = it.isBalanceHidden, cryptoCurrencyStatus = cryptoCurrencyStatus, appCurrency = appCurrency, ), ) } MultilineLambdaItParameter:StakingModel.kt$StakingModel${ stateController.update( SetFeeToTonInitializeBottomSheetTransformer( appCurrencyProvider = Provider { appCurrency }, feeCryptoCurrencyStatus = feeCryptoCurrencyStatus, fee = it.normal, isFeeApproximate = false, ), ) } MultilineLambdaItParameter:StakingStateController.kt$StakingStateController${ it.copy( showColdWalletInteractionIcon = userWallet is UserWallet.Cold, ) } - MultilineLambdaItParameter:StakingTransactionSender.kt$StakingTransactionSender${ onConstructError(it) null } - MultilineLambdaItParameter:StakingTransactionSender.kt$StakingTransactionSender${ onConstructError(it) return emptyList() } - NoNameShadowing:StakingFeeTransactionLoader.kt$StakingFeeTransactionLoader$amount - NoNameShadowing:StakingFeeTransactionLoader.kt$StakingFeeTransactionLoader${ if (!it.amount.isZero()) return feeResult } NullCheckOnMutableProperty:StakingModel.kt$StakingModel$if (feeCryptoCurrencyStatus != null && fee != null) { getBalanceNotEnoughForFeeWarningUseCase( fee = fee, userWalletId = userWalletId, tokenStatus = cryptoCurrencyStatus, coinStatus = feeCryptoCurrencyStatus ?: cryptoCurrencyStatus, ).getOrNull() } else { null } NullableToStringCall:DefaultStakingDeepLinkHandler.kt$DefaultStakingDeepLinkHandler$$networkId NullableToStringCall:DefaultStakingDeepLinkHandler.kt$DefaultStakingDeepLinkHandler$$tokenId PropertyUsedBeforeDeclaration:StakingFeeBlock.kt$FeeBlockPreviewProvider$contentState PropertyUsedBeforeDeclaration:StakingModel.kt$StakingModel$isAmountSubtractAvailable PropertyUsedBeforeDeclaration:StakingStateController.kt$StakingStateController$uiState - ReusedModifierInstance:StakingClaimRewardsValidatorContent.kt$InputRowImageInfo( subtitle = item.title, caption = item.getAprTextNeutral(), infoTitle = item.formattedFiatAmount, infoSubtitle = item.formattedCryptoAmount, imageUrl = item.validator?.image.orEmpty(), onImageError = { ValidatorImagePlaceholder() }, modifier = modifier .roundedShapeItemDecoration(index, state.rewards.lastIndex, false) .background(TangemTheme.colors.background.action) .clickable( enabled = item.pendingActions.isNotEmpty(), onClick = { clickIntents.onActiveStake(item) }, ), ) SuspendFunSwallowedCancellation:StakingModel.kt$StakingModel$runCatching UnnecessaryEventHandlerParameter:StakingInitialInfoContent.kt$onClick: (BalanceState) -> Unit - UnnecessaryFilter:StakingInfoNotificationsFactory.kt$StakingInfoNotificationsFactory$filter { it.validator?.address == validatorAddress } UnnecessaryLet:StakingModel.kt$StakingModel$let(::add) UnnecessaryLet:StakingTosText.kt$let { onTextClick(PRIVACY_POLICY_URL) } UnnecessaryLet:StakingTosText.kt$let { onTextClick(TERMS_OF_USE_URL) } UnsafeCallOnNullableType:StakingModel.kt$StakingModel$tonAccountInitializeTransaction!! - UseOrEmpty:StakingTransactionSender.kt$StakingTransactionSender$getExplorerTransactionUrlUseCase( txHash = transactionHashes.last(), networkId = cryptoCurrencyStatus.currency.network.id, ).getOrNull() ?: "" VarCouldBeVal:StakingModel.kt$StakingModel$private var actionsJobHolder: JobHolder = JobHolder() VarCouldBeVal:StakingModel.kt$StakingModel$private var approvalJobHolder: JobHolder = JobHolder() VarCouldBeVal:StakingModel.kt$StakingModel$private var feeJobHolder: JobHolder = JobHolder() diff --git a/features/tester/impl/detekt-baseline-debug.xml b/features/tester/impl/detekt-baseline-debug.xml index be0960afae..84eba5dc41 100644 --- a/features/tester/impl/detekt-baseline-debug.xml +++ b/features/tester/impl/detekt-baseline-debug.xml @@ -3,7 +3,6 @@ BooleanPropertyNaming:ExcludedBlockchainsScreenUM.kt$ExcludedBlockchainsScreenUM$val showRecoverWarning: Boolean - CanBeNonNullable:TestPushDeepLinkBottomSheet.kt$config: TangemBottomSheetConfig? CastNullableToNonNullableType:TestPushMarketTokenSearchBottomSheetTransformer.kt$TestPushMarketTokenSearchBottomSheetTransformer$as CastNullableToNonNullableType:TestPushViewModel.kt$TestPushViewModel$as ExplicitCollectionElementAccessMethod:TestPushAddKeyDataTransformer.kt$TestPushAddKeyDataTransformer$mutableData.set(index = index, updated) diff --git a/features/wallet/impl/detekt-baseline-debug.xml b/features/wallet/impl/detekt-baseline-debug.xml index f3a1111f2a..4d05f69171 100644 --- a/features/wallet/impl/detekt-baseline-debug.xml +++ b/features/wallet/impl/detekt-baseline-debug.xml @@ -25,7 +25,6 @@ BooleanPropertyNaming:WalletScreen.kt$var visible by remember { mutableStateOf(value = false) } BooleanPropertyNaming:WalletScreenState.kt$WalletScreenState$val showMarketsOnboarding: Boolean BooleanPropertyNaming:WalletWithFundsChecker.kt$WalletWithFundsChecker$val prevStatus = statusByWalletId.get(userWalletId) - CanBeNonNullable:WalletScreen.kt$bottomSheetConfig: TangemBottomSheetConfig? IgnoredReturnValue:MultiWalletTokenListStore.kt$MultiWalletTokenListStore$remove(userWalletId) MaxChainedCallsOnSameLine:HasSingleWalletSignedHashesUseCase.kt$HasSingleWalletSignedHashesUseCase$userWallet.scanResponse.card.wallets.firstOrNull()?.totalSignedHashes MultilineLambdaItParameter:BasicTokenListSubscriber.kt$BasicTokenListSubscriber${ it.getOrElse { e -> Timber.e("Failed to load app currency: $e") AppCurrency.Default } } @@ -47,11 +46,7 @@ MultilineLambdaItParameter:SingleWalletExpressStatusesSubscriber.kt$SingleWalletExpressStatusesSubscriber${ Timber.e("Unable to get primary currency status: $it") return@onEach } MultilineLambdaItParameter:TokenListAnalyticsSender.kt$TokenListAnalyticsSender${ val status = it.value if (status is CryptoCurrencyStatus.Loaded) { sendTokenBalancesForSpecificBlockchains(it, status) } } MultilineLambdaItParameter:TokenListStateConverter.kt$TokenListStateConverter${ if (isExtend) { clickIntents.onAccountCollapseClick(it) } else { clickIntents.onAccountExpandClick(it) } } - MultilineLambdaItParameter:TxHistorySubscriber.kt$TxHistorySubscriber${ SetTxHistoryCountErrorTransformer( userWallet = userWallet, error = it, pendingTransactions = status.value.pendingTransactions, clickIntents = clickIntents, ) } - MultilineLambdaItParameter:TxHistorySubscriber.kt$TxHistorySubscriber${ SetTxHistoryCountTransformer( userWalletId = userWallet.walletId, transactionsCount = it, clickIntents = clickIntents, ) } MultilineLambdaItParameter:TxHistorySubscriber.kt$TxHistorySubscriber${ SetTxHistoryItemsErrorTransformer( userWalletId = userWallet.walletId, error = it, clickIntents = clickIntents, ) } - MultilineLambdaItParameter:TxHistorySubscriberV2.kt$TxHistorySubscriberV2${ SetTxHistoryCountErrorTransformer( userWallet = userWallet, error = it, pendingTransactions = status.value.pendingTransactions, clickIntents = clickIntents, ) } - MultilineLambdaItParameter:TxHistorySubscriberV2.kt$TxHistorySubscriberV2${ SetTxHistoryCountTransformer( userWalletId = userWallet.walletId, transactionsCount = it, clickIntents = clickIntents, ) } MultilineLambdaItParameter:TxHistorySubscriberV2.kt$TxHistorySubscriberV2${ SetTxHistoryItemsErrorTransformer( userWalletId = userWallet.walletId, error = it, clickIntents = clickIntents, ) } MultilineLambdaItParameter:UpdateMultiWalletActionsTransformer.kt$UpdateMultiWalletActionsTransformer${ when (it) { is WalletManageButton.Buy -> { it.copy( enabled = buyStatus.isContent(), dimContent = !buyStatus.isContent(), ) } is WalletManageButton.Sell -> { it.copy( enabled = sellStatus.isContent(), dimContent = !sellStatus.isContent(), ) } is WalletManageButton.Swap -> { it.copy( enabled = swapStatus.isContent(), dimContent = !swapStatus.isContent(), ) } else -> it } } MultilineLambdaItParameter:UseCaseExt.kt${ Timber.e("Impossible to get primary currency status $it") null } @@ -83,7 +78,6 @@ MultilineLambdaItParameter:WalletWarningsClickIntents.kt$WalletWarningsClickIntentsImplementor${ Timber.e( """ Unable to get user wallet |- ID: $userWalletId |- Exception: $it """.trimIndent(), ) null } MultilineLambdaItParameter:WalletWarningsClickIntents.kt$WalletWarningsClickIntentsImplementor${ router.openOnboardingScreen( scanResponse = it.scanResponse, continueBackup = true, ) } MultilineLambdaItParameter:WalletWithFundsChecker.kt$WalletWithFundsChecker${ val amount = it.value.amount ?: return@any false !amount.isZero() } - NamedArguments:BasicAccountListSubscriber.kt$BasicAccountListSubscriber$updateContent(convertParams, appCurrency, yieldSupplyApyMap, stakingApyMap) NamedArguments:GetMultiWalletWarningsFactory.kt$GetMultiWalletWarningsFactory$addInformationalNotifications(userWallet, cardTypesResolver, flattenCurrencies, clickIntents) NamedArguments:GetMultiWalletWarningsFactory.kt$GetMultiWalletWarningsFactory$addWarningNotifications(cardTypesResolver, flattenCurrencies, isNeedToBackup, clickIntents) NamedArguments:TangemSnapFlingBehavior.kt$HighVelocityApproachAnimation$animateDecay(offset, animationState, decayAnimationSpec, onAnimationStep) diff --git a/features/welcome/impl/detekt-baseline-debug.xml b/features/welcome/impl/detekt-baseline-debug.xml index 9c54bf2d00..4a47c5be0a 100644 --- a/features/welcome/impl/detekt-baseline-debug.xml +++ b/features/welcome/impl/detekt-baseline-debug.xml @@ -5,7 +5,6 @@ BooleanPropertyNaming:WelcomeModel.kt$WelcomeModel$private var routedOut = false BooleanPropertyNaming:WelcomeUM.kt$WelcomeUM.SelectWallet$val showUnlockWithBiometricButton: Boolean = false MultilineLambdaItParameter:WelcomeModel.kt$WelcomeModel${ if (it.isEmpty()) { router.replaceAll(AppRoute.Home()) } wallets.value = it } - MultilineLambdaItParameter:WelcomeModel.kt$WelcomeModel${ it.handle( specificWalletId = null, onUserCancelled = { tryToUnlockWithAccessCodeRightAway() }, ) setSelectWalletState() } ReusedModifierInstance:Welcome.kt$WelcomePlain(modifier = modifier) ReusedModifierInstance:Welcome.kt$WelcomeSelectWallet( state = st, modifier = modifier, )