Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-11 13:55:41 +07:00
parent 18474637b9
commit a252e33515
17 changed files with 796 additions and 37 deletions

View file

@ -50,6 +50,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> TangemModalBottomSheet(
containerColor: Color = TangemTheme.colors.background.primary,
skipPartiallyExpanded: Boolean = true,
dismissOnClickOutside: Boolean = true,
scrollableContent: Boolean = true,
noinline onBack: (() -> Unit)? = null,
crossinline title: @Composable BoxScope.(T) -> Unit = {},
crossinline content: @Composable ColumnScope.(T) -> Unit,
@ -62,6 +63,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> TangemModalBottomSheet(
containerColor = containerColor,
title = title,
content = content,
scrollableContent = scrollableContent,
skipPartiallyExpanded = skipPartiallyExpanded,
)
} else {
@ -71,6 +73,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> TangemModalBottomSheet(
title = title,
content = content,
dismissOnClickOutside = dismissOnClickOutside,
scrollableContent = scrollableContent,
onBack = onBack,
skipPartiallyExpanded = skipPartiallyExpanded,
)
@ -84,6 +87,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> DefaultModalBottomSheet(
containerColor: Color,
skipPartiallyExpanded: Boolean = true,
dismissOnClickOutside: Boolean = true,
scrollableContent: Boolean = true,
noinline onBack: (() -> Unit)? = null,
crossinline title: @Composable (BoxScope.(T) -> Unit),
crossinline content: @Composable (ColumnScope.(T) -> Unit),
@ -104,10 +108,16 @@ inline fun <reified T : TangemBottomSheetConfigContent> DefaultModalBottomSheet(
BasicModalBottomSheet<T>(
config = config,
sheetState = sheetState,
containerColor = containerColor,
title = title,
onBack = onBack,
content = content,
bsContent = {
BsContent(
config = config,
containerColor = containerColor,
scrollableContent = scrollableContent,
title = title,
content = content,
)
},
)
}
@ -126,6 +136,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> PreviewModalBottomSheet(
config: TangemBottomSheetConfig,
containerColor: Color,
skipPartiallyExpanded: Boolean = true,
scrollableContent: Boolean = true,
crossinline title: @Composable (BoxScope.(T) -> Unit),
crossinline content: @Composable (ColumnScope.(T) -> Unit),
) {
@ -137,49 +148,64 @@ inline fun <reified T : TangemBottomSheetConfigContent> PreviewModalBottomSheet(
density = LocalDensity.current,
),
onBack = null,
containerColor = containerColor,
title = title,
content = content,
bsContent = {
BsContent(
config = config,
containerColor = containerColor,
scrollableContent = scrollableContent,
title = title,
content = content,
)
},
)
}
@Composable
inline fun <reified T : TangemBottomSheetConfigContent> BsContent(
config: TangemBottomSheetConfig,
containerColor: Color,
scrollableContent: Boolean = true,
crossinline title: @Composable (BoxScope.(T) -> Unit),
crossinline content: @Composable (ColumnScope.(T) -> Unit),
) {
val model = config.content as? T ?: return
val maxHeight = LocalConfiguration.current.screenHeightDp * MODAL_SHEET_MAX_HEIGHT
Column(
modifier = Modifier
.systemBarsPadding()
.padding(horizontal = 8.dp, vertical = 8.dp)
.clip(TangemTheme.shapes.roundedCornersLarge)
.background(containerColor)
.heightIn(max = maxHeight.dp)
.fillMaxWidth(),
) {
Box(modifier = Modifier.fillMaxWidth()) {
title(model)
}
if (scrollableContent) {
Column(
modifier = Modifier.verticalScroll(rememberScrollState()),
) {
content(model)
}
} else {
content(model)
}
}
}
@Suppress("LongParameterList")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
inline fun <reified T : TangemBottomSheetConfigContent> BasicModalBottomSheet(
config: TangemBottomSheetConfig,
sheetState: SheetState,
containerColor: Color,
noinline onBack: (() -> Unit)? = null,
crossinline title: @Composable (BoxScope.(T) -> Unit),
crossinline content: @Composable (ColumnScope.(T) -> Unit),
noinline bsContent: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
) {
val model = config.content as? T ?: return
val bsContent: @Composable ColumnScope.() -> Unit = {
val maxHeight = LocalConfiguration.current.screenHeightDp * MODAL_SHEET_MAX_HEIGHT
Column(
modifier = Modifier
.systemBarsPadding()
.padding(horizontal = 8.dp, vertical = 8.dp)
.clip(TangemTheme.shapes.roundedCornersLarge)
.background(containerColor)
.heightIn(max = maxHeight.dp)
.fillMaxWidth(),
) {
Box(modifier = Modifier.fillMaxWidth()) {
title(model)
}
Column(
modifier = Modifier.verticalScroll(rememberScrollState()),
) {
content(model)
}
}
}
if (onBack != null) {
ModalBottomSheetWithBackHandling(
modifier = modifier,

View file

@ -17,6 +17,7 @@ import com.tangem.core.ui.components.account.AccountCharIcon
import com.tangem.core.ui.components.account.AccountIconSize
import com.tangem.core.ui.components.account.AccountResIcon
import com.tangem.core.ui.components.currency.DefaultCurrencyIcon
import com.tangem.core.ui.extensions.resolveReference
import com.tangem.core.ui.res.TangemTheme
@Composable
@ -69,7 +70,7 @@ internal fun ContentIcon(
)
is CurrencyIconState.CryptoPortfolio.Letter -> AccountCharIcon(
modifier = modifier,
char = icon.char,
char = icon.char.resolveReference().first(),
color = icon.color,
size = AccountIconSize.Default,
)

View file

@ -4,6 +4,7 @@ import androidx.annotation.DrawableRes
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import com.tangem.core.ui.R
import com.tangem.core.ui.extensions.TextReference
/**
* Represents the various states an icon can be in.
@ -86,6 +87,7 @@ sealed class CurrencyIconState {
override val topBadgeIconResId: Int? = null
}
@Immutable
sealed class CryptoPortfolio : CurrencyIconState() {
override val showCustomBadge: Boolean = false
override val topBadgeIconResId: Int? = null
@ -98,7 +100,7 @@ sealed class CurrencyIconState {
) : CryptoPortfolio()
data class Letter(
val char: Char,
val char: TextReference,
override val color: Color,
override val isGrayscale: Boolean,
) : CryptoPortfolio()

View file

@ -661,7 +661,7 @@ object AccountItemPreviewData {
)
val accountLetterIcon: CurrencyIconState.CryptoPortfolio.Letter
get() = CurrencyIconState.CryptoPortfolio.Letter(
char = 'A',
char = stringReference("A"),
color = Color.Blue,
isGrayscale = false,
)