Updated on 2026-08-14
This commit is contained in:
parent
8cb232cd36
commit
89cb0e3cdb
3 changed files with 43 additions and 11 deletions
|
|
@ -10,6 +10,8 @@ import com.tangem.core.ui.extensions.TextReference
|
|||
* @property iconResId icon resource id
|
||||
* @property onClick lambda be invoked when action component is clicked
|
||||
* @property enabled enabled
|
||||
* @property dimContent determines whether the button content will be dimmed. This property will be ignored if [enabled]
|
||||
* is `false`.
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
|
|
@ -18,4 +20,5 @@ data class ActionButtonConfig(
|
|||
@DrawableRes val iconResId: Int,
|
||||
val onClick: () -> Unit,
|
||||
val enabled: Boolean = true,
|
||||
val dimContent: Boolean = false,
|
||||
)
|
||||
|
|
@ -99,14 +99,22 @@ private fun Button(
|
|||
painter = painterResource(id = config.iconResId),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(size = TangemTheme.dimens.size20),
|
||||
tint = if (config.enabled) TangemTheme.colors.icon.primary1 else TangemTheme.colors.icon.informative,
|
||||
tint = when {
|
||||
!config.enabled -> TangemTheme.colors.icon.informative
|
||||
config.dimContent -> TangemTheme.colors.icon.secondary
|
||||
else -> TangemTheme.colors.icon.primary1
|
||||
},
|
||||
)
|
||||
|
||||
SpacerW8()
|
||||
|
||||
Text(
|
||||
text = config.text.resolveReference(),
|
||||
color = if (config.enabled) TangemTheme.colors.text.primary1 else TangemTheme.colors.text.disabled,
|
||||
color = when {
|
||||
!config.enabled -> TangemTheme.colors.text.disabled
|
||||
config.dimContent -> TangemTheme.colors.text.secondary
|
||||
else -> TangemTheme.colors.text.primary1
|
||||
},
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
style = TangemTheme.typography.button,
|
||||
|
|
@ -154,6 +162,13 @@ private class ActionStateProvider : CollectionPreviewParameterProvider<ActionBut
|
|||
enabled = true,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = TextReference.Str(value = "Dimmed"),
|
||||
iconResId = R.drawable.ic_arrow_up_24,
|
||||
enabled = true,
|
||||
dimContent = true,
|
||||
onClick = {},
|
||||
),
|
||||
ActionButtonConfig(
|
||||
text = TextReference.Str(value = "Disabled"),
|
||||
iconResId = R.drawable.ic_arrow_down_24,
|
||||
|
|
|
|||
|
|
@ -50,10 +50,12 @@ internal fun OrganizeTokensScreen(state: OrganizeTokensState, modifier: Modifier
|
|||
},
|
||||
content = { paddingValues ->
|
||||
TokenList(
|
||||
modifier = Modifier.padding(paddingValues),
|
||||
modifier = Modifier
|
||||
.padding(paddingValues)
|
||||
.fillMaxSize(),
|
||||
listState = tokensListState,
|
||||
state = state.itemsState,
|
||||
dragConfig = state.dndConfig,
|
||||
dndConfig = state.dndConfig,
|
||||
)
|
||||
},
|
||||
floatingActionButtonPosition = FabPosition.Center,
|
||||
|
|
@ -68,15 +70,15 @@ internal fun OrganizeTokensScreen(state: OrganizeTokensState, modifier: Modifier
|
|||
private fun TokenList(
|
||||
listState: LazyListState,
|
||||
state: OrganizeTokensListState,
|
||||
dragConfig: OrganizeTokensState.DragAndDropConfig,
|
||||
dndConfig: OrganizeTokensState.DragAndDropConfig,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(modifier = modifier) {
|
||||
val reorderableListState = rememberReorderableLazyListState(
|
||||
onMove = dragConfig.onItemDragged,
|
||||
onMove = dndConfig.onItemDragged,
|
||||
listState = listState,
|
||||
canDragOver = dragConfig.canDragItemOver,
|
||||
onDragEnd = { _, _ -> dragConfig.onItemDragEnd() },
|
||||
canDragOver = dndConfig.canDragItemOver,
|
||||
onDragEnd = { _, _ -> dndConfig.onItemDragEnd() },
|
||||
)
|
||||
val items = state.items
|
||||
|
||||
|
|
@ -84,7 +86,8 @@ private fun TokenList(
|
|||
modifier = Modifier
|
||||
.reorderable(reorderableListState)
|
||||
.align(Alignment.TopCenter)
|
||||
.padding(horizontal = TangemTheme.dimens.spacing16),
|
||||
.padding(horizontal = TangemTheme.dimens.spacing16)
|
||||
.fillMaxSize(),
|
||||
state = reorderableListState.listState,
|
||||
contentPadding = PaddingValues(
|
||||
top = TangemTheme.dimens.spacing12,
|
||||
|
|
@ -97,7 +100,7 @@ private fun TokenList(
|
|||
) { index, item ->
|
||||
|
||||
val onDragStart = remember(item) {
|
||||
{ dragConfig.onDragStart(item) }
|
||||
{ dndConfig.onDragStart(item) }
|
||||
}
|
||||
|
||||
DraggableItem(
|
||||
|
|
@ -217,14 +220,23 @@ private fun TopBar(
|
|||
config = ActionButtonConfig(
|
||||
text = TextReference.Res(id = R.string.organize_tokens_sort_by_balance),
|
||||
iconResId = R.drawable.ic_sort_24,
|
||||
enabled = config.isEnabled,
|
||||
onClick = config.onSortClick,
|
||||
dimContent = !config.isSortedByBalance,
|
||||
),
|
||||
modifier = Modifier.weight(1f),
|
||||
color = TangemTheme.colors.background.primary,
|
||||
)
|
||||
RoundedActionButton(
|
||||
config = ActionButtonConfig(
|
||||
text = TextReference.Res(id = R.string.organize_tokens_group),
|
||||
text = TextReference.Res(
|
||||
id = if (config.isGrouped) {
|
||||
R.string.organize_tokens_ungroup
|
||||
} else {
|
||||
R.string.organize_tokens_group
|
||||
},
|
||||
),
|
||||
enabled = config.isEnabled,
|
||||
iconResId = R.drawable.ic_group_24,
|
||||
onClick = config.onGroupClick,
|
||||
),
|
||||
|
|
@ -253,6 +265,8 @@ private fun Actions(config: OrganizeTokensState.ActionsConfig, modifier: Modifie
|
|||
modifier = Modifier.weight(1f),
|
||||
text = stringResource(id = R.string.common_apply),
|
||||
onClick = config.onApplyClick,
|
||||
showProgress = config.showApplyProgress,
|
||||
enabled = config.canApply,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue