Updated on 2026-08-14
This commit is contained in:
parent
9aa3f94382
commit
a96272ee3b
1 changed files with 31 additions and 27 deletions
|
|
@ -23,6 +23,7 @@ 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.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.R
|
||||
import com.tangem.core.ui.components.SpacerW8
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -78,6 +79,7 @@ fun ActionButton(
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun Button(
|
||||
config: ActionButtonConfig,
|
||||
|
|
@ -85,6 +87,7 @@ private fun Button(
|
|||
modifier: Modifier = Modifier,
|
||||
color: Color = TangemTheme.colors.button.secondary,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val backgroundColor by animateColorAsState(
|
||||
targetValue = if (config.enabled) color else TangemTheme.colors.button.disabled,
|
||||
label = "Update background color",
|
||||
|
|
@ -92,33 +95,9 @@ private fun Button(
|
|||
|
||||
Box(
|
||||
modifier = modifier
|
||||
.heightIn(min = TangemTheme.dimens.size36)
|
||||
.heightIn(min = 36.dp)
|
||||
.widthIn(min = 100.dp)
|
||||
.clip(shape)
|
||||
.background(color = backgroundColor),
|
||||
) {
|
||||
Content(
|
||||
config = config,
|
||||
modifier = Modifier.align(alignment = Alignment.Center),
|
||||
)
|
||||
|
||||
if (config.isInProgress) {
|
||||
Loading(
|
||||
backgroundColor = backgroundColor,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.align(alignment = Alignment.Center),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun Content(config: ActionButtonConfig, modifier: Modifier = Modifier) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
.combinedClickable(
|
||||
enabled = config.enabled,
|
||||
onClick = config.onClick,
|
||||
|
|
@ -131,7 +110,32 @@ private fun Content(config: ActionButtonConfig, modifier: Modifier = Modifier) {
|
|||
}
|
||||
},
|
||||
)
|
||||
.padding(start = TangemTheme.dimens.spacing16, end = TangemTheme.dimens.spacing24)
|
||||
.background(color = backgroundColor),
|
||||
) {
|
||||
Content(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
config = config,
|
||||
)
|
||||
|
||||
if (config.isInProgress) {
|
||||
Loading(
|
||||
modifier = Modifier
|
||||
.align(alignment = Alignment.Center)
|
||||
.matchParentSize(),
|
||||
backgroundColor = backgroundColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Content(config: ActionButtonConfig, modifier: Modifier = Modifier) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.padding(
|
||||
start = TangemTheme.dimens.spacing16,
|
||||
end = TangemTheme.dimens.spacing24,
|
||||
)
|
||||
.padding(vertical = TangemTheme.dimens.spacing8),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue