Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-13 13:05:17 +05:00
parent 75e2b0b554
commit 0b7c992ec8
15 changed files with 133 additions and 8 deletions

View file

@ -0,0 +1,14 @@
package com.tangem.core.ui.clipboard
import androidx.compose.runtime.Stable
/**
* Ready to use clipboard manager.
* Does not require context to work
*/
@Stable
interface ClipboardManager {
/** Copies to clipboard [text] with optional [label] */
fun setText(label: String = "", text: String)
}

View file

@ -9,6 +9,7 @@ import com.tangem.core.ui.extensions.TextReference
* @property text text
* @property iconResId icon resource id
* @property onClick lambda be invoked when action component is clicked
* @property onLongClick lambda be invoked when action component is long clicked
* @property enabled enabled
* @property dimContent determines whether the button content will be dimmed. This property will be ignored if [enabled]
* is `false`.
@ -19,6 +20,7 @@ data class ActionButtonConfig(
val text: TextReference,
@DrawableRes val iconResId: Int,
val onClick: () -> Unit,
val onLongClick: (() -> TextReference?)? = null,
val enabled: Boolean = true,
val dimContent: Boolean = false,
)

View file

@ -1,9 +1,11 @@
package com.tangem.core.ui.components.buttons.actions
import android.content.res.Configuration
import android.widget.Toast
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
@ -14,6 +16,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
@ -74,6 +77,7 @@ fun ActionButton(
)
}
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun Button(
config: ActionButtonConfig,
@ -85,13 +89,24 @@ private fun Button(
targetValue = if (config.enabled) color else TangemTheme.colors.button.disabled,
label = "Update background color",
)
val context = LocalContext.current
Row(
modifier = modifier
.heightIn(min = TangemTheme.dimens.size36)
.clip(shape)
.background(color = backgroundColor)
.clickable(enabled = config.enabled, onClick = config.onClick)
.combinedClickable(
enabled = config.enabled,
onClick = config.onClick,
onLongClick = {
val toastReference = config.onLongClick?.invoke()
toastReference?.let {
Toast
.makeText(context, toastReference.resolveReference(context.resources), Toast.LENGTH_SHORT)
.show()
}
},
)
.padding(start = TangemTheme.dimens.spacing16, end = TangemTheme.dimens.spacing24)
.padding(vertical = TangemTheme.dimens.spacing8),
horizontalArrangement = Arrangement.Center,

View file

@ -7,5 +7,7 @@ interface HapticManager {
fun vibrateShort()
fun vibrateMeduim()
fun vibrateLong()
}

View file

@ -6,6 +6,10 @@ object MockHapticManager : HapticManager {
/** Intentionnaly do nothing */
}
override fun vibrateMeduim() {
/** Intentionnaly do nothing */
}
override fun vibrateLong() {
/** Intentionnaly do nothing */
}