Updated on 2026-08-14
This commit is contained in:
parent
8511623421
commit
7095ceec0f
21 changed files with 717 additions and 183 deletions
|
|
@ -25,10 +25,8 @@ import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
|||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetType
|
||||
import com.tangem.core.ui.components.haze.hazeEffectTangem
|
||||
import com.tangem.core.ui.components.haze.hazeSourceTangem
|
||||
import com.tangem.core.ui.ds.button.*
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBar
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBarType
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.clickableSingle
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
|
@ -38,7 +36,7 @@ import dev.chrisbanes.haze.HazeState
|
|||
import dev.chrisbanes.haze.rememberHazeState
|
||||
|
||||
@Composable
|
||||
fun TokenSelectorBottomSheet(config: TangemBottomSheetConfig, stickyFooter: StickyFooter? = null) {
|
||||
fun TokenSelectorBottomSheet(config: TangemBottomSheetConfig) {
|
||||
TangemBottomSheet<TokenSelectorContentUM>(
|
||||
config = config,
|
||||
type = TangemBottomSheetType.Modal,
|
||||
|
|
@ -47,56 +45,52 @@ fun TokenSelectorBottomSheet(config: TangemBottomSheetConfig, stickyFooter: Stic
|
|||
TokenSelectorContent(
|
||||
content = content,
|
||||
onDismiss = config.onDismissRequest,
|
||||
stickyFooter = stickyFooter,
|
||||
embedded = false,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
data class StickyFooter(val buttonText: TextReference, val isEnabled: Boolean = true, val onClick: () -> Unit)
|
||||
|
||||
@Composable
|
||||
fun TokenSelectorEmbeddedContent(
|
||||
content: TokenSelectorContentUM,
|
||||
stickyFooter: StickyFooter?,
|
||||
scrollBottomInset: Dp,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
TokenSelectorContent(
|
||||
content = content,
|
||||
onDismiss = {},
|
||||
stickyFooter = stickyFooter,
|
||||
embedded = true,
|
||||
modifier = modifier,
|
||||
scrollBottomInset = scrollBottomInset,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TokenSelectorContent(
|
||||
content: TokenSelectorContentUM,
|
||||
onDismiss: () -> Unit,
|
||||
stickyFooter: StickyFooter?,
|
||||
embedded: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
scrollBottomInset: Dp = 0.dp,
|
||||
onDismiss: () -> Unit = {},
|
||||
) {
|
||||
val hazeState = rememberHazeState()
|
||||
var topBarHeight by remember { mutableStateOf(0.dp) }
|
||||
val topContentPadding = if (embedded) {
|
||||
TangemTheme.dimens2.x4
|
||||
0.dp
|
||||
} else {
|
||||
topBarHeight
|
||||
}
|
||||
val footerHeight = TangemTheme.dimens2.x14 + TangemTheme.dimens2.x4
|
||||
val listBottomPadding = TangemTheme.dimens2.x10 + if (stickyFooter != null) footerHeight else 0.dp
|
||||
|
||||
Box(modifier = modifier.fillMaxWidth()) {
|
||||
val bottomFadeReserve = if (embedded) 0.dp else TangemTheme.dimens2.x10
|
||||
val bottomListPadding = bottomFadeReserve + scrollBottomInset
|
||||
LazyColumn(
|
||||
modifier = Modifier.hazeSourceTangem(state = hazeState, 1f),
|
||||
contentPadding = PaddingValues(
|
||||
start = TangemTheme.dimens2.x4,
|
||||
end = TangemTheme.dimens2.x4,
|
||||
top = topContentPadding,
|
||||
bottom = listBottomPadding,
|
||||
bottom = bottomListPadding,
|
||||
),
|
||||
) {
|
||||
tokenSelectorSectionItems(content.sections)
|
||||
|
|
@ -108,29 +102,11 @@ private fun TokenSelectorContent(
|
|||
hazeState = hazeState,
|
||||
onChangeHeight = { topBarHeight = it },
|
||||
)
|
||||
}
|
||||
Fade(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.BottomCenter)
|
||||
.padding(bottom = if (stickyFooter != null) footerHeight else 0.dp),
|
||||
height = TangemTheme.dimens2.x10,
|
||||
)
|
||||
if (stickyFooter != null) {
|
||||
TangemButton(
|
||||
Fade(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomCenter)
|
||||
.navigationBarsPadding()
|
||||
.padding(horizontal = TangemTheme.dimens2.x4, vertical = TangemTheme.dimens2.x2)
|
||||
.fillMaxWidth(),
|
||||
buttonUM = TangemButtonUM(
|
||||
type = TangemButtonType.Primary,
|
||||
text = stickyFooter.buttonText,
|
||||
shape = TangemButtonShape.Rounded,
|
||||
size = TangemButtonSize.X15,
|
||||
isEnabled = stickyFooter.isEnabled,
|
||||
onClick = stickyFooter.onClick,
|
||||
),
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.BottomCenter),
|
||||
height = TangemTheme.dimens2.x10,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ private fun AddButton(state: AddTokenUM.Button, modifier: Modifier = Modifier) {
|
|||
isEnabled = state.isEnabled,
|
||||
size = TangemButtonSize.X12,
|
||||
shape = TangemButtonShape.Rounded,
|
||||
isLoading = state.showProgress,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue