Updated on 2026-08-14
This commit is contained in:
parent
2c74ec0fb2
commit
3b57f24af0
6 changed files with 162 additions and 38 deletions
|
|
@ -20,28 +20,26 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import com.tangem.common.ui.charts.state.MarketChartDataProducer
|
||||
import com.tangem.core.ui.components.*
|
||||
import com.tangem.core.ui.components.appbar.TangemTopAppBar
|
||||
import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.components.buttons.segmentedbutton.SegmentedButtons
|
||||
import com.tangem.core.ui.components.currency.icon.CoinIcon
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeInPercent
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.event.EventEffect
|
||||
import com.tangem.core.ui.event.StateEvent
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.domain.markets.PriceChangeInterval
|
||||
import com.tangem.features.markets.details.impl.ui.components.*
|
||||
import com.tangem.features.markets.details.impl.ui.preview.MarketsTokenDetailsPreview
|
||||
import com.tangem.features.markets.details.impl.ui.state.ExchangesBottomSheetContent
|
||||
import com.tangem.features.markets.details.impl.ui.state.InfoBottomSheetContent
|
||||
import com.tangem.features.markets.details.impl.ui.state.MarketsTokenDetailsUM
|
||||
|
|
@ -317,36 +315,16 @@ fun PriceChangeInterval.getText(): TextReference {
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
// region Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun MarketsTokenDetailsContent_Preview(
|
||||
@PreviewParameter(MarketsTokenDetailsContentPreviewProvider::class) params: MarketsTokenDetailsUM,
|
||||
) {
|
||||
TangemThemePreview {
|
||||
MarketsTokenDetailsContent(
|
||||
state = MarketsTokenDetailsUM(
|
||||
tokenName = "Token Name",
|
||||
priceText = "$0.00000000324",
|
||||
dateTimeText = stringReference("Today"),
|
||||
priceChangePercentText = "52.00%",
|
||||
iconUrl = "",
|
||||
priceChangeType = PriceChangeType.UP,
|
||||
chartState = MarketsTokenDetailsUM.ChartState(
|
||||
dataProducer = MarketChartDataProducer.build { },
|
||||
onLoadRetryClick = {},
|
||||
status = MarketsTokenDetailsUM.ChartState.Status.LOADING,
|
||||
onMarkerPointSelected = { _, _ -> },
|
||||
),
|
||||
selectedInterval = PriceChangeInterval.H24,
|
||||
onSelectedIntervalChange = { },
|
||||
body = MarketsTokenDetailsUM.Body.Loading,
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShown = false,
|
||||
onDismissRequest = {},
|
||||
content = TangemBottomSheetConfigContent.Empty,
|
||||
),
|
||||
markerSet = false,
|
||||
triggerPriceChange = consumedEvent(),
|
||||
),
|
||||
state = params,
|
||||
onHeaderSizeChange = {},
|
||||
onBackClick = {},
|
||||
backgroundColor = TangemTheme.colors.background.tertiary,
|
||||
|
|
@ -356,4 +334,13 @@ private fun Preview() {
|
|||
addTopBarStatusBarPadding = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MarketsTokenDetailsContentPreviewProvider : PreviewParameterProvider<MarketsTokenDetailsUM> {
|
||||
override val values: Sequence<MarketsTokenDetailsUM>
|
||||
get() = sequenceOf(
|
||||
MarketsTokenDetailsPreview.loadingState,
|
||||
MarketsTokenDetailsPreview.contentState,
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
|
|
@ -8,6 +8,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.components.RectangleShimmer
|
||||
import com.tangem.core.ui.components.block.information.GridItems
|
||||
import com.tangem.core.ui.components.block.information.InformationBlock
|
||||
|
|
@ -51,12 +52,16 @@ internal fun InsightsBlock(state: InsightsUM, modifier: Modifier = Modifier) {
|
|||
currentInterval = it
|
||||
state.onIntervalChanged(it)
|
||||
},
|
||||
modifier = Modifier.width(IntrinsicSize.Min),
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.align(Alignment.Center)
|
||||
.padding(vertical = TangemTheme.dimens.spacing4),
|
||||
.padding(
|
||||
horizontal = 14.dp,
|
||||
vertical = 4.dp,
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
|
|
|
|||
|
|
@ -57,12 +57,16 @@ internal fun PricePerformanceBlock(state: PricePerformanceUM, modifier: Modifier
|
|||
currentInterval = it
|
||||
state.onIntervalChanged(it)
|
||||
},
|
||||
modifier = Modifier.width(IntrinsicSize.Min),
|
||||
) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.align(Alignment.Center)
|
||||
.padding(vertical = TangemTheme.dimens.spacing4),
|
||||
.padding(
|
||||
horizontal = 14.dp,
|
||||
vertical = TangemTheme.dimens.spacing4,
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
package com.tangem.features.markets.details.impl.ui.preview
|
||||
|
||||
import com.tangem.common.ui.charts.state.MarketChartDataProducer
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.core.ui.components.marketprice.PriceChangeType
|
||||
import com.tangem.core.ui.event.consumedEvent
|
||||
import com.tangem.core.ui.extensions.stringReference
|
||||
import com.tangem.domain.markets.PriceChangeInterval
|
||||
import com.tangem.features.markets.details.impl.ui.state.*
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
internal object MarketsTokenDetailsPreview {
|
||||
private val infoPoint = InfoPointUM(
|
||||
title = stringReference("1"),
|
||||
value = "2",
|
||||
change = InfoPointUM.ChangeType.DOWN,
|
||||
onInfoClick = {},
|
||||
)
|
||||
|
||||
val loadingState = MarketsTokenDetailsUM(
|
||||
tokenName = "Token Name",
|
||||
priceText = "$0.00000000324",
|
||||
dateTimeText = stringReference("Today"),
|
||||
priceChangePercentText = "52.00%",
|
||||
iconUrl = "",
|
||||
priceChangeType = PriceChangeType.UP,
|
||||
chartState = MarketsTokenDetailsUM.ChartState(
|
||||
dataProducer = MarketChartDataProducer.build { },
|
||||
onLoadRetryClick = {},
|
||||
status = MarketsTokenDetailsUM.ChartState.Status.LOADING,
|
||||
onMarkerPointSelected = { _, _ -> },
|
||||
),
|
||||
selectedInterval = PriceChangeInterval.H24,
|
||||
onSelectedIntervalChange = { },
|
||||
body = MarketsTokenDetailsUM.Body.Loading,
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShown = false,
|
||||
onDismissRequest = {},
|
||||
content = TangemBottomSheetConfigContent.Empty,
|
||||
),
|
||||
markerSet = false,
|
||||
triggerPriceChange = consumedEvent(),
|
||||
)
|
||||
|
||||
val contentState = MarketsTokenDetailsUM(
|
||||
tokenName = "Token Name",
|
||||
priceText = "$0.00000000324",
|
||||
dateTimeText = stringReference("Today"),
|
||||
priceChangePercentText = "52.00%",
|
||||
iconUrl = "",
|
||||
priceChangeType = PriceChangeType.UP,
|
||||
chartState = MarketsTokenDetailsUM.ChartState(
|
||||
dataProducer = MarketChartDataProducer.build { },
|
||||
onLoadRetryClick = {},
|
||||
status = MarketsTokenDetailsUM.ChartState.Status.LOADING,
|
||||
onMarkerPointSelected = { _, _ -> },
|
||||
),
|
||||
selectedInterval = PriceChangeInterval.H24,
|
||||
onSelectedIntervalChange = { },
|
||||
body = MarketsTokenDetailsUM.Body.Content(
|
||||
description = MarketsTokenDetailsUM.Description(
|
||||
shortDescription = stringReference("markets_token_details_description_short"),
|
||||
fullDescription = stringReference("markets_token_details_description_full"),
|
||||
onReadMoreClick = {},
|
||||
),
|
||||
infoBlocks = MarketsTokenDetailsUM.InformationBlocks(
|
||||
insights = InsightsUM(
|
||||
h24Info = persistentListOf(
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
),
|
||||
weekInfo = persistentListOf(
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
),
|
||||
monthInfo = persistentListOf(
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
),
|
||||
onInfoClick = {},
|
||||
onIntervalChanged = {},
|
||||
),
|
||||
securityScore = SecurityScoreUM(
|
||||
score = 2.3f,
|
||||
description = stringReference("markets_token_details_security_score_description"),
|
||||
onInfoClick = {},
|
||||
),
|
||||
metrics = MetricsUM(
|
||||
metrics = persistentListOf(
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
infoPoint,
|
||||
),
|
||||
),
|
||||
pricePerformance = PricePerformanceUM(
|
||||
h24 = PricePerformanceUM.Value(
|
||||
low = "1",
|
||||
high = "2",
|
||||
indicatorFraction = 0.3f,
|
||||
),
|
||||
month = PricePerformanceUM.Value(
|
||||
low = "1",
|
||||
high = "2",
|
||||
indicatorFraction = 0.3f,
|
||||
),
|
||||
all = PricePerformanceUM.Value(
|
||||
low = "1",
|
||||
high = "2",
|
||||
indicatorFraction = 0.3f,
|
||||
),
|
||||
onIntervalChanged = {},
|
||||
),
|
||||
listedOn = ListedOnUM.Empty,
|
||||
links = null,
|
||||
),
|
||||
),
|
||||
bottomSheetConfig = TangemBottomSheetConfig(
|
||||
isShown = false,
|
||||
onDismissRequest = {},
|
||||
content = TangemBottomSheetConfigContent.Empty,
|
||||
),
|
||||
markerSet = true,
|
||||
triggerPriceChange = consumedEvent(),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue