Updated on 2026-08-14
This commit is contained in:
parent
3580350769
commit
8aba7b07d1
49 changed files with 172 additions and 134 deletions
|
|
@ -84,12 +84,12 @@ fun ResizableText(
|
|||
reduceFactor: Double = 0.9,
|
||||
) {
|
||||
var fontSize by remember { mutableStateOf(style.fontSize) }
|
||||
var readyToDraw by remember { mutableStateOf(value = false) }
|
||||
var isReadyToDraw by remember { mutableStateOf(value = false) }
|
||||
|
||||
Text(
|
||||
modifier = modifier
|
||||
.drawWithContent {
|
||||
if (readyToDraw) drawContent()
|
||||
if (isReadyToDraw) drawContent()
|
||||
}
|
||||
.wrapContentHeight(),
|
||||
text = text,
|
||||
|
|
@ -106,7 +106,7 @@ fun ResizableText(
|
|||
|
||||
if (minFontSize != TextUnit.Unspecified && reducedFontSize <= minFontSize) {
|
||||
fontSize = minFontSize
|
||||
readyToDraw = true
|
||||
isReadyToDraw = true
|
||||
} else {
|
||||
fontSize = reducedFontSize
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ fun ResizableText(
|
|||
if (result.hasVisualOverflow) {
|
||||
reduceFontSize()
|
||||
} else {
|
||||
readyToDraw = true
|
||||
isReadyToDraw = true
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ private fun TangemTextField(
|
|||
null
|
||||
},
|
||||
)
|
||||
iconRes?.let { iconRes ->
|
||||
iconRes?.let { resId ->
|
||||
IconButton(
|
||||
modifier = Modifier.size(32.dp),
|
||||
onClick = onClear,
|
||||
|
|
@ -182,7 +182,7 @@ private fun TangemTextField(
|
|||
) {
|
||||
Icon(
|
||||
modifier = Modifier.size(24.dp),
|
||||
painter = painterResource(id = iconRes),
|
||||
painter = painterResource(id = resId),
|
||||
tint = colors.trailingIconColor(enabled = enabled, isError = isError).value,
|
||||
contentDescription = "Clear input",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ fun RoundedActionButton(
|
|||
ActionBaseButton(
|
||||
config = config,
|
||||
shape = RoundedCornerShape(size = TangemTheme.dimens.radius24),
|
||||
content = { modifier ->
|
||||
content = { contentModifier ->
|
||||
ActionButtonContent(
|
||||
config = config,
|
||||
text = { color -> Text(text = config.text, textColor = color) },
|
||||
modifier = modifier.padding(
|
||||
modifier = contentModifier.padding(
|
||||
start = TangemTheme.dimens.spacing16,
|
||||
end = TangemTheme.dimens.spacing24,
|
||||
),
|
||||
|
|
@ -138,9 +138,13 @@ fun ActionBaseButton(
|
|||
onClick = config.onClick,
|
||||
onLongClick = {
|
||||
val toastReference = config.onLongClick?.invoke()
|
||||
toastReference?.let { toastReference ->
|
||||
if (toastReference != null) {
|
||||
Toast
|
||||
.makeText(context, toastReference.resolveReference(context.resources), Toast.LENGTH_SHORT)
|
||||
.makeText(
|
||||
context,
|
||||
toastReference.resolveReference(context.resources),
|
||||
Toast.LENGTH_SHORT,
|
||||
)
|
||||
.show()
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ package com.tangem.core.ui.components.containers.pullToRefresh
|
|||
data class PullToRefreshConfig(val isRefreshing: Boolean, val onRefresh: (ShowRefreshState) -> Unit) {
|
||||
|
||||
@JvmInline
|
||||
@Suppress("BooleanPropertyNaming")
|
||||
value class ShowRefreshState(
|
||||
val value: Boolean = true,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -228,7 +228,12 @@ internal data class DropdownMenuPositionProvider(
|
|||
|
||||
onPositionCalculated(
|
||||
anchorBounds,
|
||||
IntRect(x, y, x + popupContentSize.width, y + popupContentSize.height),
|
||||
IntRect(
|
||||
left = x,
|
||||
top = y,
|
||||
right = x + popupContentSize.width,
|
||||
bottom = y + popupContentSize.height,
|
||||
),
|
||||
)
|
||||
return IntOffset(x, y)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,12 @@ fun AmountTextField(
|
|||
val decimalFormat = rememberDecimalFormat()
|
||||
BoxWithConstraints(modifier = modifier) {
|
||||
val fontSize = if (isAutoResize) {
|
||||
resizeFont(visualTransformation, value, textStyle, reduceFactor)
|
||||
resizeFont(
|
||||
visualTransformation = visualTransformation,
|
||||
value = value,
|
||||
textStyle = textStyle,
|
||||
reduceFactor = reduceFactor,
|
||||
)
|
||||
} else {
|
||||
textStyle.fontSize
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ private fun CellDecoration(
|
|||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
repeat(length) {
|
||||
val char = if (it < value.length) {
|
||||
if (isPasswordVisual) PASSWORD_VISUAL_CHAR.toString() else value[it].toString()
|
||||
repeat(length) { i ->
|
||||
val char = if (i < value.length) {
|
||||
if (isPasswordVisual) PASSWORD_VISUAL_CHAR.toString() else value[i].toString()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,12 @@ class AmountVisualTransformation(
|
|||
val groupingSymbol = decimalFormat.decimalFormatSymbols.groupingSeparator
|
||||
return TransformedText(
|
||||
text = formattedText,
|
||||
offsetMapping = OffsetMappingImpl(text.text, formattedText, symbol, groupingSymbol),
|
||||
offsetMapping = OffsetMappingImpl(
|
||||
text = text.text,
|
||||
formattedText = formattedText,
|
||||
currencySymbol = symbol,
|
||||
groupingSymbol = groupingSymbol,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +98,7 @@ class AmountVisualTransformation(
|
|||
private val text: String,
|
||||
private val formattedText: AnnotatedString,
|
||||
private val currencySymbol: String?,
|
||||
private val gropingSymbol: Char,
|
||||
private val groupingSymbol: Char,
|
||||
) : OffsetMapping {
|
||||
override fun originalToTransformed(offset: Int): Int {
|
||||
var noneDigitCount = 0
|
||||
|
|
@ -101,7 +106,7 @@ class AmountVisualTransformation(
|
|||
val symbolOffset = currencySymbol?.let { formattedText.indexOf(it) } ?: -1
|
||||
while (i < offset + noneDigitCount) {
|
||||
val char = formattedText.getOrNull(i++)
|
||||
if (char == gropingSymbol) noneDigitCount++
|
||||
if (char == groupingSymbol) noneDigitCount++
|
||||
if (symbolOffset == 0 && char?.isWhitespace() == true) noneDigitCount++
|
||||
}
|
||||
var transformedOffset = if (symbolOffset == 0 && currencySymbol != null) {
|
||||
|
|
@ -118,7 +123,7 @@ class AmountVisualTransformation(
|
|||
}
|
||||
|
||||
override fun transformedToOriginal(offset: Int): Int {
|
||||
val noneDigitCount = formattedText.take(offset).count { it == gropingSymbol }
|
||||
val noneDigitCount = formattedText.take(offset).count { it == groupingSymbol }
|
||||
return (offset - noneDigitCount).coerceIn(0, text.length)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,11 +141,11 @@ fun TangemLinearProgressIndicator(
|
|||
drawLinearIndicatorBackground(backgroundColor, strokeWidth, strokeCap)
|
||||
if (firstLineHead - firstLineTail > 0) {
|
||||
drawLinearIndicator(
|
||||
firstLineHead,
|
||||
firstLineTail,
|
||||
color,
|
||||
strokeWidth,
|
||||
strokeCap,
|
||||
startFraction = firstLineHead,
|
||||
endFraction = firstLineTail,
|
||||
color = color,
|
||||
strokeWidth = strokeWidth,
|
||||
strokeCap = strokeCap,
|
||||
)
|
||||
}
|
||||
if ((secondLineHead - secondLineTail) > 0) {
|
||||
|
|
@ -204,7 +204,12 @@ private fun DrawScope.drawLinearIndicator(
|
|||
// if there isn't enough space to draw the stroke caps, fall back to StrokeCap.Butt
|
||||
if (strokeCap == StrokeCap.Butt || height > width) {
|
||||
// Progress line
|
||||
drawLine(color, Offset(barStart, yOffset), Offset(barEnd, yOffset), strokeWidth)
|
||||
drawLine(
|
||||
color = color,
|
||||
start = Offset(barStart, yOffset),
|
||||
end = Offset(barEnd, yOffset),
|
||||
strokeWidth = strokeWidth,
|
||||
)
|
||||
} else {
|
||||
// need to adjust barStart and barEnd for the stroke caps
|
||||
val strokeCapOffset = strokeWidth / 2
|
||||
|
|
@ -253,7 +258,7 @@ private const val SECOND_LINE_TAIL_DELAY = 1267
|
|||
private val FIRST_LINE_HEAD_EASING = CubicBezierEasing(a = 0.2f, b = 0f, c = 0.8f, d = 1f)
|
||||
private val FIRST_LINE_TAIL_EASING = CubicBezierEasing(a = 0.4f, b = 0f, c = 1f, d = 1f)
|
||||
private val SECOND_LINE_HEAD_EASING = CubicBezierEasing(a = 0f, b = 0f, c = 0.65f, d = 1f)
|
||||
private val SECOND_LINE_TAIL_EASING = CubicBezierEasing(a = 0.1f, 0f, 0.45f, d = 1f)
|
||||
private val SECOND_LINE_TAIL_EASING = CubicBezierEasing(a = 0.1f, b = 0f, c = 0.45f, d = 1f)
|
||||
|
||||
// region Preview
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
|
|
|
|||
|
|
@ -99,11 +99,11 @@ fun StoriesProgressBar(
|
|||
.clip(RoundedCornerShape(2.dp))
|
||||
.background(TangemColorPalette.White)
|
||||
.fillMaxHeight()
|
||||
.let {
|
||||
.let { modifier ->
|
||||
when (index) {
|
||||
currentStep -> it.fillMaxWidth(progress.value)
|
||||
in 0..currentStep -> it.fillMaxWidth(fraction = 1f)
|
||||
else -> it
|
||||
currentStep -> modifier.fillMaxWidth(progress.value)
|
||||
in 0..currentStep -> modifier.fillMaxWidth(fraction = 1f)
|
||||
else -> modifier
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue