Updated on 2026-08-14
This commit is contained in:
parent
9c81f9ca51
commit
74e286f57b
11 changed files with 24 additions and 117 deletions
|
|
@ -19,7 +19,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.ui.TokenDetails
|
|||
import com.tangem.features.markets.token.block.TokenMarketBlockComponent
|
||||
import com.tangem.features.onramp.OnrampFeatureToggles
|
||||
import com.tangem.features.tokendetails.TokenDetailsComponent
|
||||
import com.tangem.features.txhistory.TxHistoryFeatureToggles
|
||||
import com.tangem.features.txhistory.component.TxHistoryComponent
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
|
|
@ -31,7 +30,6 @@ internal class DefaultTokenDetailsComponent @AssistedInject constructor(
|
|||
@Assisted params: TokenDetailsComponent.Params,
|
||||
tokenMarketBlockComponentFactory: TokenMarketBlockComponent.Factory,
|
||||
txHistoryComponentFactory: TxHistoryComponent.Factory,
|
||||
txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
onrampFeatureToggles: OnrampFeatureToggles,
|
||||
routingFeatureToggle: RoutingFeatureToggle,
|
||||
deepLinksRegistry: DeepLinksRegistry,
|
||||
|
|
@ -43,9 +41,9 @@ internal class DefaultTokenDetailsComponent @AssistedInject constructor(
|
|||
params = TxHistoryComponent.Params(
|
||||
userWalletId = params.userWalletId,
|
||||
currency = params.currency,
|
||||
openExplorer = { model.onExploreClick() },
|
||||
openExplorer = model::onExploreClick,
|
||||
),
|
||||
).takeIf { txHistoryFeatureToggles.isFeatureEnabled }
|
||||
)
|
||||
|
||||
init {
|
||||
lifecycle.subscribe(
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.e
|
|||
import com.tangem.features.onramp.OnrampFeatureToggles
|
||||
import com.tangem.features.tokendetails.TokenDetailsComponent
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import com.tangem.features.txhistory.TxHistoryFeatureToggles
|
||||
import com.tangem.features.txhistory.entity.TxHistoryContentUpdateEmitter
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.*
|
||||
|
|
@ -125,7 +124,6 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
private val onrampFeatureToggles: OnrampFeatureToggles,
|
||||
private val shareManager: ShareManager,
|
||||
@GlobalUiMessageSender private val uiMessageSender: UiMessageSender,
|
||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
||||
paramsContainer: ParamsContainer,
|
||||
expressStatusFactory: ExpressStatusFactory.Factory,
|
||||
|
|
@ -379,10 +377,10 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
* @param showItemsLoading - show loading items placeholder.
|
||||
*/
|
||||
private fun updateTxHistory(refresh: Boolean, showItemsLoading: Boolean, initialUpdating: Boolean = false) {
|
||||
if (txHistoryFeatureToggles.isFeatureEnabled && !initialUpdating) {
|
||||
modelScope.launch { txHistoryContentUpdateEmitter.triggerUpdate() }
|
||||
} else {
|
||||
modelScope.launch(dispatchers.main) {
|
||||
modelScope.launch {
|
||||
if (!initialUpdating) {
|
||||
txHistoryContentUpdateEmitter.triggerUpdate()
|
||||
} else {
|
||||
val txHistoryItemsCountEither = txHistoryItemsCountUseCase(
|
||||
userWalletId = userWalletId,
|
||||
currency = cryptoCurrency,
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
|
|||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import com.tangem.common.ui.expressStatus.ExpressStatusBottomSheetConfig
|
||||
import com.tangem.common.ui.expressStatus.expressTransactionsItems
|
||||
import com.tangem.common.ui.bottomsheet.chooseaddress.ChooseAddressBottomSheet
|
||||
import com.tangem.common.ui.bottomsheet.chooseaddress.ChooseAddressBottomSheetConfig
|
||||
import com.tangem.common.ui.bottomsheet.receive.TokenReceiveBottomSheet
|
||||
import com.tangem.common.ui.bottomsheet.receive.TokenReceiveBottomSheetConfig
|
||||
import com.tangem.common.ui.expressStatus.ExpressStatusBottomSheetConfig
|
||||
import com.tangem.common.ui.expressStatus.expressTransactionsItems
|
||||
import com.tangem.core.ui.components.containers.pullToRefresh.TangemPullToRefreshContainer
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlock
|
||||
import com.tangem.core.ui.components.marketprice.MarketPriceBlockState
|
||||
|
|
@ -42,6 +42,8 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.s
|
|||
import com.tangem.features.markets.token.block.TokenMarketBlockComponent
|
||||
import com.tangem.features.txhistory.component.TxHistoryComponent
|
||||
import com.tangem.features.txhistory.entity.TxHistoryUM
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
// TODO: Split to blocks [REDACTED_JIRA]
|
||||
|
|
@ -50,7 +52,7 @@ import kotlin.reflect.KProperty
|
|||
internal fun TokenDetailsScreen(
|
||||
state: TokenDetailsState,
|
||||
tokenMarketBlockComponent: TokenMarketBlockComponent?,
|
||||
txHistoryComponent: TxHistoryComponent?,
|
||||
txHistoryComponent: TxHistoryComponent,
|
||||
) {
|
||||
val bottomBarHeight = with(LocalDensity.current) { WindowInsets.systemBars.getBottom(this).toDp() }
|
||||
|
||||
|
|
@ -65,7 +67,7 @@ internal fun TokenDetailsScreen(
|
|||
null
|
||||
}
|
||||
val listState = rememberLazyListState()
|
||||
val txHistoryComponentState by txHistoryComponent?.txHistoryState?.collectAsStateWithLifecycle()
|
||||
val txHistoryComponentState by txHistoryComponent.txHistoryState.collectAsStateWithLifecycle()
|
||||
val betweenItemsPadding = TangemTheme.dimens.spacing12
|
||||
val horizontalPadding = TangemTheme.dimens.spacing16
|
||||
val itemModifier = Modifier
|
||||
|
|
@ -186,13 +188,13 @@ internal fun TokenDetailsScreen(
|
|||
@Suppress("LongParameterList")
|
||||
private fun LazyListScope.txHistoryItems(
|
||||
listState: LazyListState,
|
||||
txHistoryComponent: TxHistoryComponent?,
|
||||
txHistoryComponent: TxHistoryComponent,
|
||||
txHistoryComponentState: TxHistoryUM?,
|
||||
txHistoryState: TxHistoryState,
|
||||
txHistoryItems: LazyPagingItems<TxHistoryState.TxHistoryItemState>?,
|
||||
isBalanceHidden: Boolean,
|
||||
) {
|
||||
if (txHistoryComponent != null && txHistoryComponentState != null) {
|
||||
if (txHistoryComponentState != null) {
|
||||
with(txHistoryComponent) { txHistoryContent(listState = listState, state = txHistoryComponentState) }
|
||||
} else {
|
||||
txHistoryItems(
|
||||
|
|
@ -216,7 +218,13 @@ private fun TokenDetailsScreenPreview(
|
|||
TokenDetailsScreen(
|
||||
state = state,
|
||||
tokenMarketBlockComponent = null,
|
||||
txHistoryComponent = null,
|
||||
txHistoryComponent = object : TxHistoryComponent {
|
||||
override val txHistoryState: StateFlow<TxHistoryUM> = MutableStateFlow(
|
||||
value = TxHistoryUM.Empty(isBalanceHidden = false, onExploreClick = {}),
|
||||
)
|
||||
|
||||
override fun LazyListScope.txHistoryContent(listState: LazyListState, state: TxHistoryUM) = Unit
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue