diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen2.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen2.kt index 62e8944f16..30229f4855 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen2.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen2.kt @@ -59,8 +59,8 @@ import com.tangem.core.ui.components.sheetscaffold.* import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingAppBarBehavior import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingTopBar import com.tangem.core.ui.ds.topbar.collapsing.rememberTangemExitUntilCollapsedScrollBehavior -import com.tangem.core.ui.extensions.softLayerShadow import com.tangem.core.ui.extensions.TextReference +import com.tangem.core.ui.extensions.softLayerShadow import com.tangem.core.ui.res.* import com.tangem.core.ui.utils.TangemSharedTransitionLayout import com.tangem.feature.wallet.presentation.common.preview.WalletScreenPreviewData @@ -176,6 +176,7 @@ private fun WalletContent2( state.wallets2.getOrNull(state.selectedWalletIndex)?.pullToRefreshConfig, ) } + var subtitleBottom by remember { mutableStateOf(0.dp) } BaseScaffoldWithMarkets( modifier = modifier, @@ -240,6 +241,7 @@ private fun WalletContent2( pullToRefreshState = pullToRefreshState, pullToRefreshConfig = pullToRefreshConfig, behavior = behavior, + topOffset = subtitleBottom + TangemTheme.dimens2.x2, ) val overlay = TangemTheme.colors2.overlay.overlayPrimary @@ -306,6 +308,9 @@ private fun WalletContent2( walletBalanceUM = currentWallet.walletsBalanceUM, buttons = currentWallet.buttons, isBalanceHidden = state.isHidingMode, + onSubtitleBottomChange = { newValue -> + if (newValue > subtitleBottom) subtitleBottom = maxOf(subtitleBottom, newValue) + }, ) }, body = { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBalance.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBalance.kt index 9e1eef6fba..ac978268db 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBalance.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBalance.kt @@ -16,11 +16,15 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.scale +import androidx.compose.ui.layout.boundsInRoot +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.style.TextOverflow 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 androidx.compose.ui.unit.dp import com.tangem.core.ui.components.SpacerH import com.tangem.core.ui.components.TextShimmer @@ -32,11 +36,7 @@ import com.tangem.core.ui.ds.placeholder.TextPlaceholder import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingAppBarBehavior import com.tangem.core.ui.ds.topbar.collapsing.rememberTangemExitUntilCollapsedScrollBehavior import com.tangem.core.ui.ds.topbar.collapsing.snapToExitUntilCollapsed -import com.tangem.core.ui.extensions.orMaskWithStars -import com.tangem.core.ui.extensions.resolveAnnotatedReference -import com.tangem.core.ui.extensions.resolveReference -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.extensions.wrappedList +import com.tangem.core.ui.extensions.* import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreviewRedesign import com.tangem.core.ui.test.MainScreenTestTags @@ -58,10 +58,12 @@ internal fun WalletBalance( buttons: ImmutableList, isBalanceHidden: Boolean, modifier: Modifier = Modifier, + onSubtitleBottomChange: (Dp) -> Unit = {}, ) { val collapsedFraction = behavior.state.collapsedFraction val alpha = 1f - collapsedFraction val scale = alpha.coerceIn(MIN_SCALE, MAX_SCALE) + val density = LocalDensity.current Column( horizontalAlignment = Alignment.CenterHorizontally, @@ -85,7 +87,15 @@ internal fun WalletBalance( isBalanceHidden = isBalanceHidden, ) SpacerH(TangemTheme.dimens2.x3) - SubtitleRow(walletBalanceUM = walletBalanceUM) + Box( + modifier = Modifier.onGloballyPositioned { coordinates -> + val rawBottomPx = coordinates.boundsInRoot().bottom + if (rawBottomPx <= 0f) return@onGloballyPositioned + onSubtitleBottomChange(with(density) { rawBottomPx.toDp() }) + }, + ) { + SubtitleRow(walletBalanceUM = walletBalanceUM) + } } SpacerH(TangemTheme.dimens2.x2) ActionButtons(buttons) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletPagerIndicator.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletPagerIndicator.kt index ec7c7888f7..328070e017 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletPagerIndicator.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletPagerIndicator.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.scale import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.Dp import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig import com.tangem.core.ui.components.containers.pullToRefresh.getPullToRefreshIndicatorOffset import com.tangem.core.ui.ds.TangemPagerIndicator @@ -23,7 +24,6 @@ import com.tangem.core.ui.ds.topbar.collapsing.TangemCollapsingAppBarBehavior private const val MIN_SCALE = 0.75f private const val MAX_SCALE = 1f -private const val WALLET_INDICATOR_OFFSET = 0.6f @Composable internal fun WalletPagerIndicator( @@ -31,6 +31,7 @@ internal fun WalletPagerIndicator( behavior: TangemCollapsingAppBarBehavior, pullToRefreshConfig: PullToRefreshConfig?, pullToRefreshState: PullToRefreshState, + topOffset: Dp, ) { val collapsedFraction = behavior.state.collapsedFraction val alpha = MAX_SCALE - collapsedFraction @@ -43,7 +44,6 @@ internal fun WalletPagerIndicator( pullToRefreshConfig = pullToRefreshConfig, pullToRefreshState = pullToRefreshState, ) - val padding = height * WALLET_INDICATOR_OFFSET AnimatedVisibility( visible = pagerState.pageCount > 1, @@ -64,7 +64,7 @@ internal fun WalletPagerIndicator( TangemPagerIndicator( pagerState = pagerState, modifier = Modifier - .padding(top = padding) + .padding(top = topOffset) .scale(scaleY = 1f, scaleX = scale), ) }